refactor: Rename EuiccFragmentMarker
This commit is contained in:
parent
5514171070
commit
dedf633ce4
|
@ -31,7 +31,8 @@ import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
|
|
||||||
open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener, EuiccFragmentMarker {
|
open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener,
|
||||||
|
EuiccChannelFragmentMarker {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "EuiccManagementFragment"
|
const val TAG = "EuiccManagementFragment"
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import kotlinx.coroutines.flow.first
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
|
|
||||||
class ProfileDeleteFragment : DialogFragment(), EuiccFragmentMarker {
|
class ProfileDeleteFragment : DialogFragment(), EuiccChannelFragmentMarker {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "ProfileDeleteFragment"
|
const val TAG = "ProfileDeleteFragment"
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ import net.typeblog.lpac_jni.ProfileDownloadCallback
|
||||||
import kotlin.Exception
|
import kotlin.Exception
|
||||||
|
|
||||||
class ProfileDownloadFragment : BaseMaterialDialogFragment(),
|
class ProfileDownloadFragment : BaseMaterialDialogFragment(),
|
||||||
Toolbar.OnMenuItemClickListener, EuiccFragmentMarker {
|
Toolbar.OnMenuItemClickListener, EuiccChannelFragmentMarker {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "ProfileDownloadFragment"
|
const val TAG = "ProfileDownloadFragment"
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.Window
|
|
||||||
import android.widget.ProgressBar
|
import android.widget.ProgressBar
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
|
@ -20,7 +19,7 @@ import kotlinx.coroutines.withContext
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
import java.lang.RuntimeException
|
import java.lang.RuntimeException
|
||||||
|
|
||||||
class ProfileRenameFragment : BaseMaterialDialogFragment(), EuiccFragmentMarker {
|
class ProfileRenameFragment : BaseMaterialDialogFragment(), EuiccChannelFragmentMarker {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "ProfileRenameFragment"
|
const val TAG = "ProfileRenameFragment"
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
package im.angry.openeuicc.ui
|
package im.angry.openeuicc.util
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import im.angry.openeuicc.core.EuiccChannel
|
import im.angry.openeuicc.core.EuiccChannel
|
||||||
import im.angry.openeuicc.util.*
|
|
||||||
|
|
||||||
interface EuiccFragmentMarker: OpenEuiccContextMarker
|
interface EuiccChannelFragmentMarker: OpenEuiccContextMarker
|
||||||
|
|
||||||
fun <T> newInstanceEuicc(clazz: Class<T>, slotId: Int, portId: Int, addArguments: Bundle.() -> Unit = {}): T where T: Fragment, T: EuiccFragmentMarker {
|
// We must use extension functions because there is no way to add bounds to the type of "self"
|
||||||
|
// in the definition of an interface, so the only way is to limit where the extension functions
|
||||||
|
// can be applied.
|
||||||
|
fun <T> newInstanceEuicc(clazz: Class<T>, slotId: Int, portId: Int, addArguments: Bundle.() -> Unit = {}): T where T: Fragment, T: EuiccChannelFragmentMarker {
|
||||||
val instance = clazz.newInstance()
|
val instance = clazz.newInstance()
|
||||||
instance.arguments = Bundle().apply {
|
instance.arguments = Bundle().apply {
|
||||||
putInt("slotId", slotId)
|
putInt("slotId", slotId)
|
||||||
|
@ -17,12 +19,12 @@ fun <T> newInstanceEuicc(clazz: Class<T>, slotId: Int, portId: Int, addArguments
|
||||||
return instance
|
return instance
|
||||||
}
|
}
|
||||||
|
|
||||||
val <T> T.slotId: Int where T: Fragment, T: EuiccFragmentMarker
|
val <T> T.slotId: Int where T: Fragment, T: EuiccChannelFragmentMarker
|
||||||
get() = requireArguments().getInt("slotId")
|
get() = requireArguments().getInt("slotId")
|
||||||
val <T> T.portId: Int where T: Fragment, T: EuiccFragmentMarker
|
val <T> T.portId: Int where T: Fragment, T: EuiccChannelFragmentMarker
|
||||||
get() = requireArguments().getInt("portId")
|
get() = requireArguments().getInt("portId")
|
||||||
|
|
||||||
val <T> T.channel: EuiccChannel where T: Fragment, T: EuiccFragmentMarker
|
val <T> T.channel: EuiccChannel where T: Fragment, T: EuiccChannelFragmentMarker
|
||||||
get() =
|
get() =
|
||||||
euiccChannelManager.findEuiccChannelByPortBlocking(slotId, portId)!!
|
euiccChannelManager.findEuiccChannelByPortBlocking(slotId, portId)!!
|
||||||
|
|
Loading…
Reference in a new issue