完成了出行动态的展示
This commit is contained in:
@@ -37,8 +37,9 @@ public abstract class MvpFragment<V extends IView, P extends Presenter<V>> exten
|
||||
mRootView = inflater.inflate( getLayoutId(), container, false );
|
||||
} else {
|
||||
ViewGroup viewGroup = ( ViewGroup ) mRootView.getParent();
|
||||
if ( viewGroup != null )
|
||||
if ( viewGroup != null ) {
|
||||
viewGroup.removeView( mRootView );
|
||||
}
|
||||
}
|
||||
mRootView = inflater.inflate(getLayoutId(), container, false);
|
||||
return mRootView;
|
||||
|
||||
@@ -243,6 +243,7 @@ open class BaseDao<T : Any> : IBaseDao<T> {
|
||||
cursor?.close()
|
||||
}
|
||||
}
|
||||
Logger.d(TAG, "查询结果:" + result.size + " 条")
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.zhidao.mogo.module.event.panel">
|
||||
|
||||
/
|
||||
</manifest>
|
||||
@@ -4,7 +4,7 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
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
|
||||
import com.zhidao.mogo.module.event.panel.fragment.ScenarioHistoryFragment
|
||||
|
||||
/**
|
||||
* 事件面板viewpager2的adapter
|
||||
@@ -12,7 +12,7 @@ import com.zhidao.mogo.module.event.panel.fragment.TripRecordFragment
|
||||
* @author tongchenfei
|
||||
*/
|
||||
class EventPagerAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {
|
||||
private val fragments:Array<Fragment> = arrayOf(TripRecordFragment(), SurroundingEventFragment(), ShareEventsFragment())
|
||||
private val fragments: Array<Fragment> = arrayOf(ScenarioHistoryFragment(), SurroundingEventFragment(), ShareEventsFragment())
|
||||
|
||||
/**
|
||||
* 目前一共就三个fragment
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.zhidao.mogo.module.event.panel.adapter;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.module.common.entity.V2XHistoryScenarioData;
|
||||
import com.mogo.module.common.entity.V2XWindowTypeEnum;
|
||||
import com.zhidao.mogo.module.event.panel.adapter.holder.ScenarioHistoryIllegalParkVH;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
*/
|
||||
public class ScenarioHistoryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private ArrayList<V2XHistoryScenarioData> mV2XHistoryScenarioData;
|
||||
|
||||
public ScenarioHistoryAdapter(ArrayList<V2XHistoryScenarioData> v2XHistoryScenarioData) {
|
||||
if (v2XHistoryScenarioData != null) {
|
||||
this.mV2XHistoryScenarioData = v2XHistoryScenarioData;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
RecyclerView.ViewHolder holder;
|
||||
switch (viewType) {
|
||||
// 直播
|
||||
case V2XWindowTypeEnum.LIVE_CAR_WINDOW:
|
||||
holder = new ScenarioHistoryIllegalParkVH(parent);
|
||||
break;
|
||||
default:
|
||||
holder = new ScenarioHistoryIllegalParkVH(parent);
|
||||
}
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof ScenarioHistoryIllegalParkVH) {
|
||||
((ScenarioHistoryIllegalParkVH) holder).initView(mV2XHistoryScenarioData.get(position));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mV2XHistoryScenarioData == null ? 0 : mV2XHistoryScenarioData.size();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.zhidao.mogo.module.event.panel.adapter.holder;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.mogo.module.common.entity.V2XHistoryScenarioData;
|
||||
import com.zhidao.mogo.module.event.panel.R;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
*/
|
||||
public class ScenarioHistoryIllegalParkVH extends V2XBaseViewHolder {
|
||||
public ScenarioHistoryIllegalParkVH(@NonNull ViewGroup viewGroup) {
|
||||
super(LayoutInflater.from(viewGroup.getContext())
|
||||
.inflate(R.layout.module_event_panel_share_item, viewGroup, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView(V2XHistoryScenarioData viewData) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delayedCloseWindow() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.zhidao.mogo.module.event.panel.adapter.holder;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
import com.mogo.map.navi.MogoTraffic;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.V2XHistoryScenarioData;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* V2X展示视图公用的实现
|
||||
*
|
||||
* @author donghongyu
|
||||
*/
|
||||
public abstract class V2XBaseViewHolder
|
||||
extends RecyclerView.ViewHolder
|
||||
implements IMogoNaviListener {
|
||||
|
||||
public V2XBaseViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
public abstract void initView(V2XHistoryScenarioData viewData);
|
||||
|
||||
/**
|
||||
* 延迟关闭窗体视图
|
||||
*/
|
||||
public abstract void delayedCloseWindow();
|
||||
|
||||
/**
|
||||
* 点赞
|
||||
*/
|
||||
public void triggerZan(MarkerExploreWay noveltyInfo) {
|
||||
|
||||
delayedCloseWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打电话
|
||||
*/
|
||||
public void triggerCallChart(MarkerExploreWay noveltyInfo) {
|
||||
|
||||
delayedCloseWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
* 反馈路况错误
|
||||
*/
|
||||
public void triggerReportErr(MarkerExploreWay noveltyInfo) {
|
||||
|
||||
delayedCloseWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
* 反馈路况正确
|
||||
*/
|
||||
public void triggerReportTrue(MarkerExploreWay noveltyInfo) {
|
||||
|
||||
delayedCloseWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航规划路线
|
||||
*/
|
||||
public void triggerStartNavi(MarkerExploreWay noveltyInfo) {
|
||||
|
||||
delayedCloseWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示自定义 Toast
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public void showTip(String msg) {
|
||||
TipToast.tip(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviSuccess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdate(MogoNaviInfo naviinfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartNavi() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCalculateSuccess() {
|
||||
Logger.w("V2XBaseViewHolder", "onCalculateSuccess");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onoCalculateFailed() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTraffic(MogoTraffic traffic) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.zhidao.mogo.module.event.panel.fragment;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.PagerSnapHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.module.common.entity.V2XHistoryScenarioData;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.mogo.module.event.panel.R;
|
||||
import com.zhidao.mogo.module.event.panel.adapter.ScenarioHistoryAdapter;
|
||||
import com.zhidao.mogo.module.event.panel.presenter.ScenarioHistoryPresenter;
|
||||
import com.zhidao.mogo.module.event.panel.util.V2XSQLiteUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 出行动态,V2X 提示过的场景历史
|
||||
*
|
||||
* @author donghongyu
|
||||
*/
|
||||
public class ScenarioHistoryFragment
|
||||
extends MvpFragment<ScenarioHistoryFragment, ScenarioHistoryPresenter> {
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
private ScenarioHistoryAdapter mScenarioHistoryAdapter;
|
||||
private ArrayList<V2XHistoryScenarioData> mV2XHistoryScenarioData = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_event_panel_fragment_scenario_history;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
Log.d("ScenarioHistoryFragment", "initViews --------> ");
|
||||
|
||||
mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
|
||||
mScenarioHistoryAdapter = new ScenarioHistoryAdapter(mV2XHistoryScenarioData);
|
||||
mRecyclerView.setAdapter(mScenarioHistoryAdapter);
|
||||
// 设置切换样式
|
||||
new PagerSnapHelper().attachToRecyclerView(mRecyclerView);
|
||||
// 配置列表朝向
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
|
||||
mRecyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
List<V2XHistoryScenarioData> v2XHistoryScenarioData = V2XSQLiteUtils.getScenarioHistoryData(getActivity());
|
||||
Logger.d("ScenarioHistoryFragment", "查询到历史消息:" + v2XHistoryScenarioData);
|
||||
mV2XHistoryScenarioData.addAll(v2XHistoryScenarioData);
|
||||
mScenarioHistoryAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected ScenarioHistoryPresenter createPresenter() {
|
||||
return new ScenarioHistoryPresenter(this);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.zhidao.mogo.module.event.panel.fragment
|
||||
|
||||
import android.util.Log
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.module.common.entity.V2XMessageEntity
|
||||
import com.mogo.utils.logger.Logger
|
||||
import com.zhidao.mogo.module.event.panel.EventPanelConstants.MODULE_NAME
|
||||
import com.zhidao.mogo.module.event.panel.R
|
||||
import com.zhidao.mogo.module.event.panel.bean.TripRecord
|
||||
import com.zhidao.mogo.module.event.panel.presenter.TripRecordPresenter
|
||||
import com.zhidao.mogo.module.event.panel.util.TripRecordDataManager
|
||||
import kotlinx.android.synthetic.main.module_event_panel_fragment_trip_record.*
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
* 出行动态fragment
|
||||
*/
|
||||
class TripRecordFragment : MvpFragment<TripRecordFragment, TripRecordPresenter>() {
|
||||
private val tripRecordList = ArrayList<TripRecord>()
|
||||
override fun getLayoutId(): Int = R.layout.module_event_panel_fragment_trip_record
|
||||
|
||||
override fun initViews() {
|
||||
btnInsert.setOnClickListener {
|
||||
TripRecordDataManager.insertTripRecord(TripRecord(id = 456, eventType = 456,eventId = "456"))
|
||||
}
|
||||
btnUpdate.setOnClickListener {
|
||||
TripRecordDataManager.syncRoadEventModifyState(eventId = "456", modifyType = "2")
|
||||
}
|
||||
btnQuery.setOnClickListener {
|
||||
Log.d(MODULE_NAME, "local list: $tripRecordList")
|
||||
mPresenter.queryAllTripRecord()
|
||||
}
|
||||
}
|
||||
|
||||
override fun createPresenter(): TripRecordPresenter = TripRecordPresenter(this)
|
||||
|
||||
fun refreshTripRecordList(tripRecords: List<TripRecord>) {
|
||||
Logger.d(MODULE_NAME, "刷新出行动态列表:$tripRecords")
|
||||
tripRecordList.clear()
|
||||
tripRecordList.addAll(tripRecords)
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新单个出行动态,如果无此动态,新增动态
|
||||
*/
|
||||
fun refreshTripRecord(tripRecord: TripRecord) {
|
||||
Logger.d(MODULE_NAME, "刷新单个出行动态: $tripRecord")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.zhidao.mogo.module.event.panel.presenter;
|
||||
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.zhidao.mogo.module.event.panel.fragment.ScenarioHistoryFragment;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
*/
|
||||
public class ScenarioHistoryPresenter extends Presenter<ScenarioHistoryFragment> {
|
||||
|
||||
public ScenarioHistoryPresenter(ScenarioHistoryFragment view) {
|
||||
super(view);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.zhidao.mogo.module.event.panel.presenter
|
||||
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
import com.zhidao.mogo.module.event.panel.bean.TripRecord
|
||||
import com.zhidao.mogo.module.event.panel.fragment.TripRecordFragment
|
||||
import com.zhidao.mogo.module.event.panel.listener.ITripRecordCallback
|
||||
import com.zhidao.mogo.module.event.panel.util.TripRecordDataManager
|
||||
|
||||
class TripRecordPresenter(view: TripRecordFragment) : Presenter<TripRecordFragment>(view),ITripRecordCallback {
|
||||
|
||||
init {
|
||||
TripRecordDataManager.addTripRecordCallback(this)
|
||||
}
|
||||
|
||||
override fun onDestroy(owner: LifecycleOwner) {
|
||||
super.onDestroy(owner)
|
||||
TripRecordDataManager.removeTripRecordCallback(this)
|
||||
}
|
||||
|
||||
fun queryAllTripRecord(){
|
||||
TripRecordDataManager.queryAllTripRecord()
|
||||
}
|
||||
|
||||
override fun queryTripRecordListSuccess(tripRecordList: List<TripRecord>) {
|
||||
mView.refreshTripRecordList(tripRecordList)
|
||||
}
|
||||
|
||||
override fun insertOrUpdateTripRecordSuccess(tripRecord: TripRecord) {
|
||||
mView.refreshTripRecord(tripRecord)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.zhidao.mogo.module.event.panel.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.module.common.entity.V2XHistoryScenarioData;
|
||||
import com.mogo.utils.sqlite.BaseDaoFactory;
|
||||
import com.mogo.utils.sqlite.IBaseDao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据库操作工具类
|
||||
*
|
||||
* @author donghongyu
|
||||
*/
|
||||
public class V2XSQLiteUtils {
|
||||
/**
|
||||
* 场景数据管理
|
||||
*/
|
||||
private static IBaseDao<V2XHistoryScenarioData> mScenarioHistoryDao;
|
||||
|
||||
/**
|
||||
* 场景数据管理
|
||||
*/
|
||||
public static IBaseDao<V2XHistoryScenarioData> getScenarioHistoryDao(Context context) {
|
||||
if (mScenarioHistoryDao == null) {
|
||||
synchronized (V2XSQLiteUtils.class) {
|
||||
if (mScenarioHistoryDao == null) {
|
||||
mScenarioHistoryDao = BaseDaoFactory.Companion.getInstance()
|
||||
.getBaseDao(context, V2XHistoryScenarioData.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
return mScenarioHistoryDao;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当天的V2X数据
|
||||
*/
|
||||
public static List<V2XHistoryScenarioData> getScenarioHistoryData(Context context) {
|
||||
|
||||
return getScenarioHistoryDao(context).query(new V2XHistoryScenarioData());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#FFF">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:listitem="@layout/module_event_panel_share_item" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/clPanelContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="Trip Record"
|
||||
android:textColor="#000"
|
||||
android:textSize="40sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnInsert"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Insert"
|
||||
android:textColor="#000"
|
||||
android:textSize="30sp"
|
||||
android:layout_marginTop="100dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/btnUpdate"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnUpdate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Update"
|
||||
android:textColor="#000"
|
||||
android:textSize="30sp"
|
||||
android:layout_marginTop="100dp"
|
||||
app:layout_constraintLeft_toRightOf="@+id/btnInsert"
|
||||
app:layout_constraintRight_toLeftOf="@+id/btnDelete"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnDelete"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Delete"
|
||||
android:textColor="#000"
|
||||
android:textSize="30sp"
|
||||
android:layout_marginTop="100dp"
|
||||
app:layout_constraintLeft_toRightOf="@+id/btnUpdate"
|
||||
app:layout_constraintRight_toLeftOf="@+id/btnQuery"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnQuery"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Query"
|
||||
android:textColor="#000"
|
||||
android:textSize="30sp"
|
||||
android:layout_marginTop="100dp"
|
||||
app:layout_constraintLeft_toRightOf="@+id/btnDelete"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnGenerate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="GenerateLimitTime"
|
||||
android:textColor="#000"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnInsert" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user