orgVOs) {
97 | this.orgVOs = orgVOs;
98 | }
99 |
100 | @Override
101 | public int getItemType() {
102 | return OrgContactAdapter.ORG;
103 | }
104 |
105 | @Override
106 | public boolean equals(Object obj) {
107 | if (obj instanceof OrgVo) {
108 | OrgVo vo = (OrgVo) obj;
109 | return (id.equals(vo.id));
110 | }
111 | return false;
112 | }
113 |
114 | @Override
115 | public int hashCode() {
116 | return id.hashCode();
117 |
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/mydemo/entity/ResultVo.java:
--------------------------------------------------------------------------------
1 | package com.example.mydemo.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * Created by jack on 2017/5/21.
7 | */
8 |
9 | public class ResultVo {
10 |
11 | private String errcode;
12 |
13 | private String errmsg;
14 |
15 | private Object msg;
16 |
17 | private String result;
18 |
19 | public void setErrcode(String errcode){
20 | this.errcode = errcode;
21 | }
22 | public String getErrcode(){
23 | return this.errcode;
24 | }
25 | public void setErrmsg(String errmsg){
26 | this.errmsg = errmsg;
27 | }
28 | public String getErrmsg(){
29 | return this.errmsg;
30 | }
31 | public void setMsg(Object msg){
32 | this.msg = msg;
33 | }
34 | public Object getMsg(){
35 | return this.msg;
36 | }
37 | public void setResult(String result){
38 | this.result = result;
39 | }
40 | public String getResult(){
41 | return this.result;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/mydemo/utils/LogUtils.java:
--------------------------------------------------------------------------------
1 | package com.example.mydemo.utils;
2 |
3 | import android.content.Context;
4 | import android.os.Environment;
5 | import android.support.annotation.IntDef;
6 | import android.util.Log;
7 |
8 | import org.json.JSONArray;
9 | import org.json.JSONException;
10 | import org.json.JSONObject;
11 |
12 | import java.io.BufferedWriter;
13 | import java.io.File;
14 | import java.io.FileWriter;
15 | import java.io.IOException;
16 | import java.io.StringReader;
17 | import java.io.StringWriter;
18 | import java.lang.annotation.Retention;
19 | import java.lang.annotation.RetentionPolicy;
20 | import java.text.SimpleDateFormat;
21 | import java.util.Date;
22 | import java.util.Formatter;
23 | import java.util.Locale;
24 |
25 | import javax.xml.transform.OutputKeys;
26 | import javax.xml.transform.Source;
27 | import javax.xml.transform.Transformer;
28 | import javax.xml.transform.TransformerFactory;
29 | import javax.xml.transform.stream.StreamResult;
30 | import javax.xml.transform.stream.StreamSource;
31 |
32 | /**
33 | *
34 | * author: Blankj
35 | * blog : http://blankj.com
36 | * time : 2016/9/21
37 | * desc : 日志相关工具类
38 | *
39 | */
40 | public final class LogUtils {
41 |
42 | private LogUtils() {
43 | throw new UnsupportedOperationException("u can't instantiate me...");
44 | }
45 |
46 | public static final int V = 0x01;
47 | public static final int D = 0x02;
48 | public static final int I = 0x04;
49 | public static final int W = 0x08;
50 | public static final int E = 0x10;
51 | public static final int A = 0x20;
52 |
53 | @IntDef({V, D, I, W, E, A})
54 | @Retention(RetentionPolicy.SOURCE)
55 | public @interface TYPE {
56 | }
57 |
58 | private static final int FILE = 0xF1;
59 | private static final int JSON = 0xF2;
60 | private static final int XML = 0xF4;
61 |
62 | private static String dir; // log存储目录
63 | private static boolean sLogSwitch = true; // log总开关
64 | private static String sGlobalTag = null; // log标签
65 | private static boolean sTagIsSpace = true; // log标签是否为空白
66 | private static boolean sLog2FileSwitch = false;// log写入文件开关
67 | private static boolean sLogBorderSwitch = true; // log边框开关
68 | private static int sLogFilter = V; // log过滤器
69 |
70 | private static final String TOP_BORDER = "╔═══════════════════════════════════════════════════════════════════════════════════════════════════";
71 | private static final String LEFT_BORDER = "║ ";
72 | private static final String BOTTOM_BORDER = "╚═══════════════════════════════════════════════════════════════════════════════════════════════════";
73 | private static final String LINE_SEPARATOR = System.getProperty("line.separator");
74 |
75 | private static final int MAX_LEN = 4000;
76 | private static final String NULL_TIPS = "Log with null object.";
77 | private static final String NULL = "null";
78 | private static final String ARGS = "args";
79 |
80 | public static class Builder {
81 |
82 | public Builder(Context context) {
83 | if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
84 | dir = context.getExternalCacheDir() + File.separator + "log" + File.separator;
85 | } else {
86 | dir = context.getCacheDir() + File.separator + "log" + File.separator;
87 | }
88 | }
89 |
90 | public Builder setGlobalTag(String tag) {
91 | if (!isSpace(tag)) {
92 | LogUtils.sGlobalTag = tag;
93 | sTagIsSpace = false;
94 | } else {
95 | LogUtils.sGlobalTag = "";
96 | sTagIsSpace = true;
97 | }
98 | return this;
99 | }
100 |
101 | public Builder setLogSwitch(boolean logSwitch) {
102 | LogUtils.sLogSwitch = logSwitch;
103 | return this;
104 | }
105 |
106 | public Builder setLog2FileSwitch(boolean log2FileSwitch) {
107 | LogUtils.sLog2FileSwitch = log2FileSwitch;
108 | return this;
109 | }
110 |
111 | public Builder setBorderSwitch(boolean borderSwitch) {
112 | LogUtils.sLogBorderSwitch = borderSwitch;
113 | return this;
114 | }
115 |
116 | public Builder setLogFilter(@TYPE int logFilter) {
117 | LogUtils.sLogFilter = logFilter;
118 | return this;
119 | }
120 | }
121 |
122 | public static void v(Object contents) {
123 | log(V, sGlobalTag, contents);
124 | }
125 |
126 | public static void v(String tag, Object... contents) {
127 | log(V, tag, contents);
128 | }
129 |
130 | public static void d(Object contents) {
131 | log(D, sGlobalTag, contents);
132 | }
133 |
134 | public static void d(String tag, Object... contents) {
135 | log(D, tag, contents);
136 | }
137 |
138 | public static void i(Object contents) {
139 | log(I, sGlobalTag, contents);
140 | }
141 |
142 | public static void i(String tag, Object... contents) {
143 | log(I, tag, contents);
144 | }
145 |
146 | public static void w(Object contents) {
147 | log(W, sGlobalTag, contents);
148 | }
149 |
150 | public static void w(String tag, Object... contents) {
151 | log(W, tag, contents);
152 | }
153 |
154 | public static void e(Object contents) {
155 | log(E, sGlobalTag, contents);
156 | }
157 |
158 | public static void e(String tag, Object... contents) {
159 | log(E, tag, contents);
160 | }
161 |
162 | public static void a(Object contents) {
163 | log(A, sGlobalTag, contents);
164 | }
165 |
166 | public static void a(String tag, Object... contents) {
167 | log(A, tag, contents);
168 | }
169 |
170 | public static void file(Object contents) {
171 | log(FILE, sGlobalTag, contents);
172 | }
173 |
174 | public static void file(String tag, Object contents) {
175 | log(FILE, tag, contents);
176 | }
177 |
178 | public static void json(String contents) {
179 | log(JSON, sGlobalTag, contents);
180 | }
181 |
182 | public static void json(String tag, String contents) {
183 | log(JSON, tag, contents);
184 | }
185 |
186 | public static void xml(String contents) {
187 | log(XML, sGlobalTag, contents);
188 | }
189 |
190 | public static void xml(String tag, String contents) {
191 | log(XML, tag, contents);
192 | }
193 |
194 | private static void log(int type, String tag, Object... contents) {
195 | if (!sLogSwitch) return;
196 | final String[] processContents = processContents(type, tag, contents);
197 | tag = processContents[0];
198 | String msg = processContents[1];
199 | switch (type) {
200 | case V:
201 | case D:
202 | case I:
203 | case W:
204 | case E:
205 | case A:
206 | if (V == sLogFilter || type >= sLogFilter) {
207 | printLog(type, tag, msg);
208 | }
209 | if (sLog2FileSwitch) {
210 | print2File(tag, msg);
211 | }
212 | break;
213 | case FILE:
214 | print2File(tag, msg);
215 | break;
216 | case JSON:
217 | printLog(D, tag, msg);
218 | break;
219 | case XML:
220 | printLog(D, tag, msg);
221 | break;
222 | }
223 |
224 | }
225 |
226 | private static String[] processContents(int type, String tag, Object... contents) {
227 | StackTraceElement targetElement = Thread.currentThread().getStackTrace()[5];
228 | String className = targetElement.getClassName();
229 | String[] classNameInfo = className.split("\\.");
230 | if (classNameInfo.length > 0) {
231 | className = classNameInfo[classNameInfo.length - 1];
232 | }
233 | if (className.contains("$")) {
234 | className = className.split("\\$")[0];
235 | }
236 | if (!sTagIsSpace) {// 如果全局tag不为空,那就用全局tag
237 | tag = sGlobalTag;
238 | } else {// 全局tag为空时,如果传入的tag为空那就显示类名,否则显示tag
239 | tag = isSpace(tag) ? className : tag;
240 | }
241 |
242 | String head = new Formatter()
243 | .format("Thread: %s, %s(%s.java:%d)" + LINE_SEPARATOR,
244 | Thread.currentThread().getName(),
245 | targetElement.getMethodName(),
246 | className,
247 | targetElement.getLineNumber())
248 | .toString();
249 | String msg = NULL_TIPS;
250 | if (contents != null) {
251 | if (contents.length == 1) {
252 | Object object = contents[0];
253 | msg = object == null ? NULL : object.toString();
254 | if (type == JSON) {
255 | msg = formatJson(msg);
256 | } else if (type == XML) {
257 | msg = formatXml(msg);
258 | }
259 | } else {
260 | StringBuilder sb = new StringBuilder();
261 | for (int i = 0, len = contents.length; i < len; ++i) {
262 | Object content = contents[i];
263 | sb.append(ARGS)
264 | .append("[")
265 | .append(i)
266 | .append("]")
267 | .append(" = ")
268 | .append(content == null ? NULL : content.toString())
269 | .append(LINE_SEPARATOR);
270 | }
271 | msg = sb.toString();
272 | }
273 | }
274 | if (sLogBorderSwitch) {
275 | StringBuilder sb = new StringBuilder();
276 | String[] lines = msg.split(LINE_SEPARATOR);
277 | for (String line : lines) {
278 | sb.append(LEFT_BORDER).append(line).append(LINE_SEPARATOR);
279 | }
280 | msg = sb.toString();
281 | }
282 | return new String[]{tag, head + msg};
283 | }
284 |
285 | private static String formatJson(String json) {
286 | try {
287 | if (json.startsWith("{")) {
288 | json = new JSONObject(json).toString(4);
289 | } else if (json.startsWith("[")) {
290 | json = new JSONArray(json).toString(4);
291 | }
292 | } catch (JSONException e) {
293 | e.printStackTrace();
294 | }
295 | return json;
296 | }
297 |
298 | private static String formatXml(String xml) {
299 | try {
300 | Source xmlInput = new StreamSource(new StringReader(xml));
301 | StreamResult xmlOutput = new StreamResult(new StringWriter());
302 | Transformer transformer = TransformerFactory.newInstance().newTransformer();
303 | transformer.setOutputProperty(OutputKeys.INDENT, "yes");
304 | transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
305 | transformer.transform(xmlInput, xmlOutput);
306 | xml = xmlOutput.getWriter().toString().replaceFirst(">", ">" + LINE_SEPARATOR);
307 | } catch (Exception e) {
308 | e.printStackTrace();
309 | }
310 | return xml;
311 | }
312 |
313 | private static void printLog(int type, String tag, String msg) {
314 | if (sLogBorderSwitch) printBorder(type, tag, true);
315 | int len = msg.length();
316 | int countOfSub = len / MAX_LEN;
317 | if (countOfSub > 0) {
318 | int index = 0;
319 | String sub;
320 | for (int i = 0; i < countOfSub; i++) {
321 | sub = msg.substring(index, index + MAX_LEN);
322 | printSubLog(type, tag, sub);
323 | index += MAX_LEN;
324 | }
325 | printSubLog(type, tag, msg.substring(index, len));
326 | } else {
327 | printSubLog(type, tag, msg);
328 | }
329 | if (sLogBorderSwitch) printBorder(type, tag, false);
330 | }
331 |
332 | private static void printSubLog(final int type, final String tag, String msg) {
333 | if (sLogBorderSwitch) msg = LEFT_BORDER + msg;
334 | switch (type) {
335 | case V:
336 | Log.v(tag, msg);
337 | break;
338 | case D:
339 | Log.d(tag, msg);
340 | break;
341 | case I:
342 | Log.i(tag, msg);
343 | break;
344 | case W:
345 | Log.w(tag, msg);
346 | break;
347 | case E:
348 | Log.e(tag, msg);
349 | break;
350 | case A:
351 | Log.wtf(tag, msg);
352 | break;
353 | }
354 | }
355 |
356 | private static void printBorder(int type, String tag, boolean isTop) {
357 | String border = isTop ? TOP_BORDER : BOTTOM_BORDER;
358 | switch (type) {
359 | case V:
360 | Log.v(tag, border);
361 | break;
362 | case D:
363 | Log.d(tag, border);
364 | break;
365 | case I:
366 | Log.i(tag, border);
367 | break;
368 | case W:
369 | Log.w(tag, border);
370 | break;
371 | case E:
372 | Log.e(tag, border);
373 | break;
374 | case A:
375 | Log.wtf(tag, border);
376 | break;
377 | }
378 | }
379 |
380 | private synchronized static void print2File(final String tag, final String msg) {
381 | Date now = new Date();
382 | String date = new SimpleDateFormat("MM-dd", Locale.getDefault()).format(now);
383 | final String fullPath = dir + date + ".txt";
384 | if (!createOrExistsFile(fullPath)) {
385 | Log.e(tag, "log to " + fullPath + " failed!");
386 | return;
387 | }
388 | String time = new SimpleDateFormat("MM-dd HH:mm:ss.SSS ", Locale.getDefault()).format(now);
389 | StringBuilder sb = new StringBuilder();
390 | if (sLogBorderSwitch) sb.append(TOP_BORDER).append(LINE_SEPARATOR);
391 | sb.append(time)
392 | .append(tag)
393 | .append(": ")
394 | .append(msg)
395 | .append(LINE_SEPARATOR);
396 | if (sLogBorderSwitch) sb.append(BOTTOM_BORDER).append(LINE_SEPARATOR);
397 | final String dateLogContent = sb.toString();
398 | new Thread(new Runnable() {
399 | @Override
400 | public void run() {
401 | BufferedWriter bw = null;
402 | try {
403 | bw = new BufferedWriter(new FileWriter(fullPath, true));
404 | bw.write(dateLogContent);
405 | Log.d(tag, "log to " + fullPath + " success!");
406 | } catch (IOException e) {
407 | e.printStackTrace();
408 | Log.e(tag, "log to " + fullPath + " failed!");
409 | } finally {
410 | try {
411 | if (bw != null) {
412 | bw.close();
413 | }
414 | } catch (IOException e) {
415 | e.printStackTrace();
416 | }
417 | }
418 | }
419 | }).start();
420 | }
421 |
422 | private static boolean createOrExistsFile(String filePath) {
423 | return createOrExistsFile(isSpace(filePath) ? null : new File(filePath));
424 | }
425 |
426 | private static boolean createOrExistsFile(File file) {
427 | if (file == null) return false;
428 | if (file.exists()) return file.isFile();
429 | if (!createOrExistsDir(file.getParentFile())) return false;
430 | try {
431 | return file.createNewFile();
432 | } catch (IOException e) {
433 | e.printStackTrace();
434 | return false;
435 | }
436 | }
437 |
438 | private static boolean createOrExistsDir(File file) {
439 | return file != null && (file.exists() ? file.isDirectory() : file.mkdirs());
440 | }
441 |
442 | private static boolean isSpace(String s) {
443 | if (s == null) return true;
444 | for (int i = 0, len = s.length(); i < len; ++i) {
445 | if (!Character.isWhitespace(s.charAt(i))) {
446 | return false;
447 | }
448 | }
449 | return true;
450 | }
451 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/mydemo/view/RecyclerViewItemDecoration.java:
--------------------------------------------------------------------------------
1 | package com.example.mydemo.view;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.graphics.Canvas;
7 | import android.graphics.Color;
8 | import android.graphics.DashPathEffect;
9 | import android.graphics.NinePatch;
10 | import android.graphics.Paint;
11 | import android.graphics.Path;
12 | import android.graphics.PathEffect;
13 | import android.graphics.Rect;
14 | import android.support.annotation.ColorInt;
15 | import android.support.v7.widget.GridLayoutManager;
16 | import android.support.v7.widget.RecyclerView;
17 | import android.view.View;
18 |
19 | import java.util.regex.Pattern;
20 |
21 | /**
22 | * RecycleView item decoration
23 | * Created by Eminem Lu on 24/11/15.
24 | * Email arjinmc@hotmail.com
25 | * https://github.com/arjinmc/RecyclerViewDecoration
26 | */
27 | public class RecyclerViewItemDecoration extends RecyclerView.ItemDecoration {
28 |
29 | /**
30 | * mode for direction
31 | */
32 | public static final int MODE_HORIZONTAL = 0;
33 | public static final int MODE_VERTICAL = 1;
34 | public static final int MODE_GRID = 2;
35 |
36 | /**
37 | * default decoration color
38 | */
39 | private static final String DEFAULT_COLOR = "#bdbdbd";
40 |
41 | /**
42 | * image resource id for R.java
43 | */
44 | private int mDrawableRid = 0;
45 | /**
46 | * decoration color
47 | */
48 | private int mColor = Color.parseColor(DEFAULT_COLOR);
49 | /**
50 | * decoration thickness
51 | */
52 | private int mThickness;
53 | /**
54 | * decoration dash with
55 | */
56 | private int mDashWidth = 0;
57 | /**
58 | * decoration dash gap
59 | */
60 | private int mDashGap = 0;
61 | private boolean mFirstLineVisible;
62 | private boolean mLastLineVisible;
63 | private int mPaddingStart = 0;
64 | private int mPaddingEnd = 0;
65 | /**
66 | * direction mode for decoration
67 | */
68 | private int mMode;
69 |
70 | private Paint mPaint;
71 |
72 | private Bitmap mBmp;
73 | private NinePatch mNinePatch;
74 | /**
75 | * choose the real thickness for image or thickness
76 | */
77 | private int mCurrentThickness;
78 | /**
79 | * sign for if the resource image is a ninepatch image
80 | */
81 | private Boolean hasNinePatch = false;
82 |
83 | public RecyclerViewItemDecoration() {
84 | }
85 |
86 | @Deprecated
87 | public RecyclerViewItemDecoration(int recyclerviewMode, Context context, int drawableRid) {
88 | this.mMode = recyclerviewMode;
89 | this.mDrawableRid = drawableRid;
90 |
91 | this.mBmp = BitmapFactory.decodeResource(context.getResources(), drawableRid);
92 | if (mBmp.getNinePatchChunk() != null) {
93 | hasNinePatch = true;
94 | mNinePatch = new NinePatch(mBmp, mBmp.getNinePatchChunk(), null);
95 | }
96 | initPaint();
97 |
98 | }
99 |
100 | @Deprecated
101 | public RecyclerViewItemDecoration(int recyclerviewMode, int color, int thick, int dashWidth, int dashGap) {
102 | this.mMode = recyclerviewMode;
103 | this.mColor = color;
104 | this.mThickness = thick;
105 | this.mDashWidth = dashWidth;
106 | this.mDashGap = dashGap;
107 |
108 | initPaint();
109 |
110 | }
111 |
112 | @Deprecated
113 | public RecyclerViewItemDecoration(int recyclerviewMode, String color, int thick, int dashWidth, int dashGap) {
114 | this.mMode = recyclerviewMode;
115 | if (isColorString(color)) {
116 | this.mColor = Color.parseColor(color);
117 | } else {
118 | this.mColor = Color.parseColor(DEFAULT_COLOR);
119 | }
120 | this.mThickness = thick;
121 | this.mDashWidth = dashWidth;
122 | this.mDashGap = dashGap;
123 |
124 | initPaint();
125 | }
126 |
127 | public void setParams(Context context, Param params) {
128 |
129 | this.mMode = params.mode;
130 | this.mDrawableRid = params.drawableRid;
131 | this.mColor = params.color;
132 | this.mThickness = params.thickness;
133 | this.mDashGap = params.dashGap;
134 | this.mDashWidth = params.dashWidth;
135 | this.mPaddingStart = params.paddingStart;
136 | this.mPaddingEnd = params.paddingEnd;
137 | this.mFirstLineVisible = params.firstLineVisible;
138 | this.mLastLineVisible = params.lastLineVisible;
139 |
140 | this.mBmp = BitmapFactory.decodeResource(context.getResources(), mDrawableRid);
141 | if (mBmp != null) {
142 |
143 | if (mBmp.getNinePatchChunk() != null) {
144 | hasNinePatch = true;
145 | mNinePatch = new NinePatch(mBmp, mBmp.getNinePatchChunk(), null);
146 | }
147 |
148 | if (mMode == MODE_HORIZONTAL)
149 | mCurrentThickness = mThickness == 0 ? mBmp.getHeight() : mThickness;
150 | if (mMode == MODE_VERTICAL)
151 | mCurrentThickness = mThickness == 0 ? mBmp.getWidth() : mThickness;
152 | }
153 |
154 | initPaint();
155 |
156 | }
157 |
158 | private void initPaint() {
159 | mPaint = new Paint();
160 | mPaint.setColor(mColor);
161 | mPaint.setStyle(Paint.Style.STROKE);
162 | mPaint.setStrokeWidth(mThickness);
163 | }
164 |
165 |
166 | @Override
167 | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
168 |
169 | mPaint.setColor(mColor);
170 | if (mMode == MODE_HORIZONTAL) {
171 | drawHorinzonal(c, parent);
172 | } else if (mMode == MODE_VERTICAL) {
173 | drawVertical(c, parent);
174 | } else if (mMode == MODE_GRID) {
175 | drawGrid(c, parent);
176 | }
177 | }
178 |
179 | @Override
180 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
181 |
182 | if (mMode == MODE_HORIZONTAL) {
183 |
184 | if (!(!mLastLineVisible &&
185 | parent.getChildLayoutPosition(view) == parent.getAdapter().getItemCount() - 1)) {
186 | if (mDrawableRid != 0) {
187 | outRect.set(0, 0, 0, mCurrentThickness);
188 | } else {
189 | outRect.set(0, 0, 0, mThickness);
190 | }
191 | }
192 |
193 | if (mFirstLineVisible && parent.getChildLayoutPosition(view) == 0) {
194 | if (mDrawableRid != 0) {
195 | outRect.set(0, mCurrentThickness, 0, mCurrentThickness);
196 | } else {
197 | outRect.set(0, mThickness, 0, mThickness);
198 | }
199 | }
200 |
201 | } else if (mMode == MODE_VERTICAL) {
202 | if (!(!mLastLineVisible &&
203 | parent.getChildLayoutPosition(view) == parent.getAdapter().getItemCount() - 1)) {
204 | if (mDrawableRid != 0) {
205 | outRect.set(0, 0, mCurrentThickness, 0);
206 | } else {
207 | outRect.set(0, 0, mThickness, 0);
208 | }
209 | }
210 | if (mFirstLineVisible && parent.getChildLayoutPosition(view) == 0) {
211 | if (mDrawableRid != 0) {
212 | outRect.set(mCurrentThickness, 0, mCurrentThickness, 0);
213 | } else {
214 | outRect.set(mThickness, 0, mThickness, 0);
215 | }
216 | }
217 |
218 | } else if (mMode == MODE_GRID) {
219 | int columnSize = ((GridLayoutManager) parent.getLayoutManager()).getSpanCount();
220 | int itemSzie = parent.getAdapter().getItemCount();
221 | if (mDrawableRid != 0) {
222 | if (isLastRowGrid(parent.getChildLayoutPosition(view), itemSzie, columnSize)
223 | && isLastGridColumn(parent.getChildLayoutPosition(view), columnSize)) {
224 | outRect.set(0, 0, 0, 0);
225 | } else if (isLastRowGrid(parent.getChildLayoutPosition(view), itemSzie, columnSize)) {
226 | outRect.set(0, 0, mBmp.getWidth(), 0);
227 | } else if ((parent.getChildLayoutPosition(view) + 1) % columnSize != 0) {
228 | outRect.set(0, 0, mBmp.getWidth(), mBmp.getHeight());
229 | } else {
230 | outRect.set(0, 0, 0, mBmp.getHeight());
231 | }
232 | } else {
233 | if (isLastRowGrid(parent.getChildLayoutPosition(view), itemSzie, columnSize)
234 | && isLastGridColumn(parent.getChildLayoutPosition(view), columnSize)) {
235 | outRect.set(0, 0, 0, 0);
236 | } else if (isLastRowGrid(parent.getChildLayoutPosition(view), itemSzie, columnSize)) {
237 | outRect.set(0, 0, mThickness, 0);
238 | } else if ((parent.getChildLayoutPosition(view) + 1) % columnSize != 0) {
239 | outRect.set(0, 0, mThickness, mThickness);
240 | } else {
241 | outRect.set(0, 0, 0, mThickness);
242 | }
243 |
244 | }
245 | }
246 |
247 | }
248 |
249 | /**
250 | * judge is a color string like #xxxxxx or #xxxxxxxx
251 | *
252 | * @param colorStr
253 | * @return
254 | */
255 | public static boolean isColorString(String colorStr) {
256 | return Pattern.matches("^#([0-9a-fA-F]{6}||[0-9a-fA-F]{8})$", colorStr);
257 | }
258 |
259 | private boolean isPureLine() {
260 | if (mDashGap == 0 && mDashWidth == 0)
261 | return true;
262 | return false;
263 | }
264 |
265 | /**
266 | * draw horizonal decoration
267 | *
268 | * @param c
269 | * @param parent
270 | */
271 | private void drawHorinzonal(Canvas c, RecyclerView parent) {
272 | int childrentCount = parent.getChildCount();
273 |
274 | if (mDrawableRid != 0) {
275 |
276 | if (mFirstLineVisible) {
277 | View childView = parent.getChildAt(0);
278 | int myY = childView.getTop();
279 |
280 | if (hasNinePatch) {
281 | Rect rect = new Rect(mPaddingStart, myY - mCurrentThickness, parent.getWidth() - mPaddingEnd, myY);
282 | mNinePatch.draw(c, rect);
283 | } else {
284 | c.drawBitmap(mBmp, mPaddingStart, myY - mCurrentThickness, mPaint);
285 | }
286 | }
287 |
288 | for (int i = 0; i < childrentCount; i++) {
289 | if (!mLastLineVisible && i == childrentCount - 1)
290 | break;
291 | View childView = parent.getChildAt(i);
292 | int myY = childView.getBottom();
293 |
294 | if (hasNinePatch) {
295 | Rect rect = new Rect(mPaddingStart, myY, parent.getWidth() - mPaddingEnd, myY + mCurrentThickness);
296 | mNinePatch.draw(c, rect);
297 | } else {
298 | c.drawBitmap(mBmp, mPaddingStart, myY, mPaint);
299 | }
300 |
301 | }
302 |
303 | } else {
304 |
305 | boolean isPureLine = isPureLine();
306 | if (!isPureLine) {
307 | PathEffect effects = new DashPathEffect(new float[]{0, 0, mDashWidth, mThickness}, mDashGap);
308 | mPaint.setPathEffect(effects);
309 | }
310 |
311 | if (mFirstLineVisible) {
312 | View childView = parent.getChildAt(0);
313 | int myY = childView.getTop() - mThickness/ 2 ;
314 |
315 | if (isPureLine) {
316 | c.drawLine(mPaddingStart, myY, parent.getWidth() - mPaddingEnd, myY, mPaint);
317 | } else {
318 | Path path = new Path();
319 | path.moveTo(mPaddingStart, myY);
320 | path.lineTo(parent.getWidth() - mPaddingEnd, myY);
321 | c.drawPath(path, mPaint);
322 | }
323 | }
324 |
325 | for (int i = 0; i < childrentCount; i++) {
326 | if (!mLastLineVisible && i == childrentCount - 1)
327 | break;
328 | View childView = parent.getChildAt(i);
329 | int myY = childView.getBottom() + mThickness / 2;
330 |
331 | if (isPureLine) {
332 | c.drawLine(mPaddingStart, myY, parent.getWidth() - mPaddingEnd, myY, mPaint);
333 | } else {
334 | Path path = new Path();
335 | path.moveTo(mPaddingStart, myY);
336 | path.lineTo(parent.getWidth() - mPaddingEnd, myY);
337 | c.drawPath(path, mPaint);
338 | }
339 |
340 | }
341 |
342 | }
343 | }
344 |
345 | /**
346 | * draw vertival decoration
347 | *
348 | * @param c
349 | * @param parent
350 | */
351 | private void drawVertical(Canvas c, RecyclerView parent) {
352 | int childrentCount = parent.getChildCount();
353 | if (mDrawableRid != 0) {
354 |
355 | if (mFirstLineVisible) {
356 | View childView = parent.getChildAt(0);
357 | int myX = childView.getLeft();
358 | if (hasNinePatch) {
359 | Rect rect = new Rect(myX - mCurrentThickness, mPaddingStart, myX, parent.getHeight() - mPaddingEnd);
360 | mNinePatch.draw(c, rect);
361 | } else {
362 | c.drawBitmap(mBmp, myX - mCurrentThickness, mPaddingStart, mPaint);
363 | }
364 | }
365 | for (int i = 0; i < childrentCount; i++) {
366 | if (!mLastLineVisible && i == childrentCount - 1)
367 | break;
368 | View childView = parent.getChildAt(i);
369 | int myX = childView.getRight();
370 | if (hasNinePatch) {
371 | Rect rect = new Rect(myX, mPaddingStart, myX + mCurrentThickness, parent.getHeight() - mPaddingEnd);
372 | mNinePatch.draw(c, rect);
373 | } else {
374 | c.drawBitmap(mBmp, myX, mPaddingStart, mPaint);
375 | }
376 | }
377 |
378 | } else {
379 |
380 | boolean isPureLine = isPureLine();
381 | if (!isPureLine) {
382 | PathEffect effects = new DashPathEffect(new float[]{0, 0, mDashWidth, mThickness}, mDashGap);
383 | mPaint.setPathEffect(effects);
384 | }
385 |
386 | if (mFirstLineVisible) {
387 | View childView = parent.getChildAt(0);
388 | int myX = childView.getLeft() - mThickness / 2;
389 | if (isPureLine) {
390 | c.drawLine(myX, mPaddingStart, myX, parent.getHeight() - mPaddingEnd, mPaint);
391 | } else {
392 | Path path = new Path();
393 | path.moveTo(myX, mPaddingStart);
394 | path.lineTo(myX, parent.getHeight() - mPaddingEnd);
395 | c.drawPath(path, mPaint);
396 | }
397 | }
398 |
399 | for (int i = 0; i < childrentCount; i++) {
400 | if (!mLastLineVisible && i == childrentCount - 1)
401 | break;
402 | View childView = parent.getChildAt(i);
403 | int myX = childView.getRight() + mThickness / 2;
404 | if (isPureLine) {
405 | c.drawLine(myX, mPaddingStart, myX, parent.getHeight() - mPaddingEnd, mPaint);
406 | } else {
407 | Path path = new Path();
408 | path.moveTo(myX, mPaddingStart);
409 | path.lineTo(myX, parent.getHeight() - mPaddingEnd);
410 | c.drawPath(path, mPaint);
411 | }
412 |
413 | }
414 | }
415 | }
416 |
417 | /**
418 | * draw grid decoration
419 | *
420 | * @param c
421 | * @param parent
422 | */
423 | private void drawGrid(Canvas c, RecyclerView parent) {
424 |
425 | int childrentCount = parent.getChildCount();
426 | int columnSize = ((GridLayoutManager) parent.getLayoutManager()).getSpanCount();
427 | int adapterChildrenCount = parent.getAdapter().getItemCount();
428 |
429 | if (mDrawableRid != 0) {
430 | if (hasNinePatch) {
431 | for (int i = 0; i < childrentCount; i++) {
432 | View childView = parent.getChildAt(i);
433 | int myX = childView.getRight();
434 | int myY = childView.getBottom();
435 |
436 | //horizonal
437 | if (!isLastRowGrid(i, adapterChildrenCount, columnSize)) {
438 | Rect rect = new Rect(0, myY, myX, myY + mBmp.getHeight());
439 | mNinePatch.draw(c, rect);
440 | }
441 |
442 | //vertical
443 | if (isLastRowGrid(i, adapterChildrenCount, columnSize)
444 | && !isLastGridColumn(i, columnSize)) {
445 | Rect rect = new Rect(myX, childView.getTop(), myX + mBmp.getWidth(), myY);
446 | mNinePatch.draw(c, rect);
447 | } else if (!isLastGridColumn(i, columnSize)) {
448 | Rect rect = new Rect(myX, childView.getTop(), myX + mBmp.getWidth(), myY + mBmp.getHeight());
449 | mNinePatch.draw(c, rect);
450 | }
451 |
452 | }
453 | } else {
454 |
455 | for (int i = 0; i < childrentCount; i++) {
456 | View childView = parent.getChildAt(i);
457 | int myX = childView.getRight();
458 | int myY = childView.getBottom();
459 |
460 | //horizonal
461 | if (!isLastRowGrid(i, adapterChildrenCount, columnSize)) {
462 | c.drawBitmap(mBmp, childView.getLeft(), myY, mPaint);
463 | }
464 |
465 | //vertical
466 | if (!isLastGridColumn(i, columnSize)) {
467 | c.drawBitmap(mBmp, myX, childView.getTop(), mPaint);
468 | }
469 |
470 |
471 | }
472 | }
473 | } else if (mDashWidth == 0 && mDashGap == 0) {
474 |
475 | for (int i = 0; i < childrentCount; i++) {
476 | View childView = parent.getChildAt(i);
477 | int myX = childView.getRight() + mThickness / 2;
478 | int myY = childView.getBottom() + mThickness / 2;
479 |
480 | //horizonal
481 | if (!isLastRowGrid(i, adapterChildrenCount, columnSize)) {
482 | c.drawLine(childView.getLeft(), myY, childView.getRight() + mThickness, myY, mPaint);
483 | }
484 |
485 | //vertical
486 | if (isLastRowGrid(i, adapterChildrenCount, columnSize)
487 | && !isLastGridColumn(i, columnSize)) {
488 | c.drawLine(myX, childView.getTop(), myX, childView.getBottom(), mPaint);
489 | } else if (!isLastGridColumn(i, columnSize)) {
490 | c.drawLine(myX, childView.getTop(), myX, myY, mPaint);
491 | }
492 |
493 | }
494 |
495 |
496 | } else {
497 | PathEffect effects = new DashPathEffect(new float[]{0, 0, mDashWidth, mThickness}, mDashGap);
498 | mPaint.setPathEffect(effects);
499 | for (int i = 0; i < childrentCount; i++) {
500 | View childView = parent.getChildAt(i);
501 | int myX = childView.getRight() + mThickness / 2;
502 | int myY = childView.getBottom() + mThickness / 2;
503 |
504 | //horizonal
505 | if (!isLastRowGrid(i, adapterChildrenCount, columnSize)) {
506 | Path path = new Path();
507 | path.moveTo(0, myY);
508 | path.lineTo(myX, myY);
509 | c.drawPath(path, mPaint);
510 | }
511 |
512 | //vertical
513 | if (isLastRowGrid(i, adapterChildrenCount, columnSize)
514 | && !isLastGridColumn(i, columnSize)) {
515 | Path path = new Path();
516 | path.moveTo(myX, childView.getTop());
517 | path.lineTo(myX, childView.getBottom());
518 | c.drawPath(path, mPaint);
519 | } else if (!isLastGridColumn(i, columnSize)) {
520 | Path path = new Path();
521 | path.moveTo(myX, childView.getTop());
522 | path.lineTo(myX, childView.getBottom());
523 | c.drawPath(path, mPaint);
524 | }
525 |
526 | }
527 | }
528 | }
529 |
530 | /**
531 | * check if is one of the last columns
532 | *
533 | * @param position
534 | * @param columnSize
535 | * @return
536 | */
537 | private boolean isLastGridColumn(int position, int columnSize) {
538 | boolean isLast = false;
539 | if ((position + 1) % columnSize == 0) {
540 | isLast = true;
541 | }
542 | return isLast;
543 | }
544 |
545 | /**
546 | * check if is the last row of the grid
547 | *
548 | * @param position
549 | * @param itemSize
550 | * @param columnSize
551 | * @return
552 | */
553 | private boolean isLastRowGrid(int position, int itemSize, int columnSize) {
554 | return position / columnSize == (itemSize - 1) / columnSize;
555 | }
556 |
557 | public static class Builder {
558 |
559 | private Param params;
560 | private Context context;
561 |
562 | public Builder(Context context) {
563 |
564 | params = new Param();
565 | this.context = context;
566 |
567 | }
568 |
569 | public RecyclerViewItemDecoration create() {
570 | RecyclerViewItemDecoration recyclerViewItemDecoration = new RecyclerViewItemDecoration();
571 | recyclerViewItemDecoration.setParams(context, params);
572 | return recyclerViewItemDecoration;
573 | }
574 |
575 | public Builder mode(int mode) {
576 | params.mode = mode;
577 | return this;
578 | }
579 |
580 | public Builder drawableID(int drawableID) {
581 | params.drawableRid = drawableID;
582 | return this;
583 | }
584 |
585 | public Builder color(@ColorInt int color) {
586 | params.color = color;
587 | return this;
588 | }
589 |
590 | public Builder color(String color) {
591 | if (isColorString(color)) {
592 | params.color = Color.parseColor(color);
593 | }
594 | return this;
595 | }
596 |
597 | public Builder thickness(int thickness) {
598 | params.thickness = thickness;
599 | return this;
600 | }
601 |
602 | public Builder dashWidth(int dashWidth) {
603 | params.dashWidth = dashWidth;
604 | return this;
605 | }
606 |
607 | public Builder dashGap(int dashGap) {
608 | params.dashGap = dashGap;
609 | return this;
610 | }
611 |
612 | public Builder lastLineVisible(boolean visible) {
613 | params.lastLineVisible = visible;
614 | return this;
615 | }
616 |
617 | public Builder firstLineVisible(boolean visible) {
618 | params.firstLineVisible = visible;
619 | return this;
620 | }
621 |
622 | public Builder paddingStart(int padding) {
623 | params.paddingStart = padding;
624 | return this;
625 | }
626 |
627 | public Builder paddingEnd(int padding) {
628 | params.paddingEnd = padding;
629 | return this;
630 | }
631 | }
632 |
633 | private static class Param {
634 |
635 | public int mode = MODE_HORIZONTAL;
636 | public int drawableRid = 0;
637 | public int color = Color.parseColor(DEFAULT_COLOR);
638 | public int thickness;
639 | public int dashWidth = 0;
640 | public int dashGap = 0;
641 | public boolean lastLineVisible;
642 | public boolean firstLineVisible;
643 | public int paddingStart;
644 | public int paddingEnd;
645 | }
646 |
647 | }
648 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/common_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ShallowMeet/OrganizeSelectionDemo/ed3746f64e35ce807edad14af41f83ee821e7e82/app/src/main/res/drawable-xhdpi/common_arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_item_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 | -
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_org_contact.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
18 |
19 |
20 |
21 |
26 |
27 |
28 |
34 |
38 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_all.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_emp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_org.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
19 |
20 |
25 |
26 |
32 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ShallowMeet/OrganizeSelectionDemo/ed3746f64e35ce807edad14af41f83ee821e7e82/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ShallowMeet/OrganizeSelectionDemo/ed3746f64e35ce807edad14af41f83ee821e7e82/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ShallowMeet/OrganizeSelectionDemo/ed3746f64e35ce807edad14af41f83ee821e7e82/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ShallowMeet/OrganizeSelectionDemo/ed3746f64e35ce807edad14af41f83ee821e7e82/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ShallowMeet/OrganizeSelectionDemo/ed3746f64e35ce807edad14af41f83ee821e7e82/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ShallowMeet/OrganizeSelectionDemo/ed3746f64e35ce807edad14af41f83ee821e7e82/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ShallowMeet/OrganizeSelectionDemo/ed3746f64e35ce807edad14af41f83ee821e7e82/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ShallowMeet/OrganizeSelectionDemo/ed3746f64e35ce807edad14af41f83ee821e7e82/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ShallowMeet/OrganizeSelectionDemo/ed3746f64e35ce807edad14af41f83ee821e7e82/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ShallowMeet/OrganizeSelectionDemo/ed3746f64e35ce807edad14af41f83ee821e7e82/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MyDemo
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/mydemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.mydemo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | maven { url "https://jitpack.io" }
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | }
25 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ShallowMeet/OrganizeSelectionDemo/ed3746f64e35ce807edad14af41f83ee821e7e82/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat May 20 21:38:48 AWST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------