Merge remote-tracking branch 'origin/dev_1.1.2' into dev_1.1.2

This commit is contained in:
董宏宇
2020-07-30 20:29:28 +08:00
14 changed files with 679 additions and 47 deletions

View File

@@ -2,7 +2,6 @@ package com.zhidao.mogo.module.event.panel.adapter
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.zhidao.mogo.module.event.panel.fragment.MyShareFragment
import com.zhidao.mogo.module.event.panel.fragment.ShareEventsFragment
import com.zhidao.mogo.module.event.panel.fragment.SurroundingEventFragment
import com.zhidao.mogo.module.event.panel.fragment.TripRecordFragment

View File

@@ -0,0 +1,46 @@
package com.zhidao.mogo.module.event.panel.adapter;
import android.content.Context;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
/**
* @author lixiaopeng
* @description 周边
* @since 2020/7/29
*/
public class SurroundingEventAdapter extends RecyclerView.Adapter<SurroundingEventViewHolder>{
//TODO 数据
public SurroundingEventAdapter(Context context) {
}
@Override
public int getItemViewType(int position) {
return super.getItemViewType(position);
}
@NonNull
@Override
public SurroundingEventViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return null;
}
@Override
public void onBindViewHolder(@NonNull SurroundingEventViewHolder holder, int position) {
}
@Override
public int getItemCount() {
return 0;
}
}

View File

@@ -0,0 +1,19 @@
package com.zhidao.mogo.module.event.panel.adapter;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
/**
* @author lixiaopeng
* @description
* @since 2020/7/29
*/
public class SurroundingEventViewHolder extends RecyclerView.ViewHolder{
public SurroundingEventViewHolder(@NonNull View itemView) {
super(itemView);
}
}

View File

@@ -0,0 +1,12 @@
package com.zhidao.mogo.module.event.panel.bean
/**
* @description
*
* @author lixiaopeng
* @since 2019-10-24
*/
data class Center (
val lat: Double,
val lon: Double
)

View File

@@ -0,0 +1,20 @@
package com.zhidao.mogo.module.event.panel.bean;
/**
* @author lixiaopeng
* @description
* @since 2020/7/29
*/
public class SurroundingRequest {
private Center center;
private String[] poiTypes;
private int radius;
private int limit;
public SurroundingRequest(Center center, String[] poiTypes, int radius, int limit) {
this.center = center;
this.poiTypes = poiTypes;
this.radius = radius;
this.limit = limit;
}
}

View File

@@ -0,0 +1,347 @@
package com.zhidao.mogo.module.event.panel.bean;
import com.mogo.commons.data.BaseData;
import java.util.List;
/**
* @author lixiaopeng
* @description
* @since 2020/7/29
*/
public class SurroundingResponse extends BaseData {
/**
* code : 0
* msg : success
* result : {"total":1,"poiInfos":[{"coordinates":[116.410712,39.96833],"uploadTimestamp":1596003623000,"timeout":1596090023000,"uploadAddress":"","distance":0,"dbId":"738038266231427072","poiType":"10002","sn":"VN000017","userId":0,"userName":"伤心狼","userHead":"https://yycp-static-1255510688.cos.ap-beijing.myqcloud.com/defaultUserHeadImg/VN000016.jpg","likeNum":1,"uploadType":2,"uploadUser":"","imgUrl":"","content":"封路了","gasStationId":"","gasStationName":"","gasImg":"","gasPrices":"","endDate":"2020-07-30 14:20:23","fabulous":false,"direction":90,"virtualLikeNum":"","status":1,"sourceType":"10002","hitId":"Odo6mXMBEXitzfRvznNL","userType":2,"data":""}]}
*/
private ResultBean result;
public ResultBean getResult() {
return result;
}
public void setResult(ResultBean result) {
this.result = result;
}
public static class ResultBean {
/**
* total : 1
* poiInfos : [{"coordinates":[116.410712,39.96833],"uploadTimestamp":1596003623000,"timeout":1596090023000,"uploadAddress":"","distance":0,"dbId":"738038266231427072","poiType":"10002","sn":"VN000017","userId":0,"userName":"伤心狼","userHead":"https://yycp-static-1255510688.cos.ap-beijing.myqcloud.com/defaultUserHeadImg/VN000016.jpg","likeNum":1,"uploadType":2,"uploadUser":"","imgUrl":"","content":"封路了","gasStationId":"","gasStationName":"","gasImg":"","gasPrices":"","endDate":"2020-07-30 14:20:23","fabulous":false,"direction":90,"virtualLikeNum":"","status":1,"sourceType":"10002","hitId":"Odo6mXMBEXitzfRvznNL","userType":2,"data":""}]
*/
private int total;
private List<PoiInfosBean> poiInfos;
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public List<PoiInfosBean> getPoiInfos() {
return poiInfos;
}
public void setPoiInfos(List<PoiInfosBean> poiInfos) {
this.poiInfos = poiInfos;
}
public static class PoiInfosBean {
/**
* coordinates : [116.410712,39.96833]
* uploadTimestamp : 1596003623000
* timeout : 1596090023000
* uploadAddress :
* distance : 0
* dbId : 738038266231427072
* poiType : 10002
* sn : VN000017
* userId : 0
* userName : 伤心狼
* userHead : https://yycp-static-1255510688.cos.ap-beijing.myqcloud.com/defaultUserHeadImg/VN000016.jpg
* likeNum : 1
* uploadType : 2
* uploadUser :
* imgUrl :
* content : 封路了
* gasStationId :
* gasStationName :
* gasImg :
* gasPrices :
* endDate : 2020-07-30 14:20:23
* fabulous : false
* direction : 90
* virtualLikeNum :
* status : 1
* sourceType : 10002
* hitId : Odo6mXMBEXitzfRvznNL
* userType : 2
* data :
*/
private long uploadTimestamp;
private long timeout;
private String uploadAddress;
private int distance;
private String dbId;
private String poiType;
private String sn;
private int userId;
private String userName;
private String userHead;
private int likeNum;
private int uploadType;
private String uploadUser;
private String imgUrl;
private String content;
private String gasStationId;
private String gasStationName;
private String gasImg;
private String gasPrices;
private String endDate;
private boolean fabulous;
private int direction;
private String virtualLikeNum;
private int status;
private String sourceType;
private String hitId;
private int userType;
private String data;
private List<Double> coordinates;
public long getUploadTimestamp() {
return uploadTimestamp;
}
public void setUploadTimestamp(long uploadTimestamp) {
this.uploadTimestamp = uploadTimestamp;
}
public long getTimeout() {
return timeout;
}
public void setTimeout(long timeout) {
this.timeout = timeout;
}
public String getUploadAddress() {
return uploadAddress;
}
public void setUploadAddress(String uploadAddress) {
this.uploadAddress = uploadAddress;
}
public int getDistance() {
return distance;
}
public void setDistance(int distance) {
this.distance = distance;
}
public String getDbId() {
return dbId;
}
public void setDbId(String dbId) {
this.dbId = dbId;
}
public String getPoiType() {
return poiType;
}
public void setPoiType(String poiType) {
this.poiType = poiType;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserHead() {
return userHead;
}
public void setUserHead(String userHead) {
this.userHead = userHead;
}
public int getLikeNum() {
return likeNum;
}
public void setLikeNum(int likeNum) {
this.likeNum = likeNum;
}
public int getUploadType() {
return uploadType;
}
public void setUploadType(int uploadType) {
this.uploadType = uploadType;
}
public String getUploadUser() {
return uploadUser;
}
public void setUploadUser(String uploadUser) {
this.uploadUser = uploadUser;
}
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getGasStationId() {
return gasStationId;
}
public void setGasStationId(String gasStationId) {
this.gasStationId = gasStationId;
}
public String getGasStationName() {
return gasStationName;
}
public void setGasStationName(String gasStationName) {
this.gasStationName = gasStationName;
}
public String getGasImg() {
return gasImg;
}
public void setGasImg(String gasImg) {
this.gasImg = gasImg;
}
public String getGasPrices() {
return gasPrices;
}
public void setGasPrices(String gasPrices) {
this.gasPrices = gasPrices;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public boolean isFabulous() {
return fabulous;
}
public void setFabulous(boolean fabulous) {
this.fabulous = fabulous;
}
public int getDirection() {
return direction;
}
public void setDirection(int direction) {
this.direction = direction;
}
public String getVirtualLikeNum() {
return virtualLikeNum;
}
public void setVirtualLikeNum(String virtualLikeNum) {
this.virtualLikeNum = virtualLikeNum;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getSourceType() {
return sourceType;
}
public void setSourceType(String sourceType) {
this.sourceType = sourceType;
}
public String getHitId() {
return hitId;
}
public void setHitId(String hitId) {
this.hitId = hitId;
}
public int getUserType() {
return userType;
}
public void setUserType(int userType) {
this.userType = userType;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public List<Double> getCoordinates() {
return coordinates;
}
public void setCoordinates(List<Double> coordinates) {
this.coordinates = coordinates;
}
}
}
}

View File

@@ -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())) {

View File

@@ -0,0 +1,91 @@
package com.zhidao.mogo.module.event.panel.fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.commons.mvp.MvpFragment;
import com.zhidao.mogo.module.event.panel.R;
import com.zhidao.mogo.module.event.panel.adapter.SurroundingEventAdapter;
import com.zhidao.mogo.module.event.panel.bean.SurroundingResponse;
import com.zhidao.mogo.module.event.panel.presenter.SurroundingEventPresenter;
import com.zhidao.mogo.module.event.panel.view.SurroundingEventView;
/**
* 周边事件
*/
public class SurroundingEventFragment extends MvpFragment<SurroundingEventView, SurroundingEventPresenter> implements SurroundingEventView {
private static final String TAG = "SurroundingEventFragment";
private RecyclerView recyclerView;
private View view;
private SurroundingEventAdapter mAdapter;
private SurroundingEventPresenter surroundingEventPresenter;
@Override
protected int getLayoutId() {
return R.layout.module_event_panel_fragment_surrounding_event;
}
@Override
protected void initViews() {
Log.d("liyz", "initViews --------> ");
initRecyclerView();
initData();
}
@NonNull
@Override
protected SurroundingEventPresenter createPresenter() {
return surroundingEventPresenter;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
surroundingEventPresenter = new SurroundingEventPresenter(getContext(), this);
Log.d("liyz", "onViewCreated ---------");
}
private void initRecyclerView() {
// recyclerView = view.findViewById(R.id.c);
// mAdapter = new SurroundingEventAdapter(getActivity()); //TODO
// recyclerView.setAdapter(mAdapter);
// LinearLayoutManager linearLayoutManager =
// new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
// recyclerView.setLayoutManager(linearLayoutManager);
}
private void initData() {
surroundingEventPresenter.getSurroundingEventData();
}
/**
* 展示列表数据 TODO
*/
@Override
public void showSurroudingData(SurroundingResponse data) {
if (data.getResult() != null) {
SurroundingResponse.ResultBean resultBean = data.getResult();
}
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public void onDestroyView() {
super.onDestroyView();
}
}

View File

@@ -1,32 +0,0 @@
package com.zhidao.mogo.module.event.panel.fragment
import com.mogo.commons.mvp.MvpFragment
import com.zhidao.mogo.module.event.panel.R
import com.zhidao.mogo.module.event.panel.presenter.SurroundingEventPresenter
import kotlinx.android.synthetic.main.module_event_panel_fragment_surrounding_event.*
class SurroundingEventFragment:MvpFragment<SurroundingEventFragment,SurroundingEventPresenter>(){
/**
* 布局资源
*
* @return
*/
override fun getLayoutId(): Int = R.layout.module_event_panel_fragment_surrounding_event
/**
* 初始化控件必须在初始化完成之后才可以实例化presenter避免
* presenter 生命周期错乱
*/
override fun initViews() {
tvTitle.setOnClickListener {
EventPanelFragment.getInstance().hidePanel()
}
}
/**
* 创建 presenter 实例
*
* @return
*/
override fun createPresenter(): SurroundingEventPresenter = SurroundingEventPresenter(this)
}

View File

@@ -2,16 +2,21 @@ package com.zhidao.mogo.module.event.panel.network;
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.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
@@ -23,4 +28,9 @@ public interface ShareEventApiService {
@POST("/deva/car/pathAndPoi/no/queryInfo")
Observable<ShareEventItem> getShareEventList(@FieldMap Map<String, Object> parames);
//周边列表
@Headers({"Content-Type:application/json", "Accept:application/json"})
@POST("/deva/car/poi/no/queryNovelty/v1")
Observable<SurroundingResponse> getSurroundingEventList(@Query("sn") String sn, @Body RequestBody jsonStr);
}

View File

@@ -0,0 +1,112 @@
package com.zhidao.mogo.module.event.panel.presenter;
import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.mvp.Presenter;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.commons.network.Utils;
import com.mogo.map.location.MogoLocation;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.network.IMogoNetwork;
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.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.EventApiService;
import com.zhidao.mogo.module.event.panel.view.SurroundingEventView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.RequestBody;
/**
* @author lixiaopeng
* @description
* @since 2020/7/29
*/
public class SurroundingEventPresenter extends Presenter<SurroundingEventView> {
private Context mContext;
private IMogoNetwork mNetWork;
private IMogoServiceApis mApis;
private EventApiService eventApiService;
private static final String TAG = "SurroundingEvent";
public SurroundingEventPresenter(Context context, SurroundingEventView view) {
super(view);
mContext = context;
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.eventApiService = mNetWork.create(EventApiService.class, HostConstant.getNetHost());
}
@Override
public void onCreate(@NonNull LifecycleOwner owner) {
super.onCreate(owner);
}
public void getSurroundingEventData() {
MogoLocation location = mApis.getMapServiceApi().getSingletonLocationClient(mContext).getLastKnowLocation();
if (location == null) {
return;
}
Center center = new Center(location.getLatitude(), location.getLongitude());
String[] poiTypes = {"10002", "10003", "10006", "10007", "10008", "10010", "10011", "10013", "10015"};
SurroundingRequest request = new SurroundingRequest(center, poiTypes, 5000, 20);
eventApiService.getSurroundingEventList(Utils.getSn(), convert(GsonUtil.jsonFromObject(request)))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<SurroundingResponse>(RequestOptions.create(getContext())) {
@Override
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(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);
}
@Override
public void onLifecycleChanged(@NonNull LifecycleOwner owner, @NonNull Lifecycle.Event event) {
super.onLifecycleChanged(owner, event);
}
}

View File

@@ -1,7 +0,0 @@
package com.zhidao.mogo.module.event.panel.presenter
import com.mogo.commons.mvp.Presenter
import com.zhidao.mogo.module.event.panel.fragment.SurroundingEventFragment
class SurroundingEventPresenter(view: SurroundingEventFragment) : Presenter<SurroundingEventFragment>(view) {
}

View File

@@ -0,0 +1,14 @@
package com.zhidao.mogo.module.event.panel.view;
import com.mogo.commons.mvp.IView;
import com.zhidao.mogo.module.event.panel.bean.SurroundingResponse;
/**
* @author lixiaopeng
* @description
* @since 2020/7/29
*/
public interface SurroundingEventView extends IView {
void showSurroudingData(SurroundingResponse data);
}

View File

@@ -12,4 +12,6 @@
android:text="Surrounding Event"
android:textColor="#fff"
android:textSize="40sp" />
</androidx.constraintlayout.widget.ConstraintLayout>