From 635dd06a54bc9cb684093cd2405be7e49d0a113a Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Wed, 3 Feb 2021 20:57:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=98=85=E8=AF=BB=E4=BD=93?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updatelog.fy | 5 + .../ui/activity/BookDetailedActivity.java | 68 ++++-- .../myreader/ui/activity/MainActivity.java | 67 +++-- .../myreader/ui/activity/ReadActivity.java | 161 +++--------- .../ui/fragment/BookcaseFragment.java | 6 +- .../myreader/ui/popmenu/ReadSettingMenu.java | 6 +- .../ui/presenter/BookcasePresenter.java | 50 ++-- .../fycz/myreader/util/utils/StringUtils.java | 28 ++- .../xyz/fycz/myreader/webapi/CommonApi.java | 12 +- .../webapi/callback/ResultCallback.java | 4 - .../crawler/read/YanQingLouReadCrawler.java | 58 ++++- .../myreader/widget/page/LocalPageLoader.java | 5 - .../myreader/widget/page/NetPageLoader.java | 48 ++-- .../fycz/myreader/widget/page/PageLoader.java | 48 ++-- app/src/main/res/drawable/ic_group.xml | 8 +- app/src/main/res/layout/fragment_bookcase.xml | 231 +++++++++--------- .../layout/gridview_book_detailed_item.xml | 225 ++++++++--------- .../main/res/layout/gridview_book_item.xml | 4 +- app/src/main/res/layout/view_empty.xml | 15 -- app/src/main/res/menu/menu_book.xml | 10 +- .../main/res/menu/menu_book_detail_local.xml | 17 ++ app/src/main/res/values/strings.xml | 2 + app/version_code.properties | 2 +- 23 files changed, 574 insertions(+), 506 deletions(-) create mode 100644 app/src/main/res/menu/menu_book_detail_local.xml diff --git a/app/src/main/assets/updatelog.fy b/app/src/main/assets/updatelog.fy index fbfbb98..2d9b64e 100644 --- a/app/src/main/assets/updatelog.fy +++ b/app/src/main/assets/updatelog.fy @@ -1,3 +1,8 @@ +风月读书v1.8.2 +1、优化阅读体验 +2、修复已知bug +3、支持分享本地书籍(txt) + 2020.02.01 风月读书v1.8.1 1、新增书源:笔尖小说、言情楼、卧龙小说 diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java index 1a01018..c2d038c 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java @@ -58,6 +58,7 @@ import xyz.fycz.myreader.ui.dialog.BookGroupDialog; import xyz.fycz.myreader.ui.dialog.DialogCreator; import xyz.fycz.myreader.ui.dialog.SourceExchangeDialog; import xyz.fycz.myreader.util.IOUtils; +import xyz.fycz.myreader.util.ShareUtils; import xyz.fycz.myreader.util.SharedPreUtils; import xyz.fycz.myreader.util.StringHelper; import xyz.fycz.myreader.util.ToastUtils; @@ -494,23 +495,29 @@ public class BookDetailedActivity extends BaseActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { if ("本地书籍".equals(mBook.getType())) { - return false; + getMenuInflater().inflate(R.menu.menu_book_detail_local, menu); + } else { + getMenuInflater().inflate(R.menu.menu_book_detail, menu); } - getMenuInflater().inflate(R.menu.menu_book_detail, menu); return true; } @Override public boolean onPrepareOptionsMenu(Menu menu) { - MenuItem isUpdate = menu.findItem(R.id.action_is_update); - MenuItem groupSetting = menu.findItem(R.id.action_group_setting); - if (isCollected) { - isUpdate.setVisible(true); - //groupSetting.setVisible(true); - isUpdate.setChecked(!mBook.getIsCloseUpdate()); + if ("本地书籍".equals(mBook.getType())) { + MenuItem groupSetting = menu.findItem(R.id.action_group_setting); + groupSetting.setVisible(isCollected); } else { - isUpdate.setVisible(false); - groupSetting.setVisible(false); + MenuItem isUpdate = menu.findItem(R.id.action_is_update); + MenuItem groupSetting = menu.findItem(R.id.action_group_setting); + if (isCollected) { + isUpdate.setVisible(true); + groupSetting.setVisible(true); + isUpdate.setChecked(!mBook.getIsCloseUpdate()); + } else { + isUpdate.setVisible(false); + groupSetting.setVisible(false); + } } return super.onPrepareOptionsMenu(menu); } @@ -632,7 +639,23 @@ public class BookDetailedActivity extends BaseActivity { /** * 分享书籍 */ + private void shareBook() { + if ("本地书籍".equals(mBook.getType())) { + File file = new File(mBook.getChapterUrl()); + if (!file.exists()){ + ToastUtils.showWarring("书籍源文件不存在,无法分享!"); + return; + } + try { + ShareUtils.share(this, file, mBook.getName() + ".txt", "text/plain"); + } catch (Exception e) { + String dest = APPCONST.SHARE_FILE_DIR + File.separator + mBook.getName() + ".txt"; + FileUtils.copy(mBook.getChapterUrl(), dest); + ShareUtils.share(this, new File(dest), mBook.getName() + ".txt", "text/plain"); + } + return; + } ToastUtils.showInfo("正在生成分享图片"); Single.create((SingleOnSubscribe) emitter -> { // 使用url @@ -660,16 +683,17 @@ public class BookDetailedActivity extends BaseActivity { } emitter.onSuccess(share); }).compose(RxUtils::toSimpleSingle) - .subscribe(new MySingleObserver() { - @Override - public void onSuccess(@NonNull File File) { - share(File); - } - }); + .subscribe(new MySingleObserver() { + @Override + public void onSuccess(@NonNull File File) { + share(File); + } + }); } /** * 生成分享图片 + * * @param QRCode * @return */ @@ -745,21 +769,16 @@ public class BookDetailedActivity extends BaseActivity { /** * 分享生成的图片 + * * @param share */ private void share(File share) { - //noinspection ResultOfMethodCallIgnored - share.setReadable(true, false); - Uri contentUri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".fileprovider", share); - final Intent intent = new Intent(Intent.ACTION_SEND); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.putExtra(Intent.EXTRA_STREAM, contentUri); - intent.setType("image/png"); - startActivity(Intent.createChooser(intent, "分享书籍")); + ShareUtils.share(this, share, "分享书籍", "image/png"); } /** * 绘制简介 + * * @param lines * @param textPaint * @param canvas @@ -777,6 +796,7 @@ public class BookDetailedActivity extends BaseActivity { /** * 生成简介lines + * * @param width * @param textPaint * @return diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java index 13d8756..283a208 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java @@ -9,6 +9,9 @@ import android.provider.Settings; import android.util.Log; import android.view.Menu; import android.view.MenuItem; +import android.view.View; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -63,6 +66,8 @@ public class MainActivity extends BaseActivity { private BookcaseFragment mBookcaseFragment; private FindFragment mFindFragment; private MineFragment mMineFragment; + private Animation mBottomInAnim; + private Animation mBottomOutAnim; @Override protected void bindView() { @@ -73,7 +78,7 @@ public class MainActivity extends BaseActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { boolean startFromSplash = getIntent().getBooleanExtra("startFromSplash", false); - if (!startFromSplash && BookGroupService.getInstance().curGroupIsPrivate()){ + if (!startFromSplash && BookGroupService.getInstance().curGroupIsPrivate()) { SharedPreUtils.getInstance().putString(getString(R.string.curBookGroupId), ""); SharedPreUtils.getInstance().putString(getString(R.string.curBookGroupName), ""); } @@ -130,7 +135,7 @@ public class MainActivity extends BaseActivity { super.initClick(); mToolbar.setOnLongClickListener(v -> { - if (binding.viewPagerMain.getCurrentItem() == 0 && !BookGroupService.getInstance().curGroupIsPrivate()){ + if (binding.viewPagerMain.getCurrentItem() == 0 && !BookGroupService.getInstance().curGroupIsPrivate()) { goPrivateBookcase(); return true; } @@ -237,8 +242,11 @@ public class MainActivity extends BaseActivity { @Override public boolean onPrepareOptionsMenu(Menu menu) { + boolean isEdit = mBookcaseFragment.getmBookcasePresenter() != null && mBookcaseFragment.getmBookcasePresenter().ismEditState(); + if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { + menu.findItem(R.id.action_refresh).setVisible(!isEdit); + } if (binding.viewPagerMain.getCurrentItem() == 0) { - if (mBookcaseFragment.getmBookcasePresenter() != null && mBookcaseFragment.getmBookcasePresenter().ismEditState()) { menu.findItem(R.id.action_finish).setVisible(true); menu.setGroupVisible(R.id.bookcase_menu, false); @@ -270,8 +278,7 @@ public class MainActivity extends BaseActivity { startActivity(searchBookIntent); return true; } else if (itemId == R.id.action_finish) { - mBookcaseFragment.getmBookcasePresenter().cancelEdit(); - invalidateOptionsMenu(); + cancelEdit(); return true; } else if (itemId == R.id.action_change_group || itemId == R.id.action_group_man) { if (!mBookcaseFragment.getmBookcasePresenter().hasOnGroupChangeListener()) { @@ -280,8 +287,13 @@ public class MainActivity extends BaseActivity { getSupportActionBar().setSubtitle(groupName); }); } + } else if (itemId == R.id.action_refresh) { + mBookcaseFragment.getmBookcasePresenter().initNoReadNum(); } else if (itemId == R.id.action_edit) { invalidateOptionsMenu(); + initMenuAnim(); + binding.bottomNavigationView.setVisibility(View.GONE); + binding.bottomNavigationView.startAnimation(mBottomOutAnim); } else if (itemId == R.id.action_qr_scan) { Intent intent = new Intent(this, QRCodeScanActivity.class); startActivityForResult(intent, APPCONST.REQUEST_QR_SCAN); @@ -292,8 +304,7 @@ public class MainActivity extends BaseActivity { @Override public void onBackPressed() { if (mBookcaseFragment.getmBookcasePresenter() != null && mBookcaseFragment.getmBookcasePresenter().ismEditState()) { - mBookcaseFragment.getmBookcasePresenter().cancelEdit(); - invalidateOptionsMenu(); + cancelEdit(); return; } if (System.currentTimeMillis() - APPCONST.exitTime > APPCONST.exitConfirmTime) { @@ -311,10 +322,10 @@ public class MainActivity extends BaseActivity { BookGroup bookGroup = BookGroupService.getInstance().getGroupById(curBookGroupId); if (bookGroup == null) { groupName = ""; - }else { + } else { groupName = bookGroup.getName(); } - if (binding.viewPagerMain.getCurrentItem() == 0){ + if (binding.viewPagerMain.getCurrentItem() == 0) { getSupportActionBar().setSubtitle(groupName); } // MyApplication.checkVersionByServer(this); @@ -342,21 +353,21 @@ public class MainActivity extends BaseActivity { String[] string = result.split("#", 2); if (string.length == 2) { SharedBook sharedBook = GsonExtensionsKt.getGSON().fromJson(string[1], SharedBook.class); - if (sharedBook != null && !StringHelper.isEmpty(sharedBook.getChapterUrl())){ + if (sharedBook != null && !StringHelper.isEmpty(sharedBook.getChapterUrl())) { Book book = SharedBook.sharedBookToBook(sharedBook); Intent intent = new Intent(this, BookDetailedActivity.class); intent.putExtra(APPCONST.BOOK, book); startActivity(intent); - }else { + } else { ToastUtils.showError("书籍加载失败"); } - }else { + } else { try { Intent intent = new Intent(Intent.ACTION_VIEW); Uri uri = Uri.parse(result); intent.setData(uri); startActivity(intent); - }catch (Exception e){ + } catch (Exception e) { ToastUtils.showError(e.getLocalizedMessage()); } } @@ -449,7 +460,7 @@ public class MainActivity extends BaseActivity { } } - private void goPrivateBookcase(){ + private void goPrivateBookcase() { MyAlertDialog.showPrivateVerifyDia(this, needGoTo -> { if (needGoTo) showPrivateBooks(); }); @@ -458,7 +469,7 @@ public class MainActivity extends BaseActivity { /** * 显示私密书架 */ - private void showPrivateBooks(){ + private void showPrivateBooks() { BookGroup bookGroup = BookGroupService.getInstance(). getGroupById(SharedPreUtils.getInstance().getString("privateGroupId")); groupName = bookGroup.getName(); @@ -471,6 +482,32 @@ public class MainActivity extends BaseActivity { mBookcaseFragment.onResume(); } + /** + * 取消编辑状态 + */ + private void cancelEdit() { + mBookcaseFragment.getmBookcasePresenter().cancelEdit(); + invalidateOptionsMenu(); + initMenuAnim(); + binding.bottomNavigationView.setVisibility(View.VISIBLE); + binding.bottomNavigationView.startAnimation(mBottomInAnim); + } + + //初始化菜单动画 + public void initMenuAnim() { + if (mBottomInAnim != null) return; + mBottomInAnim = AnimationUtils.loadAnimation(this, R.anim.slide_bottom_in); + mBottomOutAnim = AnimationUtils.loadAnimation(this, R.anim.slide_bottom_out); + } + + public Animation getmBottomInAnim() { + return mBottomInAnim; + } + + public Animation getmBottomOutAnim() { + return mBottomOutAnim; + } + public interface OnGroupChangeListener { void onChange(); } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java index b5b2f5a..f7e1691 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java @@ -125,8 +125,6 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe private boolean isCollected = true;//是否在书架中 - private boolean isPrev;//是否向前翻页 - private boolean autoPage = false;//是否自动翻页 private boolean loadFinish = false; @@ -207,11 +205,9 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe mPageLoader.skipToChapter(chapterPos); mPageLoader.skipToPage(pagePos); } catch (Exception e) { - ToastUtils.showError("章节跳转失败,请截图联系作者。\n" + - e.getMessage()); + //ToastUtils.showError("章节跳转失败,请截图联系作者。\n" + e.getMessage()); e.printStackTrace(); } - binding.pbLoading.setVisibility(View.GONE); break; case 3: break; @@ -227,7 +223,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe break; case 6: mPageLoader.openChapter(); - if (isPrev) {//判断是否向前翻页打开章节,如果是则打开自己后跳转到最后一页,否则不跳转 + if (mPageLoader.isPrev()) {//判断是否向前翻页打开章节,如果是则打开自己后跳转到最后一页,否则不跳转 try {//概率性异常(空指针异常) mPageLoader.skipToPage(mPageLoader.getAllPagePos() - 1); } catch (Exception e) { @@ -365,12 +361,12 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe @Override public void prePage() { - isPrev = true; + mPageLoader.setPrev(true); } @Override public void nextPage(boolean hasNextPage) { - isPrev = false; + mPageLoader.setPrev(false); if (!hasNextPage) { if (autoPage) { autoPageStop(); @@ -402,30 +398,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe new PageLoader.OnPageChangeListener() { @Override public void onChapterChange(int pos) { - lastLoad(pos); - for (int i = 0; i < 5; i++) { - preLoad(pos - 1 + i); - } mBook.setHistoryChapterId(mChapters.get(pos).getTitle()); - MyApplication.getApplication().newThread(() -> { - if (mPageLoader == null) { - return; - } - if (mPageLoader.getPageStatus() == PageLoader.STATUS_LOADING) { - if (!NetworkUtils.isNetWorkAvailable()) { - mHandler.sendMessage(mHandler.obtainMessage(7)); - } else { - mHandler.sendMessage(mHandler.obtainMessage(6)); - } - } - }); - } - - @Override - public void requestChapters(List requestChapters) { - /*for (final Chapter chapter : requestChapters){ - getChapterContent(chapter, null); - }*/ } @Override @@ -578,6 +551,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe } }); } + @Override protected void processLogic() { super.processLogic(); @@ -738,7 +712,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe if (itemId == R.id.action_change_source) { mSourceDialog.show(); } else if (itemId == R.id.action_reload) { - isPrev = false; + mPageLoader.setPrev(false); if (!"本地书籍".equals(mBook.getType())) { mChapterService.deleteChapterCacheFile(mChapters.get(mPageLoader.getChapterPos())); } @@ -891,7 +865,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe binding.tvChapterUrl.setText(StringHelper.isEmpty(url) ? curChapter.getId() : url); binding.readSbChapterProgress.setProgress(mPageLoader.getPagePos()); binding.readSbChapterProgress.setMax(mPageLoader.getAllPagePos() - 1); - binding.readTvPageTip.setText(String.format("%s/%s", binding.readSbChapterProgress.getProgress() + 1 ,binding.readSbChapterProgress.getMax() + 1)); + binding.readTvPageTip.setText(String.format("%s/%s", binding.readSbChapterProgress.getProgress() + 1, binding.readSbChapterProgress.getMax() + 1)); } } /************************书籍相关******************************/ @@ -1087,20 +1061,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe if (hasChangeSource) { mBookService.matchHistoryChapterPos(mBook, mChapters); } - getChapterContent(mChapters.get(mBook.getHisttoryChapterNum()), new ResultCallback() { - @Override - public void onFinish(Object o, int code) { -// mChapters.get(mBook.getHisttoryChapterNum()).setContent((String) o); - mChapterService.saveOrUpdateChapter(mChapters.get(mBook.getHisttoryChapterNum()), (String) o); - mHandler.sendMessage(mHandler.obtainMessage(1)); -// getAllChapterData(); - } - - @Override - public void onError(Exception e) { - mHandler.sendMessage(mHandler.obtainMessage(1)); - } - }); + mHandler.sendMessage(mHandler.obtainMessage(1)); initMenu(); } } @@ -1113,93 +1074,14 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe * @param pagePos */ private void skipToChapterAndPage(final int chapterPos, final int pagePos) { - isPrev = false; + mPageLoader.setPrev(false); if (StringHelper.isEmpty(mChapters.get(chapterPos).getContent())) { if ("本地书籍".equals(mBook.getType())) { ToastUtils.showWarring("该章节无内容!"); return; } - binding.pbLoading.setVisibility(View.VISIBLE); - getChapterContent(mChapters.get(chapterPos), new ResultCallback() { - @Override - public void onFinish(Object o, int code) { - mChapterService.saveOrUpdateChapter(mChapters.get(chapterPos), (String) o); - mHandler.sendMessage(mHandler.obtainMessage(2, chapterPos, pagePos)); - } - - @Override - public void onError(Exception e) { - mHandler.sendMessage(mHandler.obtainMessage(2, chapterPos, pagePos)); - mHandler.sendEmptyMessage(10); - } - }); - } else { - mHandler.sendMessage(mHandler.obtainMessage(2, chapterPos, pagePos)); - } - } - - /** - * 获取章节内容 - * - * @param chapter - * @param resultCallback - */ - private void getChapterContent(final Chapter chapter, ResultCallback resultCallback) { - if (StringHelper.isEmpty(chapter.getBookId())) { - chapter.setId(mBook.getId()); - } - if (!StringHelper.isEmpty(chapter.getContent())) { - if (resultCallback != null) { - resultCallback.onFinish(mChapterService.getChapterCatheContent(chapter), 0); - } - } else { - if ("本地书籍".equals(mBook.getType())) { - return; - } - if (resultCallback != null) { - CommonApi.getChapterContent(chapter.getUrl(), mReadCrawler, resultCallback); - } else { - CommonApi.getChapterContent(chapter.getUrl(), mReadCrawler, new ResultCallback() { - @Override - public void onFinish(final Object o, int code) { -// chapter.setContent((String) o); - mChapterService.saveOrUpdateChapter(chapter, (String) o); - } - - @Override - public void onError(Exception e) { - - } - - }); - } - } - } - - /** - * 预加载下一章 - */ - private void preLoad(int position) { - if (position + 1 < mChapters.size()) { - Chapter chapter = mChapters.get(position + 1); - if (StringHelper.isEmpty(chapter.getContent())) { - mPageLoader.getChapterContent(chapter); - } - } - } - - /** - * 预加载上一章 - * - * @param position - */ - private void lastLoad(int position) { - if (position > 0) { - Chapter chapter = mChapters.get(position - 1); - if (StringHelper.isEmpty(chapter.getContent())) { - mPageLoader.getChapterContent(chapter); - } } + mHandler.sendMessage(mHandler.obtainMessage(2, chapterPos, pagePos)); } /** @@ -1287,7 +1169,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe binding.readAutoPageMenu.startAnimation(mBottomOutAnim); flag = true; } - if ( binding.readBrightnessEyeMenu.getVisibility() == VISIBLE) { + if (binding.readBrightnessEyeMenu.getVisibility() == VISIBLE) { binding.readBrightnessEyeMenu.setVisibility(GONE); binding.readBrightnessEyeMenu.startAnimation(mBottomOutAnim); flag = true; @@ -1367,9 +1249,19 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe private void initSettingListener() { binding.readSettingMenu.setOnClickListener(null); binding.readSettingMenu.setListener(this, new ReadSettingMenu.Callback() { + @Override + public void onRefreshPage() { + mPageLoader.refreshPagePara(); + } + + @Override + public void onPageModeChange() { + mPageLoader.setPageMode(mSetting.getPageMode()); + } + @Override public void onRefreshUI() { - mHandler.sendEmptyMessage(5); + mPageLoader.refreshUi(); } @Override @@ -1675,7 +1567,10 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe } MyApplication.getApplication().newThread(() -> { for (Chapter chapter : needDownloadChapters) { - getChapterContent(chapter, new ResultCallback() { + if (StringHelper.isEmpty(chapter.getBookId())) { + chapter.setId(mBook.getId()); + } + CommonApi.getChapterContent(chapter.getUrl(), mReadCrawler, new ResultCallback() { @Override public void onFinish(Object o, int code) { downloadingChapter = chapter.getTitle(); @@ -1904,9 +1799,9 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe */ public void showAction() { float x, y; - if (binding.cursorLeft.getX() - binding.cursorRight.getX() > 0){ + if (binding.cursorLeft.getX() - binding.cursorRight.getX() > 0) { x = binding.cursorRight.getX() + (binding.cursorLeft.getX() - binding.cursorRight.getX()) / 2 + ScreenUtils.dpToPx(12); - }else { + } else { x = binding.cursorLeft.getX() + (binding.cursorRight.getX() - binding.cursorLeft.getX()) / 2 + ScreenUtils.dpToPx(12); } if ((binding.cursorLeft.getY() - ScreenUtils.spToPx(mSetting.getReadWordSize()) - ScreenUtils.dpToPx(60)) < 0) { diff --git a/app/src/main/java/xyz/fycz/myreader/ui/fragment/BookcaseFragment.java b/app/src/main/java/xyz/fycz/myreader/ui/fragment/BookcaseFragment.java index dca7061..31af73d 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/fragment/BookcaseFragment.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/fragment/BookcaseFragment.java @@ -54,11 +54,7 @@ public class BookcaseFragment extends Fragment { @Override public void onResume() { super.onResume(); - if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - mBookcasePresenter.getData(); - } else { - mBookcasePresenter.init(); - } + mBookcasePresenter.init(); } public LinearLayout getLlNoDataTips() { diff --git a/app/src/main/java/xyz/fycz/myreader/ui/popmenu/ReadSettingMenu.java b/app/src/main/java/xyz/fycz/myreader/ui/popmenu/ReadSettingMenu.java index 17c7242..9794c8e 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/popmenu/ReadSettingMenu.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/popmenu/ReadSettingMenu.java @@ -100,7 +100,7 @@ public class ReadSettingMenu extends FrameLayout { //繁简切换 binding.tvSwitchSt.setOnClickListener(v -> { initSwitchST(true); - callback.onRefreshUI(); + callback.onRefreshPage(); }); //字体选择 binding.tvTextFont.setOnClickListener(v -> callback.onFontClick()); @@ -195,7 +195,7 @@ public class ReadSettingMenu extends FrameLayout { } dialog.dismiss(); SysManager.saveSetting(setting); - callback.onRefreshUI(); + callback.onPageModeChange(); }).show(); }); //横屏竖屏切换 @@ -344,6 +344,8 @@ public class ReadSettingMenu extends FrameLayout { } public interface Callback{ + void onRefreshPage(); + void onPageModeChange(); void onRefreshUI(); void onStyleChange(); void onTextSizeChange(); diff --git a/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java b/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java index 0494857..384b866 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java @@ -16,6 +16,8 @@ import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; import android.view.inputmethod.InputMethodManager; import android.widget.Button; import android.widget.EditText; @@ -74,8 +76,6 @@ public class BookcasePresenter implements BasePresenter { private final BookcaseFragment mBookcaseFragment; private final ArrayList mBooks = new ArrayList<>();//书目数组 - private ArrayList mBookGroups = new ArrayList<>();//书籍分组 - private CharSequence[] mGroupNames;//书籍分组名称 private BookcaseAdapter mBookcaseAdapter; private final BookService mBookService; private final ChapterService mChapterService; @@ -117,7 +117,6 @@ public class BookcasePresenter implements BasePresenter { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE }; - // private ChapterService mChapterService; @SuppressLint("HandlerLeak") public final Handler mHandler = new Handler() { @Override @@ -245,6 +244,7 @@ public class BookcasePresenter implements BasePresenter { } ToastUtils.showSuccess("书籍删除成功!"); init(); + mBookcaseAdapter.setCheckedAll(false); }, null); }else { DialogCreator.createCommonDialog(mMainActivity, "批量删除/移除书籍", @@ -255,6 +255,7 @@ public class BookcasePresenter implements BasePresenter { } ToastUtils.showSuccess("书籍删除成功!"); init(); + mBookcaseAdapter.setCheckedAll(false); }, (dialog, which) -> { for (Book book : mBookcaseAdapter.getSelectBooks()) { book.setGroupId(""); @@ -262,6 +263,7 @@ public class BookcasePresenter implements BasePresenter { } ToastUtils.showSuccess("书籍已从分组中移除!"); init(); + mBookcaseAdapter.setCheckedAll(false); }); } }); @@ -272,6 +274,7 @@ public class BookcasePresenter implements BasePresenter { @Override public void change() { init(); + mBookcaseAdapter.setCheckedAll(false); if (hasOnGroupChangeListener()) ogcl.onChange(); } @@ -288,7 +291,7 @@ public class BookcasePresenter implements BasePresenter { //获取数据 public void getData() { init(); - if (mSetting.isRefreshWhenStart() || android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { + if (mSetting.isRefreshWhenStart()) { mHandler.postDelayed(this::initNoReadNum, 500); } } @@ -317,7 +320,22 @@ public class BookcasePresenter implements BasePresenter { setBtnClickable(mBookcaseAdapter.getmCheckedCount() > 0); }); mBookcaseFragment.getGvBook().setDragModel(-1); - mBookcaseFragment.getGvBook().setTouchClashparent(((MainActivity) (mBookcaseFragment.getActivity())).getViewPagerMain()); + mBookcaseFragment.getGvBook().setTouchClashparent(mMainActivity.getViewPagerMain()); + mBookcaseFragment.getGvBook().setOnDragSelectListener(new DragSortGridView.OnDragSelectListener() { + @Override + public void onDragSelect(View mirror) { + if (mSetting.getBookcaseStyle() == BookcaseStyle.listMode){ + mirror.setBackgroundColor(mMainActivity.getResources().getColor(R.color.colorBackground)); + }else { + mirror.setScaleX(1.05f); + } + mirror.setScaleY(1.05f); + } + + @Override + public void onPutDown(View itemView) { + } + }); mBookcaseFragment.getGvBook().setAdapter(mBookcaseAdapter); isBookcaseStyleChange = false; } else { @@ -375,23 +393,8 @@ public class BookcasePresenter implements BasePresenter { } } - //初始化书籍分组 - private void initBookGroups(boolean isAdd) { - mBookGroups.clear(); - mBookGroups.addAll(mBookGroupService.getAllGroups()); - mGroupNames = new CharSequence[isAdd ? mBookGroups.size() + 1 : mBookGroups.size()]; - for (int i = 0; i < mBookGroups.size(); i++) { - String groupName = mBookGroups.get(i).getName(); -// mGroupNames[i] = groupName.getBytes().length > 20 ? groupName.substring(0, 8) + "···" : groupName; - mGroupNames[i] = groupName; - } - if (isAdd) { - mGroupNames[mBookGroups.size()] = "添加分组"; - } - } - //检查书籍更新 - private void initNoReadNum() { + public void initNoReadNum() { errorLoadingBooks.clear(); finishLoadBookCount = 0; for (Book book : mBooks) { @@ -557,6 +560,8 @@ public class BookcasePresenter implements BasePresenter { mBookcaseFragment.getGvBook().setDragModel(DragSortGridView.DRAG_BY_LONG_CLICK); } mBookcaseFragment.getRlBookEdit().setVisibility(View.VISIBLE); + mMainActivity.initMenuAnim(); + mBookcaseFragment.getRlBookEdit().startAnimation(mMainActivity.getmBottomInAnim()); setBtnClickable(false); changeCheckedAllStatus(); mBookcaseAdapter.notifyDataSetChanged(); @@ -571,6 +576,8 @@ public class BookcasePresenter implements BasePresenter { mBookcaseFragment.getGvBook().setDragModel(-1); mBookcaseAdapter.setmEditState(false); mBookcaseFragment.getRlBookEdit().setVisibility(View.GONE); + mMainActivity.initMenuAnim(); + mBookcaseFragment.getRlBookEdit().startAnimation(mMainActivity.getmBottomOutAnim()); mBookcaseAdapter.notifyDataSetChanged(); } } @@ -976,4 +983,5 @@ public class BookcasePresenter implements BasePresenter { mBookcaseFragment.getmCbSelectAll().setText("全选"); } } + } diff --git a/app/src/main/java/xyz/fycz/myreader/util/utils/StringUtils.java b/app/src/main/java/xyz/fycz/myreader/util/utils/StringUtils.java index 0dbbade..9b56829 100644 --- a/app/src/main/java/xyz/fycz/myreader/util/utils/StringUtils.java +++ b/app/src/main/java/xyz/fycz/myreader/util/utils/StringUtils.java @@ -348,5 +348,31 @@ public class StringUtils { s2 = s2.trim(); return s1.equals(s2); } - + /** + * 取两个文本之间的文本值 + * @param text 源文本 比如:欲取全文本为 12345 + * @param left 文本前面 + * @param right 后面文本 + * @return 返回 String + */ + public static String getSubString(String text, String left, String right) { + String result = ""; + int zLen; + if (left == null || left.isEmpty()) { + zLen = 0; + } else { + zLen = text.indexOf(left); + if (zLen > -1) { + zLen += left.length(); + } else { + zLen = 0; + } + } + int yLen = text.indexOf(right, zLen); + if (yLen < 0 || right == null || right.isEmpty()) { + yLen = text.length(); + } + result = text.substring(zLen, yLen); + return result; + } } diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/CommonApi.java b/app/src/main/java/xyz/fycz/myreader/webapi/CommonApi.java index eadde6a..da1734e 100644 --- a/app/src/main/java/xyz/fycz/myreader/webapi/CommonApi.java +++ b/app/src/main/java/xyz/fycz/myreader/webapi/CommonApi.java @@ -1,5 +1,7 @@ package xyz.fycz.myreader.webapi; +import android.util.Log; + import io.reactivex.Observable; import io.reactivex.ObservableEmitter; import io.reactivex.ObservableOnSubscribe; @@ -18,6 +20,7 @@ import xyz.fycz.myreader.webapi.crawler.base.BookInfoCrawler; import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler; import xyz.fycz.myreader.webapi.crawler.read.FYReadCrawler; import xyz.fycz.myreader.webapi.crawler.read.TianLaiReadCrawler; +import xyz.fycz.myreader.webapi.crawler.read.YanQingLouReadCrawler; import java.io.IOException; import java.util.List; @@ -91,7 +94,14 @@ public class CommonApi extends BaseApi { getCommonReturnHtmlStringApi(url, null, charset, true, new ResultCallback() { @Override public void onFinish(Object o, int code) { - callback.onFinish(rc.getContentFormHtml((String) o), 0); + String html = (String) o; + String content = rc.getContentFormHtml(html); + if (rc instanceof YanQingLouReadCrawler && content.contains("正在加载")){ + YanQingLouReadCrawler yrc = (YanQingLouReadCrawler) rc; + yrc.getAjaxContent(html, this); + }else { + callback.onFinish(content, 0); + } } @Override diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/callback/ResultCallback.java b/app/src/main/java/xyz/fycz/myreader/webapi/callback/ResultCallback.java index 9e16352..ab289c1 100644 --- a/app/src/main/java/xyz/fycz/myreader/webapi/callback/ResultCallback.java +++ b/app/src/main/java/xyz/fycz/myreader/webapi/callback/ResultCallback.java @@ -1,10 +1,6 @@ package xyz.fycz.myreader.webapi.callback; -/** - * Created by zhao on 2016/10/25. - */ - public interface ResultCallback { void onFinish(Object o, int code); diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/read/YanQingLouReadCrawler.java b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/read/YanQingLouReadCrawler.java index 16c876b..edb2dac 100644 --- a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/read/YanQingLouReadCrawler.java +++ b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/read/YanQingLouReadCrawler.java @@ -2,24 +2,33 @@ package xyz.fycz.myreader.webapi.crawler.read; import android.text.Html; +import org.json.JSONException; +import org.json.JSONObject; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; +import java.io.IOException; import java.util.ArrayList; +import okhttp3.MediaType; +import okhttp3.RequestBody; import xyz.fycz.myreader.entity.SearchBookBean; import xyz.fycz.myreader.enums.BookSource; import xyz.fycz.myreader.greendao.entity.Book; import xyz.fycz.myreader.greendao.entity.Chapter; import xyz.fycz.myreader.model.mulvalmap.ConcurrentMultiValueMap; +import xyz.fycz.myreader.util.utils.OkHttpUtils; +import xyz.fycz.myreader.util.utils.StringUtils; +import xyz.fycz.myreader.webapi.callback.ResultCallback; import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler; public class YanQingLouReadCrawler implements ReadCrawler { public static final String NAME_SPACE = "http://www.yanqinglou.com"; public static final String NOVEL_SEARCH = "http://www.yanqinglou.com/Home/Search,action=search&q={key}"; + public static final String AJAX_CONTENT = "http://www.yanqinglou.com/home/index/ajaxchapter"; public static final String CHARSET = "UTF-8"; public static final String SEARCH_CHARSET = "UTF-8"; @@ -48,6 +57,19 @@ public class YanQingLouReadCrawler implements ReadCrawler { return SEARCH_CHARSET; } + /* + var preview_page = "/lishi/220987/60.html"; + var next_page = "/lishi/220987/62.html"; + var index_page = "/lishi/220987/"; + var article_id = "220987"; + var chapter_id = "61"; + var nextcid = "62"; + var prevcid = "60"; + var articlename = "临高启明"; + var chaptername = "第十五节 遇伏"; + var hash = "38e338d183600e17"; + var localpre = "www.yanqinglou.com"; + */ /** * 从html中获取章节正文 * @@ -61,13 +83,45 @@ public class YanQingLouReadCrawler implements ReadCrawler { String content = Html.fromHtml(divContent.html()).toString(); char c = 160; String spaec = "" + c; - content = content.replace(spaec, " "); + content = content.replace(spaec, " ") + .replaceAll("您可以.*最新章节!", "") + .replaceAll("转码页面.*com/", ""); return content; } else { return ""; } } + /* + id: 220987 + eKey: fe9535a08b53e929 + cid: 62 + basecid: 62 + */ + public void getAjaxContent(String html, ResultCallback callback){ + String id = StringUtils.getSubString(html, "var article_id = \"", "\";"); + String eKey = StringUtils.getSubString(html, "var hash = \"", "\";"); + String cid = StringUtils.getSubString(html, "var chapter_id = \"", "\";"); + String body = "id=" + id + "&eKey=" + eKey + "&cid=" + cid + "&basecid=" + cid; + MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); + RequestBody requestBody = RequestBody.create(mediaType, body); + try { + String jsonStr = OkHttpUtils.getHtml(AJAX_CONTENT, requestBody, CHARSET); + JSONObject json = new JSONObject(jsonStr); + String content = json.getJSONObject("info").getString("content"); + content = Html.fromHtml(content).toString(); + char c = 160; + String spaec = "" + c; + content = content.replace(spaec, " ") + .replaceAll("您可以.*最新章节!", "") + .replaceAll("转码页面.*com/", ""); + callback.onFinish(content, 0); + } catch (IOException | JSONException e) { + e.printStackTrace(); + callback.onError(e); + } + } + /** * 从html中获取章节列表 * @@ -122,7 +176,7 @@ public class YanQingLouReadCrawler implements ReadCrawler { book.setType(divBook.getElementsByClass("author").get(1).text().replace("分类:", "")); book.setNewestChapterTitle(as.get(3).text().replace("最近更新>>", "")); book.setDesc(divBook.getElementsByClass("update").first().text().replace("简介:", "")); - book.setImgUrl(divBook.getElementsByTag("img").attr("src")); + book.setImgUrl(NAME_SPACE + divBook.getElementsByTag("img").attr("src")); book.setChapterUrl(NAME_SPACE + as.get(0).attr("href")); book.setSource(BookSource.yanqinglou.toString()); SearchBookBean sbb = new SearchBookBean(book.getName(), book.getAuthor()); diff --git a/app/src/main/java/xyz/fycz/myreader/widget/page/LocalPageLoader.java b/app/src/main/java/xyz/fycz/myreader/widget/page/LocalPageLoader.java index e7d4764..a601c19 100644 --- a/app/src/main/java/xyz/fycz/myreader/widget/page/LocalPageLoader.java +++ b/app/src/main/java/xyz/fycz/myreader/widget/page/LocalPageLoader.java @@ -398,9 +398,4 @@ public class LocalPageLoader extends PageLoader { return chapter.getEnd() > 0 || ChapterService.isChapterCached(mCollBook.getId(), chapter.getTitle()); } - - @Override - public void getChapterContent(Chapter chapter) { - - } } diff --git a/app/src/main/java/xyz/fycz/myreader/widget/page/NetPageLoader.java b/app/src/main/java/xyz/fycz/myreader/widget/page/NetPageLoader.java index 68920c9..720fe1d 100644 --- a/app/src/main/java/xyz/fycz/myreader/widget/page/NetPageLoader.java +++ b/app/src/main/java/xyz/fycz/myreader/widget/page/NetPageLoader.java @@ -1,6 +1,11 @@ package xyz.fycz.myreader.widget.page; +import android.util.Log; + +import xyz.fycz.myreader.application.MyApplication; +import xyz.fycz.myreader.util.StringHelper; +import xyz.fycz.myreader.util.ToastUtils; import xyz.fycz.myreader.webapi.callback.ResultCallback; import xyz.fycz.myreader.common.APPCONST; import xyz.fycz.myreader.entity.Setting; @@ -72,22 +77,6 @@ public class NetPageLoader extends PageLoader { + File.separator + chapter.getTitle() + FileUtils.SUFFIX_FY); if (!file.exists()) return null; BufferedReader br = new BufferedReader(new FileReader(file)); - /*try { - if (StringHelper.isEmpty(br.readLine())){ - getChapterContent(chapter); - assert chapter.getContent() != null; - //保证chapter更新完毕,暂时先这么用着 - for (int i = 0; i < 5; i++) { - if (!StringHelper.isEmpty(chapter.getContent())){ - break; - } - Thread.sleep(1000); - } - return br; - } - } catch (IOException | InterruptedException e) { - e.printStackTrace(); - }*/ return br; } @@ -135,12 +124,12 @@ public class NetPageLoader extends PageLoader { } /** - * 加载当前页的前面两个章节 + * 加载当前页的前面一个章节 */ private void loadPrevChapter() { if (mPageChangeListener != null) { int end = mCurChapterPos; - int begin = end - 2; + int begin = end - 1; if (begin < 0) { begin = 0; } @@ -176,14 +165,14 @@ public class NetPageLoader extends PageLoader { } /** - * 加载当前页的后一个章节 + * 加载当前页的后四个章节 */ private void loadNextChapter() { if (mPageChangeListener != null) { - // 提示加载后两章 + // 提示加载后四章 int begin = mCurChapterPos + 1; - int end = begin + 1; + int end = begin + 3; // 判断是否大于最后一章 if (begin >= mChapterList.size()) { @@ -220,7 +209,9 @@ public class NetPageLoader extends PageLoader { } if (!chapters.isEmpty()) { - mPageChangeListener.requestChapters(chapters); + for (Chapter chapter : chapters) { + getChapterContent(chapter); + } } } @@ -242,10 +233,21 @@ public class NetPageLoader extends PageLoader { public void onFinish(final Object o, int code) { // chapter.setContent((String) o); mChapterService.saveOrUpdateChapter(chapter, (String) o); + if (getPageStatus() == PageLoader.STATUS_LOADING) { + MyApplication.runOnUiThread(() -> { + if (isPrev) { + openChapterInLastPage(); + } else { + openChapter(); + } + }); + } } + @Override public void onError(Exception e) { - + ToastUtils.showError("章节加载失败\n" + e.getLocalizedMessage()); + e.printStackTrace(); } }); diff --git a/app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java b/app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java index 88fa917..643aa83 100644 --- a/app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java +++ b/app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java @@ -27,6 +27,7 @@ import xyz.fycz.myreader.enums.Language; import xyz.fycz.myreader.greendao.entity.Book; import xyz.fycz.myreader.entity.Setting; import xyz.fycz.myreader.greendao.entity.Chapter; +import xyz.fycz.myreader.greendao.service.ChapterService; import xyz.fycz.myreader.model.audio.ReadAloudService; import xyz.fycz.myreader.util.IOUtils; import xyz.fycz.myreader.util.ToastUtils; @@ -150,10 +151,10 @@ public abstract class PageLoader { private int mBatteryLevel; //当前页面的背景 private int mBgColor; - //繁简体 - private Language language; // 当前章 protected int mCurChapterPos = 0; + //是否向前翻页 + protected boolean isPrev; //上一章的记录 private int mLastChapterPos = 0; private int readTextLength; //已读字符数 @@ -212,9 +213,6 @@ public abstract class PageLoader { mPageMode = mSettingManager.getPageMode(); //获取字体 getFont(mSettingManager.getFont()); - //获取繁简体 - language = mSettingManager.getLanguage(); -// mPageStyle = mSettingManager.getPageStyle(); indent = StringUtils.repeat(StringUtils.halfToFull(" "), mSettingManager.getIntent()); initBgBitmap(); @@ -319,6 +317,7 @@ public abstract class PageLoader { * @return */ public boolean skipPreChapter() { + isPrev = false; if (!hasPrevChapter()) { return false; } @@ -339,6 +338,7 @@ public abstract class PageLoader { * @return */ public boolean skipNextChapter() { + isPrev = false; if (!hasNextChapter()) { return false; } @@ -359,6 +359,7 @@ public abstract class PageLoader { * @param pos:从 0 开始。 */ public void skipToChapter(int pos) { + isPrev = false; // 设置参数 mCurChapterPos = pos; @@ -540,7 +541,7 @@ public abstract class PageLoader { refreshPagePara(); } - private void refreshPagePara() { + public void refreshPagePara() { // 取消缓存 mPreChapter = null; mNextChapter = null; @@ -597,7 +598,7 @@ public abstract class PageLoader { */ public void refreshChapter(Chapter chapter) { chapter.setContent(null); - getChapterContent(chapter); + ChapterService.getInstance().deleteChapterCacheFile(chapter); openChapter(); } @@ -755,6 +756,18 @@ public abstract class PageLoader { mPageView.drawCurPage(false); } + /** + * 解析章节并跳转到最后一页 + */ + protected void openChapterInLastPage() { + if (parseCurChapter()) { + mCurPage = getCurPage(getAllPagePos() - 1); + } else { + mCurPage = new TxtPage(); + } + mPageView.drawCurPage(false); + } + public void chapterError() { //加载错误 mStatus = STATUS_ERROR; @@ -839,12 +852,6 @@ public abstract class PageLoader { */ public abstract boolean hasChapterData(Chapter chapter); - - /** - * - */ - public abstract void getChapterContent(Chapter chapter); - /***********************************default method***********************************************/ void drawPage(Bitmap bitmap, boolean isUpdate) { @@ -1985,6 +1992,14 @@ public abstract class PageLoader { return null; } + public boolean isPrev() { + return isPrev; + } + + public void setPrev(boolean prev) { + isPrev = prev; + } + /*****************************************interface*****************************************/ public interface OnPageChangeListener { @@ -1995,13 +2010,6 @@ public abstract class PageLoader { */ void onChapterChange(int pos); - /** - * 作用:请求加载章节内容 - * - * @param requestChapters:需要下载的章节列表 - */ - void requestChapters(List requestChapters); - /** * 作用:章节目录加载完成时候回调 * diff --git a/app/src/main/res/drawable/ic_group.xml b/app/src/main/res/drawable/ic_group.xml index 0ebcd45..a82d798 100644 --- a/app/src/main/res/drawable/ic_group.xml +++ b/app/src/main/res/drawable/ic_group.xml @@ -6,15 +6,15 @@ android:viewportHeight="24"> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_bookcase.xml b/app/src/main/res/layout/fragment_bookcase.xml index b5550b4..094e83d 100644 --- a/app/src/main/res/layout/fragment_bookcase.xml +++ b/app/src/main/res/layout/fragment_bookcase.xml @@ -1,148 +1,147 @@ - + + + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:scrollbars="none"> + android:id="@+id/ll_no_data_tips" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerInParent="true" + android:gravity="center" + android:orientation="vertical" + android:padding="10dp" + android:visibility="gone"> + android:layout_width="100dp" + android:layout_height="100dp" + app:srcCompat="@drawable/ic_vector_add_bookcase" + app:tint="@color/textSecondary" /> + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="10dp" + android:text="当前无任何书籍,点击添加" + android:textColor="@color/textSecondary" + android:textSize="16sp" /> - + android:id="@+id/gv_book" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_above="@+id/rl_book_edit" + android:layout_alignParentTop="true" + android:columnWidth="100dp" + android:gravity="center" + android:horizontalSpacing="10dp" + android:listSelector="@android:color/transparent" + android:numColumns="auto_fit" + android:scrollbars="none" + android:verticalSpacing="10dp" /> + android:id="@+id/rl_download_tip" + android:layout_width="match_parent" + android:layout_height="39dp" + android:layout_alignParentBottom="true" + android:background="@color/colorForeground" + android:visibility="gone"> + android:id="@+id/pb_download" + style="?android:attr/progressBarStyleHorizontal" + android:layout_width="match_parent" + android:layout_height="4dp" + android:layout_alignParentTop="true" + android:max="100" /> + android:id="@+id/tv_download_tip" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:gravity="center_vertical|start" + android:maxLines="1" + android:paddingStart="15dp" + android:text="正在初始化..." + android:textColor="@color/textSecondary" + android:textSize="14sp" /> + android:id="@+id/tv_stop_download" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_alignParentEnd="true" + android:gravity="center_vertical" + android:paddingStart="15dp" + android:paddingEnd="15dp" + android:text="@string/stop_download_tip" + android:textColor="@color/colorAccent" + android:textSize="14sp" + android:visibility="gone" /> + android:id="@+id/rl_book_edit" + android:layout_width="match_parent" + android:layout_height="52dp" + android:layout_alignParentBottom="true" + android:background="@color/colorForeground" + android:gravity="center_vertical" + android:paddingEnd="10dp" + android:visibility="gone"> + android:id="@+id/book_selected_all" + android:layout_width="120dp" + android:layout_height="40dp" + android:layout_centerVertical="true" + android:layout_marginStart="15dp" + android:text="全选" + android:textColor="@color/textSecondary" + android:textSize="15dp" + android:theme="@style/MyCheckBox" />