opt
This commit is contained in:
@@ -3,7 +3,6 @@ package com.zhidao.mogo.module.event.panel.fragment;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
@@ -26,7 +25,7 @@ import com.zhidao.mogo.module.event.panel.adapter.ShareEventAdapter;
|
||||
import com.zhidao.mogo.module.event.panel.bean.ShareEventDescription;
|
||||
import com.zhidao.mogo.module.event.panel.bean.ShareEventItem;
|
||||
import com.zhidao.mogo.module.event.panel.network.HostConstant;
|
||||
import com.zhidao.mogo.module.event.panel.network.ShareEventApiService;
|
||||
import com.zhidao.mogo.module.event.panel.network.EventApiService;
|
||||
import com.zhidao.mogo.module.event.panel.network.ShareEventParameter;
|
||||
import com.zhidao.mogo.module.event.panel.presenter.ShareEventsPresenter;
|
||||
|
||||
@@ -44,7 +43,7 @@ public class ShareEventsFragment extends MvpFragment<ShareEventsFragment, ShareE
|
||||
private View view;
|
||||
private ShareEventAdapter adapter;
|
||||
private ArrayList dataArrayList = new ArrayList();
|
||||
private ShareEventApiService shareEventApiService;
|
||||
private EventApiService eventApiService;
|
||||
private int pageNum = 1;
|
||||
private View emptyView;
|
||||
private Button shareBtn;
|
||||
@@ -79,7 +78,7 @@ public class ShareEventsFragment extends MvpFragment<ShareEventsFragment, ShareE
|
||||
|
||||
private void initData() {
|
||||
IMogoNetwork network = (IMogoNetwork) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_NETWORK).navigation(getContext());
|
||||
this.shareEventApiService = network.create(ShareEventApiService.class, HostConstant.getNetHost());
|
||||
this.eventApiService = network.create(EventApiService.class, HostConstant.getNetHost());
|
||||
|
||||
getShareEventDescription();
|
||||
getShareEventList(pageNum, 10);
|
||||
@@ -94,7 +93,7 @@ public class ShareEventsFragment extends MvpFragment<ShareEventsFragment, ShareE
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("data", GsonUtil.jsonFromObject(parameter));
|
||||
|
||||
shareEventApiService.getEnthusiasmIndex(parameters)
|
||||
eventApiService.getEnthusiasmIndex(parameters)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<ShareEventDescription>(RequestOptions.create(getContext())) {
|
||||
@@ -124,7 +123,7 @@ public class ShareEventsFragment extends MvpFragment<ShareEventsFragment, ShareE
|
||||
HashMap<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("data", GsonUtil.jsonFromObject(parameter));
|
||||
|
||||
shareEventApiService.getShareEventList(parameters)
|
||||
eventApiService.getShareEventList(parameters)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<ShareEventItem>(RequestOptions.create(getContext())) {
|
||||
|
||||
@@ -2,40 +2,19 @@ package com.zhidao.mogo.module.event.panel.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.commons.network.Utils;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.network.IMogoNetwork;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.zhidao.mogo.module.event.panel.R;
|
||||
import com.zhidao.mogo.module.event.panel.adapter.ShareEventAdapter;
|
||||
import com.zhidao.mogo.module.event.panel.adapter.SurroundingEventAdapter;
|
||||
import com.zhidao.mogo.module.event.panel.bean.ShareEventDescription;
|
||||
import com.zhidao.mogo.module.event.panel.bean.SurroundingResponse;
|
||||
import com.zhidao.mogo.module.event.panel.network.HostConstant;
|
||||
import com.zhidao.mogo.module.event.panel.network.ShareEventApiService;
|
||||
import com.zhidao.mogo.module.event.panel.presenter.SurroundingEventPresenter;
|
||||
import com.zhidao.mogo.module.event.panel.view.SurroundingEventView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* 周边事件
|
||||
*/
|
||||
@@ -56,7 +35,8 @@ public class SurroundingEventFragment extends MvpFragment<SurroundingEventView,
|
||||
@Override
|
||||
protected void initViews() {
|
||||
Log.d("liyz", "initViews --------> ");
|
||||
surroundingEventPresenter = new SurroundingEventPresenter(getContext(), this);
|
||||
initRecyclerView();
|
||||
initData();
|
||||
|
||||
}
|
||||
|
||||
@@ -69,9 +49,9 @@ public class SurroundingEventFragment extends MvpFragment<SurroundingEventView,
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
initRecyclerView();
|
||||
surroundingEventPresenter = new SurroundingEventPresenter(getContext(), this);
|
||||
Log.d("liyz", "onViewCreated ---------");
|
||||
initData();
|
||||
|
||||
}
|
||||
|
||||
private void initRecyclerView() {
|
||||
@@ -92,7 +72,10 @@ public class SurroundingEventFragment extends MvpFragment<SurroundingEventView,
|
||||
*/
|
||||
@Override
|
||||
public void showSurroudingData(SurroundingResponse data) {
|
||||
if (data.getResult() != null) {
|
||||
SurroundingResponse.ResultBean resultBean = data.getResult();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,12 +7,16 @@ import com.zhidao.mogo.module.event.panel.bean.SurroundingResponse;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.FieldMap;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.Headers;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Query;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
public interface ShareEventApiService {
|
||||
public interface EventApiService {
|
||||
|
||||
//我的分享-热心指数等
|
||||
@FormUrlEncoded
|
||||
@@ -24,9 +28,9 @@ public interface ShareEventApiService {
|
||||
@POST("/deva/car/pathAndPoi/no/queryInfo")
|
||||
Observable<ShareEventItem> getShareEventList(@FieldMap Map<String, Object> parames);
|
||||
|
||||
//我的分享-列表
|
||||
@FormUrlEncoded
|
||||
//周边列表
|
||||
@Headers({"Content-Type:application/json", "Accept:application/json"})
|
||||
@POST("/deva/car/poi/no/queryNovelty/v1")
|
||||
Observable<SurroundingResponse> getSurroundingEventList(@FieldMap Map<String, Object> parames);
|
||||
Observable<SurroundingResponse> getSurroundingEventList(@Query("sn") String sn, @Body RequestBody jsonStr);
|
||||
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.commons.network.ParamsProvider;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.commons.network.Utils;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
@@ -20,19 +19,15 @@ import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.zhidao.mogo.module.event.panel.bean.Center;
|
||||
import com.zhidao.mogo.module.event.panel.bean.ShareEventDescription;
|
||||
import com.zhidao.mogo.module.event.panel.bean.SurroundingRequest;
|
||||
import com.zhidao.mogo.module.event.panel.bean.SurroundingResponse;
|
||||
import com.zhidao.mogo.module.event.panel.network.HostConstant;
|
||||
import com.zhidao.mogo.module.event.panel.network.ShareEventApiService;
|
||||
import com.zhidao.mogo.module.event.panel.network.EventApiService;
|
||||
import com.zhidao.mogo.module.event.panel.view.SurroundingEventView;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
@@ -40,11 +35,11 @@ import io.reactivex.schedulers.Schedulers;
|
||||
* @since 2020/7/29
|
||||
*/
|
||||
public class SurroundingEventPresenter extends Presenter<SurroundingEventView> {
|
||||
|
||||
private Context mContext;
|
||||
private IMogoNetwork mNetWork;
|
||||
private IMogoServiceApis mApis;
|
||||
private ShareEventApiService shareEventApiService;
|
||||
private EventApiService eventApiService;
|
||||
private static final String TAG = "SurroundingEvent";
|
||||
|
||||
|
||||
public SurroundingEventPresenter(Context context, SurroundingEventView view) {
|
||||
@@ -53,7 +48,7 @@ public class SurroundingEventPresenter extends Presenter<SurroundingEventView> {
|
||||
mNetWork =
|
||||
((IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(view.getContext())).getNetworkApi();
|
||||
mApis = (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(getContext());
|
||||
this.shareEventApiService = mNetWork.create(ShareEventApiService.class, HostConstant.getNetHost());
|
||||
this.eventApiService = mNetWork.create(EventApiService.class, HostConstant.getNetHost());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,7 +56,6 @@ public class SurroundingEventPresenter extends Presenter<SurroundingEventView> {
|
||||
super.onCreate(owner);
|
||||
}
|
||||
|
||||
//TODO
|
||||
public void getSurroundingEventData() {
|
||||
MogoLocation location = mApis.getMapServiceApi().getSingletonLocationClient(mContext).getLastKnowLocation();
|
||||
if (location == null) {
|
||||
@@ -71,32 +65,41 @@ public class SurroundingEventPresenter extends Presenter<SurroundingEventView> {
|
||||
String[] poiTypes = {"10002", "10003", "10006", "10007", "10008", "10010", "10011", "10013", "10015"};
|
||||
SurroundingRequest request = new SurroundingRequest(center, poiTypes, 5000, 20);
|
||||
|
||||
Map<String, Object> params = new ParamsProvider.Builder(mContext)
|
||||
.append("sn", Utils.getSn())
|
||||
.append("data", GsonUtil.jsonFromObject(request))
|
||||
.build();
|
||||
|
||||
shareEventApiService.getSurroundingEventList(params)
|
||||
eventApiService.getSurroundingEventList(Utils.getSn(), convert(GsonUtil.jsonFromObject(request)))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<SurroundingResponse>(RequestOptions.create(getContext())) {
|
||||
@Override
|
||||
public void onSuccess(SurroundingResponse result) {
|
||||
Log.d("liyz", "onSuccess --------- ");
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(SurroundingResponse data) {
|
||||
super.onSuccess(data);
|
||||
if (data != null) {
|
||||
mView.showSurroudingData(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
Log.e("liyz", "onError ---- message = " + message + " >>> code =" + code);
|
||||
Log.e(TAG, "onError message = " + message + " >>> code = " + code);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static RequestBody convert(String json) {
|
||||
// String json = GsonUtil.getGson().toJson( map );
|
||||
Logger.d(TAG, "request params: %s", json);
|
||||
RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), json);
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy(@NonNull LifecycleOwner owner) {
|
||||
super.onDestroy(owner);
|
||||
|
||||
Reference in New Issue
Block a user