修复部分bug

pull/5/head
fengyuecanzhu 4 years ago
parent f17c8e1406
commit 08b2194769
  1. 8
      app/src/main/assets/updatelog.fy
  2. 4
      app/src/main/java/xyz/fycz/myreader/common/APPCONST.java
  3. 2
      app/src/main/java/xyz/fycz/myreader/custom/DragSortGridView.java
  4. 9
      app/src/main/java/xyz/fycz/myreader/entity/SearchBookBean.java
  5. 3
      app/src/main/java/xyz/fycz/myreader/ui/home/bookcase/BookcasePresenter.java
  6. 1
      app/src/main/java/xyz/fycz/myreader/ui/read/ReadPresenter.java
  7. 15
      app/src/main/java/xyz/fycz/myreader/ui/search/SearchBookActivity.java
  8. 57
      app/src/main/java/xyz/fycz/myreader/ui/search/SearchBookAdapter.java
  9. 72
      app/src/main/java/xyz/fycz/myreader/ui/search/SearchBookPrensenter.java
  10. 14
      app/src/main/res/layout/activity_search_book.xml
  11. 3
      app/src/main/res/layout/fragment_bookcase.xml
  12. 1
      app/src/main/res/layout/listview_search_book_item.xml
  13. 2
      app/version_code.properties

@ -1,11 +1,17 @@
2020.08.07
风月读书v1.20.080709
1、修复搜索书籍滑动混乱的问题
2、优化搜索书籍滑动显示
2020.07.31
风月读书v1.20.073114
风月读书v1.20.073120
1、新增书架同步功能(需要注册登录)
2、新增每日自动同步书架功能(默认关闭)
3、新增书籍一键缓存功能(实验功能,存在bug)
4、新增关于界面(检查更新、免责声明移至此界面)
5、修复正在自动翻页退出阅读时闪退的问题
6、修复软件\字体下载api
7、修复翻页切换章节时保存出错的问题
2020.07.25
风月读书v1.20.072519

@ -10,10 +10,10 @@ import java.io.File;
public class APPCONST {
public static String publicKey = "";//服务端公钥
public static String publicKey = "fyds1.0";//服务端公钥
public static String privateKey;//app私钥
public final static String s = "11940364935628058505";
public static final String KEY = "";
public static final String KEY = "readerByFengyue";
public static final String ALARM_SCHEDULE_MSG = "alarm_schedule_msg";

@ -522,9 +522,11 @@ public class DragSortGridView extends FrameLayout {
}
this.adapter = adapter;
mGridView.setAdapter(adapter);
if (adapter != null) {
adapter.registerDataSetObserver(observer);
mChildCount = adapter.getCount();
}
}
public int getNumColumns() {
return mNumColumns;

@ -9,6 +9,7 @@ import java.util.Objects;
public class SearchBookBean {
private String name;//书名
private String author;//作者
private int sourceCount;//书源数量
public SearchBookBean() {
}
@ -34,6 +35,14 @@ public class SearchBookBean {
this.author = author;
}
public int getSourceCount() {
return sourceCount;
}
public void setSourceCount(int sourceCount) {
this.sourceCount = sourceCount;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;

@ -804,8 +804,11 @@ public class BookcasePresenter implements BasePresenter {
* @return
*/
public boolean ismEditState() {
if (mBookcaseAdapter != null) {
return mBookcaseAdapter.ismEditState();
}
return false;
}
/**
* 取消编辑状态

@ -560,6 +560,7 @@ public class ReadPresenter implements BasePresenter {
preLoad(pos - 1 + i);
}
mBook.setHistoryChapterId(mChapters.get(pos).getTitle());
mHandler.sendMessage(mHandler.obtainMessage(4));
MyApplication.getApplication().newThread(() -> {
if (mPageLoader.getPageStatus() == PageLoader.STATUS_LOADING) {
if (!NetworkUtils.isNetWorkAvailable()) {

@ -13,6 +13,7 @@ import xyz.fycz.myreader.base.BaseActivity;
import butterknife.ButterKnife;
import butterknife.BindView;
import me.gujun.android.taggroup.TagGroup;
import xyz.fycz.myreader.custom.DragSortGridView;
public class SearchBookActivity extends BaseActivity {
@ -29,8 +30,10 @@ public class SearchBookActivity extends BaseActivity {
@BindView(R.id.ll_refresh_suggest_books)
LinearLayout llRefreshSuggestBooks;
@BindView(R.id.lv_search_books_list)
ListView lvSearchBooksList;
/*@BindView(R.id.lv_search_books_list)
ListView lvSearchBooksList;*/
@BindView(R.id.gv_search_books_list)
DragSortGridView gvSearchBooksList;
@BindView(R.id.ll_suggest_books_view)
LinearLayout llSuggestBooksView;
@BindView(R.id.pb_loading)
@ -98,8 +101,12 @@ public class SearchBookActivity extends BaseActivity {
return llRefreshSuggestBooks;
}
public ListView getLvSearchBooksList() {
return lvSearchBooksList;
// public ListView getLvSearchBooksList() {
// return lvSearchBooksList;
// }
public DragSortGridView getGvSearchBooksList() {
return gvSearchBooksList;
}
public LinearLayout getLlSuggestBooksView() {

@ -20,6 +20,7 @@ import xyz.fycz.myreader.callback.ResultCallback;
import xyz.fycz.myreader.crawler.BookInfoCrawler;
import xyz.fycz.myreader.crawler.ReadCrawler;
import xyz.fycz.myreader.crawler.ReadCrawlerUtil;
import xyz.fycz.myreader.custom.DragAdapter;
import xyz.fycz.myreader.entity.SearchBookBean;
import xyz.fycz.myreader.enums.BookSource;
import xyz.fycz.myreader.greendao.entity.Book;
@ -37,17 +38,21 @@ import java.util.Map;
* Created by zhao on 2017/7/26.
*/
public class SearchBookAdapter extends ArrayAdapter<SearchBookBean> {
public class SearchBookAdapter extends DragAdapter {
private int mResourceId;
private Context mContext;
private ConcurrentMultiValueMap<SearchBookBean, Book> mBooks;
private ArrayList<SearchBookBean> mTempBooks = new ArrayList<>();
private ArrayList<SearchBookBean> mSearchBookBeans;
private Handler mHandle = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
private ArrayList<SearchBookBean> mTempSearchBookBeans = new ArrayList<>();
private HashMap<SearchBookBean, Book> mTempBooks = new HashMap<>();
private Handler mHandle = new Handler(message -> {
switch (message.what) {
case 1:
@ -57,22 +62,38 @@ public class SearchBookAdapter extends ArrayAdapter<SearchBookBean> {
break;
}
return false;
}
});
public SearchBookAdapter(Context context, int resourceId, ArrayList<SearchBookBean> datas,
ConcurrentMultiValueMap<SearchBookBean, Book> mBooks){
super(context, resourceId, datas);
mContext = context;
mSearchBookBeans = datas;
mResourceId = resourceId;
this.mBooks = mBooks;
}
@Override
public int getCount() {
return mSearchBookBeans.size();
}
@Override
public SearchBookBean getItem(int position) {
return mSearchBookBeans.get(position);
}
@Override
public long getItemId(int position) {
return 0;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
ViewHolder viewHolder = null;
if (convertView == null){
viewHolder = new ViewHolder();
convertView = LayoutInflater.from(getContext()).inflate(mResourceId,null);
convertView = LayoutInflater.from(mContext).inflate(mResourceId,null);
viewHolder.ivBookImg = convertView.findViewById(R.id.iv_book_img);
viewHolder.tvBookName = convertView.findViewById(R.id.tv_book_name);
viewHolder.tvAuthor = convertView.findViewById(R.id.tv_book_author);
@ -92,17 +113,15 @@ public class SearchBookAdapter extends ArrayAdapter<SearchBookBean> {
private void initView(final int position, final ViewHolder viewHolder){
List<Book> aBooks = mBooks.getValues(getItem(position));
int bookCount = aBooks.size();
final Book book = aBooks.get(0);
Book book = aBooks.get(0);
SearchBookBean ssb = new SearchBookBean(book.getName(), book.getAuthor());
//判断是否已经加载,防止多次加载
for (SearchBookBean temp : mTempBooks){//已加载
/*for (SearchBookBean temp : mTempSearchBookBeans){//已加载
if (ssb.equals(temp)){
viewHolder.tvSource.setText("书源:" + BookSource.fromString(book.getSource()).text
+ " 共" + bookCount + "个源");
return;
}
book = mTempBooks.get(ssb);
}
}*/
if (StringHelper.isEmpty(book.getImgUrl())){
book.setImgUrl("");
@ -133,12 +152,13 @@ public class SearchBookAdapter extends ArrayAdapter<SearchBookBean> {
}
//viewHolder.tvNewestChapter.setText(book.getNewestChapterTitle());
//添加已经加载的书籍
mTempBooks.add(ssb);
/*mTempSearchBookBeans.add(ssb);
mTempBooks.put(ssb, book);*/
}
private void initOtherInfo(final int position, final ViewHolder holder){
Book book = mBooks.getValue(getItem(position), 0);
//图片
Glide.with(getContext())
Glide.with(mContext)
.load(book.getImgUrl())
// .override(DipPxUtil.dip2px(getContext(), 80), DipPxUtil.dip2px(getContext(), 150))
.error(R.mipmap.no_image)
@ -151,6 +171,11 @@ public class SearchBookAdapter extends ArrayAdapter<SearchBookBean> {
holder.tvType.setText(book.getType());
}
@Override
public void onDataModelMove(int from, int to) {
}
class ViewHolder{
ImageView ivBookImg;
TextView tvBookName;

@ -3,6 +3,7 @@ package xyz.fycz.myreader.ui.search;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
@ -49,6 +50,7 @@ public class SearchBookPrensenter implements BasePresenter {
private String searchKey;//搜索关键字
private ArrayList<SearchBookBean> mBooksBean = new ArrayList<>();
private ConcurrentMultiValueMap<SearchBookBean, Book> mBooks = new ConcurrentMultiValueMap<>();
private ArrayList<Book> mAdapterBooks = new ArrayList<>();
private ArrayList<SearchHistory> mSearchHistories = new ArrayList<>();
private ArrayList<String> mSuggestions = new ArrayList<>();
@ -56,7 +58,6 @@ public class SearchBookPrensenter implements BasePresenter {
private SearchHistoryAdapter mSearchHistoryAdapter;
private int curThreadCount;
private int allThreadCount;
@ -102,15 +103,12 @@ public class SearchBookPrensenter implements BasePresenter {
mSearchBookActivity.getTvTitleText().setText("搜索");
mSearchBookActivity.etSearchKey.requestFocus();//get the focus
//enter事件
mSearchBookActivity.getEtSearchKey().setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
mSearchBookActivity.getEtSearchKey().setOnEditorActionListener((textView, i, keyEvent) -> {
if (i == EditorInfo.IME_ACTION_UNSPECIFIED) {
mHandler.sendMessage(mHandler.obtainMessage(1));
return (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER);
}
return false;
}
});
//换一批点击事件
mSearchBookActivity.getRenewByImage().setOnClickListener(new RenewSuggestionBook());
@ -142,66 +140,43 @@ public class SearchBookPrensenter implements BasePresenter {
});
//进入书籍详情页
mSearchBookActivity.getLvSearchBooksList().setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
mSearchBookActivity.getGvSearchBooksList().setOnItemClickListener((adapterView, view, i, l) -> {
Intent intent = new Intent(mSearchBookActivity, BookInfoActivity.class);
intent.putExtra(APPCONST.SEARCH_BOOK_BEAN, new ArrayList<>(mBooks.getValues(mBooksBean.get(i))));
mSearchBookActivity.startActivity(intent);
}
});
//搜索按钮点击事件
mSearchBookActivity.getTvSearchConform().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mHandler.sendMessage(mHandler.obtainMessage(1));
}
});
mSearchBookActivity.getTvSearchConform().setOnClickListener(view -> mHandler.sendMessage(mHandler.obtainMessage(1)));
//suggestion搜索事件
mSearchBookActivity.getTgSuggestBook().setOnTagClickListener(new TagGroup.OnTagClickListener() {
@Override
public void onTagClick(String tag) {
mSearchBookActivity.getTgSuggestBook().setOnTagClickListener(tag -> {
mSearchBookActivity.getEtSearchKey().setText(tag);
mSearchBookActivity.getEtSearchKey().setSelection(tag.length());
mHandler.sendMessage(mHandler.obtainMessage(1));
}
});
//历史记录搜索事件
mSearchBookActivity.getLvHistoryList().setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mSearchBookActivity.getLvHistoryList().setOnItemClickListener((parent, view, position, id) -> {
mSearchBookActivity.getEtSearchKey().setText(mSearchHistories.get(position).getContent());
mSearchBookActivity.getEtSearchKey().setSelection(mSearchHistories.get(position).getContent().length());
mHandler.sendMessage(mHandler.obtainMessage(1));
}
});
//清空历史记录
mSearchBookActivity.getLlClearHistory().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mSearchBookActivity.getLlClearHistory().setOnClickListener(v -> {
mSearchHistoryService.clearHistory();
initHistoryList();
}
});
//清除单个历史记录
mSearchBookActivity.getLvHistoryList().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
mSearchBookActivity.getLvHistoryList().setOnItemLongClickListener((parent, view, position, id) -> {
if (mSearchHistories.get(position) != null) {
mSearchHistoryService.deleteHistory(mSearchHistories.get(position));
initHistoryList();
}
return true;
}
});
//上拉刷新
mSearchBookActivity.getSrlSearchBookList().setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
mHandler.sendMessage(mHandler.obtainMessage(1));
}
});
mSearchBookActivity.getSrlSearchBookList().setOnRefreshListener(refreshLayout -> mHandler.sendMessage(mHandler.obtainMessage(1)));
mSearchBookActivity.getSrlSearchBookList().setEnableRefresh(false);
mSearchBookActivity.getGvSearchBooksList().setNumColumns(1);
mSearchBookActivity.getGvSearchBooksList().setDragModel(-1);
initSuggestionBook();
initHistoryList();
}
@ -247,8 +222,8 @@ public class SearchBookPrensenter implements BasePresenter {
initmBooksBean();
mSearchBookAdapter = new SearchBookAdapter(mSearchBookActivity,
R.layout.listview_search_book_item, mBooksBean, mBooks);
mSearchBookActivity.getLvSearchBooksList().setAdapter(mSearchBookAdapter);
mSearchBookActivity.getLvSearchBooksList().setVisibility(View.VISIBLE);
mSearchBookActivity.getGvSearchBooksList().setAdapter(mSearchBookAdapter);
mSearchBookActivity.getGvSearchBooksList().setVisibility(View.VISIBLE);
mSearchBookActivity.getLlSuggestBooksView().setVisibility(View.GONE);
mSearchBookActivity.getLlHistoryView().setVisibility(View.GONE);
}
@ -272,9 +247,7 @@ public class SearchBookPrensenter implements BasePresenter {
mBooksBean.addAll(mBooks.keySet());
//排序,基于最符合关键字的搜书结果应该是最短的
//TODO ;这里只做了简单的比较排序,还需要继续完善
Collections.sort(mBooksBean, new Comparator<SearchBookBean>() {
@Override
public int compare(SearchBookBean o1, SearchBookBean o2) {
Collections.sort(mBooksBean, (o1, o2) -> {
if (searchKey.equals(o1.getName()))
return -1;
if (searchKey.equals(o2.getName()))
@ -288,7 +261,6 @@ public class SearchBookPrensenter implements BasePresenter {
if (o1.getName().length() == o2.getName().length())
return 0;
return 1;
}
});
/*MyApplication.runOnUiThread(new Runnable() {
@Override
@ -320,17 +292,25 @@ public class SearchBookPrensenter implements BasePresenter {
mSearchBookActivity.getPbLoading().setVisibility(View.VISIBLE);
if (StringHelper.isEmpty(searchKey)) {
mSearchBookActivity.getPbLoading().setVisibility(View.GONE);
mSearchBookActivity.getLvSearchBooksList().setVisibility(View.GONE);
mSearchBookActivity.getGvSearchBooksList().setVisibility(View.GONE);
mSearchBookActivity.getLlSuggestBooksView().setVisibility(View.VISIBLE);
initHistoryList();
mSearchBookActivity.getLvSearchBooksList().setAdapter(null);
mSearchBookActivity.getGvSearchBooksList().setAdapter(null);
mSearchBookActivity.getSrlSearchBookList().setEnableRefresh(false);
} else {
mSearchBookActivity.getLvSearchBooksList().setVisibility(View.VISIBLE);
mSearchBookActivity.getGvSearchBooksList().setVisibility(View.VISIBLE);
mSearchBookActivity.getLlSuggestBooksView().setVisibility(View.GONE);
mSearchBookActivity.getLlHistoryView().setVisibility(View.GONE);
getData();
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (mSearchBookActivity.getGvSearchBooksList().getmScrollView().getScrollY() == 0){
mSearchBookActivity.getSrlSearchBookList().setEnableRefresh(true);
}
//滑动监听器
mSearchBookActivity.getGvSearchBooksList().getmScrollView().setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
mSearchBookActivity.getSrlSearchBookList().setEnableRefresh(scrollY == 0);
});
}
mSearchHistoryService.addOrUpadteHistory(searchKey);
//收起软键盘
InputMethodManager imm = (InputMethodManager) MyApplication.getmContext().getSystemService(Context.INPUT_METHOD_SERVICE);

@ -151,15 +151,23 @@
<com.scwang.smartrefresh.header.MaterialHeader
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ListView
<!--<ListView
android:id="@+id/lv_search_books_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadingEdge="none"
android:overScrollMode="never"
android:scrollbars="none">
</ListView>
</ListView>-->
<xyz.fycz.myreader.custom.DragSortGridView
android:id="@+id/gv_search_books_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:listSelector="@android:color/transparent"
android:numColumns="auto_fit"
android:scrollbars="none"
android:padding="5dp">
</xyz.fycz.myreader.custom.DragSortGridView>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</LinearLayout>

@ -1,4 +1,5 @@
<com.scwang.smartrefresh.layout.SmartRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.scwang.smartrefresh.layout.SmartRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/srl_content"

@ -35,6 +35,7 @@
android:layout_height="24dp"
android:layout_marginTop="5dp"
android:text="bookname"
android:maxLength="15"
android:textSize="16sp"
android:textColor="@color/black"/>

@ -1,2 +1,2 @@
#Fri Jul 31 14:26:22 CST 2020
#Fri Aug 07 09:42:27 CST 2020
VERSION_CODE=140

Loading…
Cancel
Save