|
|
|
@ -5,6 +5,7 @@ import android.util.SparseArray |
|
|
|
|
import android.view.LayoutInflater |
|
|
|
|
import android.view.View |
|
|
|
|
import android.view.ViewGroup |
|
|
|
|
import androidx.recyclerview.widget.DiffUtil |
|
|
|
|
import androidx.recyclerview.widget.GridLayoutManager |
|
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
|
import java.util.* |
|
|
|
@ -122,7 +123,7 @@ abstract class CommonRecyclerAdapter<ITEM>(protected val context: Context) : Rec |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun setItems(items: List<ITEM>?, notify: Boolean = true) { |
|
|
|
|
fun setItems(items: List<ITEM>?) { |
|
|
|
|
synchronized(lock) { |
|
|
|
|
if (this.items.isNotEmpty()) { |
|
|
|
|
this.items.clear() |
|
|
|
@ -130,9 +131,19 @@ abstract class CommonRecyclerAdapter<ITEM>(protected val context: Context) : Rec |
|
|
|
|
if (items != null) { |
|
|
|
|
this.items.addAll(items) |
|
|
|
|
} |
|
|
|
|
if (notify) { |
|
|
|
|
notifyDataSetChanged() |
|
|
|
|
notifyDataSetChanged() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun setItems(items: List<ITEM>?, diffResult: DiffUtil.DiffResult) { |
|
|
|
|
synchronized(lock) { |
|
|
|
|
if (this.items.isNotEmpty()) { |
|
|
|
|
this.items.clear() |
|
|
|
|
} |
|
|
|
|
if (items != null) { |
|
|
|
|
this.items.addAll(items) |
|
|
|
|
} |
|
|
|
|
diffResult.dispatchUpdatesTo(this) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|