add top to shelf

This commit is contained in:
mwang 2019-05-04 23:17:28 +08:00
parent ef85074f05
commit 664ff9b491
24 changed files with 475 additions and 162 deletions

View File

@ -178,9 +178,13 @@ public class Activity_ChgSource extends Activity_base {
if(TextUtils.isEmpty(title)) {
title = mDatas.get(position).getDomain();
}
// title += mDatas.get(position).getDomain();
Log.d(TAG, String.format("onBindViewHolder: domain is '%s', title is '%s'",domain ,title));
if(mDatas.get(position).getDomain().equals(domain)){
title +=" (当前源)";
// title +=" (当前源)";
holder.tvTitle.setTextColor(getResources().getColor( R.color.colorPrimaryDark));
}else{
holder.tvTitle.setTextColor(getResources().getColor( R.color.blacktitle));
}
holder.tvTitle.setText(title); //.getName()

View File

@ -280,7 +280,7 @@ public class BookActivity extends Activity_base {
.load( Uri.decode(NetUtil.getCoverUrl(mNovel.getCover())))
.dontAnimate()
// .error(R.mipmap.side_bg2)
.transform(new GaoSiTransForm(this, 100, 3)) // "14":模糊度"3":图片缩放3倍后再进行模糊
.transform(new GaoSiTransForm(this, 150, 5)) // "14":模糊度"3":图片缩放3倍后再进行模糊
.into(imageViewHead);
@ -291,7 +291,7 @@ public class BookActivity extends Activity_base {
}
void setShelfButtonText() {
String title = mNovel.isOnShelf() ? "书架" : "加入书架";
String title = mNovel.isOnShelf() ? "书架" : "加入书架";
btnShelf.setText(title);
}

View File

@ -22,6 +22,7 @@ import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.novelbook.android.Main2Activity;
import com.novelbook.android.R;
@ -33,7 +34,9 @@ import com.novelbook.android.netutils.HttpMethods;
import com.novelbook.android.netutils.NetUtil;
import com.novelbook.android.netutils.OnSuccessAndFaultListener;
import com.novelbook.android.netutils.OnSuccessAndFaultSub;
import com.novelbook.android.utils.CommonUtil;
import com.novelbook.android.utils.Constants;
import com.novelbook.android.utils.FileUtils;
import com.novelbook.android.utils.GsonUtil;
import com.novelbook.android.utils.ImageUtil;
import com.novelbook.android.utils.MyImageLoader;
@ -338,6 +341,10 @@ void test(int maxAge){
tvTitle.setText(bookLists.get(position).getName());
TextView tvAuthor =(TextView) bottomSheetDialog.findViewById(R.id.tvAuthor);
tvAuthor.setText(bookLists.get(position).getAuthor());
TextView tvLatest =(TextView) bottomSheetDialog.findViewById(R.id.txtLatestUpdate);
TextView tvLatestChapt =(TextView) bottomSheetDialog.findViewById(R.id.txtLatestCate);
tvLatestChapt.setText(bookLists.get(position).getChapterName());
tvLatest.setText(CommonUtil.getDateString( bookLists.get(position).getLastUpdateTime()) );
ImageView imageView = (ImageView) bottomSheetDialog.findViewById(R.id.imageG1);
ImageUtil.loadImage(activity,bookLists.get(position).getCover(),imageView);
@ -348,6 +355,58 @@ void test(int maxAge){
showBookDetail(bookLists.get(position));
}
});
TextView tvCache =(TextView) bottomSheetDialog.findViewById(R.id.tvCache);
long size = FileUtils.getCacheSize(bookLists.get(position).getId());
size = size/1024;
tvCache.setText(String.format("%sK",size));
LinearLayout llClearCache =(LinearLayout) bottomSheetDialog.findViewById(R.id.llClearCache);
llClearCache.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
FileUtils.clearChapterCache(bookLists.get(position).getId());
long size = FileUtils.getCacheSize(bookLists.get(position).getId());
size = size/1024;
tvCache.setText(String.format("%sK",size));
Toast.makeText(activity,"缓存清除成功",Toast.LENGTH_SHORT);
}
});
LinearLayout lltop =(LinearLayout) bottomSheetDialog.findViewById(R.id.llTop);
TextView tvTop =(TextView) bottomSheetDialog.findViewById(R.id.tvTop);
ImageView imgTop =(ImageView) bottomSheetDialog.findViewById(R.id.imageTop);
if( bookLists.get(position).isTop()){
tvTop.setText("取消置顶");
imgTop.setImageResource(R.mipmap.star_inactive);
}else{
tvTop.setText("置顶显示");
imgTop.setImageResource(R.mipmap.star_active);
}
lltop.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if( bookLists.get(position).isTop()){
bookLists.get(position).setToDefault("isTop");
tvTop.setText("置顶显示");
imgTop.setImageResource(R.mipmap.star_active);
}else{
bookLists.get(position).setTop(true);
tvTop.setText("取消置顶");
imgTop.setImageResource(R.mipmap.star_inactive);
}
bookLists.get(position).update( bookLists.get(position).getId());
loadNovelsOnShelf();
mAdapter.setData(bookLists);
Toast.makeText(activity,"缓存清除成功",Toast.LENGTH_SHORT);
}
});
@ -533,7 +592,11 @@ void test(int maxAge){
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( mDatas.get(position).isTop()){
holder.imageTop.setVisibility(View.VISIBLE);
}else{
holder.imageTop.setVisibility(View.GONE);
}
// 如果设置了回调则设置点击事件
if (mOnItemClickListener != null)
@ -592,6 +655,9 @@ void test(int maxAge){
CheckBox checkBox;
@BindView(R.id.imageView)
ImageView imageView;
@BindView(R.id.imageTop)
ImageView imageTop;
@BindView(R.id.title)
TextView tvTitle;
@Nullable

View File

@ -70,7 +70,7 @@ public class Fragment_bookStore extends BasicFragment {
@Override
public void initData() {
mTitle = new String[]{"精选", "榜单","分类"};
mTitle = new String[]{"精选","分类", "榜单"};
}
public void onSexSwitch(){
@ -96,8 +96,8 @@ public class Fragment_bookStore extends BasicFragment {
// mTitle = new String[]{"精选", "榜单", "书单"};
mFragments = new ArrayList<>();
mFragments.add(new Fragment_jingxuan());
mFragments.add(new Fragment_bangdan());
mFragments.add(FragmentCates.newInstance());
mFragments.add(new Fragment_bangdan());
// mFragments.add(new Fragment_shudan());
Log.d(TAG,"initial fragments in tabs ");

View File

@ -123,6 +123,7 @@ public class Fragment_booklist extends BasicFragment {
if(!TextUtils.isEmpty(history)){
listItem = listItem =R.layout.recycle_list_item_history;
}
}
}
@ -231,6 +232,7 @@ public class Fragment_booklist extends BasicFragment {
if(!TextUtils.isEmpty(bangdan) && !TextUtils.isEmpty(fn)){ //榜单
// showProgressDialog(true, "正在加载榜单");
mAdapter.setShowTop(true);
BookSubscribe.getSiteRankDetail(fn,pageNo,Constants.SEX,new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
@Override
public void onSuccess(String result) {
@ -260,16 +262,19 @@ public class Fragment_booklist extends BasicFragment {
}else if(!TextUtils.isEmpty(fn)){ //首页 更多
mAdapter.setShowTop(true);
// showProgressDialog(true, "正在加载更多");
BookSubscribe.getNovelPaihang(fn,Constants.SEX,new OnSuccessAndFaultSub(successAndFaultListener, getActivity()));
}
else if(!TextUtils.isEmpty((cate))) { //分类
mAdapter.setShowTop(true);
// showProgressDialog(true, "正在加载分类");
BookSubscribe.getCateNovelList(cate, pageNo, Constants.SEX, progress, new OnSuccessAndFaultSub(successAndFaultListener, getActivity()));
}else if(!TextUtils.isEmpty(keyWord)){ //搜索
// showProgressDialog(true, "正在加载搜索");
mAdapter.setShowTop(true);
BookSubscribe.getSearchNovelList( keyWord,pageNo, Constants.SEX, new OnSuccessAndFaultSub(successAndFaultListener, getActivity()));
}else if(!TextUtils.isEmpty(history)){
loadHistory();
@ -350,7 +355,7 @@ public class Fragment_booklist extends BasicFragment {
@Override
public void onResume(){
super.onResume();
pageNo=1;
// pageNo=1;
if(!TextUtils.isEmpty(history)){
if(isFirstLoad) {

View File

@ -175,6 +175,7 @@ final String TAG = Fragment_paihang.class.getSimpleName();
Toast.LENGTH_SHORT).show();
}
});
mAdapter.setShowTop(true);
mAdapter.setShowFootView(true);
rvPaihang.setLayoutManager(new LinearLayoutManager(activity));
rvPaihang.setAdapter(mAdapter);

View File

@ -132,6 +132,8 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
if (intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED)) {
Log.e(TAG,Intent.ACTION_BATTERY_CHANGED);
int level = intent.getIntExtra("level", 0);
Log.d(TAG, String.format("updateBattery onReceive: Intent.ACTION_BATTERY_CHANGED level %s ",level));
pageFactory.updateBattery(level);
}else if (intent.getAction().equals(Intent.ACTION_TIME_TICK)){
Log.e(TAG,Intent.ACTION_TIME_TICK);

View File

@ -58,6 +58,17 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
private float percent =0;
private int norecord =R.string.noRecord;
private boolean isShowTop=false;
public boolean isShowTop() {
return isShowTop;
}
public void setShowTop(boolean showTop) {
isShowTop = showTop;
}
public void setNorecord(int norecord) {
this.norecord = norecord;
}
@ -67,6 +78,7 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
}
public void setShowFootView(boolean showFootView) {
this.showFootView = showFootView;
}
@ -211,6 +223,38 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
if (holder.imageView != null && !TextUtils.isEmpty(mDatas.get(position).getCover())) {
ImageUtil.loadImage(context, mDatas.get(position).getCover(), holder.imageView);
}
if (holder.imageTop != null) {
if( mDatas.get(position).isTop()){
holder.imageTop.setVisibility(View.VISIBLE);
}else{
holder.imageTop.setVisibility(View.GONE);
}
}
if(isShowTop) {
if (holder.imageTop1 != null) {
if (position == 0) {
holder.imageTop1.setVisibility(View.VISIBLE);
} else {
holder.imageTop1.setVisibility(View.GONE);
}
}
if (holder.imageTop2 != null) {
if (position == 1) {
holder.imageTop2.setVisibility(View.VISIBLE);
} else {
holder.imageTop2.setVisibility(View.GONE);
}
}
if (holder.imageTop3 != null) {
if (position == 2) {
holder.imageTop3.setVisibility(View.VISIBLE);
} else {
holder.imageTop3.setVisibility(View.GONE);
}
}
}
if (holder.imageUpdate != null) {
if( mDatas.get(position).isUpdated()){
holder.imageUpdate.setVisibility(View.VISIBLE);

View File

@ -17,6 +17,21 @@ public class MyViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.imageUpdated)
@Nullable
ImageView imageUpdate;
@BindView(R.id.imageTop)
@Nullable
ImageView imageTop;
@BindView(R.id.imageTop1)
@Nullable
ImageView imageTop1;
@BindView(R.id.imageTop2)
@Nullable
ImageView imageTop2;
@BindView(R.id.imageTop3)
@Nullable
ImageView imageTop3;
@BindView(R.id.title)
TextView tvTitle;
@Nullable

View File

@ -15,9 +15,18 @@ import com.novelbook.android.utils.FileUtils;
import java.io.File;
import java.io.IOException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.observers.DisposableObserver;
@ -197,6 +206,34 @@ public class HttpMethods {
okHttpBuilder.writeTimeout(DEFAULT_READ_TIMEOUT, TimeUnit.SECONDS);
//错误重连
okHttpBuilder.retryOnConnectionFailure(true);
// Install the all-trusting trust manager
final SSLContext sslContext;
try {
sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, trustAllCerts,
new java.security.SecureRandom());
// Create an ssl socket factory with our all-trusting manager
final javax.net.ssl.SSLSocketFactory sslSocketFactory = sslContext
.getSocketFactory();
// okHttpBuilder.sslSocketFactory(sslSocketFactory);
/* okHttpBuilder.hostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
// TODO Auto-generated method stub
return true;
}
});*/
} catch (NoSuchAlgorithmException | KeyManagementException e) {
e.printStackTrace();
}
return okHttpBuilder.build();
}
@ -271,6 +308,25 @@ public class HttpMethods {
return userAgent;
}
final TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
@Override
public void checkClientTrusted(
java.security.cert.X509Certificate[] chain,
String authType) throws CertificateException {
}
@Override
public void checkServerTrusted(
java.security.cert.X509Certificate[] chain,
String authType) throws CertificateException {
}
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
}};
}

View File

@ -41,12 +41,21 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.lang.ref.WeakReference;
import java.nio.charset.Charset;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Request;
@ -122,6 +131,7 @@ public class BookUtil {
DownloadStatus downloadStatus = DownloadStatus.notStart;
public Chapter getChapter(int chapId){
chapId = chapId >0 ?chapId : 1;
if(chapId > mChapters.size() || mChapters.size() ==0){
return Chapter.getChapter(mNovel.getId(), mNovel.getDomain(),chapId);
}else{
@ -391,7 +401,7 @@ public class BookUtil {
public int getChapterNo() {
if(chapterNo > mChapters.size()){
Log.d(TAG, String.format(" prepare book getChapterNo ,chapterNo %s, getChapters().size() %s ,mChangeChapId %s" ,chapterNo , mChapters.size(),mChangeChapId) );
// Log.d(TAG, String.format(" prepare book getChapterNo ,chapterNo %s, getChapters().size() %s ,mChangeChapId %s" ,chapterNo , mChapters.size(),mChangeChapId) );
if(mChangeChapId>0){
return mChangeChapId;
}
@ -399,7 +409,7 @@ public class BookUtil {
}
chapterNo = chapterNo<=0 ?1 :chapterNo;
Log.d(TAG, String.format(" prepare book getChapterNo ,chapterNo %s, getChapters().size() %s " ,chapterNo , mChapters.size()) );
// Log.d(TAG, String.format(" prepare book getChapterNo ,chapterNo %s, getChapters().size() %s " ,chapterNo , mChapters.size()) );
return chapterNo;
}
@ -473,6 +483,45 @@ public class BookUtil {
return f.exists();
}
public boolean retryDownLoadContent(int chaptId) {
if(chaptDownStatus.containsKey(chaptId)){
if( chaptDownStatus.get(chaptId) == DownloadStatus.failure){
if(fileRetryCnt.containsKey(chaptId)){
if(fileRetryCnt.get(chaptId) < Constants.retryCnt){
fileRetryCnt.put(chaptId,fileRetryCnt.get(chaptId)+1 );
}else{
return false;
}
}else {
fileRetryCnt.put(chaptId, 1 );
}
}else{
return false;
}
}else{
chaptDownStatus.put(chaptId,DownloadStatus.downloading);
fileRetryCnt.put(chaptId,11 );
}
if(fileRetryCnt.get(chaptId) < Constants.retryCnt) {
try {
loadChaptContent(chaptId);
chaptDownStatus.put(chaptId,DownloadStatus.downloading);
} catch (JSONException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
return true;
}
return false;
}
private class BookTask extends AsyncTask<String,Void,Boolean> {
private String domain;
@ -489,7 +538,7 @@ public class BookUtil {
Log.d(TAG, String.format("changing Source: target domain %s chaptId %s, chapt title %s,mChangeChapId %s "
,domain,chapId,chapTitle,mChangeChapId) );
int chId=chapterNo;
int chId=chapId;//chapterNo;
String title ="";
mChangeChapId = mChangeChapId >=1 ?mChangeChapId :1;//TODO: mChangeChapId 换源时不要变
if( mChapters.size() >= mChangeChapId && mChapters.get(mChangeChapId-1)!=null ){
@ -517,17 +566,36 @@ public class BookUtil {
i = 1;
for (Chapter chapter : mChapters) {
// Log.d(TAG, "changing Source: finding chapter " + i + ":" + chapter.getChapterName());
if (chapter.getChapterName().contains(mChangeTitle)) {
if ( mChangeTitle.contains(chapter.getChapterName())
||chapter.getChapterName().contains(mChangeTitle)
){
Log.d(TAG, "changing Source:successed find chapter by original title " + i + ":" + mChangeTitle);
chId = i;
title = chapter.getChapterName();
break;
}
i++;
}
i = 1;
for (Chapter chapter : mChapters) {
// Log.d(TAG, "changing Source: finding chapter " + i + ":" + chapter.getChapterName());
if ( chapter.getChapterName().startsWith(mChangeTitle)
||mChangeTitle.startsWith(chapter.getChapterName() )
){
Log.d(TAG, "changing Source:successed find chapter by original title " + i + ":" + mChangeTitle);
chId = i;
title = chapter.getChapterName();
break;
}
i++;
}
}
if (!title.contains(mChangeTitle)) {
/* if (!title.contains(mChangeTitle)) {
i = 1;
for (Chapter chapter : mChapters) {
// Log.d(TAG, "changing Source: finding chapter " + i + ":" + chapter.getChapterName());
@ -539,14 +607,14 @@ public class BookUtil {
}
i++;
}
}
}*/
}
chId = chId <= mChapters.size() ? chId: mChapters.size();
Log.d(TAG, "changing Source: to open chapter with new site source " + chId + " : "+ mChangeTitle );
pagefactory.changeChapter(chId);
mChangeChapId=0;
// mChangeChapId=0;
Toast.makeText(mContext,"换源成功",Toast.LENGTH_LONG).show();
}else{
Log.d(TAG, "changing Source: failed " );
@ -591,9 +659,7 @@ public class BookUtil {
/**
* 新线程换源 handler 有问题
* @param domain
* @param chapId
* @param chapTitle
*/
/* public void changeSourceNewThread(String domain,int chapId,String chapTitle) {
Log.d(TAG, String.format("changing Source: target domain %s chaptId %s, chapt title %s ",domain,chapId,chapTitle) );
@ -1387,7 +1453,7 @@ int muluRetryCount =0;
// getTargetSites();
}
if( mChapters.size() ==0) {
if (mMuluStatus == MuluStatus.isDone){
if (mMuluStatus != MuluStatus.isDownloading){
getSiteRule();
}
}
@ -1462,7 +1528,7 @@ int muluRetryCount =0;
error = "连不上网络";
}
loadChaptContent(index);
// loadChaptContent(index);
chaptDownStatus.put( index , DownloadStatus.failure);
Log.d(TAG, String.format("prepare book loadChaptContent retrying " ));
@ -1588,7 +1654,7 @@ private void loadChaptContent(final int chapterIndex) throws JSONException, Inte
chaptDownStatus.put(index,DownloadStatus.failure);
// setDownloadFlag(true);
Log.d( TAG,String.format("prepare book loadChaptContent fail, isDownloadChapt: %s",false));
Log.d( TAG,String.format("prepare book loadChaptContent %s fail, isDownloadChapt: %s",index,false));
e.printStackTrace();
// throw new RuntimeException("Error during writing " + fileChapterName( index));
}
@ -1609,6 +1675,9 @@ private void loadChaptContent(final int chapterIndex) throws JSONException, Inte
try {
if(mSiteRule==null){
return;
}
/* Charset charset = body.contentType().charset();
if(charset!=null){
String name = charset.displayName();
@ -1679,24 +1748,28 @@ private void loadChaptContent(final int chapterIndex) throws JSONException, Inte
.url(url)
.removeHeader("Pragma");
for(int i=0;i<mSiteRule.getHeaders().length;i+=2){
builder.header(mSiteRule.getHeaders()[i],mSiteRule.getHeaders()[i+1]);
for (int i = 0; i < mSiteRule.getHeaders().length; i += 2) {
builder.header(mSiteRule.getHeaders()[i], mSiteRule.getHeaders()[i + 1]);
}
// .header( "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
// .header( "Upgrade-Insecure-Requests", "1")
// .header("content-type", "text/html; charset=utf-8")
// .header("Content-Type", "text/plain; charset=utf-8")
// .header( "Accept", "*/*")
;
// .header("content-type", "text/html; charset=utf-8")
// .header("Content-Type", "text/plain; charset=utf-8")
// .header( "Accept", "*/*")
;
/* if(mSiteRule!=null && !TextUtils.isEmpty(mSiteRule.getEncoding()) ){
builder.header("Accept-Encoding",mSiteRule.getEncoding());
}
*/ if(maxAge>0) {
builder. header("Cache-Control", "public, max-age=" + maxAge);
*/
if (maxAge > 0) {
builder.header("Cache-Control", "public, max-age=" + maxAge);
}
return builder.build();
}

View File

@ -101,5 +101,16 @@ public class FileUtils {
}
return cachePath;
}
public static File getNovelDir(int noveId){
File f = new File(BookUtil.chapterPath+noveId);
return f;
}
public static void clearChapterCache(int novelId) {
Fileutil.deleteDir(getNovelDir(novelId));
}
public static long getCacheSize(int noveId) {
return Fileutil.getDirSize(getNovelDir(noveId));
}
}

View File

@ -48,7 +48,7 @@ public class Fileutil {
if (file.isFile()) {
dirSize += file.length();
} else if (file.isDirectory()) {
dirSize += file.length();
// dirSize += file.length();
// 递归调用
dirSize += getDirSize(file);
}

View File

@ -353,14 +353,20 @@ public class PageFactory implements ChangeSource{
new Thread() {
@Override
public void run() {
super.run();
Log.d(TAG, String.format("prepare book to preRead chapter %s ,thread.name %s",chaptId,Thread.currentThread().getName() ) );
File file = new File(getChapterFileName(chaptId));
if(file.exists()) {
chaptMap.put(chaptId, readChaptCache(chaptId));
Log.d(TAG, String.format("prepare book to preLoad success " ) );
Log.d(TAG, String.format("prepare book to preLoad %s done <-----",chaptId ) );
}else{
Log.d(TAG, String.format("prepare book to trying download the chapt %s again........... ",chaptId ) );
mBookUtil.retryDownLoadContent(chaptId) ;
}
Log.d(TAG, String.format("prepare book to preLoad done <-----" ) );
super.run();
}}.start();
}
@ -555,7 +561,7 @@ public static boolean busy(){
mBatterryPaint.setColor(m_textColor);
batteryInfoIntent = context.getApplicationContext().registerReceiver(null,
new IntentFilter(Intent.ACTION_BATTERY_CHANGED)) ;//注册广播,随时获取到电池电量信息
level = batteryInfoIntent.getIntExtra( "level" , 0 );
initBg(config.getDayOrNight());
measureMarginWidth();
}
@ -615,7 +621,7 @@ public static boolean busy(){
String status = "";
switch (mStatus){
case OPENING:
status = "正在拼命加载"+loadingTxt;
status = loadingTxt+ "正在拼命加载" ;
mAd.showRefresh(View.GONE);
break;
case FAIL:
@ -694,7 +700,7 @@ public static boolean busy(){
}
if(lastPageTime>0) {
long time = new Date().getTime() - lastPageTime;
Log.d(TAG, String.format("prepare book read time last %s,current %s,spent %s",lastPageTime,new Date().getTime(), time));
// Log.d(TAG, String.format("prepare book read time last %s,current %s,spent %s",lastPageTime,new Date().getTime(), time));
if (time > 1000) {
getNovel().setReadtime(getNovel().getReadtime() + time);
}
@ -705,11 +711,11 @@ public static boolean busy(){
// * column won't be updated.
// getNovel().save();
Novel nv = LitePal.find(Novel.class,getNovel().getId());
/* Novel nv = LitePal.find(Novel.class,getNovel().getId());
Log.d(TAG,String.format("prepare book %s ,%s isUpdated %s,saved isUpdated %s, saved lastchapt %s,lastpos %s, db lastchapt %s last pos %s",
getNovel().getId(),
getNovel().getName(),getNovel().isUpdated(),nv.isUpdated(),
currentChapter,currentPage.getBegin(),nv.getLastReadChapt(),nv.getLastReadPos()));
currentChapter,currentPage.getBegin(),nv.getLastReadChapt(),nv.getLastReadPos()));*/
lastPageTime = new Date().getTime();
@ -785,9 +791,12 @@ public static boolean busy(){
c.drawText(strPercent, mWidth - nPercentWidth, botoomY, mBatterryPaint);//x y为坐标值
c.drawText(date, marginWidth ,botoomY, mBatterryPaint);
// 画电池
level = batteryInfoIntent.getIntExtra( "level" , 0 );
Log.d(TAG, String.format("updateBattery to draw: level1 %s ",level));
// level = batteryInfoIntent.getIntExtra( "level" , 0 );
int scale = batteryInfoIntent.getIntExtra("scale", 100);
mBatteryPercentage = (float) level / scale;
Log.d(TAG, String.format("updateBattery to draw: level2 %s ",level));
float rect1Left = marginWidth + dateWith + statusMarginBottom;//电池外框left位置
//画电池外框
float width = CommonUtil.convertDpToPixel(mContext,20) - mBorderWidth;
@ -1343,6 +1352,8 @@ if(book==null){
public void updateBattery(int mLevel){
mAd.hideSystemUI();
if (currentPage != null && mBookPageWidget != null && !mBookPageWidget.isRunning()) {
Log.d(TAG, String.format("updateBattery: level old %s, new %s",level,mLevel));
if (level != mLevel) {
level = mLevel;
currentPage(false);
@ -1404,6 +1415,7 @@ if(book==null){
mPaint.setTextSize(m_fontSize);
calculateLineCount();
measureMarginWidth();
chaptMap.clear();
currentChaptPages = loadCurrentChapt(currentChapter );
currentPage = getPageForBegin(currentPage.getBegin());
currentPage(true);
@ -1415,6 +1427,7 @@ if(book==null){
mPaint.setTextSize(m_fontSize);
calculateLineCount();
measureMarginWidth();
chaptMap.clear();
currentChaptPages = loadCurrentChapt(currentChapter );
currentPage = getPageForBegin(currentPage.getBegin());
currentPage(true);
@ -1427,7 +1440,7 @@ if(book==null){
mBatterryPaint.setTypeface(typeface);
calculateLineCount();
measureMarginWidth();
chaptMap.clear();
currentPage = getPageForBegin(currentPage.getBegin());
currentPage(true);
}
@ -1499,7 +1512,9 @@ if(book==null){
Log.d(TAG, String .format("prepare Book: clearing book info %s" , getNovle().getName()));
fileRetryCnt.clear();
lastPageTime=0;
chaptMap.clear();
if(chaptMap!=null){
chaptMap.clear();
}
//mBookUtil=null;
currentChapter = 0;
bookPath = "";

View File

@ -6,14 +6,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:clipToPadding="true"
tools:context=".Activity_ChgSource">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/ToolBarTheme.AppBarOverlay">
style="@style/barLayout">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
@ -30,7 +28,7 @@
android:id="@+id/recycleView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="60dp"
android:layout_marginTop="50dp"
android:divider="@color/list_item_divider"
>
</android.support.v7.widget.RecyclerView>

View File

@ -17,7 +17,7 @@
app:tl_indicator_width="45dp"
app:tl_textSelectColor="@color/tabSelected"
app:tl_textUnselectColor="@color/grey"
app:tl_textsize="17sp"
app:tl_textsize="16sp"
app:tl_textBold="SELECT"
app:tl_tab_space_equal ="true"
app:tl_indicator_bounce_enable ="true"

View File

@ -12,25 +12,30 @@
<RelativeLayout
android:id="@+id/top_layout"
android:layout_width="match_parent"
android:layout_height="90dp"
android:layout_height="120dp"
android:elevation="1dp"
tools:ignore="UnusedAttribute">
<FrameLayout
<LinearLayout
android:clickable="true"
android:id="@+id/llBookdetail"
android:layout_width="match_parent"
android:layout_height="75dp"
android:layout_height="100dp"
android:background="@color/white"
android:layout_alignParentBottom="true"
android:paddingStart="120dp"
android:paddingStart="100dp"
android:paddingLeft="120dp"
android:orientation="horizontal"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingBottom="15dp"
android:paddingStart="15dp"
android:paddingRight="10dp"
android:layout_weight="1"
android:background="@drawable/item_selector"
android:orientation="vertical">
<TextView
@ -41,6 +46,7 @@
android:textColor="@color/colorPrimary"
android:textSize="16sp"
android:textStyle="bold"
android:ellipsize="marquee"
tools:ignore="HardcodedText,TextViewEdits" />
@ -52,15 +58,38 @@
android:text="金庸"
tools:ignore="HardcodedText" />
<TextView
android:layout_marginTop="2dp"
android:id="@+id/txtLatestCate"
style="@style/TextViewDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:ellipsize="end"
android:text=""
/>
<TextView
android:id="@+id/txtLatestUpdate"
style="@style/TextViewDesc.small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:text=""
/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="80dp"
android:layout_height="150dp"
android:layout_height="130dp"
android:layout_marginEnd="14dp"
android:layout_marginRight="14dp"
android:layout_marginStart="20dp"
@ -85,129 +114,74 @@
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="200dp"
android:gravity="center"
android:layout_height="wrap_content"
android:gravity="bottom"
android:background="@color/white"
android:padding="10dp"
android:paddingBottom="5dp"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="60dp"
android:layout_height="70dp"
android:id="@+id/llBookdetail"
android:gravity="center"
android:layout_height="wrap_content"
android:id="@+id/llClearCache"
android:gravity="bottom"
android:background="@drawable/item_selector"
android:clickable="true"
android:layout_weight="1">
<ImageView
>
<TextView
android:id="@+id/tvCache"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/googleg_standard_color_18" />
android:layout_height="20dp"
android:layout_gravity="center"
android:text=""
android:textColor="#212121" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_height="20dp"
android:gravity="center"
android:text="书籍详情"
android:layout_gravity="center"
android:text="清除缓存"
android:textColor="#212121" />
</LinearLayout>.
<LinearLayout
android:id="@+id/llTop"
android:orientation="vertical"
android:layout_width="60dp"
android:layout_height="70dp"
android:gravity="center"
android:background="@drawable/item_selector"
android:clickable="true"
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/googleg_standard_color_18" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center"
android:text="目录书摘"
android:textColor="#212121" />
</LinearLayout>.
<LinearLayout
android:orientation="vertical"
android:layout_width="60dp"
android:layout_height="70dp"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom|center_horizontal"
android:background="@drawable/item_selector"
android:clickable="true"
android:layout_weight="1">
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageTop"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/googleg_standard_color_18" />
android:src="@mipmap/star_active" />
<TextView
android:id="@+id/tvTop"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_height="20dp"
android:gravity="center"
android:text="查看书评"
android:textColor="#212121" />
</LinearLayout>.
<LinearLayout
android:orientation="vertical"
android:layout_width="60dp"
android:layout_height="70dp"
android:gravity="center"
android:background="@drawable/item_selector"
android:clickable="true"
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/googleg_standard_color_18" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center"
android:text="下载本书"
android:text="置顶显示"
android:textColor="#212121" />

View File

@ -20,13 +20,23 @@
android:src="@drawable/googleg_standard_color_18" />
<ImageView
android:id="@+id/imageUpdated"
android:layout_width="38dp"
android:layout_height="38dp"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_gravity="end"
android:layout_marginTop="2dp"
android:layout_marginRight="6dp"
android:visibility="gone"
android:src="@drawable/ic_book_update_flag" />
<ImageView
android:id="@+id/imageTop"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="start"
android:layout_marginTop="2dp"
android:layout_marginRight="6dp"
android:visibility="gone"
android:src="@mipmap/star_active" />
<CheckBox
android:id="@+id/id_check_box"
android:layout_width="wrap_content"

View File

@ -10,10 +10,47 @@
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:layout_weight="1">
<ImageView
android:id="@+id/imageView"
style="@style/NovelImage.horizon"
android:src="@drawable/googleg_standard_color_18" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView"
style="@style/NovelImage.horizon"
android:src="@drawable/googleg_standard_color_18" />
<ImageView
android:id="@+id/imageTop1"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="start"
android:layout_marginTop="2dp"
android:layout_marginRight="6dp"
android:visibility="gone"
android:src="@drawable/sc_top_one" />
<ImageView
android:id="@+id/imageTop2"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="start"
android:layout_marginTop="2dp"
android:layout_marginRight="6dp"
android:visibility="gone"
android:src="@drawable/sc_top_two" />
<ImageView
android:id="@+id/imageTop3"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="start"
android:layout_marginTop="2dp"
android:layout_marginRight="6dp"
android:visibility="gone"
android:src="@drawable/sc_top_three" />
</FrameLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"

View File

@ -10,13 +10,14 @@
<TextView
style="@style/TextViewNovelTitle.horizon.bold"
style="@style/NovelBlockTitle"
android:id="@+id/tvText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:textSize="18sp"
android:text="@string/noRecord"
/>
<!-- <LinearLayout style="@style/llGraySplit.2dp"/>-->
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 985 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -8,6 +8,7 @@
<color name="black">#000000</color>
<color name="gray">#000000</color>
<color name="white">#ffffff</color>
<color name="blacktitle">#212121</color>
<color name="ivory">#FFFFF0</color> <!--象牙色 -->
<color name="lightyellow">#FFFFE0</color><!--亮黄色-->
<color name="yellow">#FFFF00</color><!--黄色 -->

View File

@ -180,7 +180,7 @@
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">30dp</item>
<item name="android:gravity">center</item>
<item name="android:textColor">#212121</item>
<item name="android:textColor">@color/blacktitle</item>
<item name="android:maxLines">1</item>
</style>
@ -301,19 +301,19 @@
<style name="TextViewNovelTitle">
<item name="android:layout_marginLeft">0dp</item>
<item name="android:textColor">#212121</item>
<item name="android:textColor">@color/blacktitle</item>
<item name="android:layout_height">25dp</item>
<item name="android:layout_gravity">left</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:lines">1</item>
<item name="android:textSize">14dp</item>
<!--<item name="android:ellipsize">end</item>-->
<item name="android:ellipsize">marquee</item>
<item name="android:ellipsize">end</item>
<!--<item name="android:ellipsize">marquee</item>-->
</style>
<style name="TextViewNovelAuthor">
<item name="android:layout_marginLeft">10dp</item>
<item name="android:textColor">#212121</item>
<item name="android:textColor">@color/blacktitle</item>
<item name="android:textSize">12sp</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
@ -322,7 +322,7 @@
<style name="TextViewNovelType">
<item name="android:layout_marginLeft">10dp</item>
<item name="android:textColor">@color/colorAccent</item>
<item name="android:textColor">@color/colorPrimaryDark</item>
<item name="android:textSize">12sp</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
@ -371,7 +371,7 @@
<style name="NovelBlockTitle">
<item name="android:layout_marginLeft">4dp</item>
<item name="android:layout_gravity">left|center_vertical</item>
<item name="android:textColor">#212121</item>
<item name="android:textColor">@color/blacktitle</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">20dp</item>
<item name="android:layout_weight">1</item>
@ -389,7 +389,7 @@
</style>
<style name="TextViewCateTitle">
<item name="android:textColor">#212121</item>
<item name="android:textColor">@color/blacktitle</item>
<item name="android:lines">1</item>
<item name="android:ellipsize">end</item>
</style>
@ -417,7 +417,7 @@
<style name="TextViewNovelType.Status">
<item name="android:textColor">@color/mediumturquoise</item>
<item name="android:textColor">@color/colorPrimary</item>
<item name="android:textSize">12sp</item>
</style>