|
@@ -1,6 +1,7 @@
|
|
|
package com.ynstkz.shitu.android.fragment;
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
+import android.app.Activity;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
@@ -41,10 +42,12 @@ import com.ynstkz.shitu.android.base.BaseFragment;
|
|
|
import com.ynstkz.shitu.android.bean.CourseItemBean;
|
|
|
import com.ynstkz.shitu.android.bean.CourseNavigationBean;
|
|
|
import com.ynstkz.shitu.android.bean.HomeBannerBean;
|
|
|
+import com.ynstkz.shitu.android.bean.LocationDataBean;
|
|
|
import com.ynstkz.shitu.android.bean.OrgItemBean;
|
|
|
import com.ynstkz.shitu.android.bean.OrgRecommendListBean;
|
|
|
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 com.ynstkz.shitu.android.view.ScrollViewWithGridView;
|
|
|
|
|
@@ -144,7 +147,7 @@ public class HomeFragment extends BaseFragment implements PullToRefreshBase.OnRe
|
|
|
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);
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -457,12 +460,12 @@ public class HomeFragment extends BaseFragment implements PullToRefreshBase.OnRe
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
public void onMessageEvent(LocationChangedEvent event) {
|
|
|
- if (event.getAmapLocation() != null) {
|
|
|
- tvLocation.setText(event.getAmapLocation().getDistrict());
|
|
|
+ if (event.getLocationDataBean() != null) {
|
|
|
+ tvLocation.setText(event.getLocationDataBean().getCity());
|
|
|
//获取推荐机构列表
|
|
|
pageNumber = 1;
|
|
|
- longitude = event.getAmapLocation().getLongitude();
|
|
|
- latitude = event.getAmapLocation().getLatitude();
|
|
|
+ longitude = event.getLocationDataBean().getLongitude();
|
|
|
+ latitude = event.getLocationDataBean().getLatitude();
|
|
|
getOrgRecommendList(longitude + "," + latitude);
|
|
|
} else {
|
|
|
pageNumber = 1;
|
|
@@ -472,6 +475,22 @@ public class HomeFragment extends BaseFragment implements PullToRefreshBase.OnRe
|
|
|
}
|
|
|
|
|
|
@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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public void onPullDownToRefresh(PullToRefreshBase<ScrollView> refreshView) {
|
|
|
pageNumber = 1;
|
|
|
getOrgRecommendList(longitude + "," + latitude);
|
|
@@ -484,13 +503,6 @@ public class HomeFragment extends BaseFragment implements PullToRefreshBase.OnRe
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
- switch (requestCode) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
public void onDestroyView() {
|
|
|
super.onDestroyView();
|
|
|
ButterKnife.unbind(this);
|