|
|
@ -52,11 +52,12 @@ class SearchAdapter( |
|
|
|
val keyword: String |
|
|
|
val keyword: String |
|
|
|
) : DiffRecyclerAdapter<SearchBookBean, ItemSearchBookBinding>(context) { |
|
|
|
) : DiffRecyclerAdapter<SearchBookBean, ItemSearchBookBinding>(context) { |
|
|
|
private val mBooks: ConMVMap<SearchBookBean, Book> = ConMVMap() |
|
|
|
private val mBooks: ConMVMap<SearchBookBean, Book> = ConMVMap() |
|
|
|
private lateinit var mList: List<SearchBookBean> |
|
|
|
private var mList: MutableList<SearchBookBean> = ArrayList() |
|
|
|
private val tagList: MutableList<String> = ArrayList() |
|
|
|
private val tagList: MutableList<String> = ArrayList() |
|
|
|
private val handler = Handler(Looper.getMainLooper()) |
|
|
|
private val handler = Handler(Looper.getMainLooper()) |
|
|
|
private var postTime = 0L |
|
|
|
private var postTime = 0L |
|
|
|
private val sendRunnable = Runnable { upAdapter() } |
|
|
|
private val sendRunnable = Runnable { upAdapter() } |
|
|
|
|
|
|
|
var isStop = false |
|
|
|
|
|
|
|
|
|
|
|
override val diffItemCallback: DiffUtil.ItemCallback<SearchBookBean> |
|
|
|
override val diffItemCallback: DiffUtil.ItemCallback<SearchBookBean> |
|
|
|
get() = object : DiffUtil.ItemCallback<SearchBookBean>() { |
|
|
|
get() = object : DiffUtil.ItemCallback<SearchBookBean>() { |
|
|
@ -300,7 +301,7 @@ class SearchAdapter( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun addAll(newDataS: List<SearchBookBean>, keyWord: String?) { |
|
|
|
fun addAll(newDataS: List<SearchBookBean>, keyWord: String?) { |
|
|
|
val copyDataS: MutableList<SearchBookBean> = ArrayList(getItems()) |
|
|
|
val copyData: MutableList<SearchBookBean> = ArrayList(mList) |
|
|
|
val filterDataS: MutableList<SearchBookBean> = ArrayList() |
|
|
|
val filterDataS: MutableList<SearchBookBean> = ArrayList() |
|
|
|
when (SysManager.getSetting().searchFilter) { |
|
|
|
when (SysManager.getSetting().searchFilter) { |
|
|
|
0 -> filterDataS.addAll(newDataS) |
|
|
|
0 -> filterDataS.addAll(newDataS) |
|
|
@ -328,16 +329,16 @@ class SearchAdapter( |
|
|
|
} |
|
|
|
} |
|
|
|
if (filterDataS.size > 0) { |
|
|
|
if (filterDataS.size > 0) { |
|
|
|
val searchBookBeansAdd: MutableList<SearchBookBean> = ArrayList() |
|
|
|
val searchBookBeansAdd: MutableList<SearchBookBean> = ArrayList() |
|
|
|
if (copyDataS.size == 0) { |
|
|
|
if (mList.size == 0) { |
|
|
|
copyDataS.addAll(filterDataS) |
|
|
|
mList.addAll(filterDataS) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
//存在 |
|
|
|
//存在 |
|
|
|
for (temp in filterDataS) { |
|
|
|
for (temp in filterDataS) { |
|
|
|
var hasSame = false |
|
|
|
var hasSame = false |
|
|
|
var i = 0 |
|
|
|
var i = 0 |
|
|
|
val size = copyDataS.size |
|
|
|
val size = copyData.size |
|
|
|
while (i < size) { |
|
|
|
while (i < size) { |
|
|
|
val searchBook = copyDataS[i] |
|
|
|
val searchBook = copyData[i] |
|
|
|
if (TextUtils.equals(temp.name, searchBook.name) |
|
|
|
if (TextUtils.equals(temp.name, searchBook.name) |
|
|
|
&& TextUtils.equals(temp.author, searchBook.author) |
|
|
|
&& TextUtils.equals(temp.author, searchBook.author) |
|
|
|
) { |
|
|
|
) { |
|
|
@ -353,30 +354,30 @@ class SearchAdapter( |
|
|
|
//添加 |
|
|
|
//添加 |
|
|
|
for (temp in searchBookBeansAdd) { |
|
|
|
for (temp in searchBookBeansAdd) { |
|
|
|
if (TextUtils.equals(keyWord, temp.name)) { |
|
|
|
if (TextUtils.equals(keyWord, temp.name)) { |
|
|
|
for (i in copyDataS.indices) { |
|
|
|
for (i in copyData.indices) { |
|
|
|
val searchBook = copyDataS[i] |
|
|
|
val searchBook = copyData[i] |
|
|
|
if (!TextUtils.equals(keyWord, searchBook.name)) { |
|
|
|
if (!TextUtils.equals(keyWord, searchBook.name)) { |
|
|
|
copyDataS.add(i, temp) |
|
|
|
mList.add(i, temp) |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (TextUtils.equals(keyWord, temp.author)) { |
|
|
|
} else if (TextUtils.equals(keyWord, temp.author)) { |
|
|
|
for (i in copyDataS.indices) { |
|
|
|
for (i in copyData.indices) { |
|
|
|
val searchBook = copyDataS[i] |
|
|
|
val searchBook = copyData[i] |
|
|
|
if (!TextUtils.equals(keyWord, searchBook.name) && |
|
|
|
if (!TextUtils.equals(keyWord, searchBook.name) && |
|
|
|
!TextUtils.equals(keyWord, searchBook.author) |
|
|
|
!TextUtils.equals(keyWord, searchBook.author) |
|
|
|
) { |
|
|
|
) { |
|
|
|
copyDataS.add(i, temp) |
|
|
|
mList.add(i, temp) |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
copyDataS.add(temp) |
|
|
|
mList.add(temp) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
mList = copyDataS |
|
|
|
if (!isStop) |
|
|
|
upAdapter() |
|
|
|
upAdapter() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|