/** 加载更多 */ protected void startToLoadMore() { if (hasMore) { if (!isLoadingMore) { listView.showLoading(); curPageIndex = curPageIndex + 1; isLoadingMore = true; mode = 2; Log.d(TAG, "startToLoadMore--->"); findGoods(); } } }
private void initView() { titleItem = (StoreTitleItem) findViewById(R.id.main_title); seacrhing_bar = (RelativeLayout) findViewById(R.id.seacrhing_bar); LinearLayout.LayoutParams searchLayoutParams = (android.widget.LinearLayout.LayoutParams) seacrhing_bar.getLayoutParams(); searchLayoutParams.height = ((mainLogic.screenHeight * 74) / 1280); searchLayoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; seacrhing_bar.setLayoutParams(searchLayoutParams); searchEdit = (EditText) findViewById(R.id.seacrhing_park_et); searchEdit.setTextSize(TypedValue.COMPLEX_UNIT_PX, (mainLogic.screenWidth * 24) / 720); searchEdit.setOnEditorActionListener( new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == 3) { String key = searchEdit.getText().toString(); if (key != null && !key.equals("")) { Intent intent = new Intent(StoreMainActivity.this, SearchResultActivity.class); intent.putExtra(StoreConstant.SEARCHKEY, key); startActivity(intent); } else { showToast(getResources().getString(R.string.park_place_edit_hint)); } } return true; } }); searchBtn = (TextView) findViewById(R.id.seacrhing_park_btn); searchBtn.setTextSize(TypedValue.COMPLEX_UNIT_PX, (mainLogic.screenWidth * 24) / 720); searchBtn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { String key = searchEdit.getText().toString(); if (key != null && !key.equals("")) { Intent intent = new Intent(StoreMainActivity.this, SearchResultActivity.class); intent.putExtra(StoreConstant.SEARCHKEY, key); startActivity(intent); } else { showToast(getResources().getString(R.string.park_place_edit_hint)); } } }); radioGroup = (LinearLayout) findViewById(R.id.radiobutton); RelativeLayout.LayoutParams radioGroupParams = (android.widget.RelativeLayout.LayoutParams) radioGroup.getLayoutParams(); radioGroupParams.height = ((mainLogic.screenHeight * 90) / 1280); radioGroupParams.width = RelativeLayout.LayoutParams.MATCH_PARENT; radioGroup.setLayoutParams(radioGroupParams); allarrowTextView = (TextView) findViewById(R.id.tab_all_arrow); RelativeLayout.LayoutParams params1 = (LayoutParams) allarrowTextView.getLayoutParams(); params1.width = ((mainLogic.screenWidth * 19) / 720); params1.height = ((mainLogic.screenHeight * 13) / 1280); allarrowTextView.setLayoutParams(params1); neararrowTextView = (TextView) findViewById(R.id.tab_near_arrow); RelativeLayout.LayoutParams params2 = (LayoutParams) neararrowTextView.getLayoutParams(); params2.width = ((mainLogic.screenWidth * 19) / 720); params2.height = ((mainLogic.screenHeight * 13) / 1280); neararrowTextView.setLayoutParams(params2); allLoyout = (RelativeLayout) findViewById(R.id.tab_all_layout); allTextView = (TextView) findViewById(R.id.tab_all); allTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, (mainLogic.screenWidth * 30) / 720); allLoyout.setOnClickListener(this); nearLoyout = (RelativeLayout) findViewById(R.id.tab_near_layout); nearTextView = (TextView) findViewById(R.id.tab_near); nearTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, (mainLogic.screenWidth * 30) / 720); nearLoyout.setOnClickListener(this); listView = (PullRefreshListView) findViewById(R.id.main_listview); listView.setOnRefreshListener( new OnRefreshListener() { @Override public void onRefresh() { // TODO Auto-generated method stub refresh(); } }); // 加载更多 listView.setNewScrollerListener( new NewScrollerListener() { private boolean isLoadMoreFile = false; @Override public void newScrollChanged(AbsListView view, int scrollState) { // TODO Auto-generated method stub if ((scrollState == OnScrollListener.SCROLL_STATE_IDLE || scrollState == OnScrollListener.SCROLL_STATE_FLING) && isLoadMoreFile) { startToLoadMore(); } } @Override public void newScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { // TODO Auto-generated method stub isLoadMoreFile = (firstVisibleItem + visibleItemCount == totalItemCount) ? true : false; } }); adapter = new AllshoppingAdapter(getApplicationContext(), mBitmapUtils, goodsDetailInfos); listView.setAdapter(adapter); findGoods(); }
@SuppressWarnings("unchecked") public void handleMsg(Message msg) { super.handleMsg(msg); listView.onRefreshComplete(); listView.showLoadFinish(); isLoadingMore = false; switch (msg.what) { case StoreConstant.NEAR_TYPE: if (mPopupWindow != null) { mPopupWindow.dismiss(); } if (msg.obj != null) { distanceType = (Integer) msg.obj; // waresType = 0; nearTextView.setText(nearList.get(distanceType)); findGoods(); } break; case StoreConstant.ALL_TYPE: if (mPopupWindow != null) { mPopupWindow.dismiss(); } if (msg.obj != null) { waresType = (Integer) msg.obj; // distanceType = 0; allTextView.setText(allList.get(waresType)); findGoods(); } break; case StoreConstant.GET_FINDGOODS_SUCCESS: if (msg.obj != null) { List<GoodsDetailInfo> temp = (List<GoodsDetailInfo>) msg.obj; goodsDetailInfos.clear(); if (temp.size() > 0) { goodsDetailInfos.addAll(temp); adapter.notifyDataSetChanged(); } else { hasMore = false; } } break; case StoreConstant.GET_FINDGOODS_FAILED: showToast(getResources().getString(R.string.error_1)); break; case StoreConstant.GET_FINDGOODS_GET_MORE_SUCCESS: if (msg.obj != null) { List<GoodsDetailInfo> temp = (List<GoodsDetailInfo>) msg.obj; if (temp.size() > 0) { goodsDetailInfos.addAll(temp); adapter.notifyDataSetChanged(); } else { hasMore = false; } } break; case StoreConstant.GET_FINDGOODS_GET_MORE_FAILED: showToast(getResources().getString(R.string.error_1)); break; // case StoreConstant.GET_FINDGOODSCOLUMN_SUCCESS: // if (msg.obj != null) // { //// List<GoodsColumnGroup> temp = (List<GoodsColumnGroup>) msg.obj; //// goodsColumnGroups.addAll(temp); //// expandadapter.notifyDataSetChanged(); // List<String> temp = new ArrayList<String>(); // goodsColumnGroups.add("离我最近"); // goodsColumnGroups.add("1km以内"); // goodsColumnGroups.add("3km以内"); // goodsColumnGroups.add("更远"); // goodsColumnGroups.addAll(temp); // expandadapter.notifyDataSetChanged(); // } // break; // case StoreConstant.GET_FINDGOODSCOLUMN_FAILED: // showToast(getResources().getString(R.string.error_1)); // break; // case StoreConstant.GET_FINDGOODSCOLUMN_NO_DATA: // showToast(getResources().getString(R.string.store_error_1)); // break; } };