|
|
|
@ -5,6 +5,7 @@ import android.view.MenuItem |
|
|
|
|
import androidx.activity.viewModels |
|
|
|
|
import com.afollestad.materialdialogs.MaterialDialog |
|
|
|
|
import com.bingce.coordlib.model.CoordinateSystem |
|
|
|
|
import com.bingce.coordlib.util.CoordinateSystemUtil |
|
|
|
|
import com.bingce.data.database.KeyValueDb |
|
|
|
|
import com.bingce.data.database.ProjectDb |
|
|
|
|
import com.bingce.data.surveyor.designdata.kv.KeyValueConstants |
|
|
|
@ -17,8 +18,10 @@ import com.project.survey.constants.SPConstants |
|
|
|
|
import com.project.survey.databinding.ActivityProjectListBinding |
|
|
|
|
import com.project.survey.extend.smartDismiss |
|
|
|
|
import com.project.survey.extend.toast |
|
|
|
|
import com.project.survey.extend.toastLong |
|
|
|
|
import com.project.survey.logic.event.Message |
|
|
|
|
import com.project.survey.logic.viewmodel.ProjectViewModel |
|
|
|
|
import com.project.survey.model.ProjectBean |
|
|
|
|
import com.project.survey.ui.MainActivity |
|
|
|
|
import com.project.survey.ui.base.BaseBindingActivity |
|
|
|
|
import com.project.survey.ui.login.LoginActivity |
|
|
|
@ -93,44 +96,60 @@ class ProjectListActivity : BaseBindingActivity<ActivityProjectListBinding>(), O |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun initListener() { |
|
|
|
|
adapter.setOnItemClickListener { _, _, position -> |
|
|
|
|
adapter.setOnItemClickListener { adapter, _, position -> |
|
|
|
|
adapter.getItem(position)?.let { bean -> |
|
|
|
|
// 进入项目,设置当前项目 |
|
|
|
|
SPUtils.put(SPConstants.CURRENT_PROJECT, bean) |
|
|
|
|
SPUtils.put(SPConstants.PROJECT_ID, bean.XMXX_ID) |
|
|
|
|
// 存储配置--当前项目 |
|
|
|
|
ThreadPoolUtil.execute { |
|
|
|
|
//存储新的项目 |
|
|
|
|
ProjectDb.getInstance().save( |
|
|
|
|
ProjectRecord( |
|
|
|
|
bean.XMXX_ID, |
|
|
|
|
bean.XMXX_NAME, |
|
|
|
|
CoordinateSystem.newCoordinateSystem(this), |
|
|
|
|
Date().time |
|
|
|
|
).apply { |
|
|
|
|
author = bean.XMXX_CONTACTNAME |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
// 查询当前项目坐标系统 |
|
|
|
|
viewModel.fetchCoordinateSystem({ coordinateSystemString -> |
|
|
|
|
val coordinateSystem = |
|
|
|
|
CoordinateSystemUtil.importCoordSysString(coordinateSystemString) |
|
|
|
|
nav2Main(bean, coordinateSystem) |
|
|
|
|
}, { message -> |
|
|
|
|
toastLong(message + "使用默认坐标系统") |
|
|
|
|
nav2Main(bean) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var currentProjectConfig = |
|
|
|
|
KeyValueDb.getInstance().findData(KeyValueConstants.KEY_CURRENT_PROJECT_ID) |
|
|
|
|
if (currentProjectConfig != null) { |
|
|
|
|
currentProjectConfig.value = bean.XMXX_ID |
|
|
|
|
} else { |
|
|
|
|
currentProjectConfig = |
|
|
|
|
KeyValueRecord( |
|
|
|
|
KeyValueConstants.KEY_CURRENT_PROJECT_ID, |
|
|
|
|
bean.XMXX_ID |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
KeyValueDb.getInstance().save(currentProjectConfig) |
|
|
|
|
private fun nav2Main( |
|
|
|
|
bean: ProjectBean, |
|
|
|
|
coordinateSystem: CoordinateSystem = CoordinateSystem.newCoordinateSystem(this) |
|
|
|
|
) { |
|
|
|
|
// 存储配置--当前项目 |
|
|
|
|
ThreadPoolUtil.execute { |
|
|
|
|
//存储新的项目 |
|
|
|
|
ProjectDb.getInstance().save( |
|
|
|
|
ProjectRecord( |
|
|
|
|
bean.XMXX_ID, |
|
|
|
|
bean.XMXX_NAME, |
|
|
|
|
coordinateSystem, |
|
|
|
|
Date().time |
|
|
|
|
).apply { |
|
|
|
|
author = bean.XMXX_CONTACTNAME |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
viewModel.msgEvent.postValue(Message(EventConstants.UPDATE_PROJECT)) |
|
|
|
|
MainActivity.start() |
|
|
|
|
ActivityNavUtil.finishActivity<ProjectListActivity>() |
|
|
|
|
var currentProjectConfig = |
|
|
|
|
KeyValueDb.getInstance().findData(KeyValueConstants.KEY_CURRENT_PROJECT_ID) |
|
|
|
|
if (currentProjectConfig != null) { |
|
|
|
|
currentProjectConfig.value = bean.XMXX_ID |
|
|
|
|
} else { |
|
|
|
|
currentProjectConfig = |
|
|
|
|
KeyValueRecord( |
|
|
|
|
KeyValueConstants.KEY_CURRENT_PROJECT_ID, |
|
|
|
|
bean.XMXX_ID |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
KeyValueDb.getInstance().save(currentProjectConfig) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
viewModel.msgEvent.postValue(Message(EventConstants.UPDATE_PROJECT)) |
|
|
|
|
MainActivity.start() |
|
|
|
|
ActivityNavUtil.finishActivity<ProjectListActivity>() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// private fun initTabLayout() { |
|
|
|
|