书架问题
This commit is contained in:
mwang 2019-04-26 00:31:07 +08:00
parent 7af2c38a0f
commit de25db0635
32 changed files with 347 additions and 136 deletions

View File

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

View File

@ -521,7 +521,7 @@ public class BookActivity extends Activity_base {
boolean isLocalDbExist = LitePal.isExist(Novel.class, "novelId=?", novelId+"");
showProgressDialog(false,"正在加载...");
BookSubscribe.getNovel(novelId, new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
@Override
public void onSuccess(String result) {

View File

@ -49,6 +49,7 @@ import com.novelbook.android.netsubscribe.BookSubscribe;
import com.novelbook.android.netutils.NetUtil;
import com.novelbook.android.netutils.OnSuccessAndFaultListener;
import com.novelbook.android.netutils.OnSuccessAndFaultSub;
import com.novelbook.android.utils.Constants;
import com.novelbook.android.utils.ImageUtil;
import com.novelbook.android.utils.MyImageLoader;
import com.novelbook.android.utils.OnItemClickListener;
@ -244,6 +245,12 @@ public abstract class BasicFragment extends Fragment {
}
void showProgressDialog(boolean flag,String msg){
if(!Constants.showDialogOnUi){
return;
}
if(pageNo >1 && !Constants.showDialogOnUiPage){
return;
}
if(getActivity()==null){
return;
}

View File

@ -63,6 +63,7 @@ public class CatalogFragment extends BasicFragment implements MarkActivity.Sortc
}
}
boolean isAsc = true;
boolean isFirstLoad = true;
@Override
protected void fillData() {
catalogueList.clear();
@ -83,8 +84,9 @@ public class CatalogFragment extends BasicFragment implements MarkActivity.Sortc
catalogueAdapter.notifyDataSetChanged();
int count= lv_catalogue.getCount();
if(count >=pageFactory.getCurrentChapter() ){
if(count >=pageFactory.getCurrentChapter()&& isFirstLoad){
lv_catalogue.setSelection(currentChp);
isFirstLoad =false;
}
/* tvTitle.setText(pageFactory.getBookName());
@ -150,7 +152,7 @@ public class CatalogFragment extends BasicFragment implements MarkActivity.Sortc
}
int slepttime = 0;
while (NetUtil.isNetworkConnected() &&( slepttime < 1000 && ( pageFactory.isReadingCatalogs() || pageFactory.getChapters().size() == 0))) {
while (NetUtil.isNetworkConnected() &&( slepttime < 100 && ( pageFactory.isReadingCatalogs() || pageFactory.getChapters().size() == 0))) {
try {
Log.d(TAG, String .format("prepare book: to open book cate to sleep %s" , 50));
sleep(50);
@ -206,7 +208,9 @@ public class CatalogFragment extends BasicFragment implements MarkActivity.Sortc
@Override
protected void initViews() {
lv_catalogue.setFastScrollEnabled(true);
//lv_catalogue.setFastScrollStyle(R.style.FastScrollTheme); //不起作用
}
@Override

View File

@ -11,6 +11,7 @@ import android.support.design.widget.BottomSheetDialog;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -26,11 +27,17 @@ import com.novelbook.android.R;
import com.novelbook.android.db.Novel;
import com.novelbook.android.filechooser.FileChooserActivity;
import com.novelbook.android.netsubscribe.BookSubscribe;
import com.novelbook.android.netutils.NetUtil;
import com.novelbook.android.netutils.OnSuccessAndFaultListener;
import com.novelbook.android.netutils.OnSuccessAndFaultSub;
import com.novelbook.android.utils.Constants;
import com.novelbook.android.utils.GsonUtil;
import com.novelbook.android.utils.MyImageLoader;
import com.novelbook.android.utils.OnItemClickListener;
import com.novelbook.android.adapter.BookListAdapter;
import org.json.JSONObject;
import org.litepal.LitePal;
import java.io.File;
@ -57,7 +64,7 @@ public class Fragment_Shelf extends BasicFragment {
RecyclerView mRecyclerView;
// private List<Novel> mDatas;
private BookListAdapter mAdapter;
List<Novel> lstUpdate = new ArrayList<Novel>();
private List<Novel> bookLists;
// private ShelfAdapter adapter;
@ -74,7 +81,9 @@ public class Fragment_Shelf extends BasicFragment {
return fragment;
}
private void loadNovelsOnShelf(){
bookLists = Novel.getNovelsOnShelf();
}
@Override
@ -82,6 +91,48 @@ public class Fragment_Shelf extends BasicFragment {
return R.layout.fragment_fragment__shelf;
}
/**
* to get updated info from server
*/
private void getUpdatedData(){
List<Integer> novelIds;
OnSuccessAndFaultListener successAndFaultListener = new OnSuccessAndFaultListener() {
@Override
public void onSuccess(String result) {
// mFirstPage= gson.fromJson(result, FirstPage.class);
try {
lstUpdate = GsonUtil. parserJsonArray(result, Constants.BLOCK_TITLE_NOVELS);
if(lstUpdate.size()>0) {
for (Novel novel2 : lstUpdate) {
novel2.save();//更新本地信息
}
loadNovelsOnShelf();
}
} catch (Exception e) {
e.printStackTrace();
}
handler.sendEmptyMessage(1);
}
@Override
public void onFault(String errorMsg) {
//失败
Log.d(TAG, "error on get firstpage: " + errorMsg);
handler.sendEmptyMessage(1);
}
};
// BookSubscribe.getCateNovelList(cate, pageNo, tab1Pos+1, tab3Pos+1, new OnSuccessAndFaultSub(successAndFaultListener, getActivity()));
}
@Override
public void initData() {
@ -89,9 +140,15 @@ public class Fragment_Shelf extends BasicFragment {
// mDatas = initData(mDatas,'X');
// bookLists = LitePal.where("isOnShelf=? or novelId=? ","1","").find(Novel.class);
bookLists = Novel.getNovelsOnShelf();
loadNovelsOnShelf();
getUpdatedData();
flag = new boolean[bookLists.size()];
if(bookLists.size()>0) { //TODO: to remove
bookLists.get(0).setUpdated(true);
// bookLists.get(bookLists.size()-1).setUpdated(true);
}
mAdapter = new BookListAdapter(activity,bookLists,R.layout.recycle_list_item,new OnItemClickListener()
{
@ -134,10 +191,20 @@ public class Fragment_Shelf extends BasicFragment {
}
@Override
protected void fillData() {
if(bookLists.size()==0){
// return;
}
mAdapter.setData(bookLists);
// mAdapter.notifyDataSetChanged();
}
public void initReceyleView() {
initData();
// initData();
// mRecyclerView.setLayoutManager(new LinearLayoutManager(this.activity));
mRecyclerView.setLayoutManager(new GridLayoutManager(activity,3));
mRecyclerView.setAdapter(mAdapter );
@ -238,13 +305,17 @@ public class Fragment_Shelf extends BasicFragment {
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.
Log.d(TAG, "shelfZhengliSubmit: to delete novel " + nv.getName());
nv.setToDefault("isOnShelf");
//nv.setOnShelf(false);
nv.update(nv.getId());
// 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()];
@ -389,12 +460,15 @@ public class Fragment_Shelf extends BasicFragment {
// 如果设置了回调则设置点击事件
if (mOnItemClickListener != null)
{
holder.checkBox.setOnCheckedChangeListener(null);//先设置一次CheckBox的选中监听器传入参数null
holder.checkBox.setChecked(flag[position]);//用数组中的值设置CheckBox的选中状态
holder.itemView.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
holder.checkBox.setChecked( !holder.checkBox.isChecked());
}
});
@ -407,8 +481,7 @@ public class Fragment_Shelf extends BasicFragment {
}
});
holder.checkBox.setOnCheckedChangeListener(null);//先设置一次CheckBox的选中监听器传入参数null
holder.checkBox.setChecked(flag[position]);//用数组中的值设置CheckBox的选中状态
//再设置一次CheckBox的选中监听器当CheckBox的选中状态发生改变时把改变后的状态储存在数组中
holder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

View File

@ -200,7 +200,7 @@ public class Fragment_booklist extends BasicFragment {
mMoreData = GsonUtil. parserJsonArray(jsonObject,Constants.BLOCK_TITLE_NOVELS);
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(); Log.e(TAG, "onSuccess: 解析失败",e );
}
handler.sendEmptyMessage(1);
@ -214,7 +214,7 @@ public class Fragment_booklist extends BasicFragment {
}
};
showProgressDialog(false,"正在加载...");
Log.d(TAG,String.format("fn is %s",fn) );
@ -229,9 +229,11 @@ public class Fragment_booklist extends BasicFragment {
String resultstr = jsonObject.getString("rank") ;
pageCount = jsonObject.getJSONObject("rank").getInt("pageCount");
mMoreData = GsonUtil. parserJsonArray(resultstr,Constants.BLOCK_TITLE_NOVELS);
Log.d(TAG, "排行榜详细 onSuccess: pageCount " + pageCount);
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "onSuccess: 解析失败",e );
}
handler.sendEmptyMessage(1);

View File

@ -212,7 +212,7 @@ final String TAG = Fragment_paihang.class.getSimpleName();
handler.sendEmptyMessage(1);
}
};
showProgressDialog(false,"正在加载...");
BookSubscribe.getCateNovelList(cate, pageNo, tab1Pos+1, tab3Pos+1, new OnSuccessAndFaultSub(successAndFaultListener, getActivity()));
@ -226,7 +226,7 @@ final String TAG = Fragment_paihang.class.getSimpleName();
else {
initTabs();
}
//showProgressDialog(false,"加载。。。。");
showProgressDialog(false,"正在加载...");
new Thread(){
@Override
public void run() {

View File

@ -140,6 +140,8 @@ public class Main2Activity extends Activity_base
// toolbar= (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
// toolbar.setNavigationIcon(R.mipmap.ic_launcher_round);//设置导航栏图标
// toolbar.setLogo(R.mipmap.ic_launcher);//设置app logo
// toolbar.setTitle("Title");//设置主标题
@ -310,8 +312,9 @@ private int bottomSelectedIndex;
boolean showTitle = bottomSelectedIndex !=1;
String title = bottomSelectedIndex==0?"我的书架":"排行榜";
// txtTitle.setVisibility(View.GONE);
// toggle.setDrawerIndicatorEnabled(showToggle);
// toggle.syncState();
toggle.setDrawerIndicatorEnabled(showToggle);
toggle.syncState();
//spinner.setVisibility( showSpinner?View.VISIBLE:View.GONE);
rgSex.setVisibility( showSpinner?View.VISIBLE:View.GONE);
@ -486,10 +489,14 @@ private int bottomSelectedIndex;
swithToolbarItems();
botoomNavigation.setVisibility(View.VISIBLE);
fragment_shelf.initReceyleView();
toggle.setDrawerIndicatorEnabled(true);
toggle.syncState();
}else {
toggle.setDrawerIndicatorEnabled(false);
toggle.syncState();
supportInvalidateOptionsMenu();
isShelfZhengli = true;
botoomNavigation.setVisibility(View.GONE);

View File

@ -662,36 +662,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
// return bookpage;
// }
/**
* 隐藏菜单沉浸式阅读
*/
public void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
);
getWindow().setNavigationBarColor(getResources().getColor(R.color.read_dialog_bg));
pageFactory.setBusy(false);
}
private void showSystemUI() {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
);
pageFactory.setBusy(true);
}
//显示书本进度
public void showProgressBar(float progress){
@ -751,15 +722,45 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
Animation bottomAnim = AnimationUtils.loadAnimation(this, R.anim.dialog_enter);
Animation topAnim = AnimationUtils.loadAnimation(this, R.anim.dialog_top_enter);
rl_bottom.startAnimation(topAnim);
appbar.startAnimation(topAnim);
rl_bottom.startAnimation(topAnim);
appbar.startAnimation(topAnim);
// ll_top.startAnimation(topAnim);// ll_top.setVisibility(View.VISIBLE);
rl_bottom.setVisibility(View.VISIBLE);
appbar.setVisibility(View.VISIBLE);
}
}
/**
* 隐藏菜单沉浸式阅读
*/
public void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
// | View.SYSTEM_UI_FLAG_IMMERSIVE
);
getWindow().setNavigationBarColor(getResources().getColor(R.color.read_dialog_bg));
pageFactory.setBusy(false);
}
private void showSystemUI() {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
// | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
);
pageFactory.setBusy(true);
}
private void hideReadSetting() {
isShow = false;
Animation bottomAnim = AnimationUtils.loadAnimation(this, R.anim.dialog_exit);

View File

@ -36,6 +36,7 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
// private MyImageLoader loader = new MyImageLoader();
private Context context;
private List<Novel> mDatas ;
private OnItemClickListener mOnItemClickListener;
private int listItemID;
//private List<Novel> mBooks;
@ -193,8 +194,16 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
if (holder.tvAuthor != null) holder.tvAuthor.setText(mDatas.get(position).getAuthor());
if (holder.tvCate != null) holder.tvCate.setText(mDatas.get(position).getNovelType());
if (holder.tvDesc != null) holder.tvDesc.setText(mDatas.get(position).getDesc());
if (holder.tvStatus != null) holder.tvStatus.setText(mDatas.get(position).getProgress());
if (holder.imageView != null && !TextUtils.isEmpty(mDatas.get(position).getCover())) {
ImageUtil.loadImage(context, mDatas.get(position).getCover(), holder.imageView);
} if (holder.imageUpdate != null) {
if( mDatas.get(position).isUpdated()){
holder.imageUpdate.setVisibility(View.VISIBLE);
}else{
holder.imageUpdate.setVisibility(View.GONE);
}
}
if (holder.tvNum != null) holder.tvNum.setText("999");
// 如果设置了回调则设置点击事件
@ -234,6 +243,12 @@ public class BookListAdapter extends RecyclerView.Adapter< RecyclerView.ViewHol
notifyItemRemoved(position);
}
//to set booklist updated, used in shelf
public void setUpdate(List<Novel> lstUpdate) {
}
public class FooterViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.pbLoad)
ProgressBar mPbLoad;

View File

@ -14,6 +14,9 @@ import butterknife.ButterKnife;
public class MyViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.imageView)
ImageView imageView;
@BindView(R.id.imageUpdated)
@Nullable
ImageView imageUpdate;
@BindView(R.id.title)
TextView tvTitle;
@Nullable
@ -23,10 +26,14 @@ public class MyViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.category)
TextView tvCate;
@Nullable
@BindView(R.id.tvNovelStatus)
TextView tvStatus;
@Nullable
@BindView(R.id.desc)
TextView tvDesc;
@Nullable
@BindView(R.id.tvCateNums)
TextView tvNum;
public MyViewHolder(View view) {
super(view);

View File

@ -34,6 +34,24 @@ public class Novel extends LitePalSupport implements Serializable{
private long lastUpdateTime;
private boolean isOnShelf; //是否入书架
private boolean isFinished; //是否完本
private boolean isUpdated;
private boolean isTop;//置顶
public boolean isTop() {
return isTop;
}
public void setTop(boolean top) {
isTop = top;
}
public boolean isUpdated() {
return isUpdated;
}
public void setUpdated(boolean updated) {
isUpdated = updated;
}
public String getInfoUrl() {
return infoUrl;

View File

@ -77,7 +77,7 @@ public interface HttpApi {
@GET("page/siteranks")
Observable<ResponseBody> getSiteRanks(@Query("sex") int Sex);
//http://xiaoshuofenxiang.com/api/page/siterank?fn=qidian-yuanchuangfengyunbang&pn=3
@GET("page/siterank?fn=qidian-yuanchuangfengyunbang&pn=3")
@GET("page/siterank")
Observable<ResponseBody> getSiteRankDetail(@Query("fn")String fn,@Query("pn")int pageNo,@Query("sex") int Sex);
@GET( "search/{keyword}/{pageno}")
Observable<ResponseBody> getSeachNolvelist(@Path("keyword")String keyWord,@Path("pageno")int pageNo,@Query("sex") int Sex);

View File

@ -545,11 +545,15 @@ public class BookUtil {
int muluRetryCount =0;
void readChaptersAsync( ) {
if(mSite==null ||mSiteRule ==null){
Log.d(TAG,String.format("prepare book loadChapts failed---- %s ,mSite is null? %s ,mSiteRule ==null ? %s", mNovel.getName() ,mSite==null,mSiteRule ==null ));
return;
}
String url = mSite.getMuluUrl();
Request request = getTagRequest(url);
mMuluStatus = MuluStatus.isDownloading;
long startTime= new Date().getTime();
Log.d(TAG,String.format("loadChapts----start download %s 目录 from %s", mNovel.getName() ,url ));
Log.d(TAG,String.format("prepare book loadChapts----start download %s 目录 from %s", mNovel.getName() ,url ));
/* if(muluRetryCount<3){
muluRetryCount++;
@ -654,7 +658,10 @@ int muluRetryCount =0;
});
}
void buildChapters( String content ,String url){
if(mSite==null ||mSiteRule ==null){
Log.d(TAG,String.format("prepare book buildChapters failed---- %s ,mSite is null? %s ,mSiteRule ==null ? %s", mNovel.getName() ,mSite==null,mSiteRule ==null ));
return;
}
try {
JSONObject siteJson = new JSONObject();

View File

@ -33,32 +33,55 @@ public class CommonUtil {
private static final String TAG= CommonUtil.class.getSimpleName();
public static int getScreenHeight(Context context){
int diff = checkDeviceHasNavigationBar(context);
int diff = statusBarDiff(context);
int ret=0;
if(diff >0){
return getDpi(context) -diff; // return height for no navigation bar
ret = getRealScreenSize(context).y;// -diff; // return height for no navigation bar //有虚拟按键 honor 8 没有虚拟按键但顶部有其他占用高度的 mi8
Log.d(TAG, String.format("getNavigationBarSize:screen height is getRealScreenSize(context).y -diff = %s , diff is %s" ,ret ,diff));
}else {
ret = getAppUsableScreenSize(context).y; //return for with navigationbar //没有虚拟按键 mate20
Log.d(TAG, String.format("getNavigationBarSize:screen height is getAppUsableScreenSize(context).y =%s", ret));
}
return getScreenHeightWithOutBottomBar(context); //return for with navigationbar
return ret;
}
/**
* 获取是否存在NavigationBar
* @param context
* @return
*/
public static int checkDeviceHasNavigationBar(Context context) {
public static int statusBarDiff(Context context) {
Point appUsableSize = getAppUsableScreenSize(context);
Point realScreenSize = getRealScreenSize(context);
Log.d(TAG, String.format("getNavigationBarSize: usablesize.y %s,realScreenSize.y %s" +
Log.d(TAG, String.format("getNavigationBarSize:getDpi %s,getScreenHeightWithOutBottomBar %s, usablesize.y %s,realScreenSize.y %s" +
",realScreenSize.y -usablesize.y =%s, statusbar height %s"
,appUsableSize.y ,realScreenSize.y, realScreenSize.y-appUsableSize.y ,getStatusBarHeight(context) ));
,getDpi(context) ,getScreenHeightWithOutBottomBar(context),appUsableSize.y ,realScreenSize.y, realScreenSize.y-appUsableSize.y ,getStatusBarHeight(context) ));
Point p = getNavigationBarSize(context);
// Toast.makeText(context,String.format("getNavigationBarSize: usablesize.y %s,realScreenSize.y %s,diff %s",
// appUsableSize.y ,realScreenSize.y,realScreenSize.y-appUsableSize.y - getStatusBarHeight(context)),Toast.LENGTH_LONG).show();
return realScreenSize.y-appUsableSize.y - getStatusBarHeight(context);
}
//状态栏高度
public static int getStatusBarHeight(Context c) {
int resourceId = c.getResources()
.getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
return c.getResources().getDimensionPixelSize(resourceId);
}
return 0;
}
//返回值就是导航栏的高度,得到的值单位px
public float getNavigationBarHeight(Context c) {
float result = 0;
int resourceId = c.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
result = c.getResources().getDimension(resourceId);
}
return result;
}
public static Point getNavigationBarSize(Context context) {
Point appUsableSize = getAppUsableScreenSize(context);
Point realScreenSize = getRealScreenSize(context);
@ -103,54 +126,6 @@ public class CommonUtil {
return size;
}
public static int getStatusBarHeight(Context c) {
int resourceId = c.getResources()
.getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
return c.getResources().getDimensionPixelSize(resourceId);
}
return 0;
}
/* public static boolean isNavigationBarShow(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
Display display = getActivity().getWindowManager().getDefaultDisplay();
Point size = new Point();
Point realSize = new Point();
display.getSize(size);
display.getRealSize(realSize);
boolean result = realSize.y!=size.y;
return realSize.y!=size.y;
}else {
boolean menu = ViewConfiguration.get(getActivity()).hasPermanentMenuKey();
boolean back = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
if(menu || back) {
return false;
}else {
return true;
}
}
}*/
/**
* 获取是否有虚拟按键
* 通过判断是否有物理返回键反向判断是否有虚拟按键
* mate20 不行
* @param context
* @return
*/
/* public static boolean checkDeviceHasNavigationBar2(Context context) {
boolean hasMenuKey = ViewConfiguration.get(context)
.hasPermanentMenuKey();
boolean hasBackKey = KeyCharacterMap
.deviceHasKey(KeyEvent.KEYCODE_BACK);
if (!hasMenuKey & !hasBackKey) {
// 做任何你需要做的,这个设备有一个导航栏
return true;
}
return false;
}
*/
/**
* 获取虚拟功能键高度
@ -200,7 +175,7 @@ public class CommonUtil {
}
/**
* 获取 虚拟按键的高度
* 获取 虚拟按键+ 顶部状态栏 + x 的高度
* @param context
* @return
*/
@ -451,5 +426,45 @@ public class CommonUtil {
return getDateString(time,"");
}
/* public static boolean isNavigationBarShow(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
Display display = getActivity().getWindowManager().getDefaultDisplay();
Point size = new Point();
Point realSize = new Point();
display.getSize(size);
display.getRealSize(realSize);
boolean result = realSize.y!=size.y;
return realSize.y!=size.y;
}else {
boolean menu = ViewConfiguration.get(getActivity()).hasPermanentMenuKey();
boolean back = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
if(menu || back) {
return false;
}else {
return true;
}
}
}*/
/**
* 获取是否有虚拟按键
* 通过判断是否有物理返回键反向判断是否有虚拟按键
* mate20 不行
* @param context
* @return
*/
/* public static boolean checkDeviceHasNavigationBar2(Context context) {
boolean hasMenuKey = ViewConfiguration.get(context)
.hasPermanentMenuKey();
boolean hasBackKey = KeyCharacterMap
.deviceHasKey(KeyEvent.KEYCODE_BACK);
if (!hasMenuKey & !hasBackKey) {
// 做任何你需要做的,这个设备有一个导航栏
return true;
}
return false;
}
*/
}

View File

@ -17,4 +17,6 @@ public class Constants {
public static String[] lstProgress={"连载中","已完本","新书"};
public static int retryCnt =10;
// public static List<String> lstProgress=null;
public static boolean showDialogOnUi =true;
public static boolean showDialogOnUiPage =false;
}

View File

@ -69,6 +69,8 @@ public class PageFactory implements ChangeSource{
private float mBorderWidth;
// 上下与边缘的距离
private float marginHeight ;
//满屏 差异
private float screenHeihtDiff ;
// 左右与边缘的距离
private float measureMarginWidth ;
// 左右与边缘的距离
@ -455,22 +457,24 @@ public static boolean busy(){
mWidth = metric.widthPixels;
// mHeight = metric.heightPixels;
// mHeight = CommonUtil.getDpi(context);
mHeight = CommonUtil.getScreenHeight(context);
mHeight = CommonUtil.getScreenHeight(context) - CommonUtil.statusBarDiff(context);
sdf = new SimpleDateFormat("HH:mm");//HH:mm为24小时制,hh:mm为12小时制
date = sdf.format(new java.util.Date());
df = new DecimalFormat("#0.0");
marginWidth = mContext.getResources().getDimension(R.dimen.readingMarginWidth);
marginHeight = mContext.getResources().getDimension(R.dimen.readingMarginHeight);
// Log.d(TAG, "PageFactory: marginHeight +" +marginHeight);
// marginHeight = CommonUtil. getStatusBarHeight(mContext);
Log.d(TAG, "PageFactory: marginHeight " +marginHeight);
// Log.d(TAG, "getNavigationBarSize: orignal marginHeight +" +marginHeight);
// marginHeight = CommonUtil. getStatusBarHeight(mContext);
statusMarginBottom = mContext.getResources().getDimension(R.dimen.reading_status_margin_bottom);
screenHeihtDiff =CommonUtil.statusBarDiff(mContext);
Log.d(TAG, "getNavigationBarSize: screenHeihtDiff " +screenHeihtDiff);
lineSpace = context.getResources().getDimension(R.dimen.reading_line_spacing);
paragraphSpace = context.getResources().getDimension(R.dimen.reading_paragraph_spacing);
mVisibleWidth = mWidth - marginWidth * 2;
mVisibleHeight = mHeight - marginHeight * 2;
mHeight +=screenHeihtDiff;
typeface = config.getTypeface();
m_fontSize = config.getFontSize();
lineSpace =config.getLineSpace();
@ -686,8 +690,9 @@ public static boolean busy(){
// String strPercent = df.format(fPercent * 100) + "%";//进度文字
String strPercent = String.format("%s/%s",currentPage.getPageNo(),currentChaptPages.size()) + "";//进度文字
int nPercentWidth = (int) mBatterryPaint.measureText("10/25页") + 50; //Paint.measureText直接返回參數字串所佔用的寬度
c.drawText(strPercent, mWidth - nPercentWidth, mHeight - statusMarginBottom, mBatterryPaint);//x y为坐标值
c.drawText(date, marginWidth ,mHeight - statusMarginBottom, mBatterryPaint);
float botoomY =mHeight - statusMarginBottom;// +screenHeihtDiff;
c.drawText(strPercent, mWidth - nPercentWidth, botoomY, mBatterryPaint);//x y为坐标值
c.drawText(date, marginWidth ,botoomY, mBatterryPaint);
// 画电池
level = batteryInfoIntent.getIntExtra( "level" , 0 );
int scale = batteryInfoIntent.getIntExtra("scale", 100);
@ -696,8 +701,8 @@ public static boolean busy(){
//画电池外框
float width = CommonUtil.convertDpToPixel(mContext,20) - mBorderWidth;
float height = CommonUtil.convertDpToPixel(mContext,10);
rect1.set(rect1Left, mHeight - height - statusMarginBottom,rect1Left + width, mHeight - statusMarginBottom);
rect2.set(rect1Left + mBorderWidth, mHeight - height + mBorderWidth - statusMarginBottom, rect1Left + width - mBorderWidth, mHeight - mBorderWidth - statusMarginBottom);
rect1.set(rect1Left, botoomY - height ,rect1Left + width, botoomY);
rect2.set(rect1Left + mBorderWidth, botoomY - height + mBorderWidth , rect1Left + width - mBorderWidth, botoomY - mBorderWidth );
// c.save(Canvas.CLIP_SAVE_FLAG);
c.save();
c.clipRect(rect2, Region.Op.DIFFERENCE);

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 672 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 677 B

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/slide_block_click" />
<item android:drawable="@drawable/slide_block" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 975 B

View File

@ -8,9 +8,10 @@
android:orientation="vertical">
<LinearLayout
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
@ -32,9 +33,11 @@
android:layout_weight="0"
android:background="@color/white"
android:gravity="bottom"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:visibility="gone"
android:visibility="visible"
android:paddingBottom="0dp"
>
<Button
@ -50,7 +53,7 @@
android:textColor="@color/colorAccent" />
</LinearLayout>
</LinearLayout>
</FrameLayout>

View File

@ -2,7 +2,10 @@
xmlns:tools="http://schemas.android.com/tools"
style="@style/llOutside"
tools:context=".Fragments.Fragment_booklist">
tools:context=".Fragments.Fragment_booklist"
android:clipToPadding="false"
>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeLayout"
android:layout_width="match_parent"

View File

@ -10,19 +10,28 @@
android:layout_margin="0dp"
android:padding="2dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView"
style="@style/NovelImage"
android:id="@+id/imageView"
style="@style/NovelImage"
android:src="@drawable/googleg_standard_color_18" />
android:src="@drawable/googleg_standard_color_18" />
<ImageView
android:id="@+id/imageUpdated"
android:layout_width="38dp"
android:layout_height="38dp"
android:layout_gravity="end"
android:layout_marginTop="2dp"
android:layout_marginRight="6dp"
android:visibility="gone"
android:src="@drawable/ic_book_update_flag" />
<CheckBox
android:id="@+id/id_check_box"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_gravity="end"
android:layout_marginTop="5dp"
android:visibility="gone"
android:text=""/>

View File

@ -19,7 +19,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
android:layout_weight="1">
android:layout_weight="1"
>
<TextView
android:id="@+id/title"
@ -27,6 +29,7 @@
android:text=" "
/>
<LinearLayout
android:layout_marginTop="2dp"
android:layout_marginLeft="0dp"
@ -39,6 +42,13 @@
android:id="@+id/category"
android:text=" "
/>
<TextView
style="@style/TextViewNovelType.Status"
android:id="@+id/tvNovelStatus"
android:text=""
android:layout_marginLeft="10dp"
/>
<TextView
android:id="@+id/author"
style="@style/TextViewNovelAuthor"

View File

@ -5,18 +5,21 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:orientation="vertical">
android:orientation="vertical">
<!--android:clipToPadding="false"
android:fitsSystemWindows="true"
-->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:clipToPadding="true"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay"
android:visibility="gone">
@ -26,7 +29,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/read_dialog_bg"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay" />
@ -38,7 +40,9 @@
<com.novelbook.android.view.PageWidget
android:id="@+id/bookpage"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
/>
<LinearLayout
android:id="@+id/llTopAd"

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -410,6 +410,19 @@
</style>
<style name="Toolbar"></style>
<style name="FastScrollTheme">
<item name="android:textColorPrimary">?android:textColorPrimaryInverse</item>
<item name="android:fastScrollThumbDrawable">@drawable/selector_slide_view</item>
<item name="android:fastScrollTrackDrawable">@android:color/transparent</item>
</style>
<style name="TextViewNovelType.Status">
<item name="android:textColor">@color/mediumturquoise</item>
<item name="android:textSize">12sp</item>
</style>
</resources>