|
|
@@ -7,6 +7,7 @@ import android.support.annotation.Nullable;
|
|
|
import android.support.v4.app.Fragment;
|
|
|
import android.support.v4.app.FragmentManager;
|
|
|
import android.support.v4.app.FragmentTransaction;
|
|
|
+import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
@@ -19,7 +20,7 @@ import com.usai.apex.SegmentView;
|
|
|
/**
|
|
|
* A simple {@link Fragment} subclass.
|
|
|
*/
|
|
|
-public class HomeFragment extends Fragment {
|
|
|
+public class HomeFragment extends Fragment implements KPIFragment.KPIPagerScrollListener{
|
|
|
|
|
|
private SegmentView mSegmentView;
|
|
|
|
|
|
@@ -90,7 +91,7 @@ public class HomeFragment extends Fragment {
|
|
|
|
|
|
mode = 0;
|
|
|
((RootActivity)getActivity()).getSupportActionBar().setDisplayShowTitleEnabled(false);
|
|
|
- ((Activity)getActivity()).setTitle(null);
|
|
|
+// ((Activity)getActivity()).setTitle(null);
|
|
|
// getChildFragmentManager().beginTransaction().show(recentFragment).hide(kpiFragment).commit();
|
|
|
|
|
|
// getChildFragmentManager().beginTransaction().show(getChildFragmentManager().getFragments().get(1)).hide(getChildFragmentManager().getFragments().get(0)).commit();
|
|
|
@@ -102,7 +103,7 @@ public class HomeFragment extends Fragment {
|
|
|
|
|
|
mode = 1;
|
|
|
((RootActivity)getActivity()).getSupportActionBar().setDisplayShowTitleEnabled(true);
|
|
|
- ((Activity)getActivity()).setTitle(null);
|
|
|
+// ((Activity)getActivity()).setTitle(null);
|
|
|
|
|
|
|
|
|
// getChildFragmentManager().beginTransaction().show(getChildFragmentManager().getFragments().get(0)).hide(getChildFragmentManager().getFragments().get(1)).commit();
|
|
|
@@ -146,9 +147,12 @@ public class HomeFragment extends Fragment {
|
|
|
fragment = kpiFragment;
|
|
|
else
|
|
|
kpiFragment = (KPIFragment) fragment;
|
|
|
+
|
|
|
+ kpiFragment.setKPIScrollListener(this);
|
|
|
}
|
|
|
activeFragment = fragment;
|
|
|
|
|
|
+ Log.d("Home Switch Mode", "UserHint: " + getUserVisibleHint() + " isHidden: " + isHidden());
|
|
|
if (activeFragment instanceof KPIFragment) {
|
|
|
kpiFragment.showTitle(getActivity(),true);
|
|
|
} else {
|
|
|
@@ -177,38 +181,65 @@ public class HomeFragment extends Fragment {
|
|
|
//
|
|
|
// }
|
|
|
|
|
|
- @Override
|
|
|
- public void setUserVisibleHint(boolean isVisibleToUser) {
|
|
|
- super.setUserVisibleHint(isVisibleToUser);
|
|
|
- // 初始化的时候为null
|
|
|
- if (getActivity() == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- // 切换到History,再切回来
|
|
|
- if (isVisibleToUser && activeFragment != null && activeFragment instanceof KPIFragment) {
|
|
|
- ((KPIFragment) activeFragment).showTitle(getActivity(),true);
|
|
|
- } else {
|
|
|
- ((RootActivity)getActivity()).getSupportActionBar().setDisplayShowTitleEnabled(false);
|
|
|
- ((Activity)getActivity()).setTitle(null);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onHiddenChanged(boolean hidden) {
|
|
|
- super.onHiddenChanged(hidden);
|
|
|
- if (getActivity() == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- // 切换到History,再切回来
|
|
|
- if (!hidden && activeFragment != null && activeFragment instanceof KPIFragment) {
|
|
|
- ((KPIFragment) activeFragment).showTitle(getActivity(),true);
|
|
|
- } else {
|
|
|
- ((RootActivity)getActivity()).getSupportActionBar().setDisplayShowTitleEnabled(false);
|
|
|
- ((Activity)getActivity()).setTitle(null);
|
|
|
- }
|
|
|
- }
|
|
|
+// @Override
|
|
|
+// public void setUserVisibleHint(boolean isVisibleToUser) {
|
|
|
+// super.setUserVisibleHint(isVisibleToUser);
|
|
|
+// // 初始化的时候为null
|
|
|
+// if (getActivity() == null) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// // 切换到History,再切回来
|
|
|
+// if (isVisibleToUser && activeFragment != null && activeFragment instanceof KPIFragment) {
|
|
|
+//// ((KPIFragment) activeFragment).showTitle(getActivity(),true);
|
|
|
+// ((RootActivity)getActivity()).getSupportActionBar().setDisplayShowTitleEnabled(true);
|
|
|
+// } else {
|
|
|
+// ((RootActivity)getActivity()).getSupportActionBar().setDisplayShowTitleEnabled(false);
|
|
|
+//// ((Activity)getActivity()).setTitle(null);
|
|
|
+// }
|
|
|
+//// Log.d("Home Switch Mode", " set UserHint: " +isVisibleToUser + " "+ getUserVisibleHint() + " isHidden: " + isHidden());
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void onHiddenChanged(boolean hidden) {
|
|
|
+// super.onHiddenChanged(hidden);
|
|
|
+// if (getActivity() == null) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// // 切换到History,再切回来
|
|
|
+// if (!hidden && activeFragment != null && activeFragment instanceof KPIFragment) {
|
|
|
+// ((KPIFragment) activeFragment).showTitle(getActivity(),true);
|
|
|
+// } else {
|
|
|
+// ((RootActivity)getActivity()).getSupportActionBar().setDisplayShowTitleEnabled(false);
|
|
|
+// ((Activity)getActivity()).setTitle(null);
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
+// @Override
|
|
|
+// public void onResume() {
|
|
|
+// super.onResume();
|
|
|
+//
|
|
|
+// if (getActivity() == null) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// // 切换到History,再切回来
|
|
|
+// if (getUserVisibleHint() && activeFragment != null && activeFragment instanceof KPIFragment) {
|
|
|
+// ((RootActivity)getActivity()).getSupportActionBar().setDisplayShowTitleEnabled(true);
|
|
|
+// } else {
|
|
|
+// ((RootActivity)getActivity()).getSupportActionBar().setDisplayShowTitleEnabled(false);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void onStop() {
|
|
|
+// super.onStop();
|
|
|
+//
|
|
|
+// if (getActivity() == null) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// ((RootActivity)getActivity()).getSupportActionBar().setDisplayShowTitleEnabled(false);
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
|
public void onSaveInstanceState(Bundle outState) {
|
|
|
@@ -227,4 +258,14 @@ public class HomeFragment extends Fragment {
|
|
|
mSegmentView.setSelect(mode);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void KPIPagerDidScrollToPage(int position) {
|
|
|
+ Log.d("Home Switch Mode", " Scroll UserHint: " + getUserVisibleHint() + " isHidden: " + isHidden());
|
|
|
+ if (activeFragment instanceof KPIFragment) {
|
|
|
+ kpiFragment.showTitle(getActivity(),true);
|
|
|
+ } else {
|
|
|
+ kpiFragment.showTitle(getActivity(),false);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|