@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); switch (getCurrentState(savedInstanceState)) { case FIRST_TIME_START: getLoaderManager().initLoader(DB_CACHE_LOADER_ID, null, dbCallback); break; case ACTIVITY_DESTROY_AND_CREATE: userBean = (UserBean) savedInstanceState.getParcelable("userBean"); accountBean = (AccountBean) savedInstanceState.getParcelable("account"); token = savedInstanceState.getString("token"); timeLinePosition = (TimeLinePosition) savedInstanceState.getSerializable("timeLinePosition"); Loader<CommentTimeLineData> loader = getLoaderManager().getLoader(DB_CACHE_LOADER_ID); if (loader != null) { getLoaderManager().initLoader(DB_CACHE_LOADER_ID, null, dbCallback); } CommentListBean savedBean = (CommentListBean) savedInstanceState.getParcelable("bean"); if (savedBean != null && savedBean.getSize() > 0) { clearAndReplaceValue(savedBean); timeLineAdapter.notifyDataSetChanged(); refreshLayout(getList()); setListViewPositionFromPositionsCache(); } else { getLoaderManager().initLoader(DB_CACHE_LOADER_ID, null, dbCallback); } break; } }
@Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); if (isVisible() && isVisibleToUser) { // ((MainTimeLineActivity) getActivity()).setCurrentFragment(this); } }
@Override public void onPause() { super.onPause(); if (!getActivity().isChangingConfigurations()) { CommentByMeTimeLineDBTask.asyncUpdatePosition(timeLinePosition, accountBean.getUid()); } }
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelable("account", accountBean); outState.putParcelable("userBean", userBean); outState.putString("token", token); if (getActivity().isChangingConfigurations()) { outState.putParcelable("bean", bean); outState.putSerializable("timeLinePosition", timeLinePosition); } }
@Override protected void onListViewScrollStop() { super.onListViewScrollStop(); timeLinePosition = Utility.getCurrentPositionFromListView(getListView()); }
@Override public void onDestroy() { super.onDestroy(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(false); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getListView().setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); getListView().setOnItemLongClickListener(onItemLongClickListener); }