gt:         if (list == null || list.size() == 0) {
context: 
  package org.zarroboogs.weibo.fragment;
  
  import org.zarroboogs.util.net.WeiboException;
  import org.zarroboogs.utils.AppLoggerUtils;
  import org.zarroboogs.utils.Constants;
  import org.zarroboogs.weibo.GlobalContext;
  import org.zarroboogs.weibo.MyAnimationListener;
  import org.zarroboogs.weibo.R;
  import org.zarroboogs.weibo.activity.BrowserWeiboMsgActivity;
  import org.zarroboogs.weibo.activity.MainTimeLineActivity;
  import org.zarroboogs.weibo.activity.WeiboMainActivity;
  import org.zarroboogs.weibo.activity.WriteWeiboActivity;
  import org.zarroboogs.weibo.adapter.AbstractAppListAdapter;
  import org.zarroboogs.weibo.adapter.FriendsTimeLineListNavAdapter;
  import org.zarroboogs.weibo.adapter.StatusListAdapter;
  import org.zarroboogs.weibo.asynctask.GroupInfoTask;
  import org.zarroboogs.weibo.asynctask.MyAsyncTask;
  import org.zarroboogs.weibo.bean.AccountBean;
  import org.zarroboogs.weibo.bean.AsyncTaskLoaderResult;
  import org.zarroboogs.weibo.bean.GroupBean;
  import org.zarroboogs.weibo.bean.MessageBean;
  import org.zarroboogs.weibo.bean.MessageListBean;
  import org.zarroboogs.weibo.bean.MessageReCmtCountBean;
  import org.zarroboogs.weibo.bean.MessageTimeLineData;
  import org.zarroboogs.weibo.bean.TimeLinePosition;
  import org.zarroboogs.weibo.bean.UserBean;
  import org.zarroboogs.weibo.dao.TimeLineReCmtCountDao;
  import org.zarroboogs.weibo.db.task.FriendsTimeLineDBTask;
  import org.zarroboogs.weibo.fragment.base.AbsTimeLineFragment;
  import org.zarroboogs.weibo.loader.FriendsMsgLoader;
  import org.zarroboogs.weibo.othercomponent.WifiAutoDownloadPictureRunnable;
  import org.zarroboogs.weibo.setting.SettingUtils;
  import org.zarroboogs.weibo.support.lib.LogOnExceptionScheduledExecutor;
  import org.zarroboogs.weibo.support.utils.AppConfig;
  import org.zarroboogs.weibo.support.utils.AppEventAction;
  import org.zarroboogs.weibo.support.utils.BundleArgsConstants;
  import org.zarroboogs.weibo.support.utils.Utility;
  import org.zarroboogs.weibo.widget.HeaderListView;
  import org.zarroboogs.weibo.widget.TopTipsView;
  import org.zarroboogs.weibo.widget.VelocityListView;
  
  import android.annotation.SuppressLint;
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.content.IntentFilter;
  import android.graphics.Bitmap;
  import android.os.Bundle;
  import android.os.Handler;
  import android.os.Looper;
  import android.support.v4.content.Loader;
  import android.support.v4.content.LocalBroadcastManager;
  import android.support.v7.widget.Toolbar;
  import android.support.v7.widget.Toolbar.OnMenuItemClickListener;
  import android.util.Log;
  import android.util.Pair;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.ViewGroupOverlay;
  import android.view.ViewTreeObserver;
  import android.view.animation.DecelerateInterpolator;
  import android.widget.AdapterView;
  import android.widget.BaseAdapter;
  import android.widget.ImageView;
  import android.widget.ListView;
  import android.widget.Toast;
  
  import java.lang.ref.WeakReference;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Set;
  import java.util.concurrent.ScheduledExecutorService;
  import java.util.concurrent.TimeUnit;
  
  public class FriendsTimeLineFragment extends AbsTimeLineFragment<MessageListBean> implements
          GlobalContext.MyProfileInfoChangeListener,
          MainTimeLineActivity.ScrollableListFragment {
  
      private AccountBean mAccountBean;
  
      private UserBean mUserBean;
  
      private String mToken;
  
      private DBCacheTask mDBCacheTask;
  
      private ScheduledExecutorService mAutoRefreshExecutor = null;
  
      public final static String ALL_GROUP_ID = "0";
  
      public final static String BILATERAL_GROUP_ID = "1";
  
      private String currentGroupId = ALL_GROUP_ID;
  
      private HashMap<String, MessageListBean> groupDataCache = new HashMap<String, MessageListBean>();
  
      private HashMap<String, TimeLinePosition> positionCache = new HashMap<String, TimeLinePosition>();
  
      private MessageListBean bean = new MessageListBean();
  
      private BaseAdapter mBaseAdapter;
  
      private Thread mBackgroundWifiDownloadPicThread = null;
  
      private Handler mHandler = new Handler(Looper.getMainLooper());
      
      private Toolbar mToolbar;
  
      public FriendsTimeLineFragment(){
          super();
      }
      public static FriendsTimeLineFragment newInstance(AccountBean accountBean, UserBean userBean, String token) {
          FriendsTimeLineFragment fragment = new FriendsTimeLineFragment(accountBean, userBean, token);
          fragment.setArguments(new Bundle());
          return fragment;
      }
  
      public FriendsTimeLineFragment(AccountBean accountBean, UserBean userBean, String token) {
          this.mAccountBean = accountBean;
          this.mUserBean = userBean;
          this.mToken = token;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setRetainInstance(true);
          setHasOptionsMenu(true);
  
      }
  
      @Override
      public MessageListBean getList() {
          return bean;
      }
      
  //    @Override
  //    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  //        View view = inflater.inflate(R.layout.friends_time_line_listview_layout, container, false);
  //        buildLayout(inflater, view);
  //        return view;
  //    }
      
  
      @Override
      public void onViewCreated(View view, Bundle savedInstanceState) {
          super.onViewCreated(view, savedInstanceState);
          mToolbar = (Toolbar) getActivity().findViewById(R.id.mainTimeLineToolBar);
          mToolbar.setTitle(R.string.home);
          mToolbar.inflateMenu(R.menu.actionbar_menu_friendstimelinefragment);
  //        mToolbar.setOnMenuItemClickListener(new OnMenuItemClickListener() {
  //
  //            @Override
  //            public boolean onMenuItemClick(MenuItem item) {
  //
  //                switch (item.getItemId()) {
  //                    case R.id.write_weibo:
  //                        Class<?> clzz = null;
  //                        if (SettingUtils.isDebug()) {
  //                            clzz = WriteWeiboActivity.class;
  //                        } else {
  //                            clzz = WeiboMainActivity.class;
  //                        }
  //                        Intent intent = new Intent(getActivity(), clzz);
  //                        intent.putExtra(BundleArgsConstants.ACCOUNT_EXTRA, mAccountBean);
  //                        intent.putExtra(Constants.TOKEN, mToken);
  //                        intent.putExtra(Constants.ACCOUNT, mAccountBean);
  //                        startActivity(intent);
  //                        break;
  //                    case R.id.refresh:
  //                        if (allowRefresh()) {
  //                            getPullToRefreshListView().setRefreshing();
  //                            loadNewMsg();
  //                        }
  //                        break;
  //                    case R.id.switch_theme:
  //                        // make sure activity has saved current left menu position
  //                        ((MainTimeLineActivity) getActivity()).saveNavigationPositionToDB();
  //                        SettingUtils.switchToAnotherTheme();
  //                        ((MainTimeLineActivity) getActivity()).reload();
  //                        break;
  //                }
  //                return false;
  //            }
  //        });
      }
  
      @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          // use Up instead of Back to reach this fragment
          if (data == null) {
              return;
          }
          final MessageBean msg = (MessageBean) data.getParcelableExtra("msg");
          if (msg != null) {
              for (int i = 0; i < getList().getSize(); i++) {
                  if (msg.equals(getList().getItem(i))) {
                      MessageBean ori = getList().getItem(i);
                      if (ori.getComments_count() != msg.getComments_count()
                              || ori.getReposts_count() != msg.getReposts_count()) {
                          ori.setReposts_count(msg.getReposts_count());
                          ori.setComments_count(msg.getComments_count());
                          FriendsTimeLineDBTask.asyncUpdateCount(msg.getId(), msg.getComments_count(), msg.getReposts_count());
                          getAdapter().notifyDataSetChanged();
                      }
                      break;
                  }
              }
  
          }
      }
  
      @Override
      protected void onListViewScrollStop() {
          savePositionToPositionsCache();
          startDownloadingOtherPicturesOnWifiNetworkEnvironment();
  
      }
  
      private void startDownloadingOtherPicturesOnWifiNetworkEnvironment() {
          if (mBackgroundWifiDownloadPicThread == null && Utility.isWifi(getActivity()) && SettingUtils.getEnableBigPic()
                  && SettingUtils.isWifiAutoDownloadPic()) {
              final int position = getListView().getFirstVisiblePosition();
              int listVewOrientation = ((VelocityListView) getListView()).getTowardsOrientation();
              WifiAutoDownloadPictureRunnable runnable = new WifiAutoDownloadPictureRunnable(getList(), position,
                      listVewOrientation);
              mBackgroundWifiDownloadPicThread = new Thread(runnable);
              mBackgroundWifiDownloadPicThread.start();
              AppLoggerUtils.i("WifiAutoDownloadPictureRunnable startDownloadingOtherPicturesOnWifiNetworkEnvironment");
  
          }
      }
  
      @Override
      protected void onListViewScrollStateTouchScroll() {
          super.onListViewScrollStateTouchScroll();
          stopDownloadingOtherPicturesOnWifiNetworkEnvironment();
      }
  
      @Override
      protected void onListViewScrollStateFling() {
          super.onListViewScrollStateFling();
          stopDownloadingOtherPicturesOnWifiNetworkEnvironment();
      }
  
      private void stopDownloadingOtherPicturesOnWifiNetworkEnvironment() {
          if (mBackgroundWifiDownloadPicThread != null) {
              mBackgroundWifiDownloadPicThread.interrupt();
              mBackgroundWifiDownloadPicThread = null;
              AppLoggerUtils.i("WifiAutoDownloadPictureRunnable stopDownloadingOtherPicturesOnWifiNetworkEnvironment");
  
          }
      }
  
      private void savePositionToPositionsCache() {
          positionCache.put(currentGroupId, Utility.getCurrentPositionFromListView(getListView()));
      }
  
      private void saveNewMsgCountToPositionsCache() {
          final TimeLinePosition position = positionCache.get(currentGroupId);
          position.newMsgIds = newMsgTipBar.getValues();
      }
  
      private void setListViewPositionFromPositionsCache() {
          final TimeLinePosition p = positionCache.get(currentGroupId);
          Utility.setListViewSelectionFromTop(getListView(), p != null ? p.position : 0, p != null ? p.top : 0,
                  new Runnable() {
                      @Override
                      public void run() {
                          setListViewUnreadTipBar(p);
                      }
                  });
      }
  
      private void setListViewUnreadTipBar(TimeLinePosition p) {
          if (p != null && p.newMsgIds != null) {
              if (SettingUtils.getEnableAutoRefresh()) {
                  newMsgTipBar.setType(TopTipsView.Type.ALWAYS);
              }
              newMsgTipBar.setValue(p.newMsgIds);
          }
      }
  
      // must create new position every time onpause, pulltorefresh wont call
      // onListViewScrollStop
      private void savePositionToDB() {
          savePositionToPositionsCache();
          TimeLinePosition position = positionCache.get(currentGroupId);
          position.newMsgIds = newMsgTipBar.getValues();
          final String groupId = currentGroupId;
          FriendsTimeLineDBTask.asyncUpdatePosition(position, GlobalContext.getInstance().getCurrentAccountId(), groupId);
      }
  
      private void saveGroupIdToDB() {
          FriendsTimeLineDBTask.asyncUpdateRecentGroupId(GlobalContext.getInstance().getCurrentAccountId(), currentGroupId);
      }
  
      @Override
      public void onPause() {
          super.onPause();
          if (!getActivity().isChangingConfigurations()) {
              savePositionToDB();
              saveGroupIdToDB();
          }
          removeRefresh();
          stopDownloadingOtherPicturesOnWifiNetworkEnvironment();
      }
  
      @Override
      public void onResume() {
          super.onResume();
          addRefresh();
          GlobalContext.getInstance().registerForAccountChangeListener(this);
          if (SettingUtils.getEnableAutoRefresh()) {
              this.newMsgTipBar.setType(TopTipsView.Type.ALWAYS);
          } else {
              this.newMsgTipBar.setType(TopTipsView.Type.AUTO);
          }
          
          
          LocalBroadcastManager.getInstance(getActivity()).registerReceiver(switchReceiver, new IntentFilter(AppEventAction.SWITCH_WEIBO_GROUP_BROADCAST));
      }
  
      BroadcastReceiver switchReceiver = new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
              List<GroupBean> list = new ArrayList<GroupBean>();
              if (GlobalContext.getInstance().getGroup() != null) {
                  list = GlobalContext.getInstance().getGroup().getLists();
              } else {
                  list = new ArrayList<GroupBean>();
              }
              final List<GroupBean> finalList = list;
  
              int intgroupId = intent.getIntExtra(RightMenuFragment.SWITCH_GROUP_KEY, 0);
              String groupId = getGroupIdFromIndex(intgroupId, finalList);
              Log.d("SwitchGroup", "" + intgroupId + "     " + groupId);
              switchFriendsGroup(groupId);
          }
      };
      
      @Override
      public void onDestroy() {
          super.onDestroy();
          Utility.cancelTasks(mDBCacheTask);
          GlobalContext.getInstance().unRegisterForAccountChangeListener(this);
          
          LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(switchReceiver);
      }
  
      @Override
      public void onSaveInstanceState(Bundle outState) {
          super.onSaveInstanceState(outState);
          outState.putParcelable(Constants.ACCOUNT, mAccountBean);
          outState.putParcelable(Constants.USERBEAN, mUserBean);
          outState.putString(Constants.TOKEN, mToken);
  
          // outState.putSerializable(Constants.BEAN, getList());
          // outState.putSerializable("groupDataCache", groupDataCache);
          // outState.putString("currentGroupId", currentGroupId);
      }
  
      @Override
      public void onActivityCreated(Bundle savedInstanceState) {
  
          switch (getCurrentState(savedInstanceState)) {
              case FIRST_TIME_START:
                  if (Utility.isTaskStopped(mDBCacheTask) && getList().getSize() == 0) {
                      mDBCacheTask = new DBCacheTask(this, mAccountBean.getUid());
                      mDBCacheTask.executeOnIO();
                      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:
                  refreshLayout(getList());
                  buildActionBarNav();
                  setListViewPositionFromPositionsCache();
                  break;
              case ACTIVITY_DESTROY_AND_CREATE:
                  mUserBean = savedInstanceState.getParcelable(Constants.USERBEAN);
                  mAccountBean = savedInstanceState.getParcelable(Constants.ACCOUNT);
                  mToken = savedInstanceState.getString(Constants.TOKEN);
  
                  if (Utility.isTaskStopped(mDBCacheTask) && getList().getSize() == 0) {
                      mDBCacheTask = new DBCacheTask(this, mAccountBean.getUid());
                      mDBCacheTask.executeOnIO();
                      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);
  
      }
  
      @Override
      public void onHiddenChanged(boolean hidden) {
          super.onHiddenChanged(hidden);
          if (!hidden) {
              buildActionBarNav();
              // ((MainTimeLineActivity) getActivity()).setCurrentFragment(this);
          }
      }
  
      @Override
      protected void buildListAdapter() {
          StatusListAdapter adapter = new StatusListAdapter(this, getList().getItemList(), getListView(), true, false);
          adapter.setTopTipBar(newMsgTipBar);
          timeLineAdapter = adapter;
          getListView().setAdapter(timeLineAdapter);
      }
  
      private int getIndexFromGroupId(String id, List<GroupBean> list) {
  
  