pull/5/head
fengyuecanzhu 4 years ago
parent dae4748674
commit 9411c907a0
  1. 4
      app/src/main/java/xyz/fycz/myreader/common/APPCONST.java
  2. 32
      app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java
  3. 3
      app/src/main/java/xyz/fycz/myreader/ui/activity/BookInfoEditActivity.java
  4. 2
      app/src/main/java/xyz/fycz/myreader/ui/activity/BookstoreActivity.java
  5. 3
      app/src/main/java/xyz/fycz/myreader/ui/activity/CatalogActivity.java
  6. 3
      app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java
  7. 7
      app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java
  8. 5
      app/src/main/java/xyz/fycz/myreader/ui/adapter/BookcaseDetailedAdapter.java
  9. 5
      app/src/main/java/xyz/fycz/myreader/ui/adapter/BookcaseDragAdapter.java

@ -47,12 +47,8 @@ public class APPCONST {
public static final String THIRD_SOURCE = "ThirdSource";
public static final String DATA_KEY = "data_key";
public static final String BOOK = "book";
public static final String TITLE = "title";
public static final String FIND_CRAWLER = "findCrawler";
public static final String CHAPTER_PAGE = "chapter_page";
public static final String SETTING = "setting";
public static final String SEARCH_BOOK_BEAN = "SearchBookBean";
public static final String SOURCE_INDEX = "sourceIndex";
public static final String FONT = "font";
public static final String BOOK_SOURCE = "bookSource";

@ -156,16 +156,10 @@ public class BookDetailedActivity extends BaseActivity {
super.initData(savedInstanceState);
mBookService = BookService.getInstance();
mChapterService = ChapterService.getInstance();
aBooks = (ArrayList<Book>) BitIntentDataManager.getInstance().getData(getIntent());
sourceIndex = getIntent().getIntExtra(APPCONST.SOURCE_INDEX, 0);
if (aBooks != null) {
mBook = aBooks.get(sourceIndex);
} else {
mBook = (Book) getIntent().getSerializableExtra(APPCONST.BOOK);
}
if (mBook == null) {
if (!initBook()){
ToastUtils.showError("无法获取书籍!");
finish();
return;
}
isCollected = isBookCollected();
if (isCollected) {
@ -183,6 +177,21 @@ public class BookDetailedActivity extends BaseActivity {
mReadCrawler = ReadCrawlerUtil.getReadCrawler(mBook.getSource());
}
private boolean initBook() {
Object obj = BitIntentDataManager.getInstance().getData(getIntent());
sourceIndex = getIntent().getIntExtra(APPCONST.SOURCE_INDEX, 0);
if (obj == null) {
return false;
}
if (obj instanceof Book) {
mBook = (Book) obj;
} else if (obj instanceof List) {
aBooks = (ArrayList<Book>) obj;
mBook = aBooks.get(sourceIndex);
}
return mBook != null;
}
private void initTagList() {
tagList.clear();
String type = mBook.getType();
@ -376,8 +385,7 @@ public class BookDetailedActivity extends BaseActivity {
*/
public void goToMoreChapter() {
Intent intent = new Intent(this, CatalogActivity.class);
intent.putExtra(APPCONST.BOOK, mBook);
//BitIntentDataManager.getInstance().putData(intent, mBook);
BitIntentDataManager.getInstance().putData(intent, mBook);
startActivityForResult(intent, APPCONST.REQUEST_CHAPTER_PAGE);
}
@ -560,7 +568,7 @@ public class BookDetailedActivity extends BaseActivity {
mBookService.addBook(mBook);
}
Intent intent = new Intent(this, ReadActivity.class);
intent.putExtra(APPCONST.BOOK, mBook);
BitIntentDataManager.getInstance().putData(intent, mBook);
intent.putExtra("isCollected", isCollected);
startActivityForResult(intent, APPCONST.REQUEST_READ);
}
@ -628,7 +636,7 @@ public class BookDetailedActivity extends BaseActivity {
break;
case R.id.action_edit:
Intent editIntent = new Intent(this, BookInfoEditActivity.class);
editIntent.putExtra(APPCONST.BOOK, mBook);
BitIntentDataManager.getInstance().putData(editIntent, mBook);
startActivityForResult(editIntent, APPCONST.REQUEST_EDIT_BOOK);
break;
case R.id.action_reload: //重新加载

@ -11,6 +11,7 @@ import androidx.appcompat.widget.Toolbar;
import xyz.fycz.myreader.R;
import xyz.fycz.myreader.application.App;
import xyz.fycz.myreader.base.BaseActivity;
import xyz.fycz.myreader.base.BitIntentDataManager;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.databinding.ActivityBookInfoEditBinding;
import xyz.fycz.myreader.greendao.entity.Book;
@ -54,7 +55,7 @@ public class BookInfoEditActivity extends BaseActivity {
@Override
protected void initData(Bundle savedInstanceState) {
super.initData(savedInstanceState);
mBook = (Book) getIntent().getSerializableExtra(APPCONST.BOOK);
mBook = (Book) BitIntentDataManager.getInstance().getData(getIntent());
if (mBook == null) {
ToastUtils.showError("未读取到书籍信息");
finish();

@ -362,7 +362,7 @@ public class BookstoreActivity extends BaseActivity {
*/
private void goToBookDetail(Book book) {
Intent intent = new Intent(this, BookDetailedActivity.class);
intent.putExtra(APPCONST.BOOK, book);
BitIntentDataManager.getInstance().putData(intent, book);
BookstoreActivity.this.startActivity(intent);
}

@ -10,6 +10,7 @@ import androidx.appcompat.widget.Toolbar;
import xyz.fycz.myreader.R;
import xyz.fycz.myreader.base.BaseActivity;
import xyz.fycz.myreader.base.BitIntentDataManager;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.databinding.ActivityCatalogBinding;
import xyz.fycz.myreader.greendao.entity.Book;
@ -48,7 +49,7 @@ public class CatalogActivity extends BaseActivity {
@Override
protected void initData(Bundle savedInstanceState) {
super.initData(savedInstanceState);
mBook = (Book) getIntent().getSerializableExtra(APPCONST.BOOK);
mBook = (Book) BitIntentDataManager.getInstance().getData(getIntent());
}

@ -31,6 +31,7 @@ import xyz.fycz.myreader.R;
import xyz.fycz.myreader.application.App;
import xyz.fycz.myreader.application.SysManager;
import xyz.fycz.myreader.base.BaseActivity;
import xyz.fycz.myreader.base.BitIntentDataManager;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.databinding.ActivityMainBinding;
import xyz.fycz.myreader.entity.SharedBook;
@ -363,7 +364,7 @@ public class MainActivity extends BaseActivity {
if (sharedBook != null && !StringHelper.isEmpty(sharedBook.getChapterUrl())) {
Book book = SharedBook.sharedBookToBook(sharedBook);
Intent intent = new Intent(this, BookDetailedActivity.class);
intent.putExtra(APPCONST.BOOK, book);
BitIntentDataManager.getInstance().putData(intent, book);
startActivity(intent);
} else {
ToastUtils.showError("书籍加载失败");

@ -54,6 +54,7 @@ import xyz.fycz.myreader.R;
import xyz.fycz.myreader.application.App;
import xyz.fycz.myreader.application.SysManager;
import xyz.fycz.myreader.base.BaseActivity;
import xyz.fycz.myreader.base.BitIntentDataManager;
import xyz.fycz.myreader.base.observer.MyObserver;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.common.URLCONST;
@ -480,8 +481,8 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
mBook = bookTem;
toggleMenu(true);
Intent intent = new Intent(this, ReadActivity.class)
.putExtra(APPCONST.BOOK, mBook)
.putExtra("hasChangeSource", true);
BitIntentDataManager.getInstance().putData(intent, mBook);
if (!isCollected) {
intent.putExtra("isCollected", false);
}
@ -536,7 +537,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
//跳转
mHandler.postDelayed(() -> {
Intent intent = new Intent(this, CatalogActivity.class);
intent.putExtra(APPCONST.BOOK, mBook);
BitIntentDataManager.getInstance().putData(intent, mBook);
this.startActivityForResult(intent, APPCONST.REQUEST_CHAPTER_PAGE);
}, mBottomOutAnim.getDuration());
});
@ -909,7 +910,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
addLocalBook(path);
} else {
//路径为空,说明不是直接打开txt文件
mBook = (Book) getIntent().getSerializableExtra(APPCONST.BOOK);
mBook = (Book) BitIntentDataManager.getInstance().getData(getIntent());
//mBook为空,说明是从快捷方式启动
if (mBook == null) {
String bookId = SharedPreUtils.getInstance().getString(getString(R.string.lastRead), "");

@ -15,6 +15,7 @@ import java.util.ArrayList;
import xyz.fycz.myreader.R;
import xyz.fycz.myreader.application.App;
import xyz.fycz.myreader.base.BitIntentDataManager;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.ui.activity.ReadActivity;
import xyz.fycz.myreader.ui.dialog.DialogCreator;
@ -128,13 +129,13 @@ public class BookcaseDetailedAdapter extends BookcaseAdapter {
}
viewHolder.llBookRead.setOnClickListener(v -> {
Intent intent = new Intent(mContext, ReadActivity.class);
intent.putExtra(APPCONST.BOOK, book);
BitIntentDataManager.getInstance().putData(intent, book);
mBookService.updateEntity(book);
mContext.startActivity(intent);
});
viewHolder.ivBookImg.setOnClickListener(v -> {
Intent intent = new Intent(mContext, BookDetailedActivity.class);
intent.putExtra(APPCONST.BOOK, book);
BitIntentDataManager.getInstance().putData(intent, book);
mContext.startActivity(intent);
});
viewHolder.llBookRead.setOnLongClickListener(v -> {

@ -13,6 +13,7 @@ import java.util.ArrayList;
import xyz.fycz.myreader.R;
import xyz.fycz.myreader.application.App;
import xyz.fycz.myreader.base.BitIntentDataManager;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.ui.activity.ReadActivity;
import xyz.fycz.myreader.ui.dialog.DialogCreator;
@ -110,7 +111,7 @@ public class BookcaseDragAdapter extends BookcaseAdapter {
}
viewHolder.ivBookImg.setOnClickListener(v -> {
Intent intent = new Intent(mContext, ReadActivity.class);
intent.putExtra(APPCONST.BOOK, book);
BitIntentDataManager.getInstance().putData(intent, book);
mBookService.updateEntity(book);
mContext.startActivity(intent);
});
@ -122,7 +123,7 @@ public class BookcaseDragAdapter extends BookcaseAdapter {
switch (which) {
case 0:
Intent intent = new Intent(mContext, BookDetailedActivity.class);
intent.putExtra(APPCONST.BOOK, book);
BitIntentDataManager.getInstance().putData(intent, book);
mContext.startActivity(intent);
break;
case 1:

Loading…
Cancel
Save