|
|
|
@ -1,18 +1,20 @@
|
|
|
|
|
package com.todoroo.astrid.adapter
|
|
|
|
|
|
|
|
|
|
import android.app.Activity
|
|
|
|
|
import android.content.Intent
|
|
|
|
|
import android.view.View
|
|
|
|
|
import android.widget.ImageView
|
|
|
|
|
import android.widget.TextView
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
|
|
import butterknife.BindView
|
|
|
|
|
import butterknife.ButterKnife
|
|
|
|
|
import butterknife.OnClick
|
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
|
import org.tasks.LocalBroadcastManager
|
|
|
|
|
import org.tasks.R
|
|
|
|
|
import org.tasks.data.CaldavDaoBlocking
|
|
|
|
|
import org.tasks.data.GoogleTaskDaoBlocking
|
|
|
|
|
import org.tasks.data.CaldavDao
|
|
|
|
|
import org.tasks.data.GoogleTaskDao
|
|
|
|
|
import org.tasks.filters.NavigationDrawerSubheader
|
|
|
|
|
import org.tasks.filters.NavigationDrawerSubheader.SubheaderType
|
|
|
|
|
import org.tasks.preferences.Preferences
|
|
|
|
@ -21,10 +23,10 @@ import org.tasks.themes.DrawableUtil
|
|
|
|
|
|
|
|
|
|
internal class SubheaderViewHolder(
|
|
|
|
|
itemView: View,
|
|
|
|
|
activity: Activity,
|
|
|
|
|
private val activity: AppCompatActivity,
|
|
|
|
|
private val preferences: Preferences,
|
|
|
|
|
private val googleTaskDao: GoogleTaskDaoBlocking,
|
|
|
|
|
private val caldavDao: CaldavDaoBlocking,
|
|
|
|
|
private val googleTaskDao: GoogleTaskDao,
|
|
|
|
|
private val caldavDao: CaldavDao,
|
|
|
|
|
private val localBroadcastManager: LocalBroadcastManager)
|
|
|
|
|
: RecyclerView.ViewHolder(itemView) {
|
|
|
|
|
|
|
|
|
@ -38,13 +40,15 @@ internal class SubheaderViewHolder(
|
|
|
|
|
|
|
|
|
|
@OnClick(R.id.subheader_row)
|
|
|
|
|
fun onClick() {
|
|
|
|
|
val collapsed = !subheader.isCollapsed
|
|
|
|
|
when (subheader.subheaderType) {
|
|
|
|
|
SubheaderType.PREFERENCE -> preferences.setBoolean(subheader.id.toInt(), collapsed)
|
|
|
|
|
SubheaderType.GOOGLE_TASKS -> googleTaskDao.setCollapsed(subheader.id, collapsed)
|
|
|
|
|
SubheaderType.CALDAV -> caldavDao.setCollapsed(subheader.id, collapsed)
|
|
|
|
|
activity.lifecycleScope.launch {
|
|
|
|
|
val collapsed = !subheader.isCollapsed
|
|
|
|
|
when (subheader.subheaderType) {
|
|
|
|
|
SubheaderType.PREFERENCE -> preferences.setBoolean(subheader.id.toInt(), collapsed)
|
|
|
|
|
SubheaderType.GOOGLE_TASKS -> googleTaskDao.setCollapsed(subheader.id, collapsed)
|
|
|
|
|
SubheaderType.CALDAV -> caldavDao.setCollapsed(subheader.id, collapsed)
|
|
|
|
|
}
|
|
|
|
|
localBroadcastManager.broadcastRefreshList()
|
|
|
|
|
}
|
|
|
|
|
localBroadcastManager.broadcastRefreshList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun bind(subheader: NavigationDrawerSubheader) {
|
|
|
|
|