Browse Source

refactor: do not use extension functions for OpenEuiccContextMarker

we can just define them internally
Peter Cai 2 years ago
parent
commit
5514171070
1 changed files with 14 additions and 14 deletions
  1. 14 14
      app-common/src/main/java/im/angry/openeuicc/util/Utils.kt

+ 14 - 14
app-common/src/main/java/im/angry/openeuicc/util/Utils.kt

@@ -26,23 +26,23 @@ val Context.selfAppVersion: String
             throw RuntimeException(e)
             throw RuntimeException(e)
         }
         }
 
 
-interface OpenEuiccContextMarker
-
-val OpenEuiccContextMarker.context: Context
-    get() = when (this) {
-        is Context -> this
-        is Fragment -> requireContext()
-        else -> throw RuntimeException("OpenEuiccUIContextMarker shall only be used on Fragments or UI types that derive from Context")
-    }
+interface OpenEuiccContextMarker {
+    val context: Context
+        get() = when (this) {
+            is Context -> this
+            is Fragment -> requireContext()
+            else -> throw RuntimeException("OpenEuiccUIContextMarker shall only be used on Fragments or UI types that derive from Context")
+        }
 
 
-val OpenEuiccContextMarker.openEuiccApplication: OpenEuiccApplication
-    get() = context.applicationContext as OpenEuiccApplication
+    val openEuiccApplication: OpenEuiccApplication
+        get() = context.applicationContext as OpenEuiccApplication
 
 
-val OpenEuiccContextMarker.euiccChannelManager: EuiccChannelManager
-    get() = openEuiccApplication.euiccChannelManager
+    val euiccChannelManager: EuiccChannelManager
+        get() = openEuiccApplication.euiccChannelManager
 
 
-val OpenEuiccContextMarker.telephonyManager: TelephonyManager
-    get() = openEuiccApplication.telephonyManager
+    val telephonyManager: TelephonyManager
+        get() = openEuiccApplication.telephonyManager
+}
 
 
 val LocalProfileInfo.isEnabled: Boolean
 val LocalProfileInfo.isEnabled: Boolean
     get() = state == LocalProfileInfo.State.Enabled
     get() = state == LocalProfileInfo.State.Enabled