| | |
| | | import android.util.Log |
| | | import androidx.activity.ComponentActivity |
| | | import androidx.core.content.FileProvider |
| | | import androidx.lifecycle.MutableLiveData |
| | | import androidx.lifecycle.ViewModel |
| | | import com.runt.open.mvi.base.BaseActivity |
| | | import com.runt.open.mvi.base.LayoutView |
| | | import com.runt.open.mvi.data.LoadingState |
| | | import com.runt.open.mvi.data.MessageState |
| | | import com.runt.open.mvi.data.PopupMessage |
| | | import com.runt.open.mvi.retrofit.AndroidScheduler |
| | | import io.reactivex.Observable |
| | | import io.reactivex.Observer |
| | | import io.reactivex.schedulers.Schedulers |
| | | import kotlinx.coroutines.flow.MutableStateFlow |
| | | import kotlinx.coroutines.flow.asStateFlow |
| | | import okhttp3.Callback |
| | | import okhttp3.OkHttpClient |
| | | import okhttp3.Request |
| | |
| | | var TAG = ""; |
| | | |
| | | protected var mActivity : BaseActivity<LayoutView<BaseViewModel> , BaseViewModel>? = null |
| | | var verifyResult = MutableLiveData<Int>() |
| | | |
| | | private val _isLoading = MutableStateFlow(LoadingState()) |
| | | val isLoading = _isLoading.asStateFlow() |
| | | |
| | | val messageSetDismiss = { |
| | | _messageState.value = _messageState.value.copy(isVisible = false); |
| | | } |
| | | private val _messageState = MutableStateFlow(MessageState(isVisible = false, setDismiss = { })) |
| | | val messageState = _messageState.asStateFlow() |
| | | |
| | | private val _popupState = MutableStateFlow(PopupMessage(isVisible = false,"","")) |
| | | val popupState = _popupState.asStateFlow() |
| | | |
| | | open fun onCreate(activity : BaseActivity<LayoutView<BaseViewModel> , BaseViewModel>) { |
| | | mActivity = activity |
| | |
| | | return mActivity!!; |
| | | } |
| | | |
| | | fun showLoading(message : String = "加载中...") { |
| | | _isLoading.value = LoadingState(isVisible = true,message = message); |
| | | } |
| | | |
| | | fun hideLoading() { |
| | | _isLoading.value = _isLoading.value.copy(isVisible = false); |
| | | } |
| | | |
| | | fun showDialog( title:String = "", message: String = "", confirmText:String = "确定", cancelText:String = "", |
| | | touchOutside:Boolean = true,//空白和系统返回 是否关闭 |
| | | showClose:Boolean = false,//显示关闭图标(默认不显示) |
| | | confirmDissmiss:Boolean = true,//点击确定是否关闭 |
| | | cancelDissmiss:Boolean = true,//点击取消是否关闭 |
| | | onDismissRequest : () -> Unit = {}, |
| | | onConfirmRequest : () -> Unit = {}, ){ |
| | | |
| | | _messageState.value = MessageState(title = title, message = message, touchOutside = touchOutside, showClose = showClose, confirmText = confirmText, |
| | | cancelText = cancelText, confirmDissmiss = confirmDissmiss, cancelDissmiss = cancelDissmiss, onDismissRequest = onDismissRequest, |
| | | onConfirmRequest = onConfirmRequest, setDismiss = messageSetDismiss); |
| | | } |
| | | |
| | | fun showPopupWindow(title : String,message : String){ |
| | | _popupState.value = PopupMessage(isVisible = true,title,message) |
| | | } |
| | | |
| | | fun hidePopupWindow(){ |
| | | _popupState.value = _popupState.value.copy(isVisible = false); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户信息 |
| | | */ |