diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 86756a2..68c1565 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -3,8 +3,9 @@
-
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/ac_main.xml b/app/src/main/res/layout/ac_main.xml
index d3fe3a4..9c20b3f 100644
--- a/app/src/main/res/layout/ac_main.xml
+++ b/app/src/main/res/layout/ac_main.xml
@@ -34,4 +34,37 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build.gradle b/build.gradle
index aff4f41..77ce66e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.1.2'
+ classpath 'com.android.tools.build:gradle:2.1.3'
// 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 122a0dc..24c40b5 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Mon Dec 28 10:00:20 PST 2015
+#Tue Aug 16 10:13:25 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
diff --git a/libray_lxndroid/build.gradle b/libray_lxndroid/build.gradle
index 14c1d2b..9d9322b 100644
--- a/libray_lxndroid/build.gradle
+++ b/libray_lxndroid/build.gradle
@@ -27,10 +27,8 @@ dependencies {
compile 'org.xutils:xutils:3.3.34'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.linglongxin24:UncaughtExceptionSendEmail:1.0.0'
- debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
- // or 1.4-beta1
- releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
- // or 1.4-beta1
- testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
+// debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
+// releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
+// testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
compile 'com.android.support:design:23.4.0'
}
diff --git a/libray_lxndroid/src/main/java/com/kejiang/yuandl/app/MyApplication.java b/libray_lxndroid/src/main/java/com/kejiang/yuandl/app/MyApplication.java
index 813b748..8a2aa29 100644
--- a/libray_lxndroid/src/main/java/com/kejiang/yuandl/app/MyApplication.java
+++ b/libray_lxndroid/src/main/java/com/kejiang/yuandl/app/MyApplication.java
@@ -1,49 +1,41 @@
-package com.kejiang.yuandl.app;
-
-import android.app.Application;
-import android.app.admin.SystemUpdatePolicy;
-import android.content.Context;
-import android.os.Vibrator;
-
-import com.squareup.leakcanary.LeakCanary;
-import com.kejiang.yuandl.mylibrary.CustomActivityOnCrash;
-import com.orhanobut.logger.Logger;
-import com.squareup.leakcanary.RefWatcher;
-
-import org.xutils.x;
-
-/**
- * Created by yuandl on 2016/5/23 0023.
- */
-public class MyApplication extends Application {
-
- private RefWatcher refWatcher;
-
- @Override
- public void onCreate() {
- super.onCreate();
- CustomActivityOnCrash.install(this);
- CustomActivityOnCrash.setDebugMode(true);
- String[] emialTo = {"yuandl@Bluemobi.cn", "kangfh@Bluemobi.cn"};
- CustomActivityOnCrash.setEmailTo(emialTo);
- Logger.init("law");
- x.Ext.init(this);
-// refWatcher = LeakCanary.install(this);
- refWatcher = installLeakCanary();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- System.gc();
- }
-
- public static RefWatcher getRefWatcher(Context context) {
- MyApplication application = (MyApplication) context.getApplicationContext();
- return application.refWatcher;
- }
-
- protected RefWatcher installLeakCanary() {
- return RefWatcher.DISABLED;
- }
-}
+//package com.kejiang.yuandl.app;
+//
+//import android.app.Application;
+//import android.content.Context;
+//
+//import com.kejiang.yuandl.mylibrary.CustomActivityOnCrash;
+//import com.orhanobut.logger.Logger;
+//import org.xutils.x;
+//
+///**
+// * Created by yuandl on 2016/5/23 0023.
+// */
+//public class MyApplication extends Application {
+// @Override
+// public void onCreate() {
+// super.onCreate();
+//// CustomActivityOnCrash.install(this);
+//// CustomActivityOnCrash.setDebugMode(true);
+//// String[] emialTo = {"yuandl@Bluemobi.cn", "kangfh@Bluemobi.cn"};
+//// CustomActivityOnCrash.setEmailTo(emialTo);
+//// Logger.init("law");
+//// x.Ext.init(this);
+//// refWatcher = LeakCanary.install(this);
+//// refWatcher = installLeakCanary();
+// }
+//
+// @Override
+// public void onLowMemory() {
+// super.onLowMemory();
+// System.gc();
+// }
+//
+//// public static RefWatcher getRefWatcher(Context context) {
+//// MyApplication application = (MyApplication) context.getApplicationContext();
+//// return application.refWatcher;
+//// }
+////
+//// protected RefWatcher installLeakCanary() {
+//// return RefWatcher.DISABLED;
+//// }
+//}
diff --git a/libray_lxndroid/src/main/java/com/kejiang/yuandl/base/BaseActivity.java b/libray_lxndroid/src/main/java/com/kejiang/yuandl/base/BaseActivity.java
index b412ccb..444bc5b 100644
--- a/libray_lxndroid/src/main/java/com/kejiang/yuandl/base/BaseActivity.java
+++ b/libray_lxndroid/src/main/java/com/kejiang/yuandl/base/BaseActivity.java
@@ -61,6 +61,7 @@ import java.net.SocketTimeoutException;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
+import java.util.Observer;
import java.util.Set;
/**
@@ -452,7 +453,7 @@ public abstract class BaseActivity extends AutoLayoutActivity implements View.On
@Override
public void onStarted() {
- netOnStart();
+ netOnStart(requestCode);
}
@Override
@@ -546,7 +547,12 @@ public abstract class BaseActivity extends AutoLayoutActivity implements View.On
return jsonBean;
}
-
+ /**
+ * 开始访问网络
+ */
+ protected void netOnStart(int requestCode) {
+ netOnStart();
+ }
/**
* 开始访问网络
*/
@@ -622,7 +628,7 @@ public abstract class BaseActivity extends AutoLayoutActivity implements View.On
int responseCode = httpEx.getCode();
String responseMsg = httpEx.getMessage();
String errorResult = httpEx.getResult();
- Toast.makeText(x.app(), "网络错误:" + ex.getMessage(), Toast.LENGTH_LONG).show();
+ Toast.makeText(x.app(), "网络繁忙", Toast.LENGTH_LONG).show();
// ...
} else if (ex instanceof SocketTimeoutException) {
Toast.makeText(x.app(), "连接服务器超时", Toast.LENGTH_LONG).show();
@@ -706,6 +712,7 @@ public abstract class BaseActivity extends AutoLayoutActivity implements View.On
protected void onDestroy() {
// fixFocusedViewLeak(x.app());
// fixInputMethodManager();
+// fixInputMethodManagerLeak(this);
mContentLayout.removeAllViews();
mContentLayout = null;
if (cancelable != null && !cancelable.isCancelled()) {
@@ -790,6 +797,48 @@ public abstract class BaseActivity extends AutoLayoutActivity implements View.On
Reflector.invokeMethodExceptionSafe(imm, "startGettingWindowFocus", view);
}
+ public static void fixInputMethodManagerLeak(Context context) {
+ if (context == null) {
+ return;
+ }
+ try {
+ // 对 mCurRootView mServedView mNextServedView 进行置空...
+ InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (imm == null) {
+ return;
+ }// author:sodino mail:sodino@qq.com
+ Object obj_get = null;
+ Field f_mCurRootView = imm.getClass().getDeclaredField("mCurRootView");
+ Field f_mServedView = imm.getClass().getDeclaredField("mServedView");
+ Field f_mNextServedView = imm.getClass().getDeclaredField("mNextServedView");
+
+ if (f_mCurRootView.isAccessible() == false) {
+ f_mCurRootView.setAccessible(true);
+ }
+ obj_get = f_mCurRootView.get(imm);
+ if (obj_get != null) { // 不为null则置为空
+ f_mCurRootView.set(imm, null);
+ }
+
+ if (f_mServedView.isAccessible() == false) {
+ f_mServedView.setAccessible(true);
+ }
+ obj_get = f_mServedView.get(imm);
+ if (obj_get != null) { // 不为null则置为空
+ f_mServedView.set(imm, null);
+ }
+
+ if (f_mNextServedView.isAccessible() == false) {
+ f_mNextServedView.setAccessible(true);
+ }
+ obj_get = f_mNextServedView.get(imm);
+ if (obj_get != null) { // 不为null则置为空
+ f_mNextServedView.set(imm, null);
+ }
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
}
diff --git a/libray_lxndroid/src/main/java/com/kejiang/yuandl/base/BaseFragment.java b/libray_lxndroid/src/main/java/com/kejiang/yuandl/base/BaseFragment.java
index ca10fa8..be9c1e9 100644
--- a/libray_lxndroid/src/main/java/com/kejiang/yuandl/base/BaseFragment.java
+++ b/libray_lxndroid/src/main/java/com/kejiang/yuandl/base/BaseFragment.java
@@ -18,18 +18,15 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.TypeReference;
-import com.kejiang.yuandl.app.MyApplication;
import com.kejiang.yuandl.bean.JsonBean;
import com.kejiang.yuandl.utils.CheckNetwork;
import com.kejiang.yuandl.utils.SharedPreferencesUtils;
import com.kejiang.yuandl.utils.Tools;
import com.kejiang.yuandl.view.LoadingDialog;
import com.orhanobut.logger.Logger;
-import com.squareup.leakcanary.RefWatcher;
import org.xutils.common.Callback;
import org.xutils.common.util.KeyValue;
-import org.xutils.common.util.MD5;
import org.xutils.ex.HttpException;
import org.xutils.http.RequestParams;
import org.xutils.x;
@@ -120,7 +117,7 @@ public class BaseFragment extends Fragment {
@Override
public void onStarted() {
- netOnStart();
+ netOnStart(requestCode);
}
@Override
@@ -220,6 +217,12 @@ public class BaseFragment extends Fragment {
protected void netOnStart() {
loadingDialog.show("Loading...");
}
+ /**
+ * 开始访问网络
+ */
+ protected void netOnStart(int requestCode) {
+ netOnStart();
+ }
/**
* 访问网络的进程
@@ -282,7 +285,7 @@ public class BaseFragment extends Fragment {
int responseCode = httpEx.getCode();
String responseMsg = httpEx.getMessage();
String errorResult = httpEx.getResult();
- Toast.makeText(x.app(), "网络错误:" + ex.getMessage(), Toast.LENGTH_LONG).show();
+ Toast.makeText(x.app(), "网络繁忙", Toast.LENGTH_LONG).show();
// ...
} else if (ex instanceof SocketTimeoutException) {
Toast.makeText(x.app(), "连接服务器超时", Toast.LENGTH_LONG).show();
@@ -426,8 +429,8 @@ public class BaseFragment extends Fragment {
if (cancelable != null && !cancelable.isCancelled()) {
cancelable.cancel();
}
- RefWatcher refWatcher = MyApplication.getRefWatcher(getActivity());
- refWatcher.watch(this);
+// RefWatcher refWatcher = MyApplication.getRefWatcher(getActivity());
+// refWatcher.watch(this);
}
}
diff --git a/libray_lxndroid/src/main/java/com/kejiang/yuandl/base/LazyLoadFragment.java b/libray_lxndroid/src/main/java/com/kejiang/yuandl/base/LazyLoadFragment.java
new file mode 100644
index 0000000..d3db1b2
--- /dev/null
+++ b/libray_lxndroid/src/main/java/com/kejiang/yuandl/base/LazyLoadFragment.java
@@ -0,0 +1,56 @@
+package com.kejiang.yuandl.base;
+
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+/**
+ * Created by yuandl on 2016/8/8 0008.
+ */
+public abstract class LazyLoadFragment extends Fragment {
+
+ /**
+ * 控件是否初始化完成
+ */
+ private boolean isViewCreated;
+ /**
+ * 数据是否已加载完毕
+ */
+ private boolean isLoadDataCompleted;
+
+ @Nullable
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ View view = inflater.inflate(getLayout(), container, false);
+ initViews(view);
+ isViewCreated = true;
+ return view;
+ }
+
+ public abstract int getLayout();
+ public abstract void initViews(View view);
+
+ @Override
+ public void setUserVisibleHint(boolean isVisibleToUser) {
+ super.setUserVisibleHint(isVisibleToUser);
+ if (isVisibleToUser && isViewCreated && !isLoadDataCompleted) {
+ loadData();
+ }
+ }
+
+ @Override
+ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ if (getUserVisibleHint()) {
+ loadData();
+ }
+ }
+
+ public void loadData() {
+ isLoadDataCompleted = true;
+ }
+}
diff --git a/libray_lxndroid/src/main/res/layout/ac_title.xml b/libray_lxndroid/src/main/res/layout/ac_title.xml
index 61ab346..ad602d9 100644
--- a/libray_lxndroid/src/main/res/layout/ac_title.xml
+++ b/libray_lxndroid/src/main/res/layout/ac_title.xml
@@ -1,12 +1,11 @@
-
+
diff --git a/libray_lxndroid/src/main/res/layout/public_titlebar.xml b/libray_lxndroid/src/main/res/layout/public_titlebar.xml
index 80082f1..5ff3cbe 100644
--- a/libray_lxndroid/src/main/res/layout/public_titlebar.xml
+++ b/libray_lxndroid/src/main/res/layout/public_titlebar.xml
@@ -4,9 +4,9 @@
android:layout_width="match_parent"
android:layout_height="160px"
android:background="#FFFFFF"
- android:fitsSystemWindows="true"
android:orientation="horizontal">
-
+