Sliceのアレコレ

 Sliceのアレコレ

B8f695167d115eef9f32399b1c9261df?s=128

Yuki Mima

May 29, 2018
Tweet

Transcript

  1. 5.
  2. 7.

    (PPHMF*0ͷ஌ݟ w ։࠵ͷલલ೔ೖΓ͕ྑͦ͞͏ w ࣌ࠩϘέ·͡ਏ͍ w ૣΊͷ#BEHF1JDLVQͰΑΓྑ͍੮Ͱ,FZOPUFΛݟΕΔ w ௚௨ͷγϟτϧόε͕ग़Δϗςϧ͕Α͍ w

    IUUQTXXXDPVOUSZJOOTDPN w #BEHF1JDLVQͷ࣌ؒ͸ޕલ࣌෼͘Β͍͕ྑͦ͞͏ w ன൧͕ޱʹ߹Θͳ͍ w 6CFS࠷ߴ
  3. 11.
  4. 13.
  5. 15.

    class CryptoSliceProvider : SliceProvider() { private val path = "/crypto"

    override fun onCreateSliceProvider(): Boolean = true override fun onBindSlice(sliceUri: Uri): Slice? = when (sliceUri.path) { path -> { context.startService(Intent(context, CryptoService::class.java)) createCryptoSlice(sliceUri) } else -> null } private fun createCryptoSlice(sliceUri: Uri): Slice? = ListBuilder(context, sliceUri, ListBuilder.INFINITY) .addGridRow { it.apply { addCell { it.apply { addImage(IconCompat.createWithResource(context, R.drawable.ic_bitcoin), SMALL_IMAGE) addTitleText("Bitcoin") addText(CryptoService.bitcoin, true) } } ... } } .build() }
  6. 16.

    class CryptoSliceProvider : SliceProvider() { private val path = "/crypto"

    override fun onCreateSliceProvider(): Boolean = true override fun onBindSlice(sliceUri: Uri): Slice? = when (sliceUri.path) { path -> { context.startService(Intent(context, CryptoService::class.java)) createCryptoSlice(sliceUri) } else -> null } private fun createCryptoSlice(sliceUri: Uri): Slice? = ListBuilder(context, sliceUri, ListBuilder.INFINITY) .addGridRow { it.apply { addCell { it.apply { addImage(IconCompat.createWithResource(context, R.drawable.ic_bitcoin), SMALL_IMAGE) addTitleText("Bitcoin") addText(CryptoService.bitcoin, true) } } ... } } .build() }
  7. 17.

    class CryptoSliceProvider : SliceProvider() { private val path = "/crypto"

    override fun onCreateSliceProvider(): Boolean = true override fun onBindSlice(sliceUri: Uri): Slice? = when (sliceUri.path) { path -> { context.startService(Intent(context, CryptoService::class.java)) createCryptoSlice(sliceUri) } else -> null } private fun createCryptoSlice(sliceUri: Uri): Slice? = ListBuilder(context, sliceUri, ListBuilder.INFINITY) .addGridRow { it.apply { addCell { it.apply { addImage(IconCompat.createWithResource(context, R.drawable.ic_bitcoin), SMALL_IMAGE) addTitleText("Bitcoin") addText(CryptoService.bitcoin, true) } } ... } } .build() }
  8. 18.

    class CryptoSliceProvider : SliceProvider() { private val path = "/crypto"

    override fun onCreateSliceProvider(): Boolean = true override fun onBindSlice(sliceUri: Uri): Slice? = when (sliceUri.path) { path -> { context.startService(Intent(context, CryptoService::class.java)) createCryptoSlice(sliceUri) } else -> null } private fun createCryptoSlice(sliceUri: Uri): Slice? = ListBuilder(context, sliceUri, ListBuilder.INFINITY) .addGridRow { it.apply { addCell { it.apply { addImage(…) addTitleText("Bitcoin") addText(CryptoService.bitcoin, true) } } ... } } .build() }
  9. 19.

    class CryptoSliceProvider : SliceProvider() { private val path = "/crypto"

    override fun onCreateSliceProvider(): Boolean = true override fun onBindSlice(sliceUri: Uri): Slice? = when (sliceUri.path) { path -> { context.startService(Intent(context, CryptoService::class.java)) createCryptoSlice(sliceUri) } else -> null } private fun createCryptoSlice(sliceUri: Uri): Slice? = ListBuilder(context, sliceUri, ListBuilder.INFINITY) .addGridRow { it.apply { addCell { it.apply { addImage(…) addTitleText("Bitcoin") addText(CryptoService.bitcoin, true) } } ... } } .build() }
  10. 20.

    class CryptoService : Service() { companion object { var bitcoin:

    String? = null ... } override fun onBind(p0: Intent?): IBinder? = null override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int = START_NOT_STICKY.also { _ -> apiClient.getCryptoList() .doOnFinish { stopSelf() } .subscribe({ bitcoin = "ˇ${it.toNumberformat()}" ... applicationContext.contentResolver.notifyChange(uri, null) }, { }) } }
  11. 21.

    class CryptoService : Service() { companion object { var bitcoin:

    String? = null ... } override fun onBind(p0: Intent?): IBinder? = null override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int = START_NOT_STICKY.also { _ -> apiClient.getCryptoList() .doOnFinish { stopSelf() } .subscribe({ bitcoin = "ˇ${it.toNumberformat()}" applicationContext.contentResolver.notifyChange(uri, null) }, { }) } }
  12. 22.

    class CryptoService : Service() { companion object { var bitcoin:

    String? = null ... } override fun onBind(p0: Intent?): IBinder? = null override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int = START_NOT_STICKY.also { _ -> apiClient.getCryptoList() .doFinally { stopSelf() } .subscribe({ bitcoin = "ˇ${it.toNumberformat()}" ... applicationContext.contentResolver.notifyChange(uri, null) }, { }) } }
  13. 23.
  14. 25.
  15. 26.