add function

This commit is contained in:
lixiaopeng
2020-07-30 14:13:53 +08:00
parent 1f740d264b
commit fe2f4783a9
13 changed files with 683 additions and 40 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

@@ -0,0 +1,108 @@
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;
/**
* 周边事件
*/
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 --------> ");
surroundingEventPresenter = new SurroundingEventPresenter(getContext(), this);
}
@NonNull
@Override
protected SurroundingEventPresenter createPresenter() {
return surroundingEventPresenter;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initRecyclerView();
Log.d("liyz", "onViewCreated ---------");
initData();
}
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) {
}
@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,6 +2,7 @@ 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;
@@ -23,4 +24,9 @@ public interface ShareEventApiService {
@POST("/deva/car/pathAndPoi/no/queryInfo")
Observable<ShareEventItem> getShareEventList(@FieldMap Map<String, Object> parames);
//我的分享-列表
@FormUrlEncoded
@POST("/deva/car/poi/no/queryNovelty/v1")
Observable<SurroundingResponse> getSurroundingEventList(@FieldMap Map<String, Object> parames);
}

View File

@@ -0,0 +1,109 @@
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.ParamsProvider;
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.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.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;
/**
* @author lixiaopeng
* @description
* @since 2020/7/29
*/
public class SurroundingEventPresenter extends Presenter<SurroundingEventView> {
private Context mContext;
private IMogoNetwork mNetWork;
private IMogoServiceApis mApis;
private ShareEventApiService shareEventApiService;
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.shareEventApiService = mNetWork.create(ShareEventApiService.class, HostConstant.getNetHost());
}
@Override
public void onCreate(@NonNull LifecycleOwner owner) {
super.onCreate(owner);
}
//TODO
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);
Map<String, Object> params = new ParamsProvider.Builder(mContext)
.append("sn", Utils.getSn())
.append("data", GsonUtil.jsonFromObject(request))
.build();
shareEventApiService.getSurroundingEventList(params)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<SurroundingResponse>(RequestOptions.create(getContext())) {
@Override
public void onSuccess(SurroundingResponse result) {
Log.d("liyz", "onSuccess --------- ");
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
Log.e("liyz", "onError ---- message = " + message + " >>> code =" + code);
}
});
}
@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>