From 336bf152d4d38a8b2284896fe2eba8d751a41317 Mon Sep 17 00:00:00 2001
From: YuanArcheanNovice <624117230@qq.com>
Date: Thu, 18 Oct 2018 13:03:27 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=8A=B6=E6=80=81layout?=
=?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96dataadapter?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/caches/build_file_checksums.ser | Bin 595 -> 585 bytes
.idea/encodings.xml | 6 -
.idea/inspectionProfiles/Project_Default.xml | 36 -
.idea/misc.xml | 10 +-
.idea/vcs.xml | 2 +-
.idea/workspace.xml | 2373 +++++++++--------
Xadapter/Xadapter.iml | 31 +-
Xadapter/build.gradle | 8 +-
.../com/xz/xadapter/XRvPureDataAdapter.java | 20 +-
.../com/xz/xadapter/XRvStatusAdapter.java | 217 ++
.../com/xz/xadapter/xutil/XRvViewHolder.java | 6 +
.../main/res/layout/item_adapter_other.xml | 19 +
Xadapter/src/main/res/values/colors.xml | 5 +
Xadapter/src/main/res/values/styles.xml | 5 +
app/app.iml | 33 +-
app/build.gradle | 16 +-
build.gradle | 2 +-
gradle/wrapper/gradle-wrapper.properties | 4 +-
local.properties | 6 +-
19 files changed, 1623 insertions(+), 1176 deletions(-)
delete mode 100644 .idea/encodings.xml
delete mode 100644 .idea/inspectionProfiles/Project_Default.xml
create mode 100644 Xadapter/src/main/java/com/xz/xadapter/XRvStatusAdapter.java
create mode 100644 Xadapter/src/main/res/layout/item_adapter_other.xml
create mode 100644 Xadapter/src/main/res/values/colors.xml
create mode 100644 Xadapter/src/main/res/values/styles.xml
diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
index be4b980c49b9de961ecc41a457bfc64d15f3aa32..79bede630c15fb8a64a6952053537595dd9e6117 100644
GIT binary patch
delta 141
zcmV;80CNA+1jz)Dmjz~pORM0KoOcjIi!g;My2#4LK40Awh0iCGBLPJaF!zG;XV}G>
zTxgg@@yp*NlXw9gA5T$uDzj1Ud_(wWvS;2AJahmiLpoelb7gXKTtr1ylfD5~85yop
vH_(D(MVze3G2dT5E_479XL4a=Y-N*x0TmI{9gNwJ0I~$>fC-rF_(FboU64IE
delta 124
zcmV-?0E7R@1k(hNmjz|W&Nyq4oOck-q~4vZ$}}|Dz$+V;x&(TYBLPJavC&Mw3HE%|
zv*6$j%#L&2lXw9gDXBK?@&?LB(zDsS>KWeIO>_V-Lpoelb7gXKTtQ@QX>MtAbaG*I
eZ*r5g0ag$mIQDv_RH@6v3C@dZ#&uMa8Uin(G&&vt
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index 97626ba..0000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index 6560a98..0000000
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index dc34569..44a4802 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,27 +5,31 @@
-
+
+
+
-
+
+
+
-
+
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 94a25f7..35eb1dd 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 7bcf775..110bde1 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,35 +1,39 @@
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -52,107 +56,108 @@
-
-
+
+
-
-
-
+
+
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
+
+
-
-
+
+
-
-
-
+
+
-
-
+
+
-
-
-
+
+
-
-
+
+
-
-
-
+
+
-
-
+
+
-
-
-
+
+
-
-
+
+
+
+
+
-
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
-
-
+
+
+
+
+
+
@@ -165,12 +170,12 @@
-
+
-
+
@@ -188,14 +193,14 @@
-
-
-
-
+
+
+
+
@@ -217,11 +222,11 @@
-
+
-
+
@@ -235,22 +240,17 @@
-
-
-
-
-
-
+
-
+
-
+
@@ -263,11 +263,11 @@
-
+
-
+
@@ -282,6 +282,10 @@
+
+
+
+
@@ -303,10 +307,6 @@
-
-
-
-
@@ -316,6 +316,14 @@
+
+
+
+
+
+
+
+
@@ -338,24 +346,24 @@
-
+
-
+
+
-
+
-
-
+
@@ -369,6 +377,10 @@
+
+
+
+
@@ -423,6 +435,10 @@
+
+
+
+
@@ -432,6 +448,10 @@
+
+
+
+
@@ -451,7 +471,7 @@
-
+
@@ -474,24 +494,24 @@
-
+
-
+
-
+
-
-
+
+
-
+
@@ -507,11 +527,11 @@
-
+
-
+
@@ -541,10 +561,6 @@
-
-
-
-
@@ -557,6 +573,10 @@
+
+
+
+
@@ -597,6 +617,10 @@
+
+
+
+
@@ -624,6 +648,10 @@
+
+
+
+
@@ -639,15 +667,15 @@
-
+
-
+
-
+
@@ -665,7 +693,11 @@
-
+
+
+
+
+
@@ -700,6 +732,10 @@
+
+
+
+
@@ -717,10 +753,14 @@
-
+
+
+
+
+
@@ -735,11 +775,7 @@
-
-
-
-
-
+
@@ -754,13 +790,17 @@
-
+
+
+
+
+
@@ -792,17 +832,17 @@
-
-
+
+
-
+
@@ -822,6 +862,14 @@
+
+
+
+
+
+
+
+
@@ -836,6 +884,15 @@
+
+
+
+
+
+
+
+
+
@@ -850,11 +907,11 @@
-
+
-
+
@@ -866,11 +923,15 @@
-
+
+
+
+
+
-
+
@@ -900,12 +961,24 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -914,6 +987,10 @@
+
+
+
+
@@ -931,6 +1008,11 @@
+
+
+
+
+
@@ -957,6 +1039,10 @@
+
+
+
+
@@ -973,6 +1059,10 @@
+
+
+
+
@@ -981,6 +1071,14 @@
+
+
+
+
+
+
+
+
@@ -990,6 +1088,10 @@
+
+
+
+
@@ -1015,6 +1117,11 @@
+
+
+
+
+
@@ -1027,17 +1134,21 @@
+
+
+
+
-
+
-
+
@@ -1056,6 +1167,10 @@
+
+
+
+
@@ -1109,6 +1224,10 @@
+
+
+
+
@@ -1122,9 +1241,8 @@
-
-
+
@@ -1139,11 +1257,6 @@
-
-
-
-
-
@@ -1153,14 +1266,13 @@
-
+
-
+
-
-
+
@@ -1171,6 +1283,10 @@
+
+
+
+
@@ -1187,6 +1303,10 @@
+
+
+
+
@@ -1218,6 +1338,14 @@
+
+
+
+
+
+
+
+
@@ -1266,10 +1394,6 @@
-
-
-
-
@@ -1279,6 +1403,10 @@
+
+
+
+
@@ -1313,6 +1441,11 @@
+
+
+
+
+
@@ -1329,6 +1462,10 @@
+
+
+
+
@@ -1434,10 +1571,18 @@
+
+
+
+
+
+
+
+
@@ -1461,12 +1606,16 @@
-
+
+
+
+
+
@@ -1499,6 +1648,11 @@
+
+
+
+
+
@@ -1610,10 +1764,18 @@
+
+
+
+
+
+
+
+
@@ -1637,6 +1799,10 @@
+
+
+
+
@@ -1679,6 +1845,11 @@
+
+
+
+
+
@@ -1724,28 +1895,24 @@
-
+
-
+
-
+
-
+
-
-
-
-
@@ -1828,667 +1995,802 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
-
+
-
+
-
-
+
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
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-
-
-
@@ -3263,20 +3554,13 @@
-
-
-
-
-
-
-
+
-
-
-
+
+
@@ -3300,6 +3584,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -3308,15 +3603,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -3331,8 +3681,6 @@
-
-
@@ -3342,22 +3690,23 @@
-
-
+
+
+
@@ -3394,78 +3743,52 @@
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
+
-
-
+
+
-
-
-
+
+
+
+
-
-
+
+
+
-
-
-
-
- 1536671627361
+
+ 1539834415220
- 1536671627361
+ 1539834415220
@@ -3473,252 +3796,154 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
+
+
-
-
-
+
+
-
+
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
+
-
+
-
-
-
+
+
-
+
-
-
-
+
+
-
-
-
-
-
-
+
+
+
-
-
-
-
-
+
+
-
+
-
-
-
+
+
+
+
+
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
- 1.8
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Xadapter/Xadapter.iml b/Xadapter/Xadapter.iml
index 91c5a4b..3b48f92 100644
--- a/Xadapter/Xadapter.iml
+++ b/Xadapter/Xadapter.iml
@@ -17,26 +17,26 @@
-
+
-
-
+
+
-
+
-
+
@@ -71,13 +71,6 @@
-
-
-
-
-
-
-
@@ -85,12 +78,18 @@
-
+
+
+
+
+
+
+
+
-
-
-
+
+
diff --git a/Xadapter/build.gradle b/Xadapter/build.gradle
index 9a3fe49..079df90 100644
--- a/Xadapter/build.gradle
+++ b/Xadapter/build.gradle
@@ -23,12 +23,12 @@ android {
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
- testCompile 'junit:junit:4.12'
- compile "com.android.support:recyclerview-v7:${supportVersion}"
+ testImplementation 'junit:junit:4.12'
+ implementation "com.android.support:recyclerview-v7:${supportVersion}"
}
// 指定编码
diff --git a/Xadapter/src/main/java/com/xz/xadapter/XRvPureDataAdapter.java b/Xadapter/src/main/java/com/xz/xadapter/XRvPureDataAdapter.java
index a3e2bf8..84df8ab 100644
--- a/Xadapter/src/main/java/com/xz/xadapter/XRvPureDataAdapter.java
+++ b/Xadapter/src/main/java/com/xz/xadapter/XRvPureDataAdapter.java
@@ -26,6 +26,14 @@ public List getDatas() {
return mDatas;
}
+ /**
+ * 一般使用 不带刷新
+ */
+ public void setData(@NonNull T data) {
+ List lists = new ArrayList<>();
+ lists.add(data);
+ setDatas(lists, true);
+ }
/**
* 一般使用 不带刷新
@@ -42,9 +50,6 @@ public void setDatas(@NonNull List datas) {
* @param isRefresh 是否刷新
*/
public void setDatas(@NonNull List datas, boolean isRefresh) {
- if (datas == null) {
- return;
- }
if (mDatas == null) {
mDatas = new ArrayList<>();
} else {
@@ -62,7 +67,7 @@ public void setDatas(@NonNull List datas, boolean isRefresh) {
* @param data 数据
* @param isRefresh 是否刷新
*/
- public void addData(T data, boolean isRefresh) {
+ public void addData(@NonNull T data, boolean isRefresh) {
if (this.mDatas == null) {
this.mDatas = new ArrayList<>();
this.mDatas.add(data);
@@ -83,7 +88,7 @@ public void addData(T data, boolean isRefresh) {
* @param data 数据
* @param isRefresh 是否刷新
*/
- public void addDatas(List data, boolean isRefresh) {
+ public void addDatas(@NonNull List data, boolean isRefresh) {
if (this.mDatas == null) {
this.mDatas = new ArrayList<>();
this.mDatas.addAll(data);
@@ -99,14 +104,13 @@ public void addDatas(List data, boolean isRefresh) {
}
-
/**
* 移除data
*
* @param data 对象
* @return 是否移除成功
*/
- public boolean removeData(T data) {
+ public boolean removeData(@NonNull T data) {
return this.mDatas != null && this.mDatas.remove(data);
}
@@ -131,7 +135,7 @@ public boolean removeData(int index) {
if (mDatas != null && index >= 0) {
if (index < mDatas.size()) {
mDatas.remove(index);
- notifyItemRangeRemoved(index,1);
+ notifyItemRangeRemoved(index, 1);
return true;
} else {
return false;
diff --git a/Xadapter/src/main/java/com/xz/xadapter/XRvStatusAdapter.java b/Xadapter/src/main/java/com/xz/xadapter/XRvStatusAdapter.java
new file mode 100644
index 0000000..e758a26
--- /dev/null
+++ b/Xadapter/src/main/java/com/xz/xadapter/XRvStatusAdapter.java
@@ -0,0 +1,217 @@
+package com.xz.xadapter;
+
+import android.annotation.SuppressLint;
+import android.graphics.Color;
+import android.support.annotation.ColorRes;
+import android.support.annotation.DimenRes;
+import android.support.annotation.LayoutRes;
+import android.support.annotation.NonNull;
+import android.support.v7.widget.GridLayoutManager;
+import android.support.v7.widget.RecyclerView;
+
+import com.xz.xadapter.xutil.XRvViewHolder;
+import com.xz.xadapter.xutil.XRvWrapperUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author xz
+ * 状态Adapter
+ */
+public abstract class XRvStatusAdapter extends XRvPureDataAdapter {
+
+ private boolean isLoading = false;
+
+ private boolean isEmpty = false;
+
+ private boolean isError = false;
+
+ private String mStatusTip = "";
+
+ private static final int ITEM_STATUS = 9999;
+
+
+ /**
+ * 设置状态文字 颜色
+ * resouce
+ */
+ @ColorRes
+ protected int getStatusTextColor() {
+ return 0;
+ }
+
+ /**
+ * 设置状态文字大小
+ * dp
+ */
+ protected int getStatusTextSize() {
+ return 0;
+ }
+
+ /**
+ * 初始化一个实例给状态adapter,避免mData为null,或者空
+ *
+ * @return 获取实例
+ */
+ protected abstract T initStatusLayout();
+
+ /**
+ * 显示正在加载中
+ */
+ public void showLoading(boolean loading) {
+ isLoading = loading;
+ if (loading) {
+ if (mDatas == null) {
+ mDatas = new ArrayList<>();
+ mDatas.add(initStatusLayout());
+ }
+ mStatusTip = "加载中...";
+ notifyDataSetChanged();
+ }
+ }
+
+ /**
+ * 显示数据为空
+ */
+ public void showEmpty(boolean empty) {
+ isEmpty = empty;
+ if (empty) {
+ if (mDatas == null) {
+ mDatas = new ArrayList<>();
+ mDatas.add(initStatusLayout());
+ }
+ mStatusTip = "暂无数据...";
+ notifyDataSetChanged();
+ }
+ }
+
+ /**
+ * 显示加载错误
+ */
+ public void showError(boolean error) {
+ isError = error;
+ if (error) {
+ if (mDatas == null) {
+ mDatas = new ArrayList<>();
+ mDatas.add(initStatusLayout());
+ }
+ mStatusTip = "加载失败,请检查网络!";
+ notifyDataSetChanged();
+ }
+ }
+
+ @Override
+ public void setDatas(List datas) {
+ if (datas != null && datas.size() > 0) {
+ resetStatus();
+ }
+ super.setDatas(datas);
+ if (mDatas.size() == 0) {
+ showEmpty(true);
+ }
+ }
+
+ @Override
+ public void setDatas(List datas, boolean isRefresh) {
+ if (datas != null && datas.size() > 0) {
+ resetStatus();
+ }
+ super.setDatas(datas, isRefresh);
+ if (mDatas.size() == 0) {
+ showEmpty(true);
+ }
+ }
+
+ @Override
+ public void addData(T data, boolean isRefresh) {
+ resetStatus();
+ super.addData(data, isRefresh);
+ }
+
+ @Override
+ public void addDatas(List data, boolean isRefresh) {
+ resetStatus();
+ super.addDatas(data, isRefresh);
+ }
+
+ private void resetStatus() {
+ isEmpty = false;
+ isLoading = false;
+ isError = false;
+ }
+
+ @Override
+ public final int getItemViewType(int position) {
+ if (isLoading || isEmpty || isError) {
+ return ITEM_STATUS;
+ }
+ return getItemViewTypeToStaus(position);
+ }
+
+ public int getItemViewTypeToStaus(int position) {
+ return 0;
+ }
+
+ @Override
+ public final int getItemLayout(int viewType) {
+ if (viewType == ITEM_STATUS) {
+ return R.layout.item_adapter_other;
+ }
+ return getItemLayoutToStatus(viewType);
+ }
+
+ /**
+ * 设置layout
+ */
+ @LayoutRes
+ public abstract int getItemLayoutToStatus(int viewType);
+
+
+ @Override
+ public final void onBindViewHolder(@NonNull XRvViewHolder holder, int position) {
+ if (getItemViewType(position) == ITEM_STATUS) {
+ holder.setText(R.id.ie_tv, mStatusTip);
+ if (getStatusTextColor() != 0) {
+ holder.setTextColor(R.id.ie_tv, getStatusTextColor());
+ }
+ if (getStatusTextSize() > 0) {
+ holder.setTextSize(R.id.ie_tv, getStatusTextSize());
+ }
+ } else {
+ onBindViewHolderToStatus(holder, position);
+ }
+ }
+
+
+ /**
+ * 显示数据,绑定控件
+ */
+ protected abstract void onBindViewHolderToStatus(@NonNull XRvViewHolder holder, int position);
+
+
+ @Override
+ public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
+ XRvWrapperUtils.onAttachedToRecyclerView(recyclerView, new XRvWrapperUtils.SpanSizeCallback() {
+ @Override
+ public int getSpanSize(GridLayoutManager gridLayoutManager, GridLayoutManager.SpanSizeLookup oldLookup, int position) {
+ if (isEmpty || isError || isLoading) {
+ return gridLayoutManager.getSpanCount();
+ }
+ if (oldLookup != null) {
+ return oldLookup.getSpanSize(position);
+ }
+ return 1;
+ }
+ });
+ }
+
+ @Override
+ public void onViewAttachedToWindow(@NonNull XRvViewHolder holder) {
+ super.onViewAttachedToWindow(holder);
+ if (isEmpty || isError || isLoading) {
+ XRvWrapperUtils.setFullSpan(holder);
+ }
+ }
+
+}
diff --git a/Xadapter/src/main/java/com/xz/xadapter/xutil/XRvViewHolder.java b/Xadapter/src/main/java/com/xz/xadapter/xutil/XRvViewHolder.java
index 7161768..3234419 100644
--- a/Xadapter/src/main/java/com/xz/xadapter/xutil/XRvViewHolder.java
+++ b/Xadapter/src/main/java/com/xz/xadapter/xutil/XRvViewHolder.java
@@ -111,6 +111,12 @@ public XRvViewHolder setBackgroundRes(int viewId, int backgroundRes) {
return this;
}
+ public XRvViewHolder setTextSize(int viewId, int textSize) {
+ TextView view = getView(viewId);
+ view.setTextSize(textSize);
+ return this;
+ }
+
public XRvViewHolder setTextColor(int viewId, int textColor) {
TextView view = getView(viewId);
view.setTextColor(textColor);
diff --git a/Xadapter/src/main/res/layout/item_adapter_other.xml b/Xadapter/src/main/res/layout/item_adapter_other.xml
new file mode 100644
index 0000000..2fd6837
--- /dev/null
+++ b/Xadapter/src/main/res/layout/item_adapter_other.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Xadapter/src/main/res/values/colors.xml b/Xadapter/src/main/res/values/colors.xml
new file mode 100644
index 0000000..6c0b8a3
--- /dev/null
+++ b/Xadapter/src/main/res/values/colors.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/Xadapter/src/main/res/values/styles.xml b/Xadapter/src/main/res/values/styles.xml
new file mode 100644
index 0000000..0ac0de1
--- /dev/null
+++ b/Xadapter/src/main/res/values/styles.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/app/app.iml b/app/app.iml
index 051209b..7e1c871 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -23,19 +23,19 @@
-
-
+
+
-
+
-
+
@@ -49,13 +49,6 @@
-
-
-
-
-
-
-
@@ -63,6 +56,13 @@
+
+
+
+
+
+
+
@@ -84,15 +84,20 @@
+
+
+
-
-
+
+
+
+
-
+
diff --git a/app/build.gradle b/app/build.gradle
index 8fe5da2..f3fb333 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -19,22 +19,22 @@ android {
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
- compile 'com.android.support.constraint:constraint-layout:1.0.2'
- testCompile 'junit:junit:4.12'
+ implementation 'com.android.support.constraint:constraint-layout:1.0.2'
+ testImplementation 'junit:junit:4.12'
//鸿婶的BaseAdapter git(https://github.com/hongyangAndroid/baseAdapter)
- compile "com.android.support:appcompat-v7:${supportVersion}"
- compile "com.android.support:support-v4:${supportVersion}"
- compile "com.android.support:recyclerview-v7:${supportVersion}"
+ implementation "com.android.support:appcompat-v7:${supportVersion}"
+ implementation "com.android.support:support-v4:${supportVersion}"
+ implementation "com.android.support:recyclerview-v7:${supportVersion}"
//刷新加载(https://github.com/scwang90/SmartRefreshLayout)
- compile ('com.scwang.smartrefresh:SmartRefreshLayout:1.0.3-alpha-2') {
+ implementation ('com.scwang.smartrefresh:SmartRefreshLayout:1.0.3-alpha-2') {
exclude group: 'com.android.support'
}
}
diff --git a/build.gradle b/build.gradle
index ee48413..991e928 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.3'
+ classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index aa57e5a..33089d1 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Tue Sep 11 21:16:56 CST 2018
+#Thu Oct 18 11:48:03 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
diff --git a/local.properties b/local.properties
index bd34ee9..564cc72 100644
--- a/local.properties
+++ b/local.properties
@@ -4,6 +4,6 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
-#Tue Sep 11 21:13:47 CST 2018
-ndk.dir=I\:\\Android\\AndroidStudio\\Sdk\\ndk-bundle
-sdk.dir=I\:\\Android\\AndroidStudio\\Sdk
+#Thu Oct 18 11:46:55 CST 2018
+ndk.dir=D\:\\AndroidStudioFile\\AndroidSdk\\ndk-bundle
+sdk.dir=D\:\\AndroidStudioFile\\AndroidSdk