mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-11 18:53:37 +00:00
Minor code refactoring
This commit is contained in:
parent
e0410b6f10
commit
c59a41a607
@ -1,15 +1,12 @@
|
|||||||
package com.topjohnwu.magisk.di
|
package com.topjohnwu.magisk.di
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.text.method.LinkMovementMethod
|
|
||||||
import com.squareup.moshi.Moshi
|
import com.squareup.moshi.Moshi
|
||||||
import com.topjohnwu.magisk.BuildConfig
|
import com.topjohnwu.magisk.BuildConfig
|
||||||
import com.topjohnwu.magisk.ProviderInstaller
|
import com.topjohnwu.magisk.ProviderInstaller
|
||||||
import com.topjohnwu.magisk.core.Config
|
import com.topjohnwu.magisk.core.Config
|
||||||
import com.topjohnwu.magisk.core.Info
|
import com.topjohnwu.magisk.core.Info
|
||||||
import com.topjohnwu.magisk.core.utils.currentLocale
|
import com.topjohnwu.magisk.core.utils.currentLocale
|
||||||
import io.noties.markwon.Markwon
|
|
||||||
import io.noties.markwon.utils.NoCopySpannableFactory
|
|
||||||
import okhttp3.Cache
|
import okhttp3.Cache
|
||||||
import okhttp3.ConnectionSpec
|
import okhttp3.ConnectionSpec
|
||||||
import okhttp3.Dns
|
import okhttp3.Dns
|
||||||
@ -100,18 +97,3 @@ inline fun <reified T> createApiService(retrofitBuilder: Retrofit.Builder, baseU
|
|||||||
.build()
|
.build()
|
||||||
.create(T::class.java)
|
.create(T::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createMarkwon(context: Context): Markwon {
|
|
||||||
return Markwon.builder(context)
|
|
||||||
.textSetter { textView, spanned, bufferType, onComplete ->
|
|
||||||
textView.apply {
|
|
||||||
post {
|
|
||||||
movementMethod = LinkMovementMethod.getInstance()
|
|
||||||
setSpannableFactory(NoCopySpannableFactory.getInstance())
|
|
||||||
setText(spanned, bufferType)
|
|
||||||
onComplete.run()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
|
@ -2,6 +2,7 @@ package com.topjohnwu.magisk.di
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.text.method.LinkMovementMethod
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.lifecycle.ViewModelStoreOwner
|
import androidx.lifecycle.ViewModelStoreOwner
|
||||||
@ -19,6 +20,8 @@ import com.topjohnwu.magisk.ui.install.InstallViewModel
|
|||||||
import com.topjohnwu.magisk.ui.log.LogViewModel
|
import com.topjohnwu.magisk.ui.log.LogViewModel
|
||||||
import com.topjohnwu.magisk.ui.superuser.SuperuserViewModel
|
import com.topjohnwu.magisk.ui.superuser.SuperuserViewModel
|
||||||
import com.topjohnwu.magisk.ui.surequest.SuRequestViewModel
|
import com.topjohnwu.magisk.ui.surequest.SuRequestViewModel
|
||||||
|
import io.noties.markwon.Markwon
|
||||||
|
import io.noties.markwon.utils.NoCopySpannableFactory
|
||||||
|
|
||||||
val AppContext: Context inline get() = ServiceLocator.context
|
val AppContext: Context inline get() = ServiceLocator.context
|
||||||
|
|
||||||
@ -73,3 +76,13 @@ private fun createSuLogDatabase(context: Context) =
|
|||||||
Room.databaseBuilder(context, SuLogDatabase::class.java, "sulogs.db")
|
Room.databaseBuilder(context, SuLogDatabase::class.java, "sulogs.db")
|
||||||
.fallbackToDestructiveMigration()
|
.fallbackToDestructiveMigration()
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
private fun createMarkwon(context: Context) =
|
||||||
|
Markwon.builder(context).textSetter { textView, spanned, bufferType, onComplete ->
|
||||||
|
textView.apply {
|
||||||
|
movementMethod = LinkMovementMethod.getInstance()
|
||||||
|
setSpannableFactory(NoCopySpannableFactory.getInstance())
|
||||||
|
setText(spanned, bufferType)
|
||||||
|
onComplete.run()
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user