Use FlexLayoutManager for themes

This commit is contained in:
Moez Bhatti
2017-12-13 19:48:50 -05:00
parent 552b901e60
commit 0689cbbe58
2 changed files with 20 additions and 9 deletions
@@ -3,13 +3,15 @@ package com.moez.QKSMS.presentation.settings
import android.app.AlertDialog
import android.app.ProgressDialog
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import com.google.android.flexbox.FlexboxLayoutManager
import com.jakewharton.rxbinding2.view.clicks
import com.moez.QKSMS.R
import com.moez.QKSMS.common.di.appComponent
import com.moez.QKSMS.common.util.extensions.dpToPx
import com.moez.QKSMS.presentation.common.base.QkActivity
import com.moez.QKSMS.presentation.common.widget.PreferenceView
import io.reactivex.Observable
import io.reactivex.rxkotlin.plusAssign
import io.reactivex.subjects.PublishSubject
import io.reactivex.subjects.Subject
@@ -20,10 +22,10 @@ class SettingsActivity : QkActivity<SettingsViewModel>(), SettingsView {
override val viewModelClass = SettingsViewModel::class
override val preferenceClickIntent: Subject<PreferenceView> = PublishSubject.create()
override val themeSelectedIntent by lazy { themeAdapter.colorSelected }
override val themeSelectedIntent: Observable<Int> by lazy { themeAdapter.colorSelected }
// TODO remove this
private val progressDialog by lazy {
// TODO remove this
ProgressDialog(this).apply {
isIndeterminate = true
setCancelable(false)
@@ -41,14 +43,21 @@ class SettingsActivity : QkActivity<SettingsViewModel>(), SettingsView {
private val themeRecyclerView by lazy {
RecyclerView(this).apply {
layoutManager = LinearLayoutManager(this@SettingsActivity, LinearLayoutManager.HORIZONTAL, false)
val padding = 8.dpToPx(context)
setPadding(padding, padding, padding, padding)
adapter = themeAdapter
clipToPadding = false
clipChildren = false
layoutManager = FlexboxLayoutManager(this@SettingsActivity)
}
}
private val themeAdapter by lazy {
ThemeAdapter(this@SettingsActivity).apply {
data = listOf(0xFF008389, 0xFF04CBC9, 0xFF00D99B, 0xFF00A3F3, 0xFFF8BBD0).map { it.toInt() }
data = listOf(
-0x1f0d0f, -0x4d2025, -0x7f343c, -0xb24954,
-0xd95966, -0xff6978, -0xff7685, -0xff8695,
-0xff96a4, -0xffb2c0)
}
}
@@ -1,13 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="56dp"
android:layout_height="56dp">
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<View
android:id="@+id/theme"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="center"
android:layout_margin="8dp"
android:background="@drawable/circle"
tools:backgroundTint="@color/tools_theme" />