Updated on 2026-08-14
This commit is contained in:
parent
ec99dfa367
commit
78ef89d2cf
2 changed files with 30 additions and 25 deletions
|
|
@ -11,6 +11,7 @@ import android.widget.PopupMenu
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.ViewModelProviders
|
import androidx.lifecycle.ViewModelProviders
|
||||||
import com.tangem.App
|
import com.tangem.App
|
||||||
import com.tangem.Constant
|
import com.tangem.Constant
|
||||||
|
|
@ -84,23 +85,6 @@ class MainFragment : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
||||||
else
|
else
|
||||||
tvNFCHint.text = String.format(getString(R.string.scan_banknote), getString(R.string.phone))
|
tvNFCHint.text = String.format(getString(R.string.scan_banknote), getString(R.string.phone))
|
||||||
|
|
||||||
val apiHelper = ServerApiCommon()
|
|
||||||
apiHelper.setLastVersionListener { response ->
|
|
||||||
try {
|
|
||||||
if (response.isNullOrEmpty())
|
|
||||||
return@setLastVersionListener
|
|
||||||
val responseVersionName = response.trim(' ', '\n', '\r', '\t')
|
|
||||||
val responseBuildVersion = responseVersionName.split('.').last()
|
|
||||||
val appBuildVersion = BuildConfig.VERSION_NAME.split('.').last()
|
|
||||||
if (responseBuildVersion.toInt() > appBuildVersion.toInt())
|
|
||||||
if (BuildConfig.FLAVOR.equals(Constant.FLAVOR_TANGEM_ACCESS))
|
|
||||||
(activity as MainActivity).toastHelper.showSnackbarUpdateVersion(context!!, cl, responseVersionName)
|
|
||||||
} catch (E: Exception) {
|
|
||||||
E.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
apiHelper.requestLastVersion()
|
|
||||||
|
|
||||||
// set listeners
|
// set listeners
|
||||||
fab.setOnClickListener { showMenu(it) }
|
fab.setOnClickListener { showMenu(it) }
|
||||||
}
|
}
|
||||||
|
|
@ -109,11 +93,10 @@ class MainFragment : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java)
|
viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java)
|
||||||
|
|
||||||
// viewModel.getVersionName().observe(this, Observer { text ->
|
// show snackbar about new version app
|
||||||
// Log.d("", text)
|
viewModel.getVersionName().observe(this, Observer { text ->
|
||||||
// if (BuildConfig.FLAVOR.equals(Constant.FLAVOR_TANGEM_ACCESS))
|
(activity as MainActivity).toastHelper.showSnackbarUpdateVersion(context!!, cl, text)
|
||||||
// (activity as MainActivity).toastHelper.showSnackbarUpdateVersion(context!!, cl, text)
|
})
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
|
@ -185,7 +168,6 @@ class MainFragment : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
||||||
if (engineCoin != null) {
|
if (engineCoin != null) {
|
||||||
engineCoin.defineWallet()
|
engineCoin.defineWallet()
|
||||||
|
|
||||||
|
|
||||||
// val bundle = Bundle()
|
// val bundle = Bundle()
|
||||||
// bundle.putParcelable(Constant.EXTRA_LAST_DISCOVERED_TAG, lastTag)
|
// bundle.putParcelable(Constant.EXTRA_LAST_DISCOVERED_TAG, lastTag)
|
||||||
// ctx.saveToBundle(bundle)
|
// ctx.saveToBundle(bundle)
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,35 @@ package com.tangem.ui.fragment
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
|
import com.tangem.Constant
|
||||||
|
import com.tangem.data.network.ServerApiCommon
|
||||||
|
import com.tangem.wallet.BuildConfig
|
||||||
|
|
||||||
class MainViewModel : ViewModel() {
|
class MainViewModel : ViewModel() {
|
||||||
private val responseVersionName = MutableLiveData<String>()
|
private var versionName = MutableLiveData<String>()
|
||||||
|
|
||||||
fun getVersionName(): LiveData<String> {
|
fun getVersionName(): LiveData<String> {
|
||||||
|
versionName = MutableLiveData()
|
||||||
|
requestVersionName()
|
||||||
|
return versionName
|
||||||
|
}
|
||||||
|
|
||||||
return responseVersionName
|
private fun requestVersionName() {
|
||||||
|
val apiHelper = ServerApiCommon()
|
||||||
|
apiHelper.setLastVersionListener { response ->
|
||||||
|
try {
|
||||||
|
if (response.isNullOrEmpty())
|
||||||
|
return@setLastVersionListener
|
||||||
|
val responseVersionName = response.trim(' ', '\n', '\r', '\t')
|
||||||
|
val responseBuildVersion = responseVersionName.split('.').last()
|
||||||
|
val appBuildVersion = BuildConfig.VERSION_NAME.split('.').last()
|
||||||
|
if (responseBuildVersion.toInt() > appBuildVersion.toInt())
|
||||||
|
if (BuildConfig.FLAVOR.equals(Constant.FLAVOR_TANGEM_ACCESS))
|
||||||
|
versionName.value = responseVersionName
|
||||||
|
} catch (E: Exception) {
|
||||||
|
E.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
apiHelper.requestLastVersion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue