adding a FAB at the checklist fragment

This commit is contained in:
tibbi 2018-12-07 23:08:26 +01:00
parent 22be4e4ac4
commit c0acb525ad
2 changed files with 35 additions and 7 deletions

View File

@ -1,13 +1,19 @@
package com.simplemobiletools.notes.pro.fragments
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
import com.simplemobiletools.commons.extensions.isBlackAndWhiteTheme
import com.simplemobiletools.notes.pro.R
import com.simplemobiletools.notes.pro.helpers.NOTE_ID
import com.simplemobiletools.notes.pro.helpers.NotesHelper
import com.simplemobiletools.notes.pro.models.Note
import kotlinx.android.synthetic.main.fragment_checklist.view.*
class ChecklistFragment : NoteFragment() {
private var noteId = 0L
@ -25,7 +31,7 @@ class ChecklistFragment : NoteFragment() {
super.onResume()
NotesHelper(activity!!).getNoteWithId(noteId) {
if (it != null) {
if (it != null && activity?.isDestroyed == false) {
note = it
setupFragment()
}
@ -33,6 +39,13 @@ class ChecklistFragment : NoteFragment() {
}
private fun setupFragment() {
val plusIcon = resources.getColoredDrawableWithColor(R.drawable.ic_plus, if (context!!.isBlackAndWhiteTheme()) Color.BLACK else Color.WHITE)
view.checklist_fab.apply {
setImageDrawable(plusIcon)
background.applyColorFilter(context!!.getAdjustedPrimaryColor())
setOnClickListener {
}
}
}
}

View File

@ -1,10 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<com.simplemobiletools.commons.views.MyRecyclerView
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/checklist"
android:id="@+id/checklist_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:overScrollMode="never"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager"/>
android:layout_height="match_parent">
<com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/checklist_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:overScrollMode="never"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager"/>
<com.simplemobiletools.commons.views.MyFloatingActionButton
android:id="@+id/checklist_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/activity_margin"
android:src="@drawable/ic_plus"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>