1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-11-24 05:26:11 -06:00

Change marking current student in accounts dialog (#486)

This commit is contained in:
Rafał Borcz 2019-09-04 21:19:05 +02:00 committed by Mikołaj Pich
parent c3bb489851
commit 4e0f41dcb2
3 changed files with 18 additions and 11 deletions

View File

@ -1,13 +1,16 @@
package io.github.wulkanowy.ui.modules.account package io.github.wulkanowy.ui.modules.account
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.graphics.PorterDuff
import android.view.View import android.view.View
import androidx.core.graphics.ColorUtils
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
import eu.davidea.flexibleadapter.items.IFlexible import eu.davidea.flexibleadapter.items.IFlexible
import eu.davidea.viewholders.FlexibleViewHolder import eu.davidea.viewholders.FlexibleViewHolder
import io.github.wulkanowy.R import io.github.wulkanowy.R
import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.data.db.entities.Student
import io.github.wulkanowy.utils.getThemeAttrColor
import kotlinx.android.extensions.LayoutContainer import kotlinx.android.extensions.LayoutContainer
import kotlinx.android.synthetic.main.item_account.* import kotlinx.android.synthetic.main.item_account.*
@ -15,16 +18,19 @@ class AccountItem(val student: Student) : AbstractFlexibleItem<AccountItem.ViewH
override fun getLayoutRes() = R.layout.item_account override fun getLayoutRes() = R.layout.item_account
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<*>>): ViewHolder { override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<*>>) = ViewHolder(view, adapter)
return ViewHolder(view, adapter)
}
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<*>>, holder: ViewHolder, position: Int, payloads: MutableList<Any>?) { override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<*>>, holder: ViewHolder, position: Int, payloads: MutableList<Any>?) {
holder.apply { val context = holder.contentView.context
val colorImage = if (student.isCurrent) context.getThemeAttrColor(R.attr.colorPrimary)
else ColorUtils.setAlphaComponent(context.getThemeAttrColor(R.attr.colorOnSurface), 153)
with(holder) {
accountItemName.text = "${student.studentName} ${student.className}" accountItemName.text = "${student.studentName} ${student.className}"
accountItemSchool.text = student.schoolName accountItemSchool.text = student.schoolName
accountItemImage.setBackgroundResource(if (student.isCurrent) R.drawable.ic_account_circular_border else 0) accountItemImage.setColorFilter(colorImage, PorterDuff.Mode.SRC_IN)
} }
} }
@ -45,8 +51,9 @@ class AccountItem(val student: Student) : AbstractFlexibleItem<AccountItem.ViewH
return result return result
} }
class ViewHolder(view: View, adapter: FlexibleAdapter<*>) : FlexibleViewHolder(view, adapter), LayoutContainer { class ViewHolder(view: View, adapter: FlexibleAdapter<*>) : FlexibleViewHolder(view, adapter),
override val containerView: View LayoutContainer {
get() = contentView
override val containerView: View? get() = contentView
} }
} }

View File

@ -17,10 +17,9 @@
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:background="@drawable/ic_account_circular_border"
app:srcCompat="@drawable/ic_all_account" app:srcCompat="@drawable/ic_all_account"
app:tint="#7E7E7E" tools:ignore="ContentDescription"
tools:ignore="ContentDescription" /> tools:tint="@color/colorPrimary" />
<TextView <TextView
android:id="@+id/accountItemName" android:id="@+id/accountItemName"

View File

@ -8,6 +8,7 @@
<item name="android:windowBackground">?colorSurface</item> <item name="android:windowBackground">?colorSurface</item>
<item name="android:textColor">?android:textColorPrimary</item> <item name="android:textColor">?android:textColorPrimary</item>
<item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/black</item> <item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/black</item>
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">false</item>
</style> </style>
<style name="WulkanowyTheme.Black" parent="WulkanowyTheme.NoActionBar"> <style name="WulkanowyTheme.Black" parent="WulkanowyTheme.NoActionBar">