导航状态条高度问题
This commit is contained in:
parent
82c1c1ee3d
commit
7e813c9c6c
|
@ -91,6 +91,11 @@ public class Activity_ChgSource extends Activity_base {
|
|||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillData() {
|
||||
|
||||
}
|
||||
|
||||
interface OnItemClickListener
|
||||
|
|
|
@ -3,8 +3,11 @@ package com.novelbook.android;
|
|||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
@ -60,7 +63,7 @@ public abstract class Activity_base extends AppCompatActivity {
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
setContentView(getLayoutRes());
|
||||
ButterKnife.bind(this);
|
||||
setupToolbar();
|
||||
|
@ -149,7 +152,30 @@ public abstract class Activity_base extends AppCompatActivity {
|
|||
return mDatas;
|
||||
}
|
||||
|
||||
public abstract void fillData();
|
||||
|
||||
Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
|
||||
int wt = msg.what;
|
||||
|
||||
if (msg.what == 1) {
|
||||
fillData();
|
||||
} else if (msg.what == 2) //
|
||||
{
|
||||
|
||||
|
||||
Toast.makeText(Activity_base.this, " 请求失败", Toast.LENGTH_LONG).show();
|
||||
} else if (msg.what == 3) {
|
||||
|
||||
Toast.makeText(Activity_base.this, " ", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
hideProgress();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
|
|
|
@ -54,6 +54,11 @@ public class Activity_cate_books extends Activity_base {
|
|||
protected void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillData() {
|
||||
|
||||
}
|
||||
//---------tabs-------------
|
||||
|
||||
void initTabs() {
|
||||
|
|
|
@ -116,6 +116,11 @@ public class Activity_createShudan extends Activity_base {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillData() {
|
||||
|
||||
}
|
||||
|
||||
private void saveShudan() {
|
||||
|
|
|
@ -74,6 +74,11 @@ public static String TAG ="com.novelbook.android.paihangbang";
|
|||
creatToolbar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillData() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//---------tabs-------------
|
||||
|
||||
|
|
|
@ -27,6 +27,10 @@ public class Activity_shudan extends Activity_base {
|
|||
mAdapter = getBookListAdapter( mData,R.layout.recycle_list_item_horizon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillData() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
|
|
@ -57,6 +57,11 @@ public static String TAG ="com.novelbook.android.Activity_shudan_my";
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillData() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void initTabs() {
|
||||
|
||||
|
|
|
@ -699,6 +699,12 @@ void onResponseProcess( String content ,String url){
|
|||
super.onPause();
|
||||
unregisterReceiver(receiver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
|
|
@ -92,7 +92,12 @@ public class FileActivity extends Activity_base {
|
|||
initListener();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void fillData() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void initListener() {
|
||||
lvFileDrawer.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -108,7 +108,7 @@ public class CatalogFragment extends BasicFragment {
|
|||
lv_catalogue.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
showProgressDialog(true,"请稍等");
|
||||
// showProgressDialog(true,"请稍等");
|
||||
Log.d(TAG, String .format("prepare book: getPageWidget is null? %s",pageFactory.getPageWidget()==null));
|
||||
// if(pageFactory.getPageWidget()==null){
|
||||
|
||||
|
@ -116,23 +116,23 @@ public class CatalogFragment extends BasicFragment {
|
|||
if(novel!=null){
|
||||
novel.setLastReadChapt(position+1);
|
||||
novel.setLastReadPos(1);
|
||||
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
sleep(40);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ReadActivity.openBook(novel, getActivity());
|
||||
}}.start();
|
||||
}
|
||||
ReadActivity.openBook(novel, getActivity());
|
||||
/* new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
sleep(40);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ReadActivity.openBook(novel, getActivity());
|
||||
}}.start();*/
|
||||
}
|
||||
|
||||
// }else {
|
||||
// pageFactory.changeChapter(position+1);
|
||||
// }
|
||||
new Thread() {
|
||||
/*new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
|
@ -163,11 +163,11 @@ public class CatalogFragment extends BasicFragment {
|
|||
Log.d(TAG, String .format("prepare book: total slept %s for loading chapter content %s,chapter.getid %s " , slepttime*50, chapid,pageFactory.getChapters().get(chapid-1).getId()));
|
||||
|
||||
handler.sendEmptyMessage(2);
|
||||
/* if(getActivity()!=null) {
|
||||
*//* if(getActivity()!=null) {
|
||||
getActivity().finish();
|
||||
}*/
|
||||
}*//*
|
||||
}
|
||||
}.start();
|
||||
}.start();*/
|
||||
|
||||
getActivity().finish();
|
||||
|
||||
|
|
|
@ -27,10 +27,16 @@ import com.novelbook.android.Fragments.BasicFragment;
|
|||
import com.novelbook.android.Fragments.Fragment_Shelf;
|
||||
import com.novelbook.android.Fragments.Fragment_bookStore;
|
||||
import com.novelbook.android.Fragments.Fragment_paihang;
|
||||
import com.novelbook.android.netsubscribe.BookSubscribe;
|
||||
import com.novelbook.android.netutils.OnSuccessAndFaultListener;
|
||||
import com.novelbook.android.netutils.OnSuccessAndFaultSub;
|
||||
import com.novelbook.android.utils.Config;
|
||||
import com.novelbook.android.utils.Constants;
|
||||
import com.novelbook.android.utils.PageFactory;
|
||||
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
|
||||
|
@ -61,6 +67,7 @@ public class Main2Activity extends Activity_base
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
PageFactory.createPageFactory(this);
|
||||
app =(MyApp) getApplicationContext();
|
||||
// requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
|
||||
config =Config.getInstance();
|
||||
|
@ -429,14 +436,21 @@ private int bottomSelectedIndex;
|
|||
|
||||
}
|
||||
|
||||
private void setSexOption(){
|
||||
@Override
|
||||
public void fillData() {
|
||||
|
||||
}
|
||||
|
||||
private void setSexOption(){
|
||||
int s = rgSex.getCheckedRadioButtonId() == R.id.radioButtonBoy ?1:2;
|
||||
if(s!= Constants.SEX){
|
||||
Constants.SEX=s;
|
||||
config.setSexOption(s);
|
||||
Fragment current = getSupportFragmentManager().findFragmentById(R.id.realtabcontent);
|
||||
if (current != null && current instanceof BasicFragment){
|
||||
|
||||
((BasicFragment)current).reload();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -481,6 +495,33 @@ private void setSexOption(){
|
|||
}
|
||||
}
|
||||
|
||||
//----get master domain
|
||||
|
||||
private void getHostPolicy(){
|
||||
BookSubscribe.getMastDomain(new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
|
||||
// mFirstPage= gson.fromJson(result, FirstPage.class);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(result);
|
||||
String resultstr = jsonObject.getString("nts");
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
handler.sendEmptyMessage(1);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFault(String errorMsg) {
|
||||
//失败
|
||||
Log.d(TAG, "error on get firstpage: " + errorMsg);
|
||||
handler.sendEmptyMessage(2);
|
||||
}
|
||||
}, this));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -84,7 +84,10 @@ public class MarkActivity extends Activity_base {
|
|||
tabLayout.setViewPager(pager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillData() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void initListener() {
|
||||
|
|
|
@ -15,7 +15,7 @@ public class MyApp extends Application {
|
|||
super.onCreate();
|
||||
applicationContext = getApplicationContext();
|
||||
Config.createConfig(this);
|
||||
PageFactory.createPageFactory(this);
|
||||
// PageFactory.createPageFactory(this);
|
||||
|
||||
|
||||
// BlurKit.init(this);
|
||||
|
|
|
@ -43,6 +43,7 @@ import com.novelbook.android.netutils.NetUtil;
|
|||
import com.novelbook.android.utils.AdInterface;
|
||||
import com.novelbook.android.utils.BrightnessUtil;
|
||||
import com.novelbook.android.utils.Config;
|
||||
import com.novelbook.android.utils.Constants;
|
||||
import com.novelbook.android.utils.PageFactory;
|
||||
import com.novelbook.android.view.PageWidget;
|
||||
|
||||
|
@ -225,7 +226,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
|
|||
hideSystemUI();
|
||||
pageFactory.openBook(book, this);
|
||||
|
||||
showProgressDialog(true, "正在加载");
|
||||
/*showProgressDialog(true, "正在加载");
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -263,7 +264,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
|
|||
|
||||
}
|
||||
}.start();
|
||||
|
||||
*/
|
||||
|
||||
hideSystemUI();
|
||||
|
||||
|
@ -345,6 +346,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
|
|||
@Override
|
||||
public void changeFontSize(int fontSize) {
|
||||
pageFactory.changeFontSize(fontSize);
|
||||
showSystemUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -360,6 +362,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
|
|||
@Override
|
||||
public void changeLineHeight(int lineHeight) {
|
||||
pageFactory.changeLineHight(lineHeight);
|
||||
showSystemUI();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -480,7 +483,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
|
|||
Log.d(TAG, "onKeyDown: pressed key");
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
Log.d(TAG, "onKeyDown: pressed back");
|
||||
if (isShow){
|
||||
/* if (isShow){
|
||||
hideReadSetting();
|
||||
return true;
|
||||
}
|
||||
|
@ -491,7 +494,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
|
|||
if (mPageModeDialog.isShowing()){
|
||||
mPageModeDialog.hide();
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
if(!pageFactory.canExitSilent()){
|
||||
|
@ -620,6 +623,11 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillData() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static boolean openBook(final Novel book, Activity context) {
|
||||
if (book == null){
|
||||
|
@ -670,16 +678,18 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
|
|||
| 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_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
||||
);
|
||||
pageFactory.setBusy(true);
|
||||
}
|
||||
|
||||
//显示书本进度
|
||||
|
@ -818,7 +828,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
|
|||
}
|
||||
|
||||
@OnClick({R.id.tv_progress, R.id.rl_progress, R.id.tv_pre, R.id.sb_progress, R.id.tv_next, R.id.tv_directory,
|
||||
R.id.tv_dayornight,R.id.tv_pagemode, R.id.tv_setting, R.id.bookpop_bottom, R.id.rl_bottom,R.id.tv_stop_read
|
||||
R.id.tv_dayornight,R.id.tv_pagemode, R.id.tv_setting, R.id.bookpop_bottom, /*R.id.rl_bottom,*/R.id.tv_stop_read
|
||||
,R.id.llTopAd})
|
||||
public void onClick(View view) {
|
||||
if( pageFactory.isReady())
|
||||
|
@ -848,17 +858,20 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
|
|||
changeDayOrNight();
|
||||
break;
|
||||
case R.id.tv_pagemode:
|
||||
hideReadSetting();
|
||||
hideReadSetting();
|
||||
mPageModeDialog.show();
|
||||
showSystemUI();
|
||||
// getWindow().setNavigationBarColor(getResources().getColor(R.color.read_dialog_bg));
|
||||
break;
|
||||
case R.id.tv_setting:
|
||||
hideReadSetting();
|
||||
hideReadSetting();
|
||||
mSettingDialog.show();
|
||||
showSystemUI();
|
||||
break;
|
||||
case R.id.bookpop_bottom:
|
||||
break;
|
||||
case R.id.rl_bottom:
|
||||
break;
|
||||
/* case R.id.rl_bottom:
|
||||
break;*/
|
||||
case R.id.tv_stop_read:
|
||||
if (mSpeechSynthesizer!=null){
|
||||
mSpeechSynthesizer.stop();
|
||||
|
@ -878,7 +891,7 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
|
|||
// dismissProgressDialog();
|
||||
break;
|
||||
}
|
||||
hideSystemUI();
|
||||
// hideSystemUI();
|
||||
}
|
||||
/*
|
||||
ProgressDialog progressDialog;
|
||||
|
@ -984,9 +997,12 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
|
|||
|
||||
@Override
|
||||
public void showAd(boolean showAd ,int adHeight,int adY) {
|
||||
|
||||
hideSystemUI();
|
||||
llTopAd.setVisibility(View.GONE);
|
||||
|
||||
if(!Constants.SHOWAD){
|
||||
return;
|
||||
}
|
||||
if(!showAd){
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -62,30 +62,9 @@ public class activity_cates extends Activity_base {
|
|||
}
|
||||
|
||||
|
||||
Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
|
||||
int wt = msg.what;
|
||||
|
||||
if (msg.what == 1) {
|
||||
fillData();
|
||||
} else if (msg.what == 2) //
|
||||
{
|
||||
|
||||
|
||||
Toast.makeText(activity_cates.this, " 请求失败", Toast.LENGTH_LONG).show();
|
||||
} else if (msg.what == 3) {
|
||||
|
||||
Toast.makeText(activity_cates.this, " ", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
hideProgress();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
private void fillData() {
|
||||
@Override
|
||||
public void fillData() {
|
||||
List<Cataloge> cates = new ArrayList<>();
|
||||
for(Cataloge cate:mCataloges){
|
||||
if(cate!=null && cate.getNovelCount()>0){
|
||||
|
|
|
@ -61,6 +61,7 @@ public class PageModeDialog extends Dialog {
|
|||
|
||||
config = Config.getInstance();
|
||||
selectPageMode(config.getPageMode());
|
||||
// getWindow().setNavigationBarColor(getResources().getColor(R.color.read_dialog_bg));
|
||||
}
|
||||
|
||||
@OnClick({R.id.tv_simulation, R.id.tv_cover, R.id.tv_slide, R.id.tv_none})
|
||||
|
|
|
@ -14,6 +14,7 @@ import android.widget.TextView;
|
|||
|
||||
|
||||
import com.baidu.android.common.logging.Log;
|
||||
import com.novelbook.android.utils.CommonUtil;
|
||||
import com.novelbook.android.utils.Config;
|
||||
import com.novelbook.android.R;
|
||||
import com.novelbook.android.utils.DisplayUtils;
|
||||
|
@ -64,6 +65,8 @@ public class SettingDialog extends Dialog {
|
|||
TextView tv_bysong;
|
||||
@BindView(R.id.tv_lhsize)
|
||||
TextView tv_lineSpace;
|
||||
@BindView(R.id.tv_lhsize_default)
|
||||
TextView tv_lhsize_default;
|
||||
|
||||
|
||||
private Config config;
|
||||
|
@ -76,10 +79,11 @@ public class SettingDialog extends Dialog {
|
|||
private int LINE_SPACE_MIN;
|
||||
private int LINE_SPACE_MAX;
|
||||
private int currentLineSpace;
|
||||
|
||||
Context mContext;
|
||||
|
||||
private SettingDialog(Context context, boolean flag, OnCancelListener listener) {
|
||||
super(context, flag, listener);
|
||||
mContext =context;
|
||||
}
|
||||
|
||||
public SettingDialog(Context context) {
|
||||
|
@ -88,7 +92,7 @@ public class SettingDialog extends Dialog {
|
|||
|
||||
public SettingDialog(Context context, int themeResId) {
|
||||
super(context, themeResId);
|
||||
|
||||
mContext=context;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,6 +107,7 @@ public class SettingDialog extends Dialog {
|
|||
Display d = m.getDefaultDisplay();
|
||||
WindowManager.LayoutParams p = getWindow().getAttributes();
|
||||
p.width = d.getWidth();
|
||||
// p.height = CommonUtil.getDpi(mContext);
|
||||
getWindow().setAttributes(p);
|
||||
|
||||
FONT_SIZE_MIN = (int) getContext().getResources().getDimension(R.dimen.reading_min_text_size);
|
||||
|
@ -120,10 +125,11 @@ public class SettingDialog extends Dialog {
|
|||
//初始化字体大小
|
||||
currentFontSize = (int) config.getFontSize();
|
||||
tv_size.setText(currentFontSize + "");
|
||||
|
||||
setTextViewSelect(tv_size_default, currentFontSize ==60);
|
||||
//初始化行间距
|
||||
currentLineSpace =(int) config.getLineSpace();
|
||||
tv_lineSpace.setText(currentLineSpace+"");
|
||||
setTextViewSelect(tv_lhsize_default, currentLineSpace==45);
|
||||
|
||||
//初始化字体
|
||||
tv_default.setTypeface(config.getTypeface(Config.FONTTYPE_DEFAULT));
|
||||
|
@ -384,6 +390,7 @@ public class SettingDialog extends Dialog {
|
|||
if (currentLineSpace < LINE_SPACE_MAX) {
|
||||
currentLineSpace += 1;
|
||||
tv_lineSpace.setText(currentLineSpace + "");
|
||||
setTextViewSelect(tv_lhsize_default,false);
|
||||
config.setLineSpace(currentLineSpace);
|
||||
if (mSettingListener != null) {
|
||||
mSettingListener.changeLineHeight(currentLineSpace);
|
||||
|
@ -394,6 +401,7 @@ public class SettingDialog extends Dialog {
|
|||
private void defaultLineSpace() {
|
||||
currentLineSpace = (int) getContext().getResources().getDimension(R.dimen.reading_line_spacing);
|
||||
tv_lineSpace.setText(currentLineSpace + "");
|
||||
setTextViewSelect(tv_lhsize_default,true);
|
||||
config.setLineSpace(currentLineSpace);
|
||||
if (mSettingListener != null) {
|
||||
mSettingListener.changeLineHeight(currentLineSpace);
|
||||
|
@ -403,6 +411,7 @@ public class SettingDialog extends Dialog {
|
|||
private void subtractLineSpace() {
|
||||
if (currentLineSpace > LINE_SPACE_MIN) {
|
||||
currentLineSpace -= 1;
|
||||
setTextViewSelect(tv_lhsize_default,false);
|
||||
tv_lineSpace.setText(currentLineSpace + "");
|
||||
config.setLineSpace(currentLineSpace);
|
||||
if (mSettingListener != null) {
|
||||
|
@ -417,6 +426,7 @@ public class SettingDialog extends Dialog {
|
|||
if (currentFontSize < FONT_SIZE_MAX) {
|
||||
currentFontSize += 1;
|
||||
tv_size.setText(currentFontSize + "");
|
||||
setTextViewSelect(tv_size_default,false);
|
||||
config.setFontSize(currentFontSize);
|
||||
if (mSettingListener != null) {
|
||||
mSettingListener.changeFontSize(currentFontSize);
|
||||
|
@ -427,6 +437,7 @@ public class SettingDialog extends Dialog {
|
|||
private void defaultFontSize() {
|
||||
currentFontSize = (int) getContext().getResources().getDimension(R.dimen.reading_default_text_size);
|
||||
tv_size.setText(currentFontSize + "");
|
||||
setTextViewSelect(tv_size_default,true);
|
||||
config.setFontSize(currentFontSize);
|
||||
if (mSettingListener != null) {
|
||||
mSettingListener.changeFontSize(currentFontSize);
|
||||
|
@ -437,6 +448,7 @@ public class SettingDialog extends Dialog {
|
|||
private void subtractFontSize() {
|
||||
if (currentFontSize > FONT_SIZE_MIN) {
|
||||
currentFontSize -= 1;
|
||||
setTextViewSelect(tv_size_default,false);
|
||||
tv_size.setText(currentFontSize + "");
|
||||
config.setFontSize(currentFontSize);
|
||||
if (mSettingListener != null) {
|
||||
|
|
|
@ -25,7 +25,7 @@ public interface HttpApi {
|
|||
//请填写自己的接口名
|
||||
// @POST("abc")
|
||||
// Observable<ResponseBody> getDataForBean(@Body DouBanMovieRequest bean);
|
||||
//请填写自己的接口名
|
||||
|
||||
@GET("top250")
|
||||
Observable<ResponseBody> getDataForMap(@QueryMap Map<String, Integer> map);
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,47 @@
|
|||
package com.novelbook.android.netapi;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.novelbook.android.utils.Config;
|
||||
|
||||
/**
|
||||
* Created by 眼神 on 2018/3/27.
|
||||
*/
|
||||
|
||||
public class URLConstant {
|
||||
//存放全部的URL(可分为开发、测试、正式)
|
||||
public static String BASE_URL = "http://xiaoshuofenxiang.com/api/";//https://api.douban.com/v2/movie/";
|
||||
private static String BASE_URL = Config.getInstance().getBaseUrl() ;//https://api.douban.com/v2/movie/";
|
||||
public static String[] BASE_URLS = {"http://xiaoshuofenxiang.com/api/"};
|
||||
|
||||
|
||||
/**
|
||||
* 取新的baseURL
|
||||
* @return
|
||||
*/
|
||||
public static String newBaseUrl(){
|
||||
for (String url:BASE_URLS) {
|
||||
if(!url.equals(BASE_URL)){
|
||||
BASE_URL = url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(! Config.getInstance().getBaseUrl().equals(BASE_URL)){
|
||||
Config.getInstance().setBaseUrl(BASE_URL);
|
||||
}
|
||||
return BASE_URL;
|
||||
}
|
||||
|
||||
/**
|
||||
* app初始化取上次保存的baseurl
|
||||
* @return
|
||||
*/
|
||||
public static String getBaseUrl(){
|
||||
BASE_URL=Config.getInstance().getBaseUrl();
|
||||
if(TextUtils.isEmpty(BASE_URL)){
|
||||
BASE_URL = newBaseUrl();
|
||||
}
|
||||
return BASE_URL;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,10 @@ public class BookSubscribe {
|
|||
Observable<ResponseBody> observable = HttpMethods.getInstance().getHttpApi().getDataForMap(map);
|
||||
HttpMethods.getInstance().toSubscribe(observable, subscriber);
|
||||
}
|
||||
|
||||
public static void getMastDomain(DisposableObserver<ResponseBody> subscriber){
|
||||
Observable<ResponseBody> observable = HttpMethods.getInstance().getHttpApi().getMasterDomain();
|
||||
HttpMethods.getInstance().toSubscribe(observable, subscriber);
|
||||
}
|
||||
public static void getNovel(int novelId,DisposableObserver<ResponseBody> subscriber){
|
||||
Observable<ResponseBody> observable = HttpMethods.getInstance().getHttpApi().getNovel(novelId);
|
||||
HttpMethods.getInstance().toSubscribe(observable, subscriber);
|
||||
|
|
|
@ -33,14 +33,13 @@ import retrofit2.Retrofit;
|
|||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
/**
|
||||
* Created by 眼神 on 2018/3/27.
|
||||
*/
|
||||
import static com.novelbook.android.netapi.URLConstant.getBaseUrl;
|
||||
import static com.novelbook.android.netapi.URLConstant.newBaseUrl;
|
||||
|
||||
public class HttpMethods {
|
||||
public String TAG = "HttpMethods";
|
||||
public static final String CACHE_NAME = "ZHUIKE";
|
||||
public static String BASE_URL = URLConstant.BASE_URL;
|
||||
//public static String BASE_URL = getBaseUrl();
|
||||
private static final int DEFAULT_CONNECT_TIMEOUT = 30;
|
||||
private static final int DEFAULT_WRITE_TIMEOUT = 30;
|
||||
private static final int DEFAULT_READ_TIMEOUT = 30;
|
||||
|
@ -61,7 +60,7 @@ public class HttpMethods {
|
|||
.client(okHttpClient)
|
||||
.addConverterFactory(GsonConverterFactory.create())//json转换成JavaBean
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.baseUrl(BASE_URL)
|
||||
.baseUrl(getBaseUrl())
|
||||
.build();
|
||||
httpApi = retrofit.create(HttpApi.class);
|
||||
}
|
||||
|
@ -84,7 +83,7 @@ public class HttpMethods {
|
|||
/**
|
||||
* 获取retrofit
|
||||
*
|
||||
* @return
|
||||
* @returnc
|
||||
*/
|
||||
public Retrofit getRetrofit() {
|
||||
return retrofit;
|
||||
|
@ -99,7 +98,9 @@ public class HttpMethods {
|
|||
.build();
|
||||
httpApi = retrofit.create(HttpApi.class);
|
||||
}
|
||||
|
||||
public void changeBaseUrl() {
|
||||
changeBaseUrl(newBaseUrl());
|
||||
}
|
||||
/**
|
||||
* 获取httpService
|
||||
*
|
||||
|
|
|
@ -135,6 +135,7 @@ public class OnSuccessAndFaultSub extends DisposableObserver<ResponseBody>
|
|||
// Toast.makeText(context,"网关错误 ,请检查您的网络状态",Toast.LENGTH_LONG).show();
|
||||
mOnSuccessAndFaultListener.onFault("服务错误");
|
||||
}else if(code == 502) {
|
||||
HttpMethods.getInstance().changeBaseUrl(); //更新基本信息
|
||||
Toast.makeText(context,"网关错误 ,请检查您的网络状态",Toast.LENGTH_LONG).show();
|
||||
mOnSuccessAndFaultListener.onFault("服务错误");
|
||||
}else {
|
||||
|
|
|
@ -165,7 +165,7 @@ public class BookUtil {
|
|||
Thread.sleep(50);
|
||||
Log.d(TAG,String.format("prepare book %s waiting for mulu downloading ,mMuluStatus %s,msiteRule %s" ,mNovel.getName(),mMuluStatus,mSiteRule));
|
||||
if(mMuluStatus == MuluStatus.failed){
|
||||
dismissProgressDialog();
|
||||
|
||||
throw new RuntimeException("读取资源失败,请检查网络");
|
||||
}
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ public class BookUtil {
|
|||
}
|
||||
setSiteInfo();
|
||||
|
||||
showProgressDialog("正在换源",false);
|
||||
|
||||
isChangeSource = true;
|
||||
mChapters.clear();
|
||||
getSiteRule();
|
||||
|
@ -495,7 +495,7 @@ public class BookUtil {
|
|||
isDone,
|
||||
failed
|
||||
}
|
||||
private void showProgressDialog(String title,boolean canBreak) {
|
||||
/*private void showProgressDialog(String title,boolean canBreak) {
|
||||
if ( null == progressDialog) {
|
||||
progressDialog =new ProgressDialog(mContext);
|
||||
|
||||
|
@ -512,7 +512,7 @@ public class BookUtil {
|
|||
progressDialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
private void checkAndCreateDir(String path){
|
||||
File file = new File(path);
|
||||
if (!file.exists()){
|
||||
|
@ -1035,8 +1035,6 @@ public class BookUtil {
|
|||
|
||||
handlerMsg(msg);
|
||||
|
||||
|
||||
dismissProgressDialog();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1106,7 +1104,7 @@ public class BookUtil {
|
|||
File file = new File(fileChapterName(index));
|
||||
|
||||
if (!file.exists()) {
|
||||
showProgressDialog("请稍候",false);
|
||||
|
||||
new Thread(){
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -1190,7 +1188,7 @@ public class BookUtil {
|
|||
}
|
||||
Log.d("loadChaptContent",String.format("loadChaptContent slept %s for downloading ",slepttime ) );
|
||||
Log.d( "loadChaptContent",String.format("dismissing dialog " ));
|
||||
dismissProgressDialog();
|
||||
|
||||
Log.d(TAG,String.format("loadChaptContent slept %s for downloading chaptercontent ",slepttime ));
|
||||
}
|
||||
Log.d( "loadChaptContent",String.format(" %s, file.exists()? %s", file.getPath(),file.exists()));
|
||||
|
@ -1243,7 +1241,7 @@ public class BookUtil {
|
|||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
dismissProgressDialog();
|
||||
|
||||
}
|
||||
Cache cache = new Cache();
|
||||
cache.setSize(block.length);
|
||||
|
|
|
@ -4,14 +4,22 @@ import android.app.Activity;
|
|||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Display;
|
||||
import android.view.KeyCharacterMap;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.TextureView;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
@ -20,6 +28,147 @@ import java.util.Locale;
|
|||
|
||||
public class CommonUtil {
|
||||
|
||||
private static final String TAG= CommonUtil.class.getSimpleName();
|
||||
public static int getScreenHeight(Context context){
|
||||
|
||||
if(checkDeviceHasNavigationBar(context)){
|
||||
return getDpi(context);
|
||||
|
||||
}
|
||||
return getScreenHeightWithOutBottomBar(context);
|
||||
|
||||
}
|
||||
/**
|
||||
* 获取是否存在NavigationBar
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static boolean checkDeviceHasNavigationBar(Context context) {
|
||||
Point appUsableSize = getAppUsableScreenSize(context);
|
||||
Point realScreenSize = getRealScreenSize(context);
|
||||
|
||||
Log.d(TAG, String.format("getNavigationBarSize: usablesize.y %s,realScreenSize.y %s,realScreenSize.y -usablesize.y =%s, statusbar height %s"
|
||||
,appUsableSize.y ,realScreenSize.y, realScreenSize.y-appUsableSize.y ,getStatusBarHeight(context) ));
|
||||
Point p = getNavigationBarSize(context);
|
||||
return realScreenSize.y-appUsableSize.y - getStatusBarHeight(context)>0;
|
||||
|
||||
}
|
||||
public static Point getNavigationBarSize(Context context) {
|
||||
Point appUsableSize = getAppUsableScreenSize(context);
|
||||
Point realScreenSize = getRealScreenSize(context);
|
||||
|
||||
Log.d(TAG, String.format("getNavigationBarSize: usablesize.y %s,realScreenSize.y %s,realScreenSize.y -usablesize.y =%s, statusbar height %s"
|
||||
,appUsableSize.y ,realScreenSize.y, realScreenSize.y-appUsableSize.y ,getStatusBarHeight(context) ));
|
||||
// navigation bar on the side
|
||||
if (appUsableSize.x < realScreenSize.x) {
|
||||
return new Point(realScreenSize.x - appUsableSize.x, appUsableSize.y);
|
||||
}
|
||||
|
||||
// navigation bar at the bottom
|
||||
if (appUsableSize.y < realScreenSize.y) {
|
||||
return new Point(appUsableSize.x, realScreenSize.y - appUsableSize.y);
|
||||
}
|
||||
|
||||
// navigation bar is not present
|
||||
return new Point();
|
||||
}
|
||||
|
||||
public static Point getAppUsableScreenSize(Context context) {
|
||||
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = windowManager.getDefaultDisplay();
|
||||
Point size = new Point();
|
||||
display.getSize(size);
|
||||
return size;
|
||||
}
|
||||
|
||||
public static Point getRealScreenSize(Context context) {
|
||||
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = windowManager.getDefaultDisplay();
|
||||
Point size = new Point();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 17) {
|
||||
display.getRealSize(size);
|
||||
} else if (Build.VERSION.SDK_INT >= 14) {
|
||||
try {
|
||||
size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display);
|
||||
size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display);
|
||||
} catch (IllegalAccessException e) {} catch (InvocationTargetException e) {} catch (NoSuchMethodException e) {}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* 获取虚拟功能键高度
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static int getVirtualBarHeigh(Context context) {
|
||||
int vh = 0;
|
||||
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = windowManager.getDefaultDisplay();
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
try {
|
||||
@SuppressWarnings("rawtypes")
|
||||
Class c = Class.forName("android.view.Display");
|
||||
@SuppressWarnings("unchecked")
|
||||
Method method = c.getMethod("getRealMetrics", DisplayMetrics.class);
|
||||
method.invoke(display, dm);
|
||||
vh = dm.heightPixels - windowManager.getDefaultDisplay().getHeight();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return vh;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取屏幕原始尺寸高度,包括虚拟功能键高度
|
||||
* @param context
|
||||
|
@ -63,7 +212,7 @@ public class CommonUtil {
|
|||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static int getScreenHeight(Context context)
|
||||
public static int getScreenHeightWithOutBottomBar(Context context)
|
||||
{
|
||||
WindowManager wm = (WindowManager) context
|
||||
.getSystemService(Context.WINDOW_SERVICE);
|
||||
|
|
|
@ -17,6 +17,7 @@ public class Config {
|
|||
private final static String LIGHT_KEY = "light";
|
||||
private final static String SYSTEM_LIGHT_KEY = "systemlight";
|
||||
private final static String PAGE_MODE_KEY = "pagemode";
|
||||
private final static String KEY_BASE_URY = "baseurl";
|
||||
|
||||
public final static String FONTTYPE_DEFAULT = "";
|
||||
public final static String FONTTYPE_QIHEI = "font/qihei.ttf";
|
||||
|
@ -179,4 +180,15 @@ public class Config {
|
|||
this.light = light;
|
||||
sp.edit().putFloat(LIGHT_KEY,light).commit();
|
||||
}
|
||||
|
||||
|
||||
public String getBaseUrl(){
|
||||
return sp.getString(KEY_BASE_URY,"");
|
||||
}
|
||||
|
||||
public void setBaseUrl(String baseUrl){
|
||||
sp.edit().putString(KEY_BASE_URY,baseUrl).commit();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.novelbook.android.utils;
|
|||
public class Constants {
|
||||
public static final String BLOCK_TITLE_NOVELS = "ns";
|
||||
public static final int NOVEL_SPAN_CNT =3 ; //grid columns
|
||||
public static final boolean SHOWAD =false ;
|
||||
public static int SEX=1;
|
||||
public static String A_Regex = "<a[^>]+href[\\s]*=[\\s]*['\"]?([^'\"]+)['\"\\s]?[^>]*>([^<]+)<"; //TODO: 从服务器更新
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.novelbook.android.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
@ -8,7 +9,11 @@ import com.bumptech.glide.Glide;
|
|||
public class MyImageLoader extends com.youth.banner.loader.ImageLoader {
|
||||
@Override
|
||||
public void displayImage(Context context, Object path, ImageView imageView) {
|
||||
Glide.with(context).load((String) path).into(imageView);
|
||||
try {
|
||||
Glide.with(context).load((String) path).into(imageView);
|
||||
}catch (Exception e){
|
||||
Log.e("MyImageLoader", "displayImage: ",e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ import android.graphics.RectF;
|
|||
import android.graphics.Region;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
|
@ -156,7 +158,7 @@ public class PageFactory implements ChangeSource{
|
|||
private TRPage currentPage;
|
||||
private TRPage prePage;
|
||||
private TRPage cancelPage;
|
||||
private BookTask bookTask;
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
|
||||
|
||||
|
@ -165,9 +167,30 @@ public class PageFactory implements ChangeSource{
|
|||
private List<TRPage> preChaptPages;
|
||||
|
||||
private AdInterface mAd;
|
||||
private BookTask bookTask;
|
||||
|
||||
public void setAd(AdInterface ad){
|
||||
mAd =ad;
|
||||
}
|
||||
Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
|
||||
int wt = msg.what;
|
||||
|
||||
handlerMsg(msg);
|
||||
|
||||
dismissProgressDialog();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void handlerMsg(Message msg) {
|
||||
if (msg.what == 1) {
|
||||
changeChapter(currentChapter);
|
||||
}
|
||||
}
|
||||
private List<TRPage> loadCurrentChapt(int chaptId){
|
||||
|
||||
chaptId = chaptId >getChapters().size()?getChapters().size():chaptId;
|
||||
|
@ -185,9 +208,10 @@ public class PageFactory implements ChangeSource{
|
|||
drawStatus(mBookPageWidget.getCurPage());
|
||||
drawStatus(mBookPageWidget.getNextPage());
|
||||
|
||||
File file = new File(getChapterFileName(chaptId));
|
||||
final File file = new File(getChapterFileName(chaptId));
|
||||
if (!file.exists()) {
|
||||
|
||||
Log.d(TAG, String.format("prepare book to open chapter %s ,file is not download",chaptId ) );
|
||||
mStatus = Status.OPENING;
|
||||
if( !NetUtil.isNetworkConnected()){ //TODO: 500错误处理
|
||||
mStatus = Status.NETWORKFAILE;
|
||||
drawStatus(mBookPageWidget.getCurPage());
|
||||
|
@ -195,6 +219,46 @@ public class PageFactory implements ChangeSource{
|
|||
return chaptPages;
|
||||
}
|
||||
|
||||
// showProgressDialog();
|
||||
final int chid = chaptId;
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.d(TAG, String.format("prepare book to download chapter %s ,thread.name %s",chid,Thread.currentThread().getName() ) );
|
||||
mBookUtil.chaptChars(chid);
|
||||
|
||||
super.run();
|
||||
}}.start();
|
||||
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
int slepttime =0;
|
||||
while( !file.exists() && slepttime <100){
|
||||
try {
|
||||
sleep(50);
|
||||
slepttime++;
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Log.d(TAG, String.format("prepare book to download chapter %s ,slepted %s ,thread.name %s",chid,slepttime*50 ,Thread.currentThread().getName() ) );
|
||||
mStatus = Status.FINISH;
|
||||
//notice file done
|
||||
handler.sendEmptyMessage(1);
|
||||
|
||||
|
||||
super.run();
|
||||
}}.start();
|
||||
|
||||
|
||||
|
||||
drawStatus(mBookPageWidget.getCurPage());
|
||||
drawStatus(mBookPageWidget.getNextPage());
|
||||
return chaptPages;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}else if(getChapters().size()==0) {
|
||||
|
@ -262,8 +326,14 @@ public class PageFactory implements ChangeSource{
|
|||
private void showProgressDialog() {
|
||||
if ( null == progressDialog) {
|
||||
progressDialog =new ProgressDialog(mContext);
|
||||
progressDialog.setMessage("正在努力加载...");
|
||||
}
|
||||
try {
|
||||
progressDialog.show();
|
||||
}catch (Exception e)
|
||||
{
|
||||
Log.e(TAG, "prepare book: ", e);
|
||||
}
|
||||
progressDialog.show();
|
||||
// progressDialog.show(mContext,"网络不给力","正努力加载",false,true);
|
||||
}
|
||||
|
||||
|
@ -293,6 +363,13 @@ public class PageFactory implements ChangeSource{
|
|||
return mBookUtil.fileChapterName(chapid);
|
||||
}
|
||||
|
||||
private static boolean isBusy =false;
|
||||
public void setBusy(boolean isBusy) {
|
||||
this.isBusy = isBusy;
|
||||
}
|
||||
public static boolean busy(){
|
||||
return isBusy;
|
||||
}
|
||||
|
||||
public enum Status {
|
||||
OPENING,
|
||||
|
@ -318,12 +395,13 @@ public class PageFactory implements ChangeSource{
|
|||
mContext = context.getApplicationContext();
|
||||
config = Config.getInstance();
|
||||
//获取屏幕宽高
|
||||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
DisplayMetrics metric = new DisplayMetrics();
|
||||
wm.getDefaultDisplay().getMetrics(metric);
|
||||
mWidth = metric.widthPixels;
|
||||
mHeight = metric.heightPixels;
|
||||
|
||||
// mHeight = metric.heightPixels;
|
||||
// mHeight = CommonUtil.getDpi(context);
|
||||
mHeight = CommonUtil.getScreenHeight(context);
|
||||
sdf = new SimpleDateFormat("HH:mm");//HH:mm为24小时制,hh:mm为12小时制
|
||||
date = sdf.format(new java.util.Date());
|
||||
df = new DecimalFormat("#0.0");
|
||||
|
@ -415,7 +493,7 @@ public class PageFactory implements ChangeSource{
|
|||
String status = "";
|
||||
switch (mStatus){
|
||||
case OPENING:
|
||||
status = "正在打开书本...";
|
||||
status = "正在拼命加载...";
|
||||
break;
|
||||
case FAIL:
|
||||
status = "打开书本失败!";
|
||||
|
@ -472,12 +550,9 @@ public class PageFactory implements ChangeSource{
|
|||
// * column won't be updated.
|
||||
// mBook.save();
|
||||
|
||||
|
||||
|
||||
Novel nv = LitePal.find(Novel.class,mBook.getId());
|
||||
|
||||
/* Novel nv = LitePal.find(Novel.class,mBook.getId());
|
||||
Log.d(TAG,String.format("prepare book saved lastchapt %s,lastpos %s, db lastchapt %s last pos %s",
|
||||
currentChapter,currentPage.getBegin(),nv.getLastReadChapt(),nv.getLastReadPos()));
|
||||
currentChapter,currentPage.getBegin(),nv.getLastReadChapt(),nv.getLastReadPos()));*/
|
||||
|
||||
|
||||
|
||||
|
@ -687,6 +762,7 @@ public class PageFactory implements ChangeSource{
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Log.d(TAG, "prepareBook: .start prepare book " + book.getName());
|
||||
this.mBook = book ;
|
||||
mBookUtil = new BookUtil();
|
||||
|
@ -705,6 +781,7 @@ public class PageFactory implements ChangeSource{
|
|||
mBookUtil = new BookUtil();
|
||||
}
|
||||
mBookUtil.setContext(context);
|
||||
mContext =context;
|
||||
mBookUtil.pagefactory=this;
|
||||
//清空数据
|
||||
currentChapter = 0;
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.view.WindowManager;
|
|||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.Scroller;
|
||||
|
||||
import com.novelbook.android.utils.CommonUtil;
|
||||
import com.novelbook.android.utils.PageFactory;
|
||||
|
||||
|
||||
|
@ -124,7 +125,9 @@ public class BookPageWidget extends View {
|
|||
DisplayMetrics metric = new DisplayMetrics();
|
||||
wm.getDefaultDisplay().getMetrics(metric);
|
||||
mScreenWidth = metric.widthPixels;
|
||||
mScreenHeight = metric.heightPixels;
|
||||
// mScreenHeight = metric.heightPixels;
|
||||
// mScreenHeight = CommonUtil.getDpi(mContext);
|
||||
mScreenHeight = CommonUtil.getScreenHeight(mContext);
|
||||
mCurPageBitmap = Bitmap.createBitmap(mScreenWidth, mScreenHeight, Bitmap.Config.RGB_565); //android:LargeHeap=true use in manifest application
|
||||
mNextPageBitmap = Bitmap.createBitmap(mScreenWidth, mScreenHeight, Bitmap.Config.RGB_565);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.view.WindowManager;
|
|||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.Scroller;
|
||||
|
||||
import com.novelbook.android.utils.CommonUtil;
|
||||
import com.novelbook.android.utils.PageFactory;
|
||||
import com.novelbook.android.view.animation.AnimationProvider;
|
||||
import com.novelbook.android.view.animation.CoverAnimation;
|
||||
|
@ -75,7 +76,9 @@ public class PageWidget extends View {
|
|||
DisplayMetrics metric = new DisplayMetrics();
|
||||
wm.getDefaultDisplay().getMetrics(metric);
|
||||
mScreenWidth = metric.widthPixels;
|
||||
mScreenHeight = metric.heightPixels;
|
||||
// mScreenHeight = metric.heightPixels;
|
||||
// mScreenHeight = CommonUtil.getDpi(mContext);
|
||||
mScreenHeight = CommonUtil.getScreenHeight(mContext);
|
||||
mCurPageBitmap = Bitmap.createBitmap(mScreenWidth, mScreenHeight, Bitmap.Config.RGB_565); //android:LargeHeap=true use in manifest application
|
||||
mNextPageBitmap = Bitmap.createBitmap(mScreenWidth, mScreenHeight, Bitmap.Config.RGB_565);
|
||||
}
|
||||
|
@ -126,7 +129,7 @@ public class PageWidget extends View {
|
|||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
super.onTouchEvent(event);
|
||||
if (PageFactory.getStatus() == PageFactory.Status.OPENING){
|
||||
if ( PageFactory.getStatus() == PageFactory.Status.OPENING){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
android:scaleType="centerCrop"
|
||||
|
||||
|
||||
/>
|
||||
android:contentDescription="TODO" />
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
@ -151,7 +151,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="00.00%"
|
||||
android:text="@string/_00_00"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp" />
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
android:background="@color/read_dialog_bg"
|
||||
android:padding="10dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -1,125 +1,126 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/book_pop"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true">
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<!-- <LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="vertical">
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:padding="20dp"
|
||||
android:background="@color/black"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_progress"
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
android:text="00.00%"/>
|
||||
</RelativeLayout>
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:background="@color/black"
|
||||
android:padding="20dp"
|
||||
android:visibility="gone">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/bookpop_bottom"
|
||||
android:baselineAligned="false"
|
||||
android:background="@color/read_dialog_bg"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/tv_progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="00.00%"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/bookpop_bottom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="70dp"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:id="@+id/tv_pre"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/read_setting_pre"
|
||||
android:textAlignment="center"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@color/white"
|
||||
android:layout_gravity="center_vertical"
|
||||
/>
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/read_dialog_bg"
|
||||
android:baselineAligned="false"
|
||||
android:orientation="vertical">
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/sb_progress"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:max="10000"
|
||||
android:visibility="invisible"
|
||||
android:layout_gravity="center_vertical">
|
||||
</SeekBar>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="70dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_next"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/read_setting_next"
|
||||
android:textAlignment="center"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@color/white"
|
||||
android:layout_gravity="center_vertical"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/tv_pre"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/read_setting_pre"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/sb_progress"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:max="10000"
|
||||
android:visibility="invisible"></SeekBar>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_next"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/read_setting_next"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_directory"
|
||||
style="@style/text_style"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_alignParentLeft="true"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="@string/read_setting_directory" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_dayornight"
|
||||
style="@style/text_style"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="@string/read_setting_night" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_setting"
|
||||
style="@style/text_style"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="@string/read_setting_set" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
style="@style/text_style"
|
||||
android:id="@+id/tv_directory"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:gravity="center"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/read_setting_directory" />
|
||||
|
||||
<TextView
|
||||
style="@style/text_style"
|
||||
android:id="@+id/tv_dayornight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_centerInParent="true"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/read_setting_night" />
|
||||
|
||||
<TextView
|
||||
style="@style/text_style"
|
||||
android:id="@+id/tv_setting"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_alignParentRight="true"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/read_setting_set" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>-->
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
|
||||
<SeekBar
|
||||
android:id="@+id/sb_brightness"
|
||||
android:layout_width="150dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="4"
|
||||
android:layout_weight="3"
|
||||
android:gravity="center"
|
||||
android:max="100"
|
||||
android:layout_gravity="center_vertical">
|
||||
|
@ -51,7 +51,9 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/tv_xitong"
|
||||
android:layout_weight="0"
|
||||
style="@style/setting_dialog_button"
|
||||
android:layout_width="65dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:textSize="16sp"
|
||||
android:text="@string/setting_system" />
|
||||
|
@ -93,7 +95,8 @@
|
|||
android:id="@+id/tv_size_default"
|
||||
style="@style/setting_dialog_button"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:textColor="@color/white"
|
||||
android:layout_width="65dp"
|
||||
android:textSize="16sp"
|
||||
android:text="@string/setting_default" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
|
@ -132,7 +135,8 @@
|
|||
android:id="@+id/tv_lhsize_default"
|
||||
style="@style/setting_dialog_button"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:textColor="@color/white"
|
||||
android:layout_width="65dp"
|
||||
android:textSize="16sp"
|
||||
android:text="@string/setting_default" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
|
|
|
@ -186,6 +186,7 @@
|
|||
<string name="aboutContent">如风小说阅读是专注于提供更舒适的阅读体验,主打本地阅读,操作方式简单易上手,目前支持txt格式。</string>
|
||||
<string name="noRecord">没有数据</string>
|
||||
<string name="title_Activity_ChgSource">换源</string>
|
||||
<string name="_00_00">00.00%</string>
|
||||
|
||||
<string-array name="voicer_cloud_entries">
|
||||
<item>小燕—女青、中英、普通话</item>
|
||||
|
|
|
@ -261,7 +261,7 @@
|
|||
<item name="android:layout_gravity">center_vertical</item>
|
||||
<item name="android:gravity">center</item>
|
||||
<item name="android:background">@drawable/rb_nobtn_selector</item>
|
||||
<item name="android:textColor">@color/darkcyan</item>
|
||||
<item name="android:textColor">@color/white</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
</style>
|
||||
<style name="text_style">
|
||||
|
|
Loading…
Reference in New Issue