예제 #1
0
 private void initData() {
   // 从本地读取上次退出时加载的微博信息
   last_comments = WeiboSharedPreferencesUtils.getMentionComment(context);
   last_statuses = WeiboSharedPreferencesUtils.getMentionWeiboStatuses(context);
   if (rl_message_commment.isSelected()) {
     if (last_comments == null) {
       if (Utils.isNetworkConnected(this)) {
         iv_loading.setVisibility(View.VISIBLE);
         xListView.setVisibility(View.GONE);
         iv_loading.startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate));
         comments_page = 1;
         // 本地不存在则添加任务开始刷新微博信息
         HashMap<String, Object> taskParams = new HashMap<String, Object>();
         taskParams.put("instance", context.toString());
         Task task = new Task(TaskID.WEIBO_COMMENT_TIMELINE, taskParams);
         MainService.addTask(task);
       } else {
         Utils.showNetWorkErrorToast(context);
         xListView.stopRefresh();
       }
     } else {
       // 将本地微博信息加载到UI
       comments = CommentService.getCommentsFromJSON(last_comments);
       refreshUI(comments, last_comments, TaskID.WEIBO_COMMENT_TIMELINE);
       xListView.setPullLoadEnable(false);
     }
   } else {
     if (last_statuses == null) {
       if (Utils.isNetworkConnected(this)) {
         iv_loading.setVisibility(View.VISIBLE);
         xListView.setVisibility(View.GONE);
         iv_loading.startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate));
         statuses_page = 1;
         // 本地不存在则添加任务开始刷新微博信息
         HashMap<String, Object> taskParams = new HashMap<String, Object>();
         taskParams.put("instance", context.toString());
         Task task = new Task(TaskID.WEIBO_MENTION_TIMELINE, taskParams);
         MainService.addTask(task);
       } else {
         Utils.showNetWorkErrorToast(context);
         xListView.stopRefresh();
       }
     } else {
       // 将本地微博信息加载到UI
       statuses = StatuseService.getStatusesFromJSON(last_statuses);
       refreshUI(statuses, last_statuses, TaskID.WEIBO_MENTION_TIMELINE);
       xListView.setPullLoadEnable(false);
     }
   }
 }
예제 #2
0
 private void onLoad() {
   xListView.stopRefresh();
   xListView.stopLoadMore();
   xListView.setRefreshTime(Utils.getRefreshTime(xListView.getRefreshTime()));
 }