Beispiel #1
0
  /*
   * 按钮点击事件
   * (non-Javadoc)
   * @see com.wqdsoft.im.BaseActivity#onClick(android.view.View)
   */
  @Override
  public void onClick(View v) {
    super.onClick(v);
    switch (v.getId()) {
      case R.id.left_btn:
        MyFavoriteActivity.this.finish();
        break;

      case R.id.search_btn:
        SearchFavoriteDialog searchDialog = new SearchFavoriteDialog(mContext, mWeiboList);
        searchDialog.show();
        break;
      case R.id.right_btn:
        if (mSelectType == 1) { // 列表模式
          mScrollContainer.setVisibility(View.VISIBLE);
          mMapLayout.setVisibility(View.VISIBLE);
          mContainer.setVisibility(View.GONE);
          mListLayout.setVisibility(View.GONE);
          mSearchBtn.setVisibility(View.GONE);
          mRightBtn.setImageResource(R.drawable.list_favorite_btn);
          mSelectType = 2;
          getPublishWeiboData(GlobalParam.LIST_LOAD_FIRST);
        } else {
          mSelectType = 1; // 图片模式

          mSearchBtn.setVisibility(View.VISIBLE);
          mRightBtn.setImageResource(R.drawable.map_favorite_btn);
          mContainer.setVisibility(View.VISIBLE);
          mListLayout.setVisibility(View.VISIBLE);
          mScrollContainer.setVisibility(View.GONE);
          mMapLayout.setVisibility(View.GONE);
          getPublishWeiboData(GlobalParam.LIST_LOAD_FIRST);
        }
        break;

      default:
        break;
    }
  }
Beispiel #2
0
  /*
   * 实例化控件
   */
  private void initCompent() {
    setTitleContent(R.drawable.back_btn, true, R.drawable.map_favorite_btn, R.string.my_favorite);
    if (isShowRighIcon) {
      mRightBtn.setVisibility(View.VISIBLE);
      mRightBtn.setOnClickListener(this);
    } else {
      mRightBtn.setVisibility(View.GONE);
    }
    mLeftBtn.setOnClickListener(this);

    mSearchBtn.setOnClickListener(this);

    mListLayout = (LinearLayout) findViewById(R.id.category_linear);
    mRefreshViewLastUpdated = (TextView) findViewById(R.id.pull_to_refresh_time);
    mContainer = (MyPullToRefreshListView) findViewById(R.id.container);
    mListView = mContainer.getList();
    mListView.setDivider(mContext.getResources().getDrawable(R.drawable.splite));
    mListView.setCacheColorHint(0);
    mListView.setSelector(mContext.getResources().getDrawable(R.drawable.transparent_selector));
    mListView.setOnItemClickListener(this);
    mListView.setOnCreateContextMenuListener(this);
    mContainer.setOnChangeStateListener(this);

    mListView.setHeaderDividersEnabled(false);
    mListView.setOnScrollListener(
        new OnScrollListener() {

          @Override
          public void onScrollStateChanged(AbsListView view, int scrollState) {
            // TODO Auto-generated method stub
            switch (scrollState) {
              case OnScrollListener.SCROLL_STATE_IDLE: // 处理加载更多
                if (view.getLastVisiblePosition() == (view.getCount() - 1)) {
                  if (mWeibo != null && mWeibo.page != null && mWeibo.page.hasMore == 1) {
                    if (mFootView != null) {
                      Message message = new Message();
                      message.what = GlobalParam.SHOW_LOADINGMORE_INDECATOR;
                      message.obj = mFootView;
                      mCheckHandler.sendMessage(message);
                    }
                  } else {
                    mCheckHandler.sendEmptyMessage(GlobalParam.MSG_CHECK_STATE);
                  }
                }
                break;

              default:
                break;
            }
          }

          @Override
          public void onScroll(
              AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {}
        });

    mMapLayout = (LinearLayout) findViewById(R.id.map_category_linear);
    mRefreshScrollViewLastUpdated = (TextView) findViewById(R.id.scrollview_pull_to_refresh_time);

    mScrollContainer = (MyPullToRefreshScrollView) findViewById(R.id.scrollview_container);
    mScrollContainer.setOnChangeStateListener(this);
    mScrollView = mScrollContainer.getScrollView();
    mLayout = mScrollView.getLayout();
  }
Beispiel #3
0
        @Override
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case GlobalParam.SHOW_SCROLLREFRESH:
              if (mIsRefreshing) {
                mContainer.onRefreshComplete();
                break;
              }
              mIsRefreshing = true;
              if (mWeibo != null) {
                mWeibo = null;
              }
              getPublishWeiboData(GlobalParam.LIST_LOAD_REFERSH);
              break;

            case GlobalParam.HIDE_SCROLLREFRESH:
              mIsRefreshing = false;
              mContainer.onRefreshComplete();
              updateListView();
              break;

            case GlobalParam.SHOW_PROGRESS_DIALOG:
              String dialogMsg = (String) msg.obj;
              showProgressDialog(dialogMsg);
              break;
            case GlobalParam.HIDE_PROGRESS_DIALOG:
              hideProgressDialog();
              // updateListView();
              break;
            case GlobalParam.MSG_CHECK_STATE:
              // mHandler.sendEmptyMessage(HIDE_PROGRESS_DIALOG);
              hideProgressDialog();
              if (mFootView != null) {
                mListView.removeFooterView(mFootView);
              }
              if (mAdapter != null) {
                mAdapter.notifyDataSetChanged();
              }
              // Toast.makeText(mContext, "没有更多数据了", Toast.LENGTH_LONG);
              break;
            case GlobalParam.MSG_SHOW_LISTVIEW_DATA:
              updateListView();
              break;

            case GlobalParam.MSG_LOAD_ERROR:
              String error_Detail = (String) msg.obj;
              if (error_Detail != null && !error_Detail.equals("")) {
                Toast.makeText(mContext, error_Detail, Toast.LENGTH_LONG).show();
              } else {
                Toast.makeText(mContext, R.string.load_error, Toast.LENGTH_LONG).show();
              }
              break;
            case GlobalParam.MSG_NETWORK_ERROR:
              Toast.makeText(mContext, R.string.network_error, Toast.LENGTH_LONG).show();
              break;
            case GlobalParam.MSG_TICE_OUT_EXCEPTION:
              String message = (String) msg.obj;
              if (message == null || message.equals("")) {
                message = mContext.getResources().getString(R.string.timeout);
              }
              Toast.makeText(mContext, message, Toast.LENGTH_LONG).show();
              break;
            case GlobalParam.SHOW_LOADINGMORE_INDECATOR:
              LinearLayout footView = (LinearLayout) msg.obj;
              ProgressBar pb =
                  (ProgressBar) footView.findViewById(R.id.hometab_addmore_progressbar);
              pb.setVisibility(View.VISIBLE);
              TextView more = (TextView) footView.findViewById(R.id.hometab_footer_text);
              more.setText(mContext.getString(R.string.add_more_loading));
              // getLoveList(GlobalParam.LIST_LOAD_MORE);
              getPublishWeiboData(GlobalParam.LIST_LOAD_MORE);
              break;
            case GlobalParam.HIDE_LOADINGMORE_INDECATOR:
              if (mFootView != null) {
                ProgressBar pbar =
                    (ProgressBar) mFootView.findViewById(R.id.hometab_addmore_progressbar);
                pbar.setVisibility(View.GONE);
                TextView moreView = (TextView) mFootView.findViewById(R.id.hometab_footer_text);
                moreView.setText(R.string.add_more);
              }

              if (mAdapter != null) {
                mAdapter.notifyDataSetChanged();
              }
              break;
            case GlobalParam.MSG_CHECK_FAVORITE_STATUS:
              IMJiaState canclefavResult = (IMJiaState) msg.obj;
              if (canclefavResult == null) {
                Toast.makeText(mContext, R.string.commit_dataing, Toast.LENGTH_LONG).show();
                return;
              }
              if (canclefavResult.code != 0) {
                Toast.makeText(mContext, canclefavResult.errorMsg, Toast.LENGTH_LONG).show();
                return;
              } else {

                mWeiboList.remove(canclefavResult.positon);
                if (mAdapter != null) {
                  mAdapter.notifyDataSetChanged();
                }
              }
              break;
            default:
              break;
          }
        }