pull/32/head
kunfei 5 years ago
parent 56d3acb6a0
commit 13a5a7747d
  1. 37
      app/src/main/java/io/legado/app/ui/readbook/config/BgTextConfigDialog.kt

@ -16,8 +16,9 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.jaredrummler.android.colorpicker.ColorPickerDialog import com.jaredrummler.android.colorpicker.ColorPickerDialog
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.adapter.CommonRecyclerAdapter
import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.help.ImageLoader
import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadBookConfig
import io.legado.app.help.permission.Permissions import io.legado.app.help.permission.Permissions
import io.legado.app.help.permission.PermissionsCompat import io.legado.app.help.permission.PermissionsCompat
@ -34,7 +35,7 @@ class BgTextConfigDialog : DialogFragment() {
const val BG_COLOR = 122 const val BG_COLOR = 122
} }
private val ResultSelectBg = 123 private val resultSelectBg = 123
private lateinit var adapter: BgAdapter private lateinit var adapter: BgAdapter
override fun onCreateView( override fun onCreateView(
@ -124,29 +125,31 @@ class BgTextConfigDialog : DialogFragment() {
val intent = Intent(Intent.ACTION_GET_CONTENT) val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.addCategory(Intent.CATEGORY_OPENABLE) intent.addCategory(Intent.CATEGORY_OPENABLE)
intent.type = "image/*" intent.type = "image/*"
startActivityForResult(intent, ResultSelectBg) startActivityForResult(intent, resultSelectBg)
Unit Unit
} }
.request() .request()
} }
class BgAdapter(context: Context) : class BgAdapter(context: Context) :
CommonRecyclerAdapter<String>(context) { SimpleRecyclerAdapter<String>(context, R.layout.item_bg_image) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { override fun convert(holder: ItemViewHolder, item: String, payloads: MutableList<Any>) {
return super.onCreateViewHolder(parent, viewType) with(holder.itemView) {
ImageLoader.load(context, context.assets.open("bg/$item").readBytes())
.centerCrop()
.setAsBitmap(iv_bg)
tv_name.text = item.substring(0, item.lastIndexOf("."))
}
} }
// override fun convert(holder: ItemViewHolder, item: String, payloads: MutableList<Any>) {
// with(holder.itemView) {
// ImageLoader.load(context, context.assets.open("bg/$item").readBytes())
// .centerCrop()
// .setAsBitmap(iv_bg)
// tv_name.text = item.substring(0, item.lastIndexOf("."))
// }
// }
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
when (requestCode) {
resultSelectBg -> {
}
}
}
} }
Loading…
Cancel
Save