diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml new file mode 100644 index 0000000..5367e8e --- /dev/null +++ b/.idea/assetWizardSettings.xml @@ -0,0 +1,32 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 9f2d6c6..0ee8e03 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,6 +3,10 @@ diff --git a/app/src/main/java/xyz/fycz/myreader/ui/adapter/BookMarkAdapter.java b/app/src/main/java/xyz/fycz/myreader/ui/adapter/BookMarkAdapter.java index dad8fa8..5d567ca 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/adapter/BookMarkAdapter.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/adapter/BookMarkAdapter.java @@ -67,7 +67,6 @@ public class BookMarkAdapter extends ArrayAdapter { viewHolder = new ViewHolder(); convertView = LayoutInflater.from(getContext()).inflate(mResourceId,null); viewHolder.tvTitle = (TextView) convertView.findViewById(R.id.tv_chapter_title); - viewHolder.vLine = (View) convertView.findViewById(R.id.v_line); convertView.setTag(viewHolder); }else { viewHolder = (ViewHolder) convertView.getTag(); @@ -78,14 +77,7 @@ public class BookMarkAdapter extends ArrayAdapter { private void initView(int postion,final ViewHolder viewHolder){ final BookMark bookMark = getItem(postion); - assert bookMark != null; viewHolder.tvTitle.setText(String.format("%s[%s]", bookMark.getTitle(), bookMark.getBookMarkReadPosition() + 1)); - if (ChapterService.isChapterCached(bookMark)){ - viewHolder.tvTitle.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(getContext(), R.drawable.selector_category_load),null,null,null); - } else { - viewHolder.tvTitle.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(getContext(),R.drawable.selector_category_unload),null,null,null); - } - viewHolder.tvTitle.setTextColor(getContext().getResources().getColor(R.color.textSecondary)); /*if (!setting.isDayStyle()) { viewHolder.tvTitle.setTextColor(getContext().getResources().getColor(R.color.sys_night_word)); viewHolder.vLine.setBackground(getContext().getDrawable(R.color.sys_dialog_setting_line)); @@ -134,9 +126,7 @@ public class BookMarkAdapter extends ArrayAdapter { } class ViewHolder{ - TextView tvTitle; - View vLine; } } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/adapter/ChapterTitleAdapter.java b/app/src/main/java/xyz/fycz/myreader/ui/adapter/ChapterTitleAdapter.java index 8e115b3..40cfa40 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/adapter/ChapterTitleAdapter.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/adapter/ChapterTitleAdapter.java @@ -19,12 +19,15 @@ package xyz.fycz.myreader.ui.adapter; import android.content.Context; +import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Filter; +import android.widget.ImageView; import android.widget.TextView; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; @@ -37,7 +40,6 @@ import xyz.fycz.myreader.greendao.entity.Chapter; import xyz.fycz.myreader.greendao.service.ChapterService; import java.util.ArrayList; -import java.util.Collections; import java.util.List; @@ -73,7 +75,8 @@ public class ChapterTitleAdapter extends ArrayAdapter { viewHolder = new ViewHolder(); convertView = LayoutInflater.from(getContext()).inflate(mResourceId, null); viewHolder.tvTitle = (TextView) convertView.findViewById(R.id.tv_chapter_title); - viewHolder.vLine = (View) convertView.findViewById(R.id.v_line); + viewHolder.tvTag = (TextView) convertView.findViewById(R.id.tv_tag); + viewHolder.ivIcon = (ImageView) convertView.findViewById(R.id.iv_icon); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); @@ -86,21 +89,30 @@ public class ChapterTitleAdapter extends ArrayAdapter { final Chapter chapter = getItem(postion); // viewHolder.tvTitle.setText("【" + chapter.getTitle() + "】"); viewHolder.tvTitle.setText(chapter.getTitle()); + //viewHolder.ivIcon.setImageResource(R.drawable.ic_cloud_download); if (ChapterService.isChapterCached(chapter) || chapter.getEnd() > 0) { - viewHolder.tvTitle.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(getContext(),R.drawable.selector_category_load), null, null, null); + viewHolder.ivIcon.setVisibility(View.GONE); + viewHolder.tvTitle.setTextColor(getContext().getResources().getColor(R.color.textPrimary)); } else { - viewHolder.tvTitle.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(getContext(),R.drawable.selector_category_unload), null, null, null); + viewHolder.ivIcon.setVisibility(View.VISIBLE); + viewHolder.tvTitle.setTextColor(getContext().getResources().getColor(R.color.textSecondary)); } - viewHolder.tvTitle.setTextColor(getContext().getResources().getColor(R.color.textSecondary)); /*if (!setting.isDayStyle()) { viewHolder.tvTitle.setTextColor(getContext().getResources().getColor(R.color.sys_night_word)); viewHolder.vLine.setBackground(getContext().getDrawable(R.color.sys_dialog_setting_line)); }else { viewHolder.tvTitle.setTextColor(getContext().getColor(R.color.title_black)); }*/ - + if (TextUtils.isEmpty(chapter.getUpdateTime())) { + viewHolder.tvTag.setVisibility(View.GONE); + } else { + viewHolder.tvTag.setText(chapter.getUpdateTime()); + viewHolder.tvTag.setVisibility(View.VISIBLE); + } if (chapter.getNumber() == mBook.getHisttoryChapterNum()) { viewHolder.tvTitle.setTextColor(getContext().getResources().getColor(R.color.colorAccent)); + /*viewHolder.ivIcon.setImageResource(R.drawable.ic_check); + viewHolder.ivIcon.setVisibility(View.VISIBLE);*/ } } @@ -152,7 +164,8 @@ public class ChapterTitleAdapter extends ArrayAdapter { class ViewHolder { TextView tvTitle; - View vLine; + TextView tvTag; + ImageView ivIcon; } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/CatalogHolder.java b/app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/CatalogHolder.java index d73b67d..23156c0 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/CatalogHolder.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/CatalogHolder.java @@ -36,7 +36,7 @@ public class CatalogHolder extends ViewHolderImpl { private TextView tvTitle; @Override protected int getItemLayoutId() { - return R.layout.listview_chapter_title_item; + return R.layout.item_chapter; } @Override @@ -46,11 +46,6 @@ public class CatalogHolder extends ViewHolderImpl { @Override public void onBind(RecyclerView.ViewHolder holder, Chapter data, int pos) { - if (ChapterService.isChapterCached(data) || data.getEnd() > 0) { - tvTitle.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(getContext(),R.drawable.selector_category_load), null, null, null); - } else { - tvTitle.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(getContext(),R.drawable.selector_category_unload), null, null, null); - } tvTitle.setText(data.getTitle()); } } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/FindBookHolder.java b/app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/FindBookHolder.java index 56c3783..35f5584 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/FindBookHolder.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/adapter/holder/FindBookHolder.java @@ -49,6 +49,7 @@ import xyz.fycz.myreader.webapi.BookApi; import xyz.fycz.myreader.webapi.crawler.ReadCrawlerUtil; import xyz.fycz.myreader.webapi.crawler.base.BookInfoCrawler; import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler; +import xyz.fycz.myreader.webapi.crawler.source.ThirdCrawler; import xyz.fycz.myreader.widget.CoverImageView; /** @@ -96,7 +97,7 @@ public class FindBookHolder extends ViewHolderImpl { tvBookName.setText(data.getName()); if (!StringHelper.isEmpty(data.getAuthor())) { tvAuthor.setText(data.getAuthor()); - }else { + } else { tvAuthor.setText(""); } initTagList(data); @@ -114,7 +115,7 @@ public class FindBookHolder extends ViewHolderImpl { } if (!StringHelper.isEmpty(source.getSourceName()) && !"未知书源".equals(source.getSourceName())) tvSource.setText(String.format("书源:%s", source.getSourceName())); - if (needGetInfo(data) && rc instanceof BookInfoCrawler) { + if (!(rc instanceof ThirdCrawler) && rc instanceof BookInfoCrawler && needGetInfo(data)) { Log.i(data.getName(), "initOtherInfo"); BookInfoCrawler bic = (BookInfoCrawler) rc; BookApi.getBookInfo(data, bic).compose(RxUtils::toSimpleSingle) @@ -163,6 +164,7 @@ public class FindBookHolder extends ViewHolderImpl { tflBookTag.setAdapter(new BookTagAdapter(getContext(), tagList, 11)); } } + private boolean needGetInfo(Book bookBean) { if (StringHelper.isEmpty(bookBean.getAuthor())) return true; if (StringHelper.isEmpty(bookBean.getType())) return true; @@ -170,10 +172,11 @@ public class FindBookHolder extends ViewHolderImpl { if (StringHelper.isEmpty(bookBean.getNewestChapterTitle())) return true; return StringHelper.isEmpty(bookBean.getImgUrl()); } + /** * Here is the key method to apply the animation */ - protected void setAnimation(View viewToAnimate, int position){ + protected void setAnimation(View viewToAnimate, int position) { // If the bound view wasn't previously displayed on screen, it's animated Animation animation = AnimationUtils.loadAnimation(viewToAnimate.getContext(), R.anim.anim_recycle_item); diff --git a/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookMarkPresenter.java b/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookMarkPresenter.java index b3ad661..ed396bc 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookMarkPresenter.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookMarkPresenter.java @@ -21,7 +21,6 @@ package xyz.fycz.myreader.ui.presenter; import android.app.Activity; import android.content.Intent; import xyz.fycz.myreader.R; -import xyz.fycz.myreader.application.SysManager; import xyz.fycz.myreader.base.BasePresenter; import xyz.fycz.myreader.common.APPCONST; import xyz.fycz.myreader.greendao.entity.Book; @@ -74,7 +73,7 @@ public class BookMarkPresenter implements BasePresenter { private void initBookMarkList() { mBookMarks = (ArrayList) mBookMarkService.findBookAllBookMarkByBookId(mBook.getId()); - mBookMarkAdapter = new BookMarkAdapter(mBookMarkFragment.getActivity(), R.layout.listview_chapter_title_item, mBookMarks); + mBookMarkAdapter = new BookMarkAdapter(mBookMarkFragment.getActivity(), R.layout.item_chapter, mBookMarks); mBookMarkFragment.getLvBookmarkList().setAdapter(mBookMarkAdapter); } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/presenter/CatalogPresenter.java b/app/src/main/java/xyz/fycz/myreader/ui/presenter/CatalogPresenter.java index 07fcba4..ba3123e 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/presenter/CatalogPresenter.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/presenter/CatalogPresenter.java @@ -24,7 +24,6 @@ import android.view.View; import org.jetbrains.annotations.NotNull; -import io.reactivex.disposables.Disposable; import xyz.fycz.myreader.R; import xyz.fycz.myreader.application.App; import xyz.fycz.myreader.base.BasePresenter; @@ -137,7 +136,7 @@ public class CatalogPresenter implements BasePresenter { //设置布局管理器 int curChapterPosition; curChapterPosition = mBook.getHisttoryChapterNum(); - mChapterTitleAdapter = new ChapterTitleAdapter(mCatalogFragment.getContext(), R.layout.listview_chapter_title_item, mChapters, mBook); + mChapterTitleAdapter = new ChapterTitleAdapter(mCatalogFragment.getContext(), R.layout.item_chapter, mChapters, mBook); mCatalogFragment.getLvChapterList().setAdapter(mChapterTitleAdapter); mCatalogFragment.getLvChapterList().setSelection(curChapterPosition); } diff --git a/app/src/main/res/drawable/ic_cloud_download.xml b/app/src/main/res/drawable/ic_cloud_download.xml new file mode 100644 index 0000000..ffd5f56 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud_download.xml @@ -0,0 +1,33 @@ + + + + + + + diff --git a/app/src/main/res/layout/item_chapter.xml b/app/src/main/res/layout/item_chapter.xml new file mode 100644 index 0000000..454eb29 --- /dev/null +++ b/app/src/main/res/layout/item_chapter.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_book_detail_content.xml b/app/src/main/res/layout/layout_book_detail_content.xml index a1d9970..364323c 100644 --- a/app/src/main/res/layout/layout_book_detail_content.xml +++ b/app/src/main/res/layout/layout_book_detail_content.xml @@ -64,7 +64,7 @@ android:id="@+id/book_detail_tv_catalog" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="15dp" + android:padding="12dp" android:text="最新章节" android:textColor="@color/textPrimary" android:textSize="15sp" /> @@ -73,8 +73,8 @@ android:id="@+id/book_detail_tv_catalog_more" android:layout_width="match_parent" android:layout_height="wrap_content" - android:gravity="right" - android:padding="15dp" + android:gravity="end" + android:padding="12dp" android:text="更多" android:textColor="@color/textSecondary" android:textSize="15sp" /> @@ -84,7 +84,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/book_detail_tv_catalog" - android:foregroundGravity="center" /> + android:foregroundGravity="center" + android:paddingHorizontal="4dp" /> - - - - - - - - \ No newline at end of file