|
@@ -1,5 +1,6 @@
|
|
|
package com.ynstkz.shitu.android.fragment;
|
|
|
|
|
|
+import android.app.Activity;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.text.TextUtils;
|
|
@@ -26,10 +27,12 @@ import com.ynstkz.shitu.android.adapter.OrgFilterListAdapter;
|
|
|
import com.ynstkz.shitu.android.adapter.OrgListAdapter;
|
|
|
import com.ynstkz.shitu.android.application.STSign;
|
|
|
import com.ynstkz.shitu.android.base.BaseFragment;
|
|
|
+import com.ynstkz.shitu.android.bean.LocationDataBean;
|
|
|
import com.ynstkz.shitu.android.bean.OrgItemBean;
|
|
|
import com.ynstkz.shitu.android.bean.OrgListBean;
|
|
|
import com.ynstkz.shitu.android.common.Constants;
|
|
|
import com.ynstkz.shitu.android.data.RequestGroup;
|
|
|
+import com.ynstkz.shitu.android.data.SharedPreferencesUtils;
|
|
|
import com.ynstkz.shitu.android.event.LocationChangedEvent;
|
|
|
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
@@ -83,6 +86,9 @@ public class OrgListFragment extends BaseFragment implements PullToRefreshBase.O
|
|
|
|
|
|
private double longitude;
|
|
|
private double latitude;
|
|
|
+ private String sortType;
|
|
|
+
|
|
|
+ private String agencyTypeId;
|
|
|
|
|
|
@Override
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
@@ -101,7 +107,9 @@ public class OrgListFragment extends BaseFragment implements PullToRefreshBase.O
|
|
|
|
|
|
private void initData() {
|
|
|
pageNumber = 1;
|
|
|
- getOrgList(Constants.KM_LONGITUDE + "," + Constants.KM_LATITUDE);
|
|
|
+ longitude = Double.parseDouble(Constants.KM_LONGITUDE);
|
|
|
+ latitude = Double.parseDouble(Constants.KM_LATITUDE);
|
|
|
+ getOrgList();
|
|
|
}
|
|
|
|
|
|
private void setListener() {
|
|
@@ -161,7 +169,7 @@ public class OrgListFragment extends BaseFragment implements PullToRefreshBase.O
|
|
|
llLocationSelect.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
- startActivityForResult(new Intent(getActivity(), LocationSelectActivity.class), 10);
|
|
|
+ startActivityForResult(new Intent(getActivity(), LocationSelectActivity.class), 20);
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -198,21 +206,21 @@ public class OrgListFragment extends BaseFragment implements PullToRefreshBase.O
|
|
|
@Override
|
|
|
public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
pageNumber = 1;
|
|
|
- getOrgList(longitude + "," + latitude);
|
|
|
+ getOrgList();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
pageNumber++;
|
|
|
- getOrgList(longitude + "," + latitude);
|
|
|
+ getOrgList();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取推荐机构列表
|
|
|
*/
|
|
|
- private void getOrgList(String location) {
|
|
|
+ private void getOrgList() {
|
|
|
|
|
|
- RequestGroup.getNearbyAgencyList(pageNumber + "", "10", location, new Callback() {
|
|
|
+ RequestGroup.getNearbyAgencyList(pageNumber + "", longitude+"", latitude+"", agencyTypeId, sortType, "", new Callback() {
|
|
|
@Override
|
|
|
public Object parseNetworkResponse(Response response, int id) throws Exception {
|
|
|
return new Gson().fromJson(response.body().string(), OrgListBean.class);
|
|
@@ -280,6 +288,11 @@ public class OrgListFragment extends BaseFragment implements PullToRefreshBase.O
|
|
|
llHomeTitle.setVisibility(visibility);
|
|
|
}
|
|
|
|
|
|
+ public void setOrgFilterType(String agencyTypeId){
|
|
|
+ this.agencyTypeId = agencyTypeId;
|
|
|
+ getOrgList();
|
|
|
+ }
|
|
|
+
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
public void onMessageEvent(LocationChangedEvent event) {
|
|
|
if (event.getLocationDataBean() != null) {
|
|
@@ -288,10 +301,26 @@ public class OrgListFragment extends BaseFragment implements PullToRefreshBase.O
|
|
|
pageNumber = 1;
|
|
|
longitude = event.getLocationDataBean().getLongitude();
|
|
|
latitude = event.getLocationDataBean().getLatitude();
|
|
|
- getOrgList(longitude + "," + latitude);
|
|
|
+ getOrgList();
|
|
|
} else {
|
|
|
pageNumber = 1;
|
|
|
- getOrgList("");
|
|
|
+ getOrgList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ switch (requestCode){
|
|
|
+ case 20:
|
|
|
+ if(resultCode == Activity.RESULT_OK) {
|
|
|
+ LocationDataBean locationDataBean = new LocationDataBean();
|
|
|
+ locationDataBean.setCity(data.getStringExtra("city"));
|
|
|
+ locationDataBean.setLatitude(data.getDoubleExtra("latitude", 0));
|
|
|
+ locationDataBean.setLongitude(data.getDoubleExtra("longitude", 0));
|
|
|
+ EventBus.getDefault().post(new LocationChangedEvent(locationDataBean));
|
|
|
+ SharedPreferencesUtils.setLocation(data.getStringExtra("city"));
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|