@Override public void onActivityCreated(Bundle savedInstanceState) { if (savedInstanceState != null) { userBean = (UserBean) savedInstanceState.getSerializable("userBean"); accountBean = (AccountBean) savedInstanceState.getSerializable("account"); token = savedInstanceState.getString("token"); hashMap = (HashMap) savedInstanceState.getSerializable("hashmap"); selectedId = savedInstanceState.getString("selectedId"); clearAndReplaceValue((MessageListBean) savedInstanceState.getSerializable("bean")); timeLineAdapter.notifyDataSetChanged(); refreshLayout(bean); } else { if (dbTask == null || dbTask.getStatus() == MyAsyncTask.Status.FINISHED) { dbTask = new DBCacheTask(); dbTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR); } hashMap.put("0", new MessageListBean()); hashMap.put("1", new MessageListBean()); } super.onActivityCreated(savedInstanceState); groupTask = new GroupTask(); groupTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR); }
@Override public void onActivityCreated(Bundle savedInstanceState) { commander = ((AbstractAppActivity) getActivity()).getBitmapDownloader(); switch (getCurrentState(savedInstanceState)) { case FIRST_TIME_START: if (Utility.isTaskStopped(dbTask)) { dbTask = new DBCacheTask(); dbTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR); } break; case SCREEN_ROTATE: // nothing refreshLayout(getList()); break; case ACTIVITY_DESTROY_AND_CREATE: getList().addNewData((MessageListBean) savedInstanceState.getSerializable("bean")); userBean = (UserBean) savedInstanceState.getSerializable("userBean"); token = savedInstanceState.getString("token"); getAdapter().notifyDataSetChanged(); refreshLayout(bean); break; } super.onActivityCreated(savedInstanceState); }
@Override public void onDetach() { super.onDetach(); if (dbTask != null) dbTask.cancel(true); if (groupTask != null) groupTask.cancel(true); }
@Override public void onActivityCreated(Bundle savedInstanceState) { switch (getCurrentState(savedInstanceState)) { case FIRST_TIME_START: if (Utility.isTaskStopped(dbTask) && getList().getSize() == 0) { dbTask = new DBCacheTask(this, accountBean.getUid()); dbTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR); GroupInfoTask groupInfoTask = new GroupInfoTask( GlobalContext.getInstance().getSpecialToken(), GlobalContext.getInstance().getCurrentAccountId()); groupInfoTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR); } else { getAdapter().notifyDataSetChanged(); refreshLayout(getList()); } groupDataCache.put(ALL_GROUP_ID, new MessageListBean()); groupDataCache.put(BILATERAL_GROUP_ID, new MessageListBean()); if (getList().getSize() > 0) { groupDataCache.put(ALL_GROUP_ID, getList().copy()); } buildActionBarNav(); break; case SCREEN_ROTATE: // nothing refreshLayout(getList()); buildActionBarNav(); setListViewPositionFromPositionsCache(); break; case ACTIVITY_DESTROY_AND_CREATE: userBean = savedInstanceState.getParcelable("userBean"); accountBean = savedInstanceState.getParcelable("account"); token = savedInstanceState.getString("token"); if (Utility.isTaskStopped(dbTask) && getList().getSize() == 0) { dbTask = new DBCacheTask(this, accountBean.getUid()); dbTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR); GroupInfoTask groupInfoTask = new GroupInfoTask( GlobalContext.getInstance().getSpecialToken(), GlobalContext.getInstance().getCurrentAccountId()); groupInfoTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR); } else { getAdapter().notifyDataSetChanged(); refreshLayout(getList()); } groupDataCache.put(ALL_GROUP_ID, new MessageListBean()); groupDataCache.put(BILATERAL_GROUP_ID, new MessageListBean()); if (getList().getSize() > 0) { groupDataCache.put(ALL_GROUP_ID, getList().copy()); } buildActionBarNav(); break; } super.onActivityCreated(savedInstanceState); }