Fix detected issues

This commit is contained in:
Benoit Marty 2022-02-17 21:25:09 +01:00 committed by Benoit Marty
parent 133d1972a3
commit 26edf79aa2
1 changed files with 2 additions and 3 deletions

View File

@ -18,11 +18,11 @@ package org.billcarsonfr.jsonviewer
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.view.ContextMenu
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.getSystemService
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyHolder
import com.airbnb.epoxy.EpoxyModelClass
@ -77,8 +77,7 @@ internal abstract class ValueItem : EpoxyModelWithHolder<ValueItem.Holder>() {
) {
if (copyValue != null) {
val menuItem = menu?.add(R.string.copy_value)
val clipService =
v?.context?.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
val clipService = v?.context?.getSystemService<ClipboardManager>()
menuItem?.setOnMenuItemClickListener {
clipService?.setPrimaryClip(ClipData.newPlainText("", copyValue))
true