| | |
| | | package com.dayu.general |
| | | |
| | | import android.app.Application |
| | | import android.nfc.Tag |
| | | import com.dayu.general.dao.BaseDaoSingleton |
| | | import com.dayu.general.dao.ProjectDataDao |
| | | |
| | | class BaseApplication private constructor() { |
| | | |
| | |
| | | @Volatile |
| | | private var myApplication: BaseApplication? = null |
| | | |
| | | var tag: String = "" |
| | | var token: String = "" |
| | | var userId: String = "" |
| | | |
| | | var userName: String = "" |
| | | var userPhone: String = "" |
| | | |
| | | //片区信息 |
| | | var blockId:String="" |
| | | var blockName:String="" |
| | | |
| | | |
| | | var projectDataDao: ProjectDataDao? = null |
| | | |
| | | @JvmStatic |
| | | fun getInstance(): BaseApplication { |
| | | return myApplication ?: synchronized(this) { |
| | | myApplication ?: BaseApplication().also { |
| | | myApplication = it |
| | | fun getInstance(application: Application): BaseApplication { |
| | | if (myApplication == null) { |
| | | BaseApplication.application = application |
| | | myApplication = BaseApplication().apply { |
| | | // 通过实例调用 init() |
| | | init() |
| | | } |
| | | } |
| | | return myApplication as BaseApplication |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | fun init() { |
| | | projectDataDao = application?.let { BaseDaoSingleton.getInstance(it)?.projectDataDao() } |
| | | if (projectDataDao != null) { |
| | | val projectDataBean = projectDataDao?.findFirst() |
| | | if (projectDataBean != null) { |
| | | tag = projectDataBean.projectTag |
| | | } |
| | | } |
| | | } |
| | | |