hardworking

This commit is contained in:
mwang 2019-04-10 22:19:06 +08:00
parent c2d52b7588
commit d57aab3251
32 changed files with 730 additions and 191 deletions

View File

@ -2,7 +2,7 @@
<litepal>
<dbname value="book" ></dbname>
<version value="1" ></version>
<version value="2" ></version>
<list>
<mapping class="com.novelbook.android.db.Chapter"></mapping>

View File

@ -33,6 +33,7 @@ import com.novelbook.android.filechooser.FileChooserActivity;
import com.novelbook.android.netsubscribe.BookSubscribe;
import com.novelbook.android.netsubscribe.MovieSubscribe;
import com.novelbook.android.netutils.HttpMethods;
import com.novelbook.android.netutils.NetUtil;
import com.novelbook.android.netutils.OnSuccessAndFaultListener;
import com.novelbook.android.netutils.OnSuccessAndFaultSub;
@ -70,7 +71,7 @@ import static com.novelbook.android.FileActivity.EXTERNAL_STORAGE_REQ_CODE;
public class BookActivity extends Activity_base {
private PageFactory pageFactory;
int novelId = 31590;
int novelId = 0;
// String muluUrl = "https://www.qu.la/book/390/";
private Novel mNovel;
private Chapter mChapter;
@ -141,13 +142,13 @@ public class BookActivity extends Activity_base {
});
}
public final static String EXTRA_BOOK ="book";
@Override
protected void setTitle() {
// String title = getIntent().getStringExtra("BOOKNAME");
// this.setTitle(title);
int bookId = getIntent().getIntExtra("bookId", 0);
// this.setTitle("bookName");
mNovel = (Novel) getIntent().getSerializableExtra(EXTRA_BOOK);
novelId = mNovel.getNovelId();
this.setTitle(mNovel.getName());
}
@ -160,22 +161,27 @@ public class BookActivity extends Activity_base {
}
pageFactory = PageFactory.getInstance();
setBookInfo();//set title ,data from novel list
if (mNovel == null) {
getBookInfo();
}
getBookInfo();
mData = getFakeData(5);
mAdapter = getBookListAdapter(mData);
}
/**
* 设置book list 传过来的基本信息
*/
private void setBookInfo() {
}
private MyImageLoader loader = new MyImageLoader();
/**
* 设置服务器传来的详细信息
*/
public void setBookDetailInfo() {
setShelfButtonText();
this.setTitle(mNovel.getName());//why not apply
//this.setTitle(mNovel.getName());//why not apply
this.txtAuth.setText(mNovel.getAuthor());
this.txtCategory.setText(mNovel.getNovelType());
this.txtDesc.setText(mNovel.getDesc ());
@ -187,16 +193,7 @@ public class BookActivity extends Activity_base {
}
if (!TextUtils.isEmpty(mNovel.getCover())) {
String cover =mNovel.getCover();
if(!TextUtils.isEmpty(cover) ){
if(cover.startsWith("//")){
cover ="http:"+cover;
}
}
loader.displayImage(BookActivity.this, cover, imageView);
}
loader.displayImage(BookActivity.this, NetUtil.getCoverUrl(mNovel.getCover()), imageView);
}
@ -205,7 +202,7 @@ public class BookActivity extends Activity_base {
btnShelf.setText(title);
}
@OnClick({R.id.btnRead, R.id.btnCacheBook, R.id.btnShelf})
@OnClick({R.id.btnRead, R.id.btnCacheBook, R.id.btnShelf,R.id.llCate})
void submitButton(View view) {
switch (view.getId()) {
@ -222,7 +219,10 @@ public class BookActivity extends Activity_base {
case R.id.btnShelf:
shelfBook();
break;
case R.id.llCate:
Intent intent = new Intent(BookActivity.this, MarkActivity.class);
startActivity(intent);;
break;
}
}

View File

@ -28,6 +28,7 @@ import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.Gson;
import com.novelbook.android.Activity_base;
import com.novelbook.android.Activity_paihangbang;
import com.novelbook.android.Activity_shudan;
import com.novelbook.android.BookActivity;
@ -126,6 +127,7 @@ public abstract class BasicFragment extends Fragment {
for (int i = 'A'; i < x; i++)
{
Novel bk = new Novel();
bk.setNovelId(i);
bk.setAuthor("金庸");
bk.setName("射雕英雄传" +(char)i);
bk.setNovelType("武侠");
@ -135,9 +137,9 @@ public abstract class BasicFragment extends Fragment {
return mDatas;
}
void showBookDetail(int id) {
void showBookDetail(Novel book) {
Intent intent = new Intent(activity, BookActivity.class);
intent.putExtra("bookId",id);
intent.putExtra(BookActivity.EXTRA_BOOK,book);
startActivity(intent);
}
@ -157,8 +159,14 @@ public abstract class BasicFragment extends Fragment {
nv= LitePal.find(Novel.class,id);
PageFactory.getInstance().prepareBook(nv ); //打开本地小说内容
ReadActivity.openBook(nv ,activity);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
ReadActivity.openBook(novel ,activity);
}
@ -167,11 +175,17 @@ public abstract class BasicFragment extends Fragment {
//失败
Toast.makeText(getActivity(),"Novel 请求失败:"+errorMsg,Toast.LENGTH_SHORT).show();
PageFactory.getInstance().prepareBook(novel ); //打开本地小说内容
ReadActivity.openBook(novel ,activity);
ReadActivity.openBook(novel ,activity);
}
},getActivity()));
}
void showProgressDialog(boolean flag,String msg){
((Activity_base) getActivity()).showProgress(flag,msg);
}
void hideProgress(){
((Activity_base) getActivity()).hideProgress();
}
void openBook(Novel book, BookListAdapter mAdapter) {
//从新从数据库抓取该书的最新阅读进度
@ -184,8 +198,25 @@ public abstract class BasicFragment extends Fragment {
Toast.makeText(activity, book.getName() + "加载", Toast.LENGTH_SHORT).show();
if(!book.isLocalBook()){
getBookInfo(book);
/*
PageFactory pageFactory = PageFactory.getInstance();
showProgressDialog(false,"读取目录信息");
int slept = 0;
while(slept <100 || pageFactory.getChapters() == null || pageFactory.getChapters().size()==0){
try {
Thread.sleep(50);
slept++;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
hideProgress();
*/
//ReadActivity.openBook(book ,activity);
return;
}

View File

@ -58,7 +58,7 @@ public class BookMarkFragment extends BasicFragment {
lv_bookmark.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
pageFactory.changeChapter(position+1);
pageFactory.openBookmark(bookMarksList.get(position).getChapt(),bookMarksList.get(position).getBegin());
getActivity().finish();
}
});

View File

@ -10,8 +10,10 @@ import android.widget.AdapterView;
import android.widget.ListView;
import com.novelbook.android.R;
import com.novelbook.android.ReadActivity;
import com.novelbook.android.adapter.CatalogueAdapter;
import com.novelbook.android.db.Chapter;
import com.novelbook.android.db.Novel;
import com.novelbook.android.utils.PageFactory;
@ -65,6 +67,15 @@ public class CatalogFragment extends BasicFragment {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
showProgressDialog();
if(pageFactory.getPageWidget()==null){
Novel novel = pageFactory.getNovle();
if(novel!=null){
novel.setLastReadChapt(position+1);
novel.setLastReadPos(1);
ReadActivity.openBook(novel,getActivity());
}
}else
pageFactory.changeChapter(position+1);
dismissProgressDialog();
getActivity().finish();
@ -75,7 +86,7 @@ public class CatalogFragment extends BasicFragment {
@Override
protected void initViews() {
CatalogueAdapter catalogueAdapter = new CatalogueAdapter(getContext(), catalogueList);
catalogueAdapter.setCharter(pageFactory.getCurrentCharter());
catalogueAdapter.setCharter(pageFactory.getCurrentChapter());
lv_catalogue.setAdapter(catalogueAdapter);
catalogueAdapter.notifyDataSetChanged();
}

View File

@ -10,6 +10,7 @@ import android.support.annotation.Nullable;
import android.support.design.widget.BottomSheetDialog;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -25,6 +26,8 @@ import com.novelbook.android.R;
import com.novelbook.android.db.Novel;
import com.novelbook.android.filechooser.FileChooserActivity;
import com.novelbook.android.netutils.NetUtil;
import com.novelbook.android.utils.MyImageLoader;
import com.novelbook.android.utils.OnItemClickListener;
import com.novelbook.android.adapter.BookListAdapter;
@ -47,7 +50,7 @@ public class Fragment_Shelf extends BasicFragment {
private boolean[] flag ;//此处添加一个boolean类型的数组
private boolean isSelectAll =true;
private MyImageLoader loader = new MyImageLoader();
@BindView(R.id.llShelfBottom)
LinearLayout llShelfBottom;
@BindView(R.id.id_recyclerview)
@ -82,12 +85,12 @@ public class Fragment_Shelf extends BasicFragment {
@Override
public void initData() {
flag = new boolean[100];
// mDatas = initData(mDatas,'X');
// bookLists = LitePal.where("isOnShelf=? or novelId=? ","1","").find(Novel.class);
bookLists = LitePal.where("isOnShelf=? ","1" ).find(Novel.class);
bookLists = Novel.getNovelsOnShelf();
flag = new boolean[bookLists.size()];
mAdapter = new BookListAdapter(activity,bookLists,R.layout.recycle_list_item,new OnItemClickListener()
{
@ -118,37 +121,13 @@ public class Fragment_Shelf extends BasicFragment {
}
@Override
public void initViews(){
initData();
initReceyleView();
}
/*
@Override
public void onHiddenChanged(boolean hidden) {
super.onHiddenChanged(hidden);
if(hidden){
//pause
}else{
bookLists = LitePal.findAll(Novel.class);
mAdapter.notifyDataSetChanged();
}
}
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
//相当于Fragment的onResume为true时Fragment已经可见
bookLists = LitePal.findAll(Novel.class);
mAdapter.notifyDataSetChanged();
} else {
//相当于Fragment的onPause为false时Fragment不可见
}
}
*/
public void initReceyleView() {
initData();
// mRecyclerView.setLayoutManager(new LinearLayoutManager(this.activity));
mRecyclerView.setLayoutManager(new GridLayoutManager(activity,3));
mRecyclerView.setAdapter(mAdapter );
@ -228,13 +207,38 @@ public class Fragment_Shelf extends BasicFragment {
isSelectAll =!isSelectAll;
mChkAdapter.notifyDataSetChanged();
}else if(view.getId()== R.id.btnDelete){
List<Integer> toRemove = new ArrayList<Integer>();
for (int i = 0; i < bookLists.size(); i++) {
if(flag[i] ){
bookLists.get(i).delete();
bookLists.remove(i);
Novel nv = bookLists.get(i);
if(nv.isLocalBook())
{
nv.delete();
//TODO: remove cache on a new thread
//Fileutil.deleteDir(file)
}else{
nv.setOnShelf(false);
nv.save();
// nv.update(nv.getId()); //not work,,,If you set a default value to a field, the corresponding column won't be updated.
}
// flag = new boolean[bookLists.size()];
// bookLists.remove(i);
}
}
mChkAdapter.notifyDataSetChanged();
/*for (int i = 0; i < bookLists.size(); i++) {
if (flag[i]) {
bookLists.remove(i);
flag[i] =false;
}
}
*/
bookLists =Novel.getNovelsOnShelf();
flag = new boolean[bookLists.size()];
zhengliShelf();
initData();
// mChkAdapter.notifyDataSetChanged();
}
}
@ -246,64 +250,13 @@ public class Fragment_Shelf extends BasicFragment {
Main2Activity main2Activity = (Main2Activity)activity;
main2Activity.switchShelfZhengli(false);
/*
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this.activity);
bottomSheetDialog.setContentView(R.layout.fragment_shelf_zhengli_sheet);
//给布局设置透明背景色
bottomSheetDialog.getDelegate().findViewById(android.support.design.R.id.design_bottom_sheet)
.setBackgroundColor(getResources().getColor(android.R.color.transparent));
Button btnSelectAll = bottomSheetDialog.findViewById(R.id.btnSelect);
btnSelectAll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
isSelectAll =!isSelectAll;
if(isSelectAll) {
btnSelectAll.setText("全选");
}else
{
btnSelectAll.setText("全不选");
}
for (int i = 0; i < flag.length; i++) {
flag[i] = isSelectAll;
}
mChkAdapter.notifyDataSetChanged();
}
});
Button btnDel = bottomSheetDialog.findViewById(R.id.btnDelete);
btnDel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
for (int i = 0; i < mDatas.size(); i++) {
if(flag[i] ){
mDatas.remove(i);
}
}
mChkAdapter.notifyDataSetChanged();
}
});
bottomSheetDialog.show();
*/
}
@Override
public void onResume() {
super.onResume();
// bookLists = LitePal.findAll(Novel.class);
// mAdapter.notifyDataSetChanged();
// synchronized (mAdapter) {
// Refresh the state of the +1 button each time the activity receives focus.
// ((Main2Activity)getActivity()).swithToolbarItems();
}
@ -404,6 +357,10 @@ public class Fragment_Shelf extends BasicFragment {
if(holder.tvCate!=null) holder.tvCate.setText(mDatas.get(position).getNovelType());
if(holder.tvDesc!=null) holder.tvDesc.setText(mDatas.get(position).getDesc ());
if(holder.checkBox!=null) holder.checkBox.setVisibility(View.VISIBLE);
if (holder.imageView != null && !TextUtils.isEmpty(mDatas.get(position).getCover())) {
loader.displayImage(context, NetUtil.getCoverUrl(mDatas.get(position).getCover()) ,holder.imageView);
}
// 如果设置了回调则设置点击事件
if (mOnItemClickListener != null)
{

View File

@ -64,7 +64,7 @@ public class Fragment_bangdan extends BasicFragment {
// Toast.makeText(activity, "book "+ bookId + " clicked", Toast.LENGTH_SHORT).show();
showBookDetail(position);
showBookDetail(mData.get(position));
// openBook();
}
});

View File

@ -51,7 +51,7 @@ public class Fragment_booklist extends BasicFragment {
@Override
public void onItemClick(View view, int position) {
showBookDetail(mData.get(position).getId());
showBookDetail(mData.get(position) );
// openBook(mData.get(position),mAdapter);
}

View File

@ -2,6 +2,8 @@ package com.novelbook.android.Fragments;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v7.widget.GridLayoutManager;
@ -11,10 +13,17 @@ import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.novelbook.android.BookActivity;
import com.novelbook.android.R;
import com.novelbook.android.bean.FirstPage;
import com.novelbook.android.db.Novel;
import com.novelbook.android.db.SiteRule;
import com.novelbook.android.netsubscribe.BookSubscribe;
import com.novelbook.android.netutils.OnSuccessAndFaultListener;
import com.novelbook.android.netutils.OnSuccessAndFaultSub;
import com.novelbook.android.utils.CyclePageIndicator;
import com.novelbook.android.utils.MyViewPager;
import com.novelbook.android.utils.OnItemClickListener;
@ -25,6 +34,8 @@ import com.youth.banner.Transformer;
import com.youth.banner.listener.OnBannerListener;
import com.youth.banner.loader.ImageLoader;
import org.litepal.LitePal;
import java.util.ArrayList;
import java.util.List;
@ -55,6 +66,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
private ArrayList<String> list_path;
private ArrayList<String> list_title;
private FirstPage mFirstPage;
public Fragment_jingxuan() {
// Required empty public constructor
@ -71,6 +83,27 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
}
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
int wt = msg.what;
if (msg.what == 1) {
} else if (msg.what == 2) //
{
Toast.makeText(getActivity(), " ", Toast.LENGTH_LONG).show();
} else if (msg.what == 3) {
Toast.makeText(getActivity(), " ", Toast.LENGTH_LONG).show();
}
}
};
@Override
@ -80,6 +113,24 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
@Override
public void initData() {
BookSubscribe.getFirstPage( new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
@Override
public void onSuccess(String result) {
mFirstPage= gson.fromJson(result, FirstPage.class);
handler.sendEmptyMessage(1);
}
@Override
public void onFault(String errorMsg) {
//失败
Log.d(TAG,"error on get firstpage: "+errorMsg);
}
},getActivity()));
mHotNewData_l = initData(mHotNewData_l,'B');
mHotNewData_g= initData(mHotNewData_g,'D');
mHotLianZaiData_l= initData(mHotLianZaiData_l,'C');
@ -255,7 +306,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
@Override
public void onItemClick(View view, int position)
{
showBookDetail(position);
showBookDetail(mHotNewData_l.get(position));
// openBook(mHotNewData_l.get(position),null);
}
@ -284,8 +335,8 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
@Override
public void onItemClick(View view, int position)
{
showBookDetail(mHotNewData_g.get(position));
showBookDetail(position);
// openBook( mHotNewData_g.get(position) ,null);
}
@ -312,7 +363,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
// Toast.makeText(activity, position + "grid click", Toast.LENGTH_SHORT).show();
showBookDetail(position);
showBookDetail(mHotLianZaiData_l.get(position));
// openBook( mHotLianZaiData_l.get(position) ,null);
}
@ -339,8 +390,8 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
{
// Toast.makeText(activity, position + "grid click", Toast.LENGTH_SHORT).show();
showBookDetail(mHotLianZaiData_g.get(position));
showBookDetail(position);
// openBook( mHotLianZaiData_g.get(position) ,null);
}
@ -365,8 +416,8 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
{
// Toast.makeText(activity, position + "grid click", Toast.LENGTH_SHORT).show();
showBookDetail(mFinishedData_l.get(position));
showBookDetail(position);
// openBook( mFinishedData_l.get(position) ,null);
}
@ -392,8 +443,8 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
{
// Toast.makeText(activity, position + "grid click", Toast.LENGTH_SHORT).show();
showBookDetail(mFinishedData_g.get(position));
showBookDetail(position);
// openBook( mFinishedData_g.get(position) ,null);
}

View File

@ -91,8 +91,8 @@ public class Fragment_paihang extends BasicFragment {
@Override
public void onItemClick(View view, int position) {
openBook(mData.get(position),null);
showBookDetail(mData.get(position) );
//openBook(mData.get(position),mAdapter);
}
@Override

View File

@ -35,7 +35,7 @@ import org.xutils.x;
import butterknife.BindView;
import butterknife.ButterKnife;
public class Main2Activity extends AppCompatActivity
public class Main2Activity extends Activity_base
implements NavigationView.OnNavigationItemSelectedListener{//} , BasicFragment.OnFragmentInteractionListener {
public MyApp app ;
public static String TAG ="com.novelbook.android.Main2Activity";
@ -48,18 +48,38 @@ public class Main2Activity extends AppCompatActivity
@BindView(R.id.navigation )
BottomNavigationView botoomNavigation;
@Override
public int getLayoutRes() {
return R.layout.activity_main2;
}
@Override
protected void initViews() {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app =(MyApp) getApplicationContext();
// requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_main2);
ButterKnife.bind(this);
// ButterKnife.bind(this);
}
@Override
protected void setTitle() {
}
@Override
protected void initData() {
creatToolbar();
setupNavi();
showHome();
getDataFromServer();
}

View File

@ -72,11 +72,11 @@ public class MarkActivity extends Activity_base {
}
});
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(pageFactory.getBookName());
// getSupportActionBar().setTitle(pageFactory.getBookName());
}
setTabsValue();
pager.setAdapter(new MyPagerAdapter(getSupportFragmentManager(),pageFactory.getNovle().getId()));
pager.setAdapter(new MyPagerAdapter(getSupportFragmentManager(),0));
tabs.setViewPager(pager);
}

View File

@ -32,11 +32,9 @@ import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import com.baidu.tts.auth.AuthInfo;
import com.baidu.tts.client.SpeechError;
import com.baidu.tts.client.SpeechSynthesizer;
import com.baidu.tts.client.SpeechSynthesizerListener;
import com.baidu.tts.client.TtsMode;
import com.novelbook.android.db.Chapter;
import com.novelbook.android.db.Novel;
import com.novelbook.android.db.BookMarks;
@ -52,7 +50,6 @@ import org.litepal.LitePal;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -63,7 +60,7 @@ import butterknife.OnClick;
public class ReadActivity extends Activity_base implements SpeechSynthesizerListener , AdInterface {
private static final String TAG = "ReadActivity";
private final static String EXTRA_BOOK = "book";
// private final static String EXTRA_CHAPTER = "chapter";
private final static String EXTRA_CHAPTER = "chapter";
private final static int MESSAGE_CHANGEPROGRESS = 1;
@BindView(R.id.bookpage)
@ -109,7 +106,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
private Config config;
private WindowManager.LayoutParams lp;
private Novel book;
// private Chapter mChapter;
private Chapter mChapter;
private PageFactory pageFactory;
private int screenWidth, screenHeight;
// popwindow是否显示
@ -121,11 +118,6 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
private SpeechSynthesizer mSpeechSynthesizer;
private boolean isSpeaking = false;
public void showTopAd(boolean show){
llTopAd.setVisibility(show? View.VISIBLE:View.GONE);
}
// 接收电池信息更新的广播
private BroadcastReceiver myReceiver = new BroadcastReceiver(){
@ -176,6 +168,19 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
config = Config.getInstance();
pageFactory = PageFactory.getInstance();
pageFactory.setAd(this);
llTopAd.setVisibility(View.GONE);
// showProgress (false,"读取目录信息");
/* int slept = 0;
while(slept <100 && (pageFactory.getChapters() == null || pageFactory.getChapters().size()==0)){
try {
Thread.sleep(50);
slept++;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
hideProgress() ;*/
IntentFilter mfilter = new IntentFilter();
mfilter.addAction(Intent.ACTION_BATTERY_CHANGED);
@ -201,13 +206,23 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
}
//获取intent中的携带的信息
Intent intent = getIntent();
book = (Novel) intent.getSerializableExtra(EXTRA_BOOK);
if(intent.hasExtra(EXTRA_BOOK)){
book = (Novel) intent.getSerializableExtra(EXTRA_BOOK);
}
if(intent.hasExtra(EXTRA_CHAPTER)){
mChapter = ( Chapter ) intent.getSerializableExtra(EXTRA_CHAPTER);
}
// mChapter = ( Chapter ) intent.getSerializableExtra(EXTRA_CHAPTER);
bookpage.setPageMode(config.getPageMode());
pageFactory.setPageWidget(bookpage);
try {
pageFactory.openBook(book,this);
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(this, "打开电子书失败", Toast.LENGTH_SHORT).show();
@ -235,7 +250,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
pro = (float) (progress / 10000.0);
showProgress(pro);
showProgressBar(pro);
}
// 表示进度条刚开始拖动开始拖动时候触发的操作
@ -486,7 +501,8 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
if (id == R.id.action_add_bookmark){
if (pageFactory.getCurrentPage() != null) {
List<BookMarks> bookMarksList = LitePal.where("novelId = ? and begin = ?", pageFactory.getNovle().getId()+"",pageFactory.getCurrentPage().getBegin() + "").find(BookMarks.class);
List<BookMarks> bookMarksList = LitePal.where("novelId = ? and chapt = ? " +
" and begin = ?", pageFactory.getNovle().getId()+"",pageFactory.getCurrentChapter()+"",pageFactory.getCurrentPage().getBegin() + "").find(BookMarks.class);
if (!bookMarksList.isEmpty()){
Toast.makeText(ReadActivity.this, "该书签已存在", Toast.LENGTH_SHORT).show();
@ -504,6 +520,8 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
bookMarks.setBegin(pageFactory.getCurrentPage().getBegin());
bookMarks.setText(word);
bookMarks.setNovelId(pageFactory.getNovle().getId());
bookMarks.setChapt(pageFactory.getCurrentChapter());
bookMarks.setChaptName(((pageFactory.getChapters().get(bookMarks.getChapt()).getChapterName())));
bookMarks.save();
Toast.makeText(ReadActivity.this, "书签添加成功", Toast.LENGTH_SHORT).show();
@ -547,7 +565,20 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
Intent intent = new Intent(context, ReadActivity.class);
intent.putExtra(EXTRA_BOOK, book);
// intent.putExtra(EXTRA_CHAPTER, chapter);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);
context.startActivity(intent);
return true;
}
public static boolean openChapter(final Novel book, final Chapter chapter, Activity context) {
if (book == null){
throw new NullPointerException("Novel can not be null");
}
Intent intent = new Intent(context, ReadActivity.class);
intent.putExtra(EXTRA_BOOK, book);
intent.putExtra(EXTRA_CHAPTER, chapter);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);
@ -586,7 +617,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
}
//显示书本进度
public void showProgress(float progress){
public void showProgressBar(float progress){
if (rl_progress.getVisibility() != View.VISIBLE) {
rl_progress.setVisibility(View.VISIBLE);
}
@ -594,7 +625,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
}
//隐藏书本进度
public void hideProgress(){
public void hideProgressBar(){
rl_progress.setVisibility(View.GONE);
}
@ -782,6 +813,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
}
hideSystemUI();
}
/*
ProgressDialog progressDialog;
private void showProgressDialog() {
if ( null == progressDialog) {
@ -797,8 +829,9 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
if ( null != progressDialog) {
progressDialog.dismiss();
}
}
*/
/*
* @param arg0
*/
@ -883,10 +916,14 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
final int contentAdHight=350;
@Override
public void showAd(int adHeight,int adY) {
public void showAd(boolean showAd ,int adHeight,int adY) {
hideSystemUI();
llTopAd.setVisibility(View.GONE);
if(!showAd){
return;
}
if(adHeight >contentAdHight){
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) llTopAd.getLayoutParams();

View File

@ -7,8 +7,10 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.novelbook.android.BookActivity;
import com.novelbook.android.db.Novel;
import com.novelbook.android.netutils.NetUtil;
import com.novelbook.android.utils.MyImageLoader;
import com.novelbook.android.utils.OnItemClickListener;
@ -87,7 +89,8 @@ public class BookListAdapter extends RecyclerView.Adapter< MyViewHolder> {
if (holder.tvCate != null) holder.tvCate.setText(mDatas.get(position).getNovelType());
if (holder.tvDesc != null) holder.tvDesc.setText(mDatas.get(position).getDesc());
if (holder.imageView != null && !TextUtils.isEmpty(mDatas.get(position).getCover())) {
loader.displayImage(context,mDatas.get(position).getCover(),holder.imageView);
loader.displayImage(context,NetUtil.getCoverUrl(mDatas.get(position).getCover()) ,holder.imageView);
}
if(holder.tvNum!=null)holder.tvNum.setText("999");
// 如果设置了回调则设置点击事件

View File

@ -67,10 +67,12 @@ public class MarkAdapter extends BaseAdapter {
}
viewHolder.text_mark.setText(list.get(position).getText());
long begin = list.get(position).getBegin();
float fPercent = (float) (begin * 1.0 / pageFactory.getBookLen());
/* float fPercent = (float) (begin * 1.0 / pageFactory.getBookLen());
DecimalFormat df = new DecimalFormat("#0.0");
String strPercent = df.format(fPercent * 100) + "%";
viewHolder.progress1.setText(strPercent);
String strPercent = df.format(fPercent * 100) + "%";*/
viewHolder.progress1.setText(list.get(position).getChaptName());
viewHolder.mark_time.setText(list.get(position).getTime().substring(0, 16));
return convertView;
}

View File

@ -0,0 +1,177 @@
package com.novelbook.android.bean;
import com.novelbook.android.db.Novel;
public class FirstPage {
private Banner[] banners;
private Block[] blocks;
private CateButton[] cateButtons;
public Banner[] getBanners() {
return banners;
}
public void setBanners(Banner[] banners) {
this.banners = banners;
}
public Block[] getBlocks() {
return blocks;
}
public void setBlocks(Block[] blocks) {
this.blocks = blocks;
}
public CateButton[] getCateButtons() {
return cateButtons;
}
public void setCateButtons(CateButton[] cateButtons) {
this.cateButtons = cateButtons;
}
}
/**
* 分类按钮
*/
class CateButton{
//上方显示的图标
private String icon;
//下方文字
private String title;
//分类关键字
private String key;
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
}
/**
*首页大类别
*/
class Block{
private String title;
private String icon;
private SubBlock[] subBlocks;
private String key;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public SubBlock[] getSubBlocks() {
return subBlocks;
}
public void setSubBlocks(SubBlock[] subBlocks) {
this.subBlocks = subBlocks;
}
}
/**
* 子类别
*/
class SubBlock{
int displayModel;
Novel[] nvs;
public int getDisplayModel() {
return displayModel;
}
public void setDisplayModel(int displayModel) {
this.displayModel = displayModel;
}
public Novel[] getNvs() {
return nvs;
}
public void setNvs(Novel[] nvs) {
this.nvs = nvs;
}
}
/**
* banner
*/
class Banner{
private String txt;
private String imgUrl;
private String target;
private int type;
public String getTxt() {
return txt;
}
public void setTxt(String txt) {
this.txt = txt;
}
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
}

View File

@ -7,11 +7,14 @@ import org.litepal.crud.LitePalSupport;
public class BookMarks extends LitePalSupport {
private int id ;
// private int page;
private int chapt;
private String chaptName;
private long begin; // 书签记录页面的结束点位置
// private int count;
private String text;
private String time;
private int novelId;
public int getId() {
return this.id;
}
@ -52,4 +55,19 @@ public class BookMarks extends LitePalSupport {
this.novelId = novelId;
}
public String getChaptName() {
return chaptName;
}
public void setChaptName(String chaptName) {
this.chaptName = chaptName;
}
public int getChapt() {
return chapt;
}
public void setChapt(int chapt) {
this.chapt = chapt;
}
}

View File

@ -101,8 +101,9 @@ public class Chapter extends LitePalSupport implements Serializable {
}
public static List<Chapter> getUnCachedChapters(int noveId,String domain ){
return LitePal.where("novelId = ? and domain = ? and chapterPath = ?" ,noveId+"",domain,"") .find(Chapter.class);
// return LitePal.where("novelId = ? and domain = ? " ,noveId+"",domain).find(Chapter.class);
// return LitePal.where("novelId = ? and domain = ? and chapterPath = null" ,noveId+"",domain ) .find(Chapter.class);
return LitePal.where("novelId = ? and domain = ? " ,noveId+"",domain).find(Chapter.class);
}

View File

@ -229,4 +229,8 @@ public class Novel extends LitePalSupport implements Serializable{
return LitePal.where("novelPath !=? ","").find(Novel.class);
}
}

View File

@ -46,6 +46,11 @@ public interface HttpApi {
Observable<ResponseBody> getNovelSites(@Path("id") int novelId);
//http://xiaoshuofenxiang.com/api/s/www.qu.la.json
@GET("s/{siteDomain}.json")
Observable<ResponseBody> getNovelRule(@Path("siteDomain") String siteDomain);
@GET("s/{siteDomain}.json")
Observable<ResponseBody> getNovelRule(@Path("siteDomain") String siteDomain);
@GET("/page/index")
Observable<ResponseBody> getFirstPage();
}

View File

@ -30,4 +30,11 @@ public class BookSubscribe {
Observable<ResponseBody> observable = HttpMethods.getInstance().getHttpApi().getNovelRule(domain);
HttpMethods.getInstance().toSubscribe(observable, subscriber);
}
public static void getFirstPage(DisposableObserver<ResponseBody> subscriber){
Observable<ResponseBody> observable = HttpMethods.getInstance().getHttpApi().getFirstPage();
HttpMethods.getInstance().toSubscribe(observable, subscriber);
}
}

View File

@ -3,6 +3,8 @@ package com.novelbook.android.netutils;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.text.TextUtils;
import android.widget.ImageView;
import com.novelbook.android.MyApp;
@ -192,4 +194,18 @@ public class NetUtil {
return uas[new Random().nextInt(uas.length-1)];
}
public static String getCoverUrl(String url){
if (!TextUtils.isEmpty(url)) {
if(!TextUtils.isEmpty(url) ){
if(url.startsWith("//")){
url ="http:"+url;
}
}
}
return url;
}
}

View File

@ -3,6 +3,7 @@ package com.novelbook.android.netutils;
import android.app.ProgressDialog;
import android.content.Context;
import android.util.Log;
import android.widget.Toast;
import org.json.JSONObject;
@ -176,6 +177,7 @@ public class OnSuccessAndFaultSub extends DisposableObserver<ResponseBody>
Log.e("OnSuccessAndFaultSub", "errorMsg: " + errorMsg);
}
} catch (Exception e) {
Toast.makeText(context,"出错了" + e.getMessage(),Toast.LENGTH_LONG);
e.printStackTrace();
}
}

View File

@ -2,24 +2,181 @@ package com.novelbook.android.service;
import android.app.IntentService;
import android.content.Intent;
import android.util.Log;
public class ChapterDownloadSvrc extends IntentService {
public ChapterDownloadSvrc(String name) {
super(name);
static final String TAG= "ChapterDownloadSvr";
public ChapterDownloadSvrc() {
super(TAG);
}
@Override
public void onCreate() {
super.onCreate();
// 创建一个初始化线程,若干个买票线程
// 要等初始化线程初始化好了之后,才能买票
// 创建一个Ticket类的对象,分别传给不同的线程
Ticket ticket = new Ticket();
Thread t1 = new InitTicketThread("初始化线程", ticket);
// 等初始化线程初始化好车票之后,才能开始卖票
try {
t1.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
// 创建四个买票线程,开始卖票
Thread t2 = new SaleTicketThread("卖票线程1", ticket);
Thread t3 = new SaleTicketThread("卖票线程2", ticket);
Thread t4 = new SaleTicketThread("卖票线程3", ticket);
Thread t5 = new SaleTicketThread("卖票线程4", ticket);
Log.d(TAG,"---------------------------------------------------------------------");
Log.d(TAG,"test service ChapterDownloadSvrc onCreate...");
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
Log.d(TAG,"test service onStart");
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(TAG,"test service onStartCommand");
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onDestroy() {
Log.d(TAG,"test service onDestroy");
super.onDestroy();
}
@Override
/* @Override
protected void onHandleIntent(Intent intent) {
Log.d(TAG,"test service ChapterDownloadSvrc onHandleIntent...");
}*/
@Override
protected void onHandleIntent( Intent intent) {
Log.d(TAG,"test service onHandleIntent...");
Log.d(TAG,"test service ChapterDownloadSvrc onHandleIntent...");
}
/**
* 创建车票类初始化车票
* @author haokui
*
*/
class Ticket {
// 初始化200张票的空间
private String[] tickets = new String[200];
private int index = tickets.length - 1; // 指向数组的索引(第一张票)
public Ticket() {
}
public void initTicket() {
// 初始化车票,给数组的元素赋值,考虑是否要同步
for (int i = 0; i < tickets.length; i++) {
tickets[i] = "" + (i + 1) + "号车票";
}
}
public synchronized String saleTicket() throws NoTicketException {
// 判断是否有票,有票的情况下再卖票,没有票呢,抛出异常,
// 考虑是否需要同步
if (index >= 0) {
String s = tickets[index];
// 故意制造了一个问题,出现多个线程共卖一张车票
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
tickets[index] = null;
index--;
return s;
} else {
throw new NoTicketException("没有车票了");
}
}
}
/**
* 创建卖票线程类
* @author haokui
*
*/
class SaleTicketThread extends Thread {
private Ticket ticket;
public SaleTicketThread(String name, Ticket ticket) {
super(name);
this.ticket = ticket;
this.start();
}
// 在run方法中卖车票
public void run() {
for (int i = 0; i < 60; i++) {
try {
String s = ticket.saleTicket();
System.out.println(this.getName() + "卖票成功========>" + s);
} catch (NoTicketException e) {
System.out.println(this.getName() + " 卖票时发生异常!");
e.printStackTrace();
// 如果发生异常,说明没有车票了,就中断循环,不要在卖票了
break;
}
}
}
}
/**
* 初始化车票的线程,负责初始化车票,也就是初始化Ticket类中的数组
* @author haokui
*
*/
class InitTicketThread extends Thread {
private Ticket ticket;
public InitTicketThread(String name, Ticket ticket) {
super(name);
this.ticket = ticket;
this.start();
}
// 在run方法中初始化车票
public void run() {
ticket.initTicket();
}
}
/**
* 自定义异常
* @author haokui
*
*/
class NoTicketException extends Exception {
public NoTicketException() {
}
public NoTicketException(String msg) {
super(msg);
}
}
}

View File

@ -237,6 +237,7 @@ public class ServiceDownload extends IntentService {
SiteRule siteRule = SiteRule. getSiteRuleByDomain(dt.getDomain());
if(siteRule==null){
//to do get siterule from web
Log.d(TAG, String.format("没找到site rule: %s",dt.getDomain()));
}else {
siteRuleMap.put(dt.getNovelId(),siteRule);

View File

@ -6,5 +6,5 @@ public interface AdInterface {
* @param height
* @param adY
*/
public void showAd(int height,int adY);
public void showAd(boolean showAd,int height,int adY);
}

View File

@ -180,6 +180,8 @@ public class BookUtil {
}
mSiteRule =sr;
setSiteInfo();
Log.d(TAG, String.format("目录正则表达式下载完成,开始读取章节信息") );
readChaptersAsync();
@ -335,13 +337,15 @@ public class BookUtil {
Request request = getTagRequest(url);
mMuluStatus = MuluStatus.isDownloading;
long startTime= new Date().getTime();
Log.d(TAG,String.format("loadChaptContent----start download %s 目录 from %s", mNovel.getName() ,url ));
Log.d(TAG,String.format("loadChapts----start download %s 目录 from %s", mNovel.getName() ,url ));
HttpMethods.getOkClient().newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.d(TAG, "onFailure: " + e.getMessage());
Log.d(TAG,String.format("loadChapts---- failed %s 目录 from %s", mNovel.getName() ,url ));
if( mNovelSites.getSites().length ==1){ //仅有一个rule,且失败了
mMuluStatus = MuluStatus.failed;
return;
@ -362,6 +366,8 @@ public class BookUtil {
public void onResponse(Call call, Response response){
ResponseBody body = response.body();
if(response.code()!=200){
Log.d(TAG,String.format("loadChapts----failed, %s 目录 from %s,return code %s", mNovel.getName() ,url,response.code() ));
mMuluStatus = MuluStatus.failed;
return;
}
@ -369,11 +375,11 @@ public class BookUtil {
try {
String bodyStr = body.string();
Log.d(TAG, "onResponse: " +bodyStr);
Log.d(TAG,String.format("loadChaptContent----end download %s 目录, 目录数量 %s, cost %s", mNovel.getName() , mChapters.size(), new Date().getTime() -startTime ));
long startTime2= new Date().getTime();
// Log.d(TAG, "onResponse: " +bodyStr);
// Log.d(TAG,String.format("loadChaptContent----end download %s 目录, 目录数量 %s, cost %s", mNovel.getName() , mChapters.size(), new Date().getTime() -startTime ));
// long startTime2= new Date().getTime();
buildCharacters(bodyStr,url);
Log.d(TAG,String.format("loadChaptContent----end download %s 目录, 目录数量 %s, cost %s", mNovel.getName() , mChapters.size(), new Date().getTime() -startTime2 ));
Log.d(TAG,String.format("loadChaptContent----end download %s 目录, 目录数量 %s, cost %s", mNovel.getName() , mChapters.size(), new Date().getTime() -startTime ));
mMuluStatus = MuluStatus.isDone;
@ -395,8 +401,8 @@ public class BookUtil {
siteJson.put("chapterUrlPattern", mSiteRule.getChapterUrlPattern());
siteJson.put("chapterUrlRegexOnMulu", mSiteRule.getChapterUrlRegexOnMulu());//示例接口表达式有问题
siteJson.put("chapterUrlRegexOnMulu", "<dd> <a[^>]*href=\"(/book/[\\d]+/[\\d]+\\.html)\">([^<]+)</a></dd>");
// siteJson.put("chapterUrlRegexOnMulu", "<dd> <a[^>]*href=\"(/book/[\\d]+/[\\d]+\\.html)\">([^<]+)</a></dd>");
siteJson.put("chapterUrlRegexOnMulu", mSiteRule.getChapterUrlRegexOnMulu());
mChapters = NovelParseUtil.getChapters(mSite.getDomain(),url, content, siteJson);
Log.d(TAG,String.format("mulu on Site %s download status %s",mSite.getDomain(),mMuluStatus));
/* if (mChapters != null) {
@ -827,7 +833,7 @@ public class BookUtil {
Log.d("loadChaptContent",String.format("handler msg, download %s",isDownloadChapt) );
}else if(msg.what==1){
isDownloadChapt =true;
Toast.makeText(mContext,"网络错误",Toast.LENGTH_LONG).show();
// Toast.makeText(mContext,"网络错误",Toast.LENGTH_LONG).show();
}
}
@ -855,8 +861,19 @@ public class BookUtil {
if(!file.exists()) {
if(mChapters ==null || mChapters.size() ==0){
String error = "网络错误";
int slept = 0;
while(slept <100 && mMuluStatus ==MuluStatus.isDownloading){
try {
Thread.sleep(50);
slept++;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
if( mChapters ==null || mChapters.size() ==0){
String error = "获取目录失败,网络错误,请重试";
return error.toCharArray();
}

View File

@ -34,6 +34,9 @@ public class NovelParseUtil {
public static List<Chapter> getChapters(String domain,String muluUrl, String html, JSONObject siteJson) throws JSONException {
Map<String, String> muluMap = getChaptersMap(muluUrl, html, siteJson);
if(muluMap==null){
return new ArrayList<Chapter>();
}
Chapter[] tmp = new Chapter[muluMap.size()];

View File

@ -13,7 +13,6 @@ import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.WindowManager;
@ -21,14 +20,11 @@ import android.widget.Toast;
import com.novelbook.android.Config;
import com.novelbook.android.R;
import com.novelbook.android.bean.NovelSites;
import com.novelbook.android.db.Chapter;
import com.novelbook.android.db.Novel;
import com.novelbook.android.netutils.NetUtil;
import com.novelbook.android.view.PageWidget;
import org.litepal.LitePal;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
@ -359,7 +355,7 @@ public class PageFactory {
public void onDraw(Bitmap bitmap,List<String> m_lines,Boolean updateChapter) {
if (getChapters().size() > 0 && updateChapter) {
currentChapter = getCurrentCharter();
currentChapter = getCurrentChapter();
}
//更新数据库进度
if (currentPage != null && mBook != null){
@ -483,9 +479,13 @@ public class PageFactory {
}
private void showAd(int adHeight,int adY) {
if(mAd!=null){
mAd.showAd(adHeight,adY);
}
boolean showAd = getCurrentPage().getPageNo() > 2
&&NetWorkUtil.isNetworkConnected(mContext);
if (mAd != null) {
mAd.showAd(showAd,adHeight, adY);
}
}
@ -557,6 +557,7 @@ public class PageFactory {
if(mBook!=null &&mBook.getNovelId() !=book.getNovelId()){ //取消未上本书完成的web请求待验证效果
NetUtil.cancelRequest(mBook.getNovelId()+"" );
}
this.mBook = book ;
mBookUtil = new BookUtil();
//this.mBookUtil.setContext(context);
this.mBookUtil.setNovel(book);
@ -883,7 +884,7 @@ public class PageFactory {
if (mBookUtil.getChapters().size() > 0){
int num = currentChapter;
if (num ==1){
num =getCurrentCharter();
num = getCurrentChapter();
}
num --;
if (num >= 1){
@ -903,7 +904,7 @@ public class PageFactory {
public void nextChapter(){
int num = currentChapter;
if (num == 0){
num =getCurrentCharter();
num = getCurrentChapter();
}
num ++;
if (num <= getChapters().size()){
@ -919,7 +920,7 @@ public class PageFactory {
}
//获取现在的章
public int getCurrentCharter(){
public int getCurrentChapter(){
/*int num = 0;
for (int i = 0;getDirectoryList().size() > i;i++){
Chapter bookCatalogue = getDirectoryList().get(i);
@ -968,7 +969,7 @@ public class PageFactory {
currentPage(true);
}
//改变进度
//改变章节
public void changeChapter(int chapNum){
preChaptPages =currentChaptPages;
@ -980,6 +981,17 @@ public class PageFactory {
}
public void openBookmark(int chapNum,long position){
preChaptPages =currentChaptPages;
currentChapter = chapNum;
mBookUtil.setChapterNo(currentChapter);
currentChaptPages = loadCurrentChapt(currentChapter ) ;
currentPage = getPageForBegin(position);
currentPage(true);
}
//改变行间距
public void changeLineHight(int lineSpace) {
@ -1152,6 +1164,9 @@ public class PageFactory {
public void setPageWidget(PageWidget mBookPageWidget){
this.mBookPageWidget = mBookPageWidget;
}
public PageWidget getPageWidget( ){
return mBookPageWidget;
}
public void setPageEvent(PageEvent pageEvent){
this.mPageEvent = pageEvent;

View File

@ -148,8 +148,11 @@
</LinearLayout>
<LinearLayout
android:id="@+id/llCate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:orientation="horizontal">
<ImageView
@ -255,7 +258,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="xxx 还写过" />
android:text="作者其他作品" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rvBooklist"

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="100dp"
android:layout_height="120dp"
android:layout_width="120dp"
android:layout_height="165dp"
android:gravity="center"
android:background="@drawable/item_selector"
android:clickable="true"
@ -14,10 +14,11 @@
<ImageView
android:id="@+id/imageView"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_width="100dp"
android:layout_height="120dp"
android:layout_weight="1"
android:gravity="center"
android:scaleType="fitStart"
android:src="@drawable/googleg_standard_color_18" />
<CheckBox
android:id="@+id/id_check_box"
@ -31,8 +32,8 @@
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center"
android:layout_height="50dp"
android:gravity="top|center"
android:text="天龙八部"
android:textColor="#212121" />

View File

@ -22,7 +22,7 @@
android:layout_height="150dp"
android:layout_marginTop="520dp"
android:visibility="visible">
android:visibility="gone">
<ImageView
android:layout_width="match_parent"