pull/23/head
fengyuecanzhu 3 years ago
parent 56ffb9ce9c
commit ac4bdde1b9
  1. 43
      app/src/main/java/xyz/fycz/myreader/ui/activity/SearchBookActivity.java
  2. 31
      app/src/main/java/xyz/fycz/myreader/ui/adapter/SearchAdapter.kt
  3. 3
      build.gradle

@ -156,6 +156,25 @@ public class SearchBookActivity extends BaseActivity<ActivitySearchBookBinding>
} }
} }
@Override
protected void onStop() {
if (mSearchBookAdapter != null) {
mSearchBookAdapter.setStop(true);
}
super.onStop();
}
@Override
protected void onStart() {
super.onStart();
if (mSearchBookAdapter != null) {
mSearchBookAdapter.setStop(false);
if (showBooks) {
mSearchBookAdapter.addAll(new ArrayList<>(), searchKey);
}
}
}
@Override @Override
protected void initData(Bundle savedInstanceState) { protected void initData(Bundle savedInstanceState) {
super.initData(savedInstanceState); super.initData(savedInstanceState);
@ -757,28 +776,8 @@ public class SearchBookActivity extends BaseActivity<ActivitySearchBookBinding>
/*for (ReadCrawler readCrawler : readCrawlers) { /*for (ReadCrawler readCrawler : readCrawlers) {
searchBookByCrawler(readCrawler, readCrawler.getSearchCharset()); searchBookByCrawler(readCrawler, readCrawler.getSearchCharset());
}*/ }*/
if (readCrawlers.size() > 2000 && !SharedPreUtils.getInstance().getBoolean("searchBookWarning")) { searchEngine.initSearchEngine(readCrawlers);
DialogCreator.createThreeButtonDialog(this, "书源过多警告", searchEngine.search(searchKey);
"当前搜索书源数量超过2000(建议1000以内),继续搜索可能会导致软件异常(如搜索时前往阅读页返回后将会导致卡死黑屏),确定要继续搜索吗?",
true, "继续搜索并不再提示", "书源管理", "继续搜索",
(dialog, which) -> {
SharedPreUtils.getInstance().putBoolean("searchBookWarning", true);
searchEngine.initSearchEngine(readCrawlers);
searchEngine.search(searchKey);
}, (dialog, which) -> {
startActivityForResult(new Intent(this, BookSourceActivity.class),
APPCONST.REQUEST_BOOK_SOURCE);
},
(dialog, which) -> {
searchEngine.initSearchEngine(readCrawlers);
searchEngine.search(searchKey);
}
);
} else {
searchEngine.initSearchEngine(readCrawlers);
searchEngine.search(searchKey);
}
} }
/** /**

@ -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()
} }
} }

@ -28,6 +28,7 @@ buildscript {
maven { url 'https://s3.amazonaws.com/fabric-artifacts/public' } maven { url 'https://s3.amazonaws.com/fabric-artifacts/public' }
maven { url 'https://plugins.gradle.org/m2/' } maven { url 'https://plugins.gradle.org/m2/' }
maven { url "https://maven.java.net/content/groups/public/" } maven { url "https://maven.java.net/content/groups/public/" }
maven { url 'https://jitpack.io' }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.1.3' classpath 'com.android.tools.build:gradle:4.1.3'
@ -38,6 +39,8 @@ buildscript {
classpath 'com.github.megatronking.stringfog:gradle-plugin:3.0.0' classpath 'com.github.megatronking.stringfog:gradle-plugin:3.0.0'
// xor算法使 // xor算法使
classpath 'com.github.megatronking.stringfog:xor:3.0.0' classpath 'com.github.megatronking.stringfog:xor:3.0.0'
classpath "com.github.CodingGay:BlackObfuscator-ASPlugin:3.7"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
} }

Loading…
Cancel
Save