@@ -11,7 +11,6 @@ import com.google.gson.Gson
11
11
import com.google.gson.reflect.TypeToken
12
12
import com.simplemobiletools.commons.activities.BaseSimpleActivity
13
13
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
14
- import com.simplemobiletools.commons.extensions.applyColorFilter
15
14
import com.simplemobiletools.commons.extensions.beGoneIf
16
15
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
17
16
import com.simplemobiletools.commons.extensions.isBlackAndWhiteTheme
@@ -23,9 +22,6 @@ import com.simplemobiletools.notes.pro.extensions.config
23
22
import com.simplemobiletools.notes.pro.models.ChecklistItem
24
23
import com.simplemobiletools.notes.pro.models.Note
25
24
import com.simplemobiletools.notes.pro.models.NoteType
26
- import kotlinx.android.synthetic.main.open_new_note_item.view.open_new_note_icon
27
- import kotlinx.android.synthetic.main.open_new_note_item.view.open_new_note_item_holder
28
- import kotlinx.android.synthetic.main.open_new_note_item.view.open_new_note_item_title
29
25
import kotlinx.android.synthetic.main.open_note_item.view.open_note_item_holder
30
26
import kotlinx.android.synthetic.main.open_note_item.view.open_note_item_text
31
27
import kotlinx.android.synthetic.main.open_note_item.view.open_note_item_title
@@ -34,12 +30,6 @@ class OpenNoteAdapter(
34
30
activity : BaseSimpleActivity , var items : List <Note >,
35
31
recyclerView : MyRecyclerView , itemClick : (Any ) -> Unit
36
32
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
37
- private companion object {
38
- const val NEW_NOTE_ID = - 1
39
- const val VIEW_TYPE_NOTE = 0
40
- const val VIEW_TYPE_NEW_NOTE = 1
41
- }
42
-
43
33
override fun getActionMenuId () = 0
44
34
45
35
override fun actionItemPressed (id : Int ) {}
@@ -48,50 +38,29 @@ class OpenNoteAdapter(
48
38
49
39
override fun getIsItemSelectable (position : Int ) = false
50
40
51
- override fun getItemSelectionKey (position : Int ) = items.getOrNull(position)?.id?.toInt() ? : NEW_NOTE_ID
41
+ override fun getItemSelectionKey (position : Int ) = items.getOrNull(position)?.id?.toInt()
52
42
53
- override fun getItemKeyPosition (key : Int ) = if (key == NEW_NOTE_ID ) {
54
- items.size
55
- } else {
56
- items.indexOfFirst { it.id?.toInt() == key }
57
- }
43
+ override fun getItemKeyPosition (key : Int ) = items.indexOfFirst { it.id?.toInt() == key }
58
44
59
45
override fun onActionModeCreated () {}
60
46
61
47
override fun onActionModeDestroyed () {}
62
48
63
49
override fun prepareActionMode (menu : Menu ) {}
64
50
65
- override fun getItemViewType (position : Int ): Int = if (position == items.size) {
66
- VIEW_TYPE_NEW_NOTE
67
- } else {
68
- VIEW_TYPE_NOTE
69
- }
70
-
71
51
override fun onCreateViewHolder (parent : ViewGroup , viewType : Int ): ViewHolder {
72
- val layout = if (viewType == VIEW_TYPE_NEW_NOTE ) {
73
- R .layout.open_new_note_item
74
- } else {
75
- R .layout.open_note_item
76
- }
77
- return createViewHolder(layout, parent)
52
+ return createViewHolder(R .layout.open_note_item, parent)
78
53
}
79
54
80
55
override fun onBindViewHolder (holder : ViewHolder , position : Int ) {
81
- if (position == items.size) {
82
- holder.bindView(NEW_NOTE_ID , true , false ) { itemView, layoutPosition ->
83
- setupNewNoteView(itemView)
84
- }
85
- } else {
86
- val item = items[position]
87
- holder.bindView(item, true , false ) { itemView, layoutPosition ->
88
- setupView(itemView, item)
89
- }
56
+ val item = items[position]
57
+ holder.bindView(item, true , false ) { itemView, layoutPosition ->
58
+ setupView(itemView, item)
90
59
}
91
60
bindViewHolder(holder)
92
61
}
93
62
94
- override fun getItemCount () = items.size + 1
63
+ override fun getItemCount () = items.size
95
64
96
65
private fun setupView (view : View , note : Note ) {
97
66
view.apply {
@@ -109,17 +78,6 @@ class OpenNoteAdapter(
109
78
}
110
79
}
111
80
112
- private fun setupNewNoteView (view : View ) {
113
- view.apply {
114
- setupCard(open_new_note_item_holder)
115
- open_new_note_item_title.apply {
116
- setText(R .string.create_new_note)
117
- setTextColor(properPrimaryColor)
118
- }
119
- open_new_note_icon.applyColorFilter(properPrimaryColor)
120
- }
121
- }
122
-
123
81
private fun View.setupCard (holder : View ) {
124
82
if (context.isBlackAndWhiteTheme()) {
125
83
holder.setBackgroundResource(R .drawable.black_dialog_background)
0 commit comments