opt
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -4,7 +4,7 @@
|
||||
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
|
||||
<groovy codeStyle="LEGACY" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -27,34 +27,34 @@ PASSWORD=xintai2018
|
||||
RELEASE=false
|
||||
# 模块版本
|
||||
## 工程内模块
|
||||
MOGO_COMMONS_VERSION=1.2.1.11
|
||||
MOGO_UTILS_VERSION=1.2.1.11
|
||||
MAP_AMAP_VERSION=1.2.1.11
|
||||
MAP_AUTONAVI_VERSION=1.2.1.11
|
||||
MOGO_MAP_VERSION=1.2.1.11
|
||||
MOGO_MAP_API_VERSION=1.2.1.11
|
||||
MOGO_SERVICE_VERSION=1.2.1.11
|
||||
MOGO_SERVICE_API_VERSION=1.2.1.11
|
||||
MOGO_CONNECTION_VERSION=1.2.1.11
|
||||
MOGO_MODULE_APPS_VERSION=1.2.1.11
|
||||
MOGO_MODULE_NAVI_VERSION=1.2.1.11
|
||||
MOGO_MODULE_SHARE_VERSION=1.2.1.11
|
||||
MOGO_MODULE_COMMON_VERSION=1.2.1.11
|
||||
MOGO_MODULE_MAIN_VERSION=1.2.1.11
|
||||
MOGO_MODULE_MAP_VERSION=1.2.1.11
|
||||
MOGO_MODULE_SERVICE_VERSION=1.2.1.11
|
||||
MOGO_MODULE_EXTENSIONS_VERSION=1.2.1.11
|
||||
MOGO_MODULE_SEARCH_VERSION=1.2.1.11
|
||||
MOGO_MODULE_BACK_VERSION=1.2.1.11
|
||||
MOGO_MODULE_GPS_SIMULATOR_VERSION=1.2.1.11
|
||||
MOGO_MODULE_GPS_SIMULATOR_DEBUG_VERSION=1.2.1.11
|
||||
MOGO_MODULE_GPS_SIMULATOR_NOOP_VERSION=1.2.1.11
|
||||
MOGO_MODULE_AUTHORIZE_VERSION=1.2.1.11
|
||||
MOGO_MODULE_GUIDE_VERSION=1.2.1.11
|
||||
MOGO_MODULE_MEDIA_VERSION=1.2.1.11
|
||||
MOGO_COMMONS_VERSION=1.2.1.12
|
||||
MOGO_UTILS_VERSION=1.2.1.12
|
||||
MAP_AMAP_VERSION=1.2.1.12
|
||||
MAP_AUTONAVI_VERSION=1.2.1.12
|
||||
MOGO_MAP_VERSION=1.2.1.12
|
||||
MOGO_MAP_API_VERSION=1.2.1.12
|
||||
MOGO_SERVICE_VERSION=1.2.1.12
|
||||
MOGO_SERVICE_API_VERSION=1.2.1.12
|
||||
MOGO_CONNECTION_VERSION=1.2.1.12
|
||||
MOGO_MODULE_APPS_VERSION=1.2.1.12
|
||||
MOGO_MODULE_NAVI_VERSION=1.2.1.12
|
||||
MOGO_MODULE_SHARE_VERSION=1.2.1.12
|
||||
MOGO_MODULE_COMMON_VERSION=1.2.1.13
|
||||
MOGO_MODULE_MAIN_VERSION=1.2.1.12
|
||||
MOGO_MODULE_MAP_VERSION=1.2.1.12
|
||||
MOGO_MODULE_SERVICE_VERSION=1.2.1.12
|
||||
MOGO_MODULE_EXTENSIONS_VERSION=1.2.1.12
|
||||
MOGO_MODULE_SEARCH_VERSION=1.2.1.12
|
||||
MOGO_MODULE_BACK_VERSION=1.2.1.12
|
||||
MOGO_MODULE_GPS_SIMULATOR_VERSION=1.2.1.12
|
||||
MOGO_MODULE_GPS_SIMULATOR_DEBUG_VERSION=1.2.1.12
|
||||
MOGO_MODULE_GPS_SIMULATOR_NOOP_VERSION=1.2.1.12
|
||||
MOGO_MODULE_AUTHORIZE_VERSION=1.2.1.12
|
||||
MOGO_MODULE_GUIDE_VERSION=1.2.1.12
|
||||
MOGO_MODULE_MEDIA_VERSION=1.2.1.12
|
||||
|
||||
MOGO_MODULE_MAIN_LAUNCHER_VERSION = 1.2.1.11
|
||||
MOGO_MODULE_MAIN_INDEPENDENT_VERSION = 1.2.1.11
|
||||
MOGO_MODULE_MAIN_LAUNCHER_VERSION = 1.2.1.12
|
||||
MOGO_MODULE_MAIN_INDEPENDENT_VERSION = 1.2.1.12
|
||||
|
||||
MOGO_MODULE_OBU_VERSION = 1.2.1.10-SNAPSHOT
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.mogo.utils.logger.Logger
|
||||
import com.zhidao.mogo.module.event.panel.EventPanelConstants.MODULE_NAME
|
||||
import com.zhidao.mogo.module.event.panel.EventPanelConstants.PATH_NAME
|
||||
import com.zhidao.mogo.module.event.panel.fragment.EventPanelFragment
|
||||
import com.zhidao.mogo.module.event.panel.util.MogoApiManager
|
||||
|
||||
/**
|
||||
* 事件面板provider
|
||||
@@ -31,6 +32,7 @@ class EventPanelModuleProvider : IEventPanelProvider {
|
||||
*/
|
||||
override fun init(context: Context) {
|
||||
Logger.d(MODULE_NAME, "模块初始化====")
|
||||
MogoApiManager.init(context)
|
||||
}
|
||||
|
||||
override fun createFragment(context: Context, data: Bundle?): Fragment? {
|
||||
|
||||
@@ -9,10 +9,9 @@ import androidx.room.PrimaryKey
|
||||
* @author
|
||||
*/
|
||||
@Entity
|
||||
class TripRecord {
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
var id:Int = 0
|
||||
var canUsed:Boolean = true
|
||||
var isUsed:Boolean = false
|
||||
var entity:String? = null
|
||||
}
|
||||
data class TripRecord(@PrimaryKey(autoGenerate = true)
|
||||
var id: Int = 0,
|
||||
var canUsed: Boolean = true,
|
||||
var isUsed: Boolean = false,
|
||||
var entity: String? = null,
|
||||
var recordTime: Long = 0)
|
||||
@@ -2,10 +2,12 @@ package com.zhidao.mogo.module.event.panel.dao
|
||||
|
||||
import androidx.room.*
|
||||
import com.zhidao.mogo.module.event.panel.bean.TripRecord
|
||||
import io.reactivex.Flowable
|
||||
|
||||
@Dao
|
||||
interface TripRecordDao {
|
||||
// fun getAllTripRecord():List<TripRecord>
|
||||
@Query(value = "SELECT * FROM TripRecord")
|
||||
fun getAllTripRecord():Flowable<List<TripRecord>>
|
||||
|
||||
@Insert
|
||||
fun insert(vararg tripRecord: TripRecord)
|
||||
|
||||
@@ -9,11 +9,17 @@ import com.zhidao.mogo.module.event.panel.bean.TripRecord
|
||||
@Database(entities = [TripRecord::class], version = 1, exportSchema = false)
|
||||
abstract class TripRecordDatabase : RoomDatabase() {
|
||||
companion object{
|
||||
const val DB_NAME = "TripRecordDatabase.db"
|
||||
private var instance:TripRecordDatabase? = null
|
||||
fun getInstance(context: Context):TripRecordDatabase{
|
||||
if (instance == null) {
|
||||
synchronized(TripRecordDatabase::class.java) {
|
||||
if (instance == null) {
|
||||
instance = Room.databaseBuilder(context, TripRecordDatabase::class.java, "TripRecordDatabase.db").build()
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance!!
|
||||
}
|
||||
}
|
||||
fun create(context: Context):TripRecordDatabase {
|
||||
return Room.databaseBuilder(context, TripRecordDatabase::class.java, DB_NAME).build()
|
||||
}
|
||||
|
||||
abstract fun getTripRecordDao():TripRecordDao
|
||||
}
|
||||
@@ -1,31 +1,55 @@
|
||||
package com.zhidao.mogo.module.event.panel.fragment
|
||||
|
||||
import android.util.Log
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
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 kotlinx.android.synthetic.main.module_event_panel_fragment_trip_record.*
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
* 出行动态fragment
|
||||
*/
|
||||
const val TAG = "TripRecordFragment"
|
||||
class TripRecordFragment: MvpFragment<TripRecordFragment, TripRecordPresenter>() {
|
||||
/**
|
||||
* 布局资源
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private val tripRecordList = ArrayList<TripRecord>()
|
||||
override fun getLayoutId(): Int = R.layout.module_event_panel_fragment_trip_record
|
||||
|
||||
/**
|
||||
* 初始化控件,必须在初始化完成之后才可以实例化presenter,避免
|
||||
* presenter 生命周期错乱
|
||||
*/
|
||||
override fun initViews() {
|
||||
btnInsert.setOnClickListener {
|
||||
val tripRecord = TripRecord()
|
||||
val random = Random.nextInt(10)
|
||||
tripRecord.entity = "entity: $random"
|
||||
tripRecord.recordTime = System.currentTimeMillis()
|
||||
tripRecordList.add(tripRecord)
|
||||
mPresenter.insertTripRecord(tripRecord)
|
||||
Log.d(TAG, "insert over: $tripRecord")
|
||||
}
|
||||
|
||||
btnDelete.setOnClickListener {
|
||||
val random = Random.nextInt(tripRecordList.size)
|
||||
val tripRecord = tripRecordList.removeAt(random)
|
||||
mPresenter.deleteTripRecords(tripRecord)
|
||||
Log.d(TAG, "delete over: $tripRecord")
|
||||
}
|
||||
|
||||
btnUpdate.setOnClickListener {
|
||||
val random = Random.nextInt(tripRecordList.size)
|
||||
val tripRecord = tripRecordList[random]
|
||||
Log.d(TAG,"before update: $tripRecord")
|
||||
tripRecord.recordTime = System.currentTimeMillis()
|
||||
mPresenter.updateTripRecords(tripRecord)
|
||||
Log.d(TAG, "update over: $tripRecord")
|
||||
}
|
||||
|
||||
btnQuery.setOnClickListener {
|
||||
Log.d(TAG, "local list: $tripRecordList")
|
||||
mPresenter.queryAllTripRecord()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 presenter 实例
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
override fun createPresenter(): TripRecordPresenter = TripRecordPresenter(this)
|
||||
}
|
||||
@@ -1,15 +1,35 @@
|
||||
package com.zhidao.mogo.module.event.panel.presenter
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import android.util.Log
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.zhidao.mogo.module.event.panel.bean.TripRecord
|
||||
import com.zhidao.mogo.module.event.panel.dao.TripRecordDatabase
|
||||
import com.zhidao.mogo.module.event.panel.fragment.TripRecordFragment
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
class TripRecordPresenter(view: TripRecordFragment) : Presenter<TripRecordFragment>(view) {
|
||||
private val serviceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(view.context) as IMogoServiceApis
|
||||
|
||||
init {
|
||||
|
||||
fun queryAllTripRecord() {
|
||||
val disposable = TripRecordDatabase.getInstance(context).getTripRecordDao().getAllTripRecord().subscribeOn(Schedulers.io()).subscribe {
|
||||
Log.d("TripRecordFragment", "db query: $it")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun insertTripRecord(vararg records: TripRecord) {
|
||||
thread {
|
||||
TripRecordDatabase.getInstance(context).getTripRecordDao().insert(*records)
|
||||
}
|
||||
}
|
||||
|
||||
fun updateTripRecords(vararg records: TripRecord) {
|
||||
thread {
|
||||
TripRecordDatabase.getInstance(context).getTripRecordDao().update(*records)
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteTripRecords(vararg records: TripRecord) {
|
||||
thread {
|
||||
TripRecordDatabase.getInstance(context).getTripRecordDao().delete(*records)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.zhidao.mogo.module.event.panel.util
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
|
||||
object MogoApiManager {
|
||||
lateinit var serviceApis:IMogoServiceApis
|
||||
|
||||
fun init(context: Context) {
|
||||
serviceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context) as IMogoServiceApis
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,7 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/clPanelContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/vpEventPanel"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?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">
|
||||
@@ -12,4 +13,49 @@
|
||||
android:text="Trip Record"
|
||||
android:textColor="#fff"
|
||||
android:textSize="40sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnInsert"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Insert"
|
||||
android:textColor="#fff"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/btnUpdate"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnUpdate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Update"
|
||||
android:textColor="#fff"
|
||||
android:textSize="30sp"
|
||||
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="#fff"
|
||||
android:textSize="30sp"
|
||||
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="#fff"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintLeft_toRightOf="@+id/btnDelete"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user