123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- package com.sybotan.android.demo.activities
- import android.Manifest
- import android.content.SharedPreferences
- import android.content.pm.PackageManager
- import android.os.Bundle
- import android.widget.Button
- import androidx.appcompat.app.AppCompatActivity
- import androidx.constraintlayout.widget.ConstraintLayout
- import androidx.core.app.ActivityCompat
- import androidx.core.content.edit
- import com.framework.app.tools.MacUtil
- import com.framework.mvvm.model.vo.AdmRequest
- import com.framework.mvvm.mv.AdmViewModel
- import com.sybotan.android.demo.R
- import com.sybotan.android.demo.activities.poc.SceneActivity
- import com.sybotan.android.demo.activities.poc.SpaceActivity
- import com.sybotan.android.demo.tools.ToastUtils
- import com.sybotan.android.demo.tools.LocalDataOperation
- import org.jetbrains.anko.startActivity
- import org.kodein.di.DI
- import org.kodein.di.DIAware
- import org.kodein.di.android.closestDI
- import org.kodein.di.android.x.viewmodel.viewModel
- import org.kodein.di.instance
- class PocActivity : AppCompatActivity(), DIAware {
- override val di: DI by closestDI()
- private val mVm: AdmViewModel by viewModel()
- private val sp: SharedPreferences by instance()
- private val REQUEST_EXTERNAL_STORAGE = 1 // 不可改
- private lateinit var downloadBtn: Button
- private lateinit var uploadBtn: Button
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- setContentView(R.layout.activity_poc)
- checkStoragePermission()
- LocalDataOperation.getInstance().offlineSendRequest.uploadImageNew(this)
- downloadBtn = findViewById(R.id.downloadBtn)
- uploadBtn = findViewById(R.id.uploadBtn)
- downloadBtn.setOnClickListener {
- mVm.downloadBuilding(sp) {
- ToastUtils.showMyToast("下载建筑数据完成")
- }
- }
- uploadBtn.setOnClickListener {
- mVm.uploadBuilding {
- ToastUtils.showMyToast("建筑数据上传成功")
- }
- }
- val spaceCL = findViewById<ConstraintLayout>(R.id.spaceCL)
- spaceCL.setOnClickListener {
- startActivity<SpaceActivity>()
- }
- val sceneCL = findViewById<ConstraintLayout>(R.id.sceneCL)
- sceneCL.setOnClickListener {
- startActivity<SceneActivity>()
- }
- mVm.requestFrame(
- AdmRequest(
- userId = "bdtp",
- projectId = "Pj0002220011",
- groupCode = "BR"
- )
- )
- mVm.requestDict(
- AdmRequest(
- userId = "bdtp",
- projectId = "Pj000222001",
- groupCode = "BR"
- )
- )
- // mVm.requestBuilding(
- // AdmRequest(
- // userId = "bdtp",
- // projectId = "Pj0002220011",
- // groupCode = "BR",
- // buildingId = "Bd0002220002bcaa181bd406439c9ecaddac13b0d543"
- // )
- // )
- }
- private fun checkStoragePermission() {
- // ActivityCompat.requestPermissions(
- // this, arrayOf(
- // Manifest.permission.READ_EXTERNAL_STORAGE,
- // Manifest.permission.WRITE_EXTERNAL_STORAGE
- // ),
- // REQUEST_EXTERNAL_STORAGE
- // )
- if (ActivityCompat.checkSelfPermission(
- this,
- Manifest.permission.WRITE_EXTERNAL_STORAGE
- ) != PackageManager.PERMISSION_GRANTED
- ) {
- ActivityCompat.requestPermissions(
- this,
- arrayOf(
- Manifest.permission.WRITE_EXTERNAL_STORAGE,
- Manifest.permission.READ_PHONE_STATE
- ),
- 1
- )
- }
- }
- override fun onRequestPermissionsResult(
- requestCode: Int,
- permissions: Array<out String>,
- grantResults: IntArray
- ) {
- super.onRequestPermissionsResult(requestCode, permissions, grantResults)
- if (requestCode == 1) {
- val mac = MacUtil.getMacAddress(this)!!
- println("deviceId: $mac")
- sp.edit {
- putString("deviceId", mac)
- }
- }
- }
- }
|