1
0
mirror of https://github.com/tateisu/SubwayTooter synced 2025-01-31 02:54:57 +01:00
This commit is contained in:
tateisu 2019-12-31 04:07:09 +09:00
parent 92ebbfcab0
commit 1cbf22ccfb
2 changed files with 17 additions and 6 deletions

View File

@ -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)

View File

@ -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 {
//