mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-26 05:05:15 +00:00
viewmodel test 2
This commit is contained in:
parent
ca74a58b43
commit
d4cfef8517
5 changed files with 19 additions and 8 deletions
|
@ -104,6 +104,7 @@ open class Home : BaseFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
val microgVerText = view.findViewById<TextView>(R.id.microg_installed_version)
|
||||
if (microgStatus!!) {
|
||||
val microgVer = pm.getPackageInfo("com.mgoogle.android.gms", 0).versionName
|
||||
|
@ -112,8 +113,9 @@ open class Home : BaseFragment() {
|
|||
uninstallApk("com.mgoogle.android.gms")
|
||||
}
|
||||
|
||||
|
||||
microgsettingsbtn.setOnClickListener {
|
||||
/*try {
|
||||
try {
|
||||
val intent = Intent()
|
||||
intent.component = ComponentName(
|
||||
"com.mgoogle.android.gms",
|
||||
|
@ -124,8 +126,10 @@ open class Home : BaseFragment() {
|
|||
Toast.makeText(activity, "App not installed", Toast.LENGTH_SHORT).show()
|
||||
activity?.recreate()
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
//microgVerText.text = microgVer
|
||||
} else {
|
||||
//microgsettingsbtn.visibility = View.INVISIBLE
|
||||
|
@ -139,6 +143,7 @@ open class Home : BaseFragment() {
|
|||
vancedinstallbtn.icon = null
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
val vancedVerText = view.findViewById<TextView>(R.id.vanced_installed_version)
|
||||
/*if (vancedStatus!!) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import androidx.navigation.findNavController
|
|||
import androidx.navigation.ui.AppBarConfiguration
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.vanced.manager.BR
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.core.Main
|
||||
import com.vanced.manager.databinding.ActivityMainBinding
|
||||
|
@ -22,8 +23,8 @@ class MainActivity : Main() {
|
|||
private lateinit var binding: ActivityMainBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
|
||||
binding.lifecycleOwner = this
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.view.*
|
|||
import android.widget.TextView
|
||||
import androidx.core.animation.addListener
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.dezlum.codelabs.getjson.GetJson
|
||||
|
@ -20,6 +21,7 @@ import com.vanced.manager.adapter.SectionPageAdapter
|
|||
import com.vanced.manager.adapter.SectionPageRootAdapter
|
||||
import com.vanced.manager.core.fragments.Home
|
||||
import com.vanced.manager.databinding.FragmentHomeBinding
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
@ -39,7 +41,9 @@ class HomeFragment : Home() {
|
|||
): View? {
|
||||
activity?.title = getString(R.string.title_home)
|
||||
setHasOptionsMenu(true)
|
||||
val viewModel: HomeViewModel by viewModels()
|
||||
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_home, container, false)
|
||||
binding.viewModel = viewModel
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
@ -87,13 +91,13 @@ class HomeFragment : Home() {
|
|||
if (isConnectedToInternet) {
|
||||
vancedinstallbtn?.visibility = View.VISIBLE
|
||||
|
||||
val vancedRemoteVer =
|
||||
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/vanced.json")
|
||||
.get("version").asString
|
||||
//val vancedRemoteVer =
|
||||
// GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/vanced.json")
|
||||
// .get("version").asString
|
||||
val microgRemoteVer =
|
||||
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/microg.json")
|
||||
.get("version").asString
|
||||
vancedLatestTxt?.text = vancedRemoteVer
|
||||
//vancedLatestTxt?.text = vancedRemoteVer
|
||||
|
||||
//val vancedRemoteCode =
|
||||
// GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/vanced.json")
|
||||
|
|
|
@ -23,6 +23,7 @@ class HomeViewModel(application: Application): AndroidViewModel(application) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
val isMicrogInstalled: Boolean = isPackageInstalled("com.mgoogle.android.gms", Activity().packageManager)
|
||||
val isVancedInstalled: Boolean = isPackageInstalled("com.vanced.android.youtube", Activity().packageManager)
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
<TextView
|
||||
style="@style/AppVer.Bold"
|
||||
android:id="@+id/vanced_installed_version"
|
||||
android:text="@{viewModel.microgInstalled ? viewModel.vancedInstalledVersion : @string/unavailable}" />
|
||||
android:text="@{viewModel.vancedInstalled ? viewModel.vancedInstalledVersion : @string/unavailable}" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue