@Override public void onResponse(JSONObject response) { LogUtil.v("LoginListener TAG", response.toString()); try { boolean stat = response.getBoolean("stat"); if (!stat) { // 失败 int errorcode = response.getInt("errcode"); // 获取失败码 NetFailToast.show(errorcode); // 提示失败原因 if (context instanceof LoginActivity) { // 回调activity Message mess = new Message(); mess.what = 300; messhandler.sendMessage(mess); } } else { // 成功 Gson gson = new Gson(); ResponseLogin reslogin = gson.fromJson(response.toString(), ResponseLogin.class); ((WelcomeActivity) context).onFinishLogin(reslogin); } /** 释放引用 */ messhandler = null; context = null; } catch (JSONException e) { e.printStackTrace(); } }
/** 计算距离 */ public void calculateDistance(Double lati, Double logti) { LatLng startpos = new LatLng(mTown.getGeoinfo().getLatitude(), mTown.getGeoinfo().getLongitude()); LatLng endpos = new LatLng(lati, logti); float distan = AMapUtils.calculateLineDistance(startpos, endpos); if (distan < DISTANCE) { LogUtil.v("MessboardActivity info: ", "distance is in 50!"); this.mEditView.setVisibility(View.VISIBLE); this.mTophint.setText(getString(R.string.messboard_canmess)); // stop location this.stopLocation(); } else { LogUtil.v("MessboardActivity info: ", "distance is out of 50!"); this.mTophint.setText(getString(R.string.messboard_showdistan, (int) distan)); } }
/** header响应 */ public void onGetHeader(ModelCommuHeader header) { this.onLoad(); if (header != null) { this.mHeader = header; this.adminId = this.mHeader.getAdminid(); this.hasjoin = this.mHeader.isHasjoin(); LogUtil.v("Community info: ", "Got header"); if (this.ties != null) { this.texthint.setVisibility(View.GONE); this.onLoad(); this.communityAdater = new CommunityAdapter(this, mHeader, ties); this.mXList.setAdapter(communityAdater); this.communityAdater.notifyDataSetChanged(); LogUtil.v("Community info: ", "refresh list!"); } } }
public void initLocation() { LogUtil.v("NearFragment info: ", "enter initLocation()!"); mLocationManagerProxy = LocationManagerProxy.getInstance(this.getActivity()); // 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗, // 注意设置合适的定位时间的间隔,并且在合适时间调用removeUpdates()方法来取消定位请求 // 在定位结束后,在合适的生命周期调用destroy()方法 // 其中如果间隔时间为-1,则定位只定一次 mLocationManagerProxy.requestLocationData(LocationProviderProxy.AMapNetwork, 3 * 1000, 5, this); }
@Override public void onLocationChanged(AMapLocation amapLocation) { if (amapLocation != null && amapLocation.getAMapException().getErrorCode() == 0) { // get geoinfo Double lati = amapLocation.getLatitude(); Double logti = amapLocation.getLongitude(); String address = amapLocation.getAddress(); String province = amapLocation.getProvince(); String country = amapLocation.getCountry(); String city = amapLocation.getCity(); String citycode = amapLocation.getCityCode(); String district = amapLocation.getDistrict(); String street = amapLocation.getStreet(); float Accuracy = amapLocation.getAccuracy(); String road = amapLocation.getRoad(); geo.setLatitude(lati); geo.setLongitude(logti); geo.setAddress(address); geo.setProvince(province); geo.setCountry(country); geo.setCity(city); geo.setCitycode(citycode); geo.setDistrict(district); geo.setStreet(street); geo.setAccuracy(Accuracy); geo.setRoad(road); LogUtil.v( "Location info: ", lati + " " + logti + " " + address + " " + province + " " + country + " " + city + " " + citycode + " " + district + " " + street + " " + Accuracy + " " + road); loadNear(); } else { this.stopLocation(); onLoad(); this.mTexthint.setClickable(true); this.mTexthint.setText(getString(R.string.get_no_position)); LogUtil.v("NearFragment info: ", "enter onLocationChanged() + ERROR!"); LogUtil.v( "NearFragment info : AmapErr", "Location ERR:" + amapLocation.getAMapException().getErrorCode()); } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { LogUtil.v( "Community info: ", "result info: requestCode: " + requestCode + " resultCode: " + resultCode); switch (resultCode) { case RESULT_OK: firstload(); break; } }
/** 主题贴响应 */ public void onGetTieth(List<ModelTieTheme> ties) { this.onLoad(); if (ties != null && ties.size() > 0) { LogUtil.v("Community info: ", "Got ties!"); this.ties = ties; this.texthint.setVisibility(View.GONE); if (mHeader != null && isRefresh) { isRefresh = false; this.texthint.setVisibility(View.GONE); if (this.communityAdater != null) this.communityAdater.update(mHeader, ties); else { this.communityAdater = new CommunityAdapter(this, mHeader, ties); this.mXList.setAdapter(communityAdater); this.communityAdater.notifyDataSetChanged(); } LogUtil.v("Community info: ", "refresh list!"); } else if (this.mHeader != null) { this.communityAdater.loadMore(ties); } // update rejectids for (int i = 0; i < ties.size(); i++) { this.mRejectids.add(ties.get(i).getTieid()); } } // else if (isRefresh){ // isRefresh = false; // if (mHeader != null ) { // this.texthint.setVisibility(View.GONE); // this.mXList.setFooterHint("还没有帖子"); // this.communityAdater = new CommunityAdapter(this,mHeader,this.ties); // this.mXList.setAdapter(communityAdater); // this.communityAdater.notifyDataSetChanged(); // } // } else { this.texthint.setVisibility(View.GONE); this.mXList.setFooterHint("暂无更多"); } }
@Override public void onLocationChanged(AMapLocation amapLocation) { LogUtil.v( "MessboardActivity info: ", "enter onLocationChanged()!" + amapLocation.getLatitude()); if (amapLocation != null && amapLocation.getAMapException().getErrorCode() == 0) { LogUtil.v("MessboardActivity info: ", "enter onLocationChanged()!" + " enter IF!"); // get geoinfo Double lati = amapLocation.getLatitude(); Double logti = amapLocation.getLongitude(); String address = amapLocation.getAddress(); String province = amapLocation.getProvince(); String country = amapLocation.getCountry(); String city = amapLocation.getCity(); String citycode = amapLocation.getCityCode(); String district = amapLocation.getDistrict(); String street = amapLocation.getStreet(); float Accuracy = amapLocation.getAccuracy(); String road = amapLocation.getRoad(); geo.setLatitude(lati); geo.setLongitude(logti); geo.setAddress(address); geo.setProvince(province); geo.setCountry(country); geo.setCity(city); geo.setCitycode(citycode); geo.setDistrict(district); geo.setStreet(street); geo.setAccuracy(Accuracy); geo.setRoad(road); LogUtil.v( "Location info: ", lati + " " + logti + " " + address + " " + province + " " + country + " " + city + " " + citycode + " " + district + " " + street + " " + Accuracy + " " + road); this.calculateDistance(lati, logti); } else { LogUtil.v("MessboardActivity info: ", "enter onLocationChanged() + ERROR!"); Log.e("AmapErr", "Location ERR:" + amapLocation.getAMapException().getErrorCode()); } }
/** 网络返回葡萄 */ public void onFinishNetwork(List<ModelMessboard> mess) { onLoad(); if (mess.size() == 0) { this.mXListView.setPullLoadEnable(false); return; } List<View> listview = new ArrayList<View>(); for (int i = 0; i < mess.size(); i++) { ListItemMessboard item = new ListItemMessboard(this, mess.get(i)); View view = item.makeItemView(); listview.add(view); // add to recycle recycleResource.put(item.imagev, ""); } LogUtil.v("MessboardActivity info: ", " mAdapterList size: " + this.mAdapterList.size()); if (this.mAdapterList.size() == 1) { // 第一次加载 this.mAdapterList.remove(0); this.mAdapterList.addAll(listview); } else if (this.refreshcomment) { // refresh this.mAdapterList.removeAll(mAdapterList); this.mAdapterList.addAll(listview); } else { // load more this.mAdapterList.addAll(listview); } this.mAdapter.notifyDataSetChanged(); if (this.mAdapterList.size() < 10) this.mXListView.setPullLoadEnable(false); else this.mXListView.setPullLoadEnable(true); if (refreshcomment) { // 滚动到顶端 new Handler() .postDelayed( new Runnable() { @Override public void run() { mXListView.setSelection(1); } }, 200); } }
@Override public void onReceive(List<ApplyTown> towns) { LogUtil.v("HotFragment info: ", "onReceive!"); // 停止缓冲动画 onLoad(); if (towns.size() == 0) { this.mTexthint.setText(getString(R.string.near_none)); return; } // set pull load more enable this.mXList.setPullLoadEnable(true); // add to reject list for (int i = 0; i < towns.size(); i++) { this.mRejectids.add(towns.get(i).getTownid()); } this.mMainLayout.removeView(mTexthint); this.mXList.setVisibility(View.VISIBLE); this.towndata.addAll(towns); this.mMainAdapter.notifyDataSetChanged(); this.mMainAdapter.isFirstEnter = true; }
@Override public void onClick(View v) { LogUtil.v("Community.OnItemSelected info: ", "onclick !"); ThemeTieActivity.startAction(activity, tie, adminid); }