diff --git a/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/fragment/ShareEventsFragment.java b/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/fragment/ShareEventsFragment.java index 20567d7ca7..f3596b3d7f 100644 --- a/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/fragment/ShareEventsFragment.java +++ b/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/fragment/ShareEventsFragment.java @@ -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 parameters = new HashMap<>(); parameters.put("data", GsonUtil.jsonFromObject(parameter)); - shareEventApiService.getEnthusiasmIndex(parameters) + eventApiService.getEnthusiasmIndex(parameters) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new SubscribeImpl(RequestOptions.create(getContext())) { @@ -124,7 +123,7 @@ public class ShareEventsFragment extends MvpFragment parameters = new HashMap<>(); parameters.put("data", GsonUtil.jsonFromObject(parameter)); - shareEventApiService.getShareEventList(parameters) + eventApiService.getShareEventList(parameters) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new SubscribeImpl(RequestOptions.create(getContext())) { diff --git a/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/fragment/SurroundingEventFragment.java b/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/fragment/SurroundingEventFragment.java index adca8cb6b1..5d0ec07aa1 100644 --- a/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/fragment/SurroundingEventFragment.java +++ b/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/fragment/SurroundingEventFragment.java @@ -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 "); - surroundingEventPresenter = new SurroundingEventPresenter(getContext(), this); + initRecyclerView(); + initData(); } @@ -69,9 +49,9 @@ public class SurroundingEventFragment extends MvpFragment getShareEventList(@FieldMap Map parames); - //我的分享-列表 - @FormUrlEncoded + //周边列表 + @Headers({"Content-Type:application/json", "Accept:application/json"}) @POST("/deva/car/poi/no/queryNovelty/v1") - Observable getSurroundingEventList(@FieldMap Map parames); + Observable getSurroundingEventList(@Query("sn") String sn, @Body RequestBody jsonStr); } diff --git a/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/presenter/SurroundingEventPresenter.java b/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/presenter/SurroundingEventPresenter.java index 29ab82e915..bbb3cfe1ca 100644 --- a/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/presenter/SurroundingEventPresenter.java +++ b/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/presenter/SurroundingEventPresenter.java @@ -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 { - 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 { 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 { 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 { String[] poiTypes = {"10002", "10003", "10006", "10007", "10008", "10010", "10011", "10013", "10015"}; SurroundingRequest request = new SurroundingRequest(center, poiTypes, 5000, 20); - Map 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(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);