mirror of
https://github.com/tateisu/SubwayTooter
synced 2025-01-31 02:54:57 +01:00
refactor
This commit is contained in:
parent
92ebbfcab0
commit
1cbf22ccfb
@ -698,8 +698,8 @@ class ActMediaViewer : AppCompatActivity(), View.OnClickListener {
|
||||
return
|
||||
}
|
||||
|
||||
val downLoadManager = getSystemService(DOWNLOAD_SERVICE) as? DownloadManager
|
||||
?: throw NotImplementedError("missing DownloadManager system service")
|
||||
val downLoadManager :DownloadManager = systemService(this)
|
||||
?: error("missing DownloadManager system service")
|
||||
|
||||
val url = if(ta is TootAttachment) {
|
||||
ta.getLargeUrl(App1.pref)
|
||||
|
@ -1,7 +1,18 @@
|
||||
//package jp.juggler.util
|
||||
//
|
||||
//import android.util.SparseBooleanArray
|
||||
//import kotlin.collections.set
|
||||
package jp.juggler.util
|
||||
|
||||
import android.content.Context
|
||||
import androidx.core.content.ContextCompat
|
||||
|
||||
// 型推論できる文脈だと型名を書かずにすむ
|
||||
@Suppress("unused")
|
||||
inline fun <reified T : Any> Any?.cast(): T = this as T
|
||||
|
||||
inline fun <reified T : Any> Any?.castOrNull(): T? = this as? T
|
||||
|
||||
// 型推論できる文脈だと型名を書かずにすむ
|
||||
inline fun <reified T> systemService(context: Context): T? =
|
||||
/* ContextCompat. */ ContextCompat.getSystemService(context, T::class.java)
|
||||
|
||||
//
|
||||
//object Utils {
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user