/* * 按钮点击事件 * (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; } }
/* * 实例化控件 */ 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(); }
@Override public void handleMessage(Message msg) { switch (msg.what) { case GlobalParam.SHOW_SCROLLREFRESH: if (mIsRefreshing) { mScrollContainer.onRefreshComplete(); break; } mIsRefreshing = true; getPublishWeiboData(GlobalParam.LIST_LOAD_REFERSH); break; case GlobalParam.HIDE_SCROLLREFRESH: mIsRefreshing = false; mScrollContainer.onRefreshComplete(); for (int i = 0; i < mColumnCount; i++) { clearMap(mPinMark[i]); } clearArray(mColumnHeight, true); clearMap(mIViews); clearMap(mPins); clearArray(mLineIndex, false); clearArray(mBottomIndex, false); clearArray(mTopIndex, true); if (mWaterFallContainer != null) { for (int i = 0; i < mWaterFallContainer.getChildCount(); i++) { if (mWaterFallContainer.getChildAt(i) != null) { LinearLayout linearLayout = (LinearLayout) mWaterFallContainer.getChildAt(i); linearLayout.removeAllViews(); } } mWaterFallContainer.requestLayout(); } AddItemToContainer(0); if (mPicList != null && mPicList.size() > 0) { mCount = mPicList.size(); } break; case GlobalParam.HIDE_PROGRESS_DIALOG: if (isLoadMore) { isLoadMore = false; if (mCount < mPicList.size()) { AddItemToContainer(mCount); } } else { InitLayout(); } if (mPicList != null && mPicList.size() > 0) { mCount = mPicList.size(); } hideProgressDialog(); break; case GlobalParam.MSG_NETWORK_ERROR: hideProgressDialog(); if (mIsRefreshing) { mIsRefreshing = false; mScrollContainer.onRefreshComplete(); } Toast.makeText(mContext, R.string.network_error, Toast.LENGTH_LONG).show(); break; default: break; } }