diff --git a/app/src/main/java/com/maning/gankmm/app/MyApplication.java b/app/src/main/java/com/maning/gankmm/app/MyApplication.java index 7b67a3f..2166712 100644 --- a/app/src/main/java/com/maning/gankmm/app/MyApplication.java +++ b/app/src/main/java/com/maning/gankmm/app/MyApplication.java @@ -15,6 +15,7 @@ import com.maning.librarycrashmonitor.main.MCrashMonitor; import com.readystatesoftware.chuck.ChuckInterceptor; import com.socks.library.KLog; +import com.umeng.analytics.MobclickAgent; import java.io.File; import java.io.IOException; @@ -60,6 +61,9 @@ public void onCreate() { //初始化异常捕获 initCrash(); + //Umeng统计相关 + initUmeng(); + //开启违例检测:StrictMode if (BuildConfig.LOG_DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build()); @@ -68,8 +72,13 @@ public void onCreate() { } + private void initUmeng() { + //禁止默认的页面统计方式 + MobclickAgent.openActivityDurationTrack(false); + } + private void initLog() { - KLog.init(BuildConfig.LOG_DEBUG, "GankMM"); + KLog.init(BuildConfig.LOG_DEBUG, "---GankMM---"); } diff --git a/app/src/main/java/com/maning/gankmm/ui/base/BaseActivity.java b/app/src/main/java/com/maning/gankmm/ui/base/BaseActivity.java index b3c98b4..d0d7674 100644 --- a/app/src/main/java/com/maning/gankmm/ui/base/BaseActivity.java +++ b/app/src/main/java/com/maning/gankmm/ui/base/BaseActivity.java @@ -118,14 +118,22 @@ protected void onDestroy() { @Override protected void onResume() { super.onResume(); - MobclickAgent.onPageStart(this.getClass().getSimpleName()); + // MainActivity 内嵌套Fragment,应在Fragment中统计页面 + String className = this.getClass().getSimpleName(); + if (!"MainActivity".equals(className)) { + MobclickAgent.onPageStart(className); // 统计页面 + } MobclickAgent.onResume(this); //统计时长 } @Override protected void onPause() { super.onPause(); - MobclickAgent.onPageStart(this.getClass().getSimpleName()); + // MainActivity 内嵌套Fragment,应在Fragment中统计页面 + String className = this.getClass().getSimpleName(); + if (!"MainActivity".equals(className)) { + MobclickAgent.onPageEnd(className); // 统计页面 + } MobclickAgent.onPause(this); } diff --git a/app/src/main/java/com/maning/gankmm/ui/base/BaseFragment.java b/app/src/main/java/com/maning/gankmm/ui/base/BaseFragment.java index 27ebfd0..39fe871 100644 --- a/app/src/main/java/com/maning/gankmm/ui/base/BaseFragment.java +++ b/app/src/main/java/com/maning/gankmm/ui/base/BaseFragment.java @@ -9,6 +9,9 @@ public class BaseFragment extends Fragment { + //统计名字判断 + public String className; + private SVProgressHUD mSVProgressHUD; @@ -18,6 +21,8 @@ public class BaseFragment extends Fragment { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + className = this.getClass().getSimpleName(); + context = getActivity(); initDialog(); @@ -43,13 +48,20 @@ public void dissmissProgressDialog() { @Override public void onResume() { super.onResume(); - MobclickAgent.onPageStart(this.getClass().getSimpleName()); + //CategoryFragment 内嵌套Fragment,统计子页面 + if (!"CategoryFragment".equals(className)) { + MobclickAgent.onPageStart(className); + } } @Override public void onPause() { super.onPause(); - MobclickAgent.onPageEnd(this.getClass().getSimpleName()); + //CategoryFragment 内嵌套Fragment,统计子页面 + if (!"CategoryFragment".equals(className)) { + MobclickAgent.onPageEnd(className); + } + } } diff --git a/app/src/main/java/com/maning/gankmm/ui/fragment/PublicFragment.java b/app/src/main/java/com/maning/gankmm/ui/fragment/PublicFragment.java index 93a059f..89214c7 100644 --- a/app/src/main/java/com/maning/gankmm/ui/fragment/PublicFragment.java +++ b/app/src/main/java/com/maning/gankmm/ui/fragment/PublicFragment.java @@ -18,9 +18,7 @@ import com.maning.gankmm.ui.base.BaseFragment; import com.maning.gankmm.ui.iView.IPublicView; import com.maning.gankmm.ui.presenter.impl.PublicPresenterImpl; -import com.maning.gankmm.utils.IntentUtils; import com.maning.gankmm.utils.MySnackbar; -import com.socks.library.KLog; import java.util.List; @@ -55,14 +53,14 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { flagFragment = getArguments().getString(Constants.FlagFragment); - KLog.i("CommentFragment-----onCreate:" + flagFragment); + //这个页面单独统计 + className = "CategoryFragment-" + flagFragment; } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - KLog.i("PublicFragment-----onCreateView"); View view = inflater.inflate(R.layout.fragment_common, container, false); ButterKnife.bind(this, view); @@ -76,8 +74,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - KLog.i("PublicFragment-----onViewCreated"); - publicPresenter = new PublicPresenterImpl(getActivity(), this, flagFragment); publicPresenter.getDBDatas();