parent
0e5e8968d6
commit
02df9f1114
|
@ -64,8 +64,8 @@
|
||||||
android:value=".Main7Activity" />
|
android:value=".Main7Activity" />
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".Main5Activity"
|
android:name=".Activity_ChgSource"
|
||||||
android:label="@string/title_activity_main5" />
|
android:label="@string/title_Activity_ChgSource" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".BookActivity"
|
android:name=".BookActivity"
|
||||||
android:label="@string/title_activity_book"
|
android:label="@string/title_activity_book"
|
||||||
|
|
|
@ -0,0 +1,219 @@
|
||||||
|
package com.novelbook.android;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.novelbook.android.bean.Site;
|
||||||
|
import com.novelbook.android.db.Novel;
|
||||||
|
|
||||||
|
import com.novelbook.android.utils.PageFactory;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
|
public class Activity_ChgSource extends Activity_base {
|
||||||
|
|
||||||
|
private static final String TAG = Activity_ChgSource.class.getSimpleName();
|
||||||
|
|
||||||
|
@BindView(R.id.recycleView)
|
||||||
|
RecyclerView recyclerView;
|
||||||
|
|
||||||
|
private ArrayList<Fragment> mFragments;
|
||||||
|
String chaptTitle;
|
||||||
|
int chaptId;
|
||||||
|
String domain;
|
||||||
|
public final static String EXTR_TITLE="title";
|
||||||
|
public final static String EXTR_ID="id";
|
||||||
|
public final static String EXTR_SITE="site";
|
||||||
|
|
||||||
|
PageFactory pageFactory;
|
||||||
|
|
||||||
|
List<Site> mSites;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLayoutRes() {
|
||||||
|
return R.layout.activity_chgsource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initViews() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setTitle() {
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
|
WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes();
|
||||||
|
localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags);
|
||||||
|
|
||||||
|
}
|
||||||
|
chaptTitle = getIntent().getStringExtra(EXTR_TITLE);
|
||||||
|
|
||||||
|
chaptId = getIntent().getIntExtra(EXTR_ID,1);
|
||||||
|
|
||||||
|
domain = getIntent().getStringExtra(EXTR_SITE);
|
||||||
|
this.setTitle(chaptTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initData() {
|
||||||
|
pageFactory =PageFactory.getInstance();
|
||||||
|
mSites = new ArrayList<Site>(Arrays.asList(pageFactory.getNovelSites().getSites()));
|
||||||
|
SiteAdapter mAdapter = new SiteAdapter(this, mSites, R.layout.recycle_list_one_item, new OnItemClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClick(View view, int position) {
|
||||||
|
|
||||||
|
Site site = mSites.get(position);
|
||||||
|
Log.d(TAG, "changing Source: " + site.getDomain());
|
||||||
|
pageFactory.changeSource(site.getDomain(),chaptId,chaptTitle);
|
||||||
|
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||||
|
recyclerView.setAdapter(mAdapter);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnItemClickListener
|
||||||
|
{
|
||||||
|
void onItemClick(View view, int position);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class SiteAdapter extends RecyclerView.Adapter<SiteAdapter.SiteViewHolder> {
|
||||||
|
private final int EMPTY_VIEW = 1;
|
||||||
|
private final int PROGRESS_VIEW = 2;
|
||||||
|
private final int IMAGE_VIEW = 3;
|
||||||
|
|
||||||
|
private Context context;
|
||||||
|
private List<Site> mDatas ;
|
||||||
|
private OnItemClickListener mOnItemClickListener;
|
||||||
|
private int listItemID;
|
||||||
|
|
||||||
|
private List<Novel> mSites;
|
||||||
|
|
||||||
|
public SiteAdapter(Context context, List<Site> mSites, int listItemID, OnItemClickListener clickLitener) {
|
||||||
|
this.context = context;
|
||||||
|
this.mDatas = mSites;
|
||||||
|
this.mOnItemClickListener = clickLitener;
|
||||||
|
this.listItemID = listItemID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public SiteAdapter(Context context, OnItemClickListener clickLitener) {
|
||||||
|
this.context = context;
|
||||||
|
this.mOnItemClickListener = clickLitener;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setListener(OnItemClickListener clickLitener){
|
||||||
|
this.mOnItemClickListener = clickLitener;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType(int position) {
|
||||||
|
if (mDatas.size() == 0) {
|
||||||
|
return EMPTY_VIEW;
|
||||||
|
} else if (mDatas.get(position) == null) {
|
||||||
|
return PROGRESS_VIEW;
|
||||||
|
} else {
|
||||||
|
return super.getItemViewType(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SiteViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
|
SiteAdapter.SiteViewHolder holder = new SiteViewHolder(LayoutInflater.from(
|
||||||
|
context).inflate(listItemID, parent,
|
||||||
|
false));
|
||||||
|
return holder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setParameters(List<Site> mDatas, int listItemID) {
|
||||||
|
this.mDatas = mDatas;
|
||||||
|
this.listItemID = listItemID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnItemClickLitener(OnItemClickListener mOnItemClickLitener) {
|
||||||
|
this.mOnItemClickListener = mOnItemClickLitener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder( SiteViewHolder holder, int position) {
|
||||||
|
String title =mDatas.get(position).getDomain();
|
||||||
|
Log.d(TAG, String.format("onBindViewHolder: domain is '%s', title is '%s'",domain ,title));
|
||||||
|
if(title.equals(domain)){
|
||||||
|
title +=" (当前源)";
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.tvTitle.setText(title); //.getName()
|
||||||
|
|
||||||
|
// 如果设置了回调,则设置点击事件
|
||||||
|
if (mOnItemClickListener != null) {
|
||||||
|
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
int pos = holder.getLayoutPosition();
|
||||||
|
mOnItemClickListener.onItemClick(holder.itemView, pos);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return mDatas.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addData(int position) {
|
||||||
|
// mDatas.add(position, "Insert One");
|
||||||
|
notifyItemInserted(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeData(int position) {
|
||||||
|
mDatas.remove(position);
|
||||||
|
notifyItemRemoved(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SiteViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
@BindView(R.id.tvText)
|
||||||
|
TextView tvTitle;
|
||||||
|
public SiteViewHolder(View view) {
|
||||||
|
super(view);
|
||||||
|
ButterKnife.bind(this, view);
|
||||||
|
//tvTitle = (TextView) view.findViewById(R.id.title);
|
||||||
|
// tvAuthor = (TextView) view.findViewById(R.id.author);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -87,8 +87,10 @@ public abstract class Activity_base extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(View view, int position)
|
public void onItemClick(View view, int position)
|
||||||
{
|
{
|
||||||
|
|
||||||
// showBook("射雕" +position);
|
// showBook("射雕" +position);
|
||||||
showBookDetail(mDatas.get(position));
|
showBookDetail(mDatas.get(position));
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -279,7 +279,7 @@ public class BookActivity extends Activity_base {
|
||||||
.load( Uri.decode(NetUtil.getCoverUrl(mNovel.getCover())))
|
.load( Uri.decode(NetUtil.getCoverUrl(mNovel.getCover())))
|
||||||
.dontAnimate()
|
.dontAnimate()
|
||||||
// .error(R.mipmap.side_bg2)
|
// .error(R.mipmap.side_bg2)
|
||||||
.transform(new GaoSiTransForm(this, 50, 3)) // "14":模糊度;"3":图片缩放3倍后再进行模糊
|
.transform(new GaoSiTransForm(this, 100, 3)) // "14":模糊度;"3":图片缩放3倍后再进行模糊
|
||||||
.into(imageViewHead);
|
.into(imageViewHead);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package com.novelbook.android;
|
package com.novelbook.android;
|
||||||
|
|
||||||
import android.app.SearchManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
@ -10,7 +8,6 @@ import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.support.v7.widget.AppCompatSpinner;
|
import android.support.v7.widget.AppCompatSpinner;
|
||||||
import android.support.v7.widget.SearchView;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -18,7 +15,6 @@ import android.support.design.widget.NavigationView;
|
||||||
import android.support.v4.view.GravityCompat;
|
import android.support.v4.view.GravityCompat;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.support.v7.app.ActionBarDrawerToggle;
|
import android.support.v7.app.ActionBarDrawerToggle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
@ -31,14 +27,11 @@ import com.novelbook.android.Fragments.BasicFragment;
|
||||||
import com.novelbook.android.Fragments.Fragment_Shelf;
|
import com.novelbook.android.Fragments.Fragment_Shelf;
|
||||||
import com.novelbook.android.Fragments.Fragment_bookStore;
|
import com.novelbook.android.Fragments.Fragment_bookStore;
|
||||||
import com.novelbook.android.Fragments.Fragment_paihang;
|
import com.novelbook.android.Fragments.Fragment_paihang;
|
||||||
|
import com.novelbook.android.utils.Config;
|
||||||
import com.novelbook.android.utils.Constants;
|
import com.novelbook.android.utils.Constants;
|
||||||
|
|
||||||
|
|
||||||
import org.litepal.util.Const;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import butterknife.OnCheckedChanged;
|
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
|
|
||||||
public class Main2Activity extends Activity_base
|
public class Main2Activity extends Activity_base
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
package com.novelbook.android;
|
|
||||||
|
|
||||||
import android.animation.Animator;
|
|
||||||
import android.animation.AnimatorListenerAdapter;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.design.widget.BottomNavigationView;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import io.alterac.blurkit.BlurLayout;
|
|
||||||
|
|
||||||
public class Main5Activity extends AppCompatActivity {
|
|
||||||
private BlurLayout blurLayout;
|
|
||||||
private float movement = 150;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_main5);
|
|
||||||
blurLayout = (BlurLayout) findViewById(R.id.blurLayout);
|
|
||||||
|
|
||||||
blurLayout.animate().translationY(movement).setDuration(1500).setListener(new AnimatorListenerAdapter() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation) {
|
|
||||||
super.onAnimationEnd(animation);
|
|
||||||
movement = movement > 0 ? -150 : 150;
|
|
||||||
blurLayout.animate().translationY(movement).setDuration(1500).setListener(this).start();
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
blurLayout.startBlur();
|
|
||||||
blurLayout.lockView();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop() {
|
|
||||||
super.onStop();
|
|
||||||
blurLayout.pauseBlur();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,22 +1,17 @@
|
||||||
package com.novelbook.android;
|
package com.novelbook.android;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.support.design.widget.AppBarLayout;
|
import android.support.design.widget.AppBarLayout;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.astuetz.PagerSlidingTabStrip;
|
|
||||||
import com.flyco.tablayout.SlidingTabLayout;
|
import com.flyco.tablayout.SlidingTabLayout;
|
||||||
import com.novelbook.android.adapter.MyPagerAdapter;
|
import com.novelbook.android.adapter.MyPagerAdapter;
|
||||||
import com.novelbook.android.db.Chapter;
|
import com.novelbook.android.db.Chapter;
|
||||||
import com.novelbook.android.db.Novel;
|
import com.novelbook.android.utils.Config;
|
||||||
import com.novelbook.android.utils.FileUtils;
|
|
||||||
import com.novelbook.android.utils.PageFactory;
|
import com.novelbook.android.utils.PageFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
|
@ -3,13 +3,11 @@ package com.novelbook.android;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.novelbook.android.utils.Config;
|
||||||
import com.novelbook.android.utils.PageFactory;
|
import com.novelbook.android.utils.PageFactory;
|
||||||
|
|
||||||
import org.litepal.LitePal;
|
import org.litepal.LitePal;
|
||||||
|
|
||||||
|
|
||||||
import io.alterac.blurkit.BlurKit;
|
|
||||||
|
|
||||||
public class MyApp extends Application {
|
public class MyApp extends Application {
|
||||||
public static volatile Context applicationContext = null;
|
public static volatile Context applicationContext = null;
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.novelbook.android;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.ProgressDialog;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
@ -42,6 +41,7 @@ import com.novelbook.android.dialog.PageModeDialog;
|
||||||
import com.novelbook.android.dialog.SettingDialog;
|
import com.novelbook.android.dialog.SettingDialog;
|
||||||
import com.novelbook.android.utils.AdInterface;
|
import com.novelbook.android.utils.AdInterface;
|
||||||
import com.novelbook.android.utils.BrightnessUtil;
|
import com.novelbook.android.utils.BrightnessUtil;
|
||||||
|
import com.novelbook.android.utils.Config;
|
||||||
import com.novelbook.android.utils.PageFactory;
|
import com.novelbook.android.utils.PageFactory;
|
||||||
import com.novelbook.android.view.PageWidget;
|
import com.novelbook.android.view.PageWidget;
|
||||||
|
|
||||||
|
@ -430,8 +430,10 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
Log.d(TAG, "onKeyDown: pressed key");
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
|
Log.d(TAG, "onKeyDown: pressed back");
|
||||||
if (isShow){
|
if (isShow){
|
||||||
hideReadSetting();
|
hideReadSetting();
|
||||||
return true;
|
return true;
|
||||||
|
@ -533,7 +535,8 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if (id == R.id.action_read_book){
|
}
|
||||||
|
/* else if (id == R.id.action_read_book){
|
||||||
initialTts();
|
initialTts();
|
||||||
if (mSpeechSynthesizer != null){
|
if (mSpeechSynthesizer != null){
|
||||||
mSpeechSynthesizer.setParam(SpeechSynthesizer.PARAM_VOLUME, "5");
|
mSpeechSynthesizer.setParam(SpeechSynthesizer.PARAM_VOLUME, "5");
|
||||||
|
@ -552,6 +555,13 @@ public class ReadActivity extends Activity_base implements SpeechSynthesizerLis
|
||||||
isSpeaking = true;
|
isSpeaking = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
|
else if (id == R.id.action_change_source) {
|
||||||
|
Intent intent = new Intent(ReadActivity.this, Activity_ChgSource.class);
|
||||||
|
intent.putExtra(Activity_ChgSource.EXTR_ID,pageFactory.getCurrentChapter());
|
||||||
|
intent.putExtra(Activity_ChgSource.EXTR_TITLE,pageFactory.getChapterName());
|
||||||
|
intent.putExtra(Activity_ChgSource.EXTR_SITE,pageFactory.getSite());
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
|
|
|
@ -8,7 +8,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.novelbook.android.Config;
|
import com.novelbook.android.utils.Config;
|
||||||
import com.novelbook.android.R;
|
import com.novelbook.android.R;
|
||||||
import com.novelbook.android.db.Chapter;
|
import com.novelbook.android.db.Chapter;
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class CatalogueAdapter extends BaseAdapter {
|
||||||
}else {
|
}else {
|
||||||
viewHolder = (ViewHolder)convertView.getTag();
|
viewHolder = (ViewHolder)convertView.getTag();
|
||||||
}
|
}
|
||||||
if (currentCharter == position){
|
if (currentCharter == position+1){
|
||||||
viewHolder.catalogue_tv.setTextColor(mContext.getResources().getColor(R.color.colorPrimaryDark));
|
viewHolder.catalogue_tv.setTextColor(mContext.getResources().getColor(R.color.colorPrimaryDark));
|
||||||
}else{
|
}else{
|
||||||
viewHolder.catalogue_tv.setTextColor(mContext.getResources().getColor(R.color.dark_gray));
|
viewHolder.catalogue_tv.setTextColor(mContext.getResources().getColor(R.color.dark_gray));
|
||||||
|
|
|
@ -9,12 +9,11 @@ import android.widget.BaseAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
|
||||||
import com.novelbook.android.Config;
|
import com.novelbook.android.utils.Config;
|
||||||
import com.novelbook.android.R;
|
import com.novelbook.android.R;
|
||||||
import com.novelbook.android.db.BookMarks;
|
import com.novelbook.android.db.BookMarks;
|
||||||
import com.novelbook.android.utils.PageFactory;
|
import com.novelbook.android.utils.PageFactory;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.novelbook.android.bean;
|
package com.novelbook.android.bean;
|
||||||
|
|
||||||
public class Site {
|
public class Site {
|
||||||
|
private String name;
|
||||||
private String domain;
|
private String domain;
|
||||||
private String muluUrl;
|
private String muluUrl;
|
||||||
private Boolean selectedByDefault;
|
private Boolean selectedByDefault;
|
||||||
|
@ -28,4 +29,12 @@ public class Site {
|
||||||
public void setSelectedByDefault(Boolean selectedByDefault) {
|
public void setSelectedByDefault(Boolean selectedByDefault) {
|
||||||
this.selectedByDefault = selectedByDefault;
|
this.selectedByDefault = selectedByDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.novelbook.android.Config;
|
import com.novelbook.android.utils.Config;
|
||||||
import com.novelbook.android.R;
|
import com.novelbook.android.R;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import android.widget.RelativeLayout;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.novelbook.android.Config;
|
import com.novelbook.android.utils.Config;
|
||||||
import com.novelbook.android.R;
|
import com.novelbook.android.R;
|
||||||
import com.novelbook.android.view.BookPageWidget;
|
import com.novelbook.android.view.BookPageWidget;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import android.widget.TextView;
|
||||||
|
|
||||||
|
|
||||||
import com.baidu.android.common.logging.Log;
|
import com.baidu.android.common.logging.Log;
|
||||||
import com.novelbook.android.Config;
|
import com.novelbook.android.utils.Config;
|
||||||
import com.novelbook.android.R;
|
import com.novelbook.android.R;
|
||||||
import com.novelbook.android.utils.DisplayUtils;
|
import com.novelbook.android.utils.DisplayUtils;
|
||||||
import com.novelbook.android.view.CircleImageView;
|
import com.novelbook.android.view.CircleImageView;
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
@ -115,6 +116,10 @@ public class BookUtil {
|
||||||
private Site mSite;
|
private Site mSite;
|
||||||
private SiteRule mSiteRule;
|
private SiteRule mSiteRule;
|
||||||
|
|
||||||
|
public NovelSites getmNovelSites() {
|
||||||
|
return mNovelSites;
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void openBook(Novel novel) throws IOException, InterruptedException {
|
public synchronized void openBook(Novel novel) throws IOException, InterruptedException {
|
||||||
this.mNovel = novel;
|
this.mNovel = novel;
|
||||||
//如果当前缓存不是要打开的书本就缓存书本同时删除缓存
|
//如果当前缓存不是要打开的书本就缓存书本同时删除缓存
|
||||||
|
@ -306,15 +311,190 @@ public class BookUtil {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isChangeSource =false;
|
||||||
|
private int mChangeChapId;
|
||||||
|
private String mChangeTitle;
|
||||||
|
public void changeSource(String domain,int chapId,String chapTitle) {
|
||||||
|
Log.d(TAG, String.format("changing Source: target domain %s chaptId %s, chapt title %s ",domain,chapId,chapTitle) );
|
||||||
|
if(mSite.getDomain().equals(domain)){ //当前源
|
||||||
|
Log.d(TAG, "changing Source: same site with original " + domain);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mChangeChapId = chapId;
|
||||||
|
mChangeTitle =chapTitle;
|
||||||
|
for (Site site:mNovelSites.getSites() ) {
|
||||||
|
if(site.getDomain().equals(domain)){
|
||||||
|
mSite = site;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setSiteInfo();
|
||||||
|
|
||||||
|
showProgressDialog("正在换源",false);
|
||||||
|
isChangeSource = true;
|
||||||
|
mChapters.clear();
|
||||||
|
getSiteRule();
|
||||||
|
|
||||||
|
BookTask btsk = new BookTask();
|
||||||
|
btsk.execute( domain, chapId+"", chapTitle);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSite() {
|
||||||
|
return mSite !=null? mSite.getDomain():"";
|
||||||
|
}
|
||||||
|
|
||||||
|
private class BookTask extends AsyncTask<String,Void,Boolean> {
|
||||||
|
private String domain;
|
||||||
|
private int chapId;
|
||||||
|
private String chapTitle;
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Boolean result) {
|
||||||
|
super.onPostExecute(result);
|
||||||
|
Log.d("onPostExecute",isCancelled() + "");
|
||||||
|
if (isCancelled()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (result) {
|
||||||
|
Log.d(TAG, "changing Source:successed get chapters for " + mSite.getDomain() );
|
||||||
|
|
||||||
|
int chId=chapterNo;
|
||||||
|
String title ="";
|
||||||
|
if( mChapters.size() >= mChangeChapId && mChapters.get(mChangeChapId-1)!=null ){
|
||||||
|
title= mChapters.get(mChangeChapId-1).getChapterName();
|
||||||
|
Log.d(TAG, "changing Source:chapter name in new site " + title );
|
||||||
|
}
|
||||||
|
if(title.equals(mChangeTitle)) {
|
||||||
|
Log.d(TAG, "changing Source:successed find chapter by original chaptId " + mChangeChapId + ":" + mChangeTitle);
|
||||||
|
chId = mChangeChapId;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int i = 1;
|
||||||
|
for (Chapter chapter : mChapters) {
|
||||||
|
Log.d(TAG, "changing Source: finding chapter " + i + ":" + chapter.getChapterName());
|
||||||
|
if (chapter.getChapterName().equals(mChangeTitle)) {
|
||||||
|
Log.d(TAG, "changing Source:successed find chapter by original title " + i + ":" + mChangeTitle);
|
||||||
|
chId = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
|
||||||
|
Toast.makeText(mContext,"换源成功",Toast.LENGTH_LONG).show();
|
||||||
|
}else{
|
||||||
|
Log.d(TAG, "changing Source: failed " );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean doInBackground(String... params) {
|
||||||
|
domain = params[0];
|
||||||
|
chapId = Integer.parseInt( params[1]);
|
||||||
|
chapTitle = params[2];
|
||||||
|
|
||||||
|
int splet =0;
|
||||||
|
while(isChangeSource){
|
||||||
|
try {
|
||||||
|
Thread.sleep(50);
|
||||||
|
splet++;
|
||||||
|
Log.d(TAG, String.format("changing Source slept %s,isChangeSource %s ", splet, isChangeSource ));
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute() {
|
||||||
|
super.onPreExecute();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onProgressUpdate(Void... values) {
|
||||||
|
super.onProgressUpdate(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新线程换源 ,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) );
|
||||||
|
if(mSite.getDomain().equals(domain)){ //当前源
|
||||||
|
Log.d(TAG, "changing Source: same site with original " + domain);
|
||||||
|
// return;
|
||||||
|
}
|
||||||
|
mChangeChapId = chapId;
|
||||||
|
mChangeTitle =chapTitle;
|
||||||
|
for (Site site:mNovelSites.getSites() ) {
|
||||||
|
if(site.getDomain().equals(domain)){
|
||||||
|
mSite = site;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setSiteInfo();
|
||||||
|
|
||||||
|
// showProgressDialog();
|
||||||
|
isChangeSource = true;
|
||||||
|
new Thread(){
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Log.d(TAG, "changing Source: to get site rule" );
|
||||||
|
getSiteRule();
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
while(isChangeSource){
|
||||||
|
try {
|
||||||
|
Thread.sleep(50);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
new Thread(){
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Log.d(TAG, "changing Source: to get site rule" );
|
||||||
|
getSiteRule();
|
||||||
|
}
|
||||||
|
}.start();*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
enum MuluStatus{
|
enum MuluStatus{
|
||||||
isDownloading,
|
isDownloading,
|
||||||
isDone,
|
isDone,
|
||||||
failed
|
failed
|
||||||
}
|
}
|
||||||
private void showProgressDialog() {
|
private void showProgressDialog(String title,boolean canBreak) {
|
||||||
if ( null == progressDialog) {
|
if ( null == progressDialog) {
|
||||||
progressDialog =new ProgressDialog(mContext);
|
progressDialog =new ProgressDialog(mContext);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
progressDialog.setMessage(title);
|
||||||
|
progressDialog.setCancelable(canBreak);
|
||||||
progressDialog.show();
|
progressDialog.show();
|
||||||
// progressDialog.show(mContext,"网络不给力","正努力加载",false,true);
|
// progressDialog.show(mContext,"网络不给力","正努力加载",false,true);
|
||||||
}
|
}
|
||||||
|
@ -335,38 +515,7 @@ public class BookUtil {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// String getMuluUrl() {
|
|
||||||
// return "https://www.qu.la/book/390/";
|
|
||||||
// }
|
|
||||||
/* void readChapters( String url){
|
|
||||||
Request request = getTagRequest(url);
|
|
||||||
|
|
||||||
ResponseBody body =null;
|
|
||||||
try {
|
|
||||||
|
|
||||||
long startTime= new Date().getTime();
|
|
||||||
Log.d(TAG,String.format("loadChaptContent----start download %s 目录 from %s", mNovel.getName() ,url ));
|
|
||||||
|
|
||||||
|
|
||||||
Response response = HttpMethods.getOkClient().newCall(request).execute();
|
|
||||||
Log.d(TAG,String.format("loadChaptContent----end download %s 目录, 目录数量 %s, cost %s", mNovel.getName() , mChapters.size(), new Date().getTime() -startTime ));
|
|
||||||
startTime= new Date().getTime();
|
|
||||||
body = response.body();
|
|
||||||
String bodyStr = body.string();
|
|
||||||
Log.d(TAG, "onResponse: " +bodyStr);
|
|
||||||
|
|
||||||
buildCharacters(bodyStr,url);
|
|
||||||
Log.d(TAG,String.format("loadChaptContent----end build %s 目录, 目录数量 %s, cost %s", mNovel.getName() , mChapters.size(), new Date().getTime() -startTime ));
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}finally {
|
|
||||||
if(body!=null){
|
|
||||||
body.close();;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
void readChaptersAsync( ) {
|
void readChaptersAsync( ) {
|
||||||
String url = mSite.getMuluUrl();
|
String url = mSite.getMuluUrl();
|
||||||
|
@ -383,6 +532,7 @@ public class BookUtil {
|
||||||
Log.e(TAG, "loadChapts---- failed: ",e );
|
Log.e(TAG, "loadChapts---- failed: ",e );
|
||||||
Log.d(TAG,String.format("loadChapts---- failed %s 目录 from %s", mNovel.getName() ,url ));
|
Log.d(TAG,String.format("loadChapts---- failed %s 目录 from %s", mNovel.getName() ,url ));
|
||||||
|
|
||||||
|
handler.sendEmptyMessage(3);
|
||||||
|
|
||||||
//TODO 如果是取消了访问,则返回
|
//TODO 如果是取消了访问,则返回
|
||||||
if( mNovelSites.getSites().length ==1){ //仅有一个rule,且失败了
|
if( mNovelSites.getSites().length ==1){ //仅有一个rule,且失败了
|
||||||
|
@ -406,7 +556,7 @@ public class BookUtil {
|
||||||
ResponseBody body = response.body();
|
ResponseBody body = response.body();
|
||||||
if(response.code()!=200){
|
if(response.code()!=200){
|
||||||
Log.d(TAG,String.format("loadChapts----failed, %s 目录 from %s,return code %s", mNovel.getName() ,url,response.code() ));
|
Log.d(TAG,String.format("loadChapts----failed, %s 目录 from %s,return code %s", mNovel.getName() ,url,response.code() ));
|
||||||
|
handler.sendEmptyMessage(3);
|
||||||
mMuluStatus = MuluStatus.failed;
|
mMuluStatus = MuluStatus.failed;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -426,6 +576,7 @@ public class BookUtil {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}finally {
|
}finally {
|
||||||
body.close();
|
body.close();
|
||||||
|
handler.sendEmptyMessage(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -858,26 +1009,65 @@ public class BookUtil {
|
||||||
isDownloadChapt = flag;
|
isDownloadChapt = flag;
|
||||||
Log.d("loadChaptContent",String.format("set download flat",isDownloadChapt) );
|
Log.d("loadChaptContent",String.format("set download flat",isDownloadChapt) );
|
||||||
}
|
}
|
||||||
|
public ChangeSource pagefactory;
|
||||||
final Handler handler = new Handler() {
|
Handler handler = new Handler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
|
|
||||||
int wt = msg.what;
|
int wt = msg.what;
|
||||||
|
|
||||||
|
handlerMsg(msg);
|
||||||
|
|
||||||
|
|
||||||
dismissProgressDialog();
|
dismissProgressDialog();
|
||||||
|
|
||||||
if (msg.what == 123) {
|
|
||||||
isDownloadChapt =true;
|
|
||||||
Log.d("loadChaptContent",String.format("handler msg, download %s",isDownloadChapt) );
|
|
||||||
}else if(msg.what==1){
|
|
||||||
isDownloadChapt =true;
|
|
||||||
// Toast.makeText(mContext,"网络错误",Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void handlerMsg(Message msg){
|
||||||
|
if (msg.what == 123) {
|
||||||
|
isDownloadChapt =true;
|
||||||
|
Log.d("loadChaptContent",String.format("handler msg, download %s",isDownloadChapt) );
|
||||||
|
}else if(msg.what==1){
|
||||||
|
isDownloadChapt =true;
|
||||||
|
// Toast.makeText(mContext,"网络错误",Toast.LENGTH_LONG).show();
|
||||||
|
}else if(msg.what==3){ //change source
|
||||||
|
isChangeSource =false;
|
||||||
|
Log.d(TAG, "changing Source:successed get chapters for " + mSite.getDomain() );
|
||||||
|
/*if(isChangeSource){
|
||||||
|
Log.d(TAG, "changing Source:successed get chapters for " + mSite.getDomain() );
|
||||||
|
isChangeSource =false;
|
||||||
|
int chapId=chapterNo;
|
||||||
|
if( mChapters.size() >= mChangeChapId && mChapters.get(mChangeChapId-1)!=null ){
|
||||||
|
String title = mChapters.get(mChangeChapId-1).getChapterName();
|
||||||
|
Log.d(TAG, "changing Source:chapter name in new site " + title );
|
||||||
|
if(title.equals(mChangeTitle)) {
|
||||||
|
Log.d(TAG, "changing Source:successed find chapter by original chaptId " + mChangeChapId + ":" + mChangeTitle);
|
||||||
|
chapId = mChangeChapId;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
int i =1;
|
||||||
|
for (Chapter chapter : mChapters) {
|
||||||
|
|
||||||
|
if (chapter.getChapterName().equals(mChangeTitle)) {
|
||||||
|
Log.d(TAG, "changing Source:successed find chapter by original title " +i + ":"+ mChangeTitle );
|
||||||
|
chapId = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chapId = chapId <= mChapters.size() ? chapId: mChapters.size();
|
||||||
|
Log.d(TAG, "changing Source: to open chapter with new site source " + chapId + " : "+ mChangeTitle );
|
||||||
|
pagefactory.changeChapter(chapId);
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private Map<Integer,Cache> chaptCache = new HashMap<Integer,Cache>();
|
private Map<Integer,Cache> chaptCache = new HashMap<Integer,Cache>();
|
||||||
private Map<Integer,DownloadStatus> chaptDownStatus = new HashMap<Integer, DownloadStatus>();
|
private Map<Integer,DownloadStatus> chaptDownStatus = new HashMap<Integer, DownloadStatus>();
|
||||||
DownloadStatus downloadStatus = DownloadStatus.notStart;
|
DownloadStatus downloadStatus = DownloadStatus.notStart;
|
||||||
|
@ -887,6 +1077,42 @@ public class BookUtil {
|
||||||
failure,
|
failure,
|
||||||
success
|
success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isChapterContentExist(int index) {
|
||||||
|
char[] block = null;
|
||||||
|
if (chaptCache.containsKey(Integer.valueOf(index))) {
|
||||||
|
block = chaptCache.get(index).getData().get();
|
||||||
|
}
|
||||||
|
if (block == null) {
|
||||||
|
// cleanCacheFile(); //to remove
|
||||||
|
|
||||||
|
File file = new File(fileChapterName(index));
|
||||||
|
|
||||||
|
if (!file.exists()) {
|
||||||
|
showProgressDialog("请稍候",false);
|
||||||
|
new Thread(){
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
loadChaptContent(index);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//获取chapter 缓存
|
//获取chapter 缓存
|
||||||
public char[] chaptChars(final int index) {
|
public char[] chaptChars(final int index) {
|
||||||
char[] block=null;
|
char[] block=null;
|
||||||
|
@ -924,7 +1150,7 @@ public class BookUtil {
|
||||||
|
|
||||||
Log.d(TAG,String.format("loadChaptContent----start %s" ,new Date().toString() ));
|
Log.d(TAG,String.format("loadChaptContent----start %s" ,new Date().toString() ));
|
||||||
|
|
||||||
//showProgressDialog();//why not show
|
|
||||||
|
|
||||||
Log.d( "loadChaptContent",String.format("begin to load content for chapter %s",index));
|
Log.d( "loadChaptContent",String.format("begin to load content for chapter %s",index));
|
||||||
Log.d( "loadChaptContent",String.format("isDownloadChapt: %s",isDownloadChapt));
|
Log.d( "loadChaptContent",String.format("isDownloadChapt: %s",isDownloadChapt));
|
||||||
|
@ -1015,6 +1241,7 @@ private void loadChaptContent(final int chapterIndex) throws JSONException, Inte
|
||||||
Chapter chapter = mChapters.get(index -1);
|
Chapter chapter = mChapters.get(index -1);
|
||||||
String url = chapter.getChapterUrl();
|
String url = chapter.getChapterUrl();
|
||||||
if( TextUtils.isEmpty( url)){
|
if( TextUtils.isEmpty( url)){
|
||||||
|
handler.sendEmptyMessage(1);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
long startTime= new Date().getTime();
|
long startTime= new Date().getTime();
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.novelbook.android.utils;
|
||||||
|
|
||||||
|
public interface ChangeSource {
|
||||||
|
public void changeChapter(int chapNum);
|
||||||
|
}
|
|
@ -1,9 +1,11 @@
|
||||||
package com.novelbook.android;
|
package com.novelbook.android.utils;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
|
|
||||||
|
import com.novelbook.android.R;
|
||||||
|
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
private final static String SP_NAME = "config";
|
private final static String SP_NAME = "config";
|
|
@ -1,5 +1,6 @@
|
||||||
package com.novelbook.android.utils;
|
package com.novelbook.android.utils;
|
||||||
|
|
||||||
|
import android.app.ProgressDialog;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -15,12 +16,12 @@ import android.graphics.Typeface;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.novelbook.android.Config;
|
|
||||||
import com.novelbook.android.R;
|
import com.novelbook.android.R;
|
||||||
|
import com.novelbook.android.bean.NovelSites;
|
||||||
|
import com.novelbook.android.bean.Site;
|
||||||
import com.novelbook.android.db.Chapter;
|
import com.novelbook.android.db.Chapter;
|
||||||
import com.novelbook.android.db.Novel;
|
import com.novelbook.android.db.Novel;
|
||||||
import com.novelbook.android.netutils.NetUtil;
|
import com.novelbook.android.netutils.NetUtil;
|
||||||
|
@ -37,7 +38,7 @@ import java.util.List;
|
||||||
//import static com.baidu.tts.loopj.AsyncHttpClient.log;
|
//import static com.baidu.tts.loopj.AsyncHttpClient.log;
|
||||||
|
|
||||||
|
|
||||||
public class PageFactory {
|
public class PageFactory implements ChangeSource{
|
||||||
private static final String TAG = "PageFactory";
|
private static final String TAG = "PageFactory";
|
||||||
private static PageFactory pageFactory;
|
private static PageFactory pageFactory;
|
||||||
|
|
||||||
|
@ -171,7 +172,7 @@ public class PageFactory {
|
||||||
|
|
||||||
chaptId = mChapters!=null && mChapters.size() <= chaptId ? 1 : chaptId;
|
chaptId = mChapters!=null && mChapters.size() <= chaptId ? 1 : chaptId;
|
||||||
|
|
||||||
// Log.d(TAG, String.format("prepare book to open chapter %s ",chaptId ) );
|
Log.d(TAG, String.format("changing Source prepare book to open chapter %s ",chaptId ) );
|
||||||
char[] chars = mBookUtil.chaptChars(chaptId);
|
char[] chars = mBookUtil.chaptChars(chaptId);
|
||||||
String s = new String(chars);
|
String s = new String(chars);
|
||||||
// Log.d(TAG, String.format("prepare book to open chapter %s,chars %s ",chaptId ,s ) );
|
// Log.d(TAG, String.format("prepare book to open chapter %s,chars %s ",chaptId ,s ) );
|
||||||
|
@ -215,6 +216,39 @@ public class PageFactory {
|
||||||
|
|
||||||
private static Status mStatus = Status.OPENING;
|
private static Status mStatus = Status.OPENING;
|
||||||
|
|
||||||
|
public NovelSites getNovelSites() {
|
||||||
|
return mBookUtil.getmNovelSites();
|
||||||
|
}
|
||||||
|
private ProgressDialog progressDialog;
|
||||||
|
private void showProgressDialog() {
|
||||||
|
if ( null == progressDialog) {
|
||||||
|
progressDialog =new ProgressDialog(mContext);
|
||||||
|
}
|
||||||
|
progressDialog.show();
|
||||||
|
// progressDialog.show(mContext,"网络不给力","正努力加载",false,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void dismissProgressDialog() {
|
||||||
|
if ( null != progressDialog) {
|
||||||
|
progressDialog.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void changeSource(String domain,int chapId,String chapTitle) {
|
||||||
|
|
||||||
|
mBookUtil.changeSource(domain, chapId, chapTitle);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChapterName() {
|
||||||
|
return getChapters().get(currentChapter-1).getChapterName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSite() {
|
||||||
|
return mBookUtil.getSite();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public enum Status {
|
public enum Status {
|
||||||
|
@ -494,7 +528,7 @@ public class PageFactory {
|
||||||
}else*/
|
}else*/
|
||||||
if (getChapters().size() > 0)
|
if (getChapters().size() > 0)
|
||||||
{
|
{
|
||||||
String chapterName = CommonUtil.subString(getChapters().get(currentChapter-1).getChapterName(),16);
|
String chapterName = CommonUtil.subString(getChapterName(),16);
|
||||||
int nChaterWidth = (int) mBatterryPaint.measureText(chapterName) + 1;
|
int nChaterWidth = (int) mBatterryPaint.measureText(chapterName) + 1;
|
||||||
c.drawText(chapterName, mWidth - marginWidth - nChaterWidth, statusMarginBottom + mBatterryFontSize, mBatterryPaint);
|
c.drawText(chapterName, mWidth - marginWidth - nChaterWidth, statusMarginBottom + mBatterryFontSize, mBatterryPaint);
|
||||||
|
|
||||||
|
@ -612,6 +646,7 @@ public class PageFactory {
|
||||||
mBookUtil = new BookUtil();
|
mBookUtil = new BookUtil();
|
||||||
}
|
}
|
||||||
mBookUtil.setContext(context);
|
mBookUtil.setContext(context);
|
||||||
|
mBookUtil.pagefactory=this;
|
||||||
//清空数据
|
//清空数据
|
||||||
currentChapter = 0;
|
currentChapter = 0;
|
||||||
// m_mbBufLen = 0;
|
// m_mbBufLen = 0;
|
||||||
|
|
|
@ -13,7 +13,6 @@ import android.view.WindowManager;
|
||||||
import android.view.animation.LinearInterpolator;
|
import android.view.animation.LinearInterpolator;
|
||||||
import android.widget.Scroller;
|
import android.widget.Scroller;
|
||||||
|
|
||||||
import com.novelbook.android.Config;
|
|
||||||
import com.novelbook.android.utils.PageFactory;
|
import com.novelbook.android.utils.PageFactory;
|
||||||
import com.novelbook.android.view.animation.AnimationProvider;
|
import com.novelbook.android.view.animation.AnimationProvider;
|
||||||
import com.novelbook.android.view.animation.CoverAnimation;
|
import com.novelbook.android.view.animation.CoverAnimation;
|
||||||
|
@ -21,7 +20,7 @@ import com.novelbook.android.view.animation.NoneAnimation;
|
||||||
import com.novelbook.android.view.animation.SimulationAnimation;
|
import com.novelbook.android.view.animation.SimulationAnimation;
|
||||||
import com.novelbook.android.view.animation.SlideAnimation;
|
import com.novelbook.android.view.animation.SlideAnimation;
|
||||||
|
|
||||||
import static com.novelbook.android.Config.*;
|
import static com.novelbook.android.utils.Config.*;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -100,13 +100,15 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/author"
|
android:id="@+id/author"
|
||||||
style="@style/TextViewNovelAuthor"
|
style="@style/TextViewNovelAuthor"
|
||||||
|
android:layout_marginTop="3dp"
|
||||||
|
android:layout_marginBottom="1dp"
|
||||||
android:text=""
|
android:text=""
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="2dp"
|
android:layout_marginTop="3dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/category"
|
android:id="@+id/category"
|
||||||
|
@ -122,8 +124,10 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<TextView
|
<TextView
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
android:id="@+id/progress"
|
android:id="@+id/progress"
|
||||||
style="@style/TextViewNovelAuthor"
|
style="@style/TextViewNovelAuthor"
|
||||||
|
android:textColor="@color/common_google_signin_btn_text_light"
|
||||||
android:text=""
|
android:text=""
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/main_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:fitsSystemWindows="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">
|
||||||
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/toolbarHeight"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:popupTheme="@style/ToolBarTheme.PopupOverlay">
|
||||||
|
|
||||||
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
|
<android.support.v7.widget.RecyclerView
|
||||||
|
android:id="@+id/recycleView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="60dp"
|
||||||
|
android:divider="@color/list_item_divider"
|
||||||
|
>
|
||||||
|
</android.support.v7.widget.RecyclerView>
|
||||||
|
|
||||||
|
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
|
@ -20,6 +20,8 @@
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
app:headerLayout="@layout/nav_header_main2"
|
app:headerLayout="@layout/nav_header_main2"
|
||||||
app:menu="@menu/activity_main2_drawer" />
|
app:menu="@menu/activity_main2_drawer"
|
||||||
|
|
||||||
|
/>
|
||||||
|
|
||||||
</android.support.v4.widget.DrawerLayout>
|
</android.support.v4.widget.DrawerLayout>
|
||||||
|
|
|
@ -21,8 +21,9 @@
|
||||||
<!--android:layout_height="?attr/actionBarSize"-->
|
<!--android:layout_height="?attr/actionBarSize"-->
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.v7.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
|
style="@style/Toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_height="@dimen/toolbarHeight"
|
||||||
android:background="?attr/colorPrimary"
|
android:background="?attr/colorPrimary"
|
||||||
app:popupTheme="@style/ToolBarTheme.PopupOverlay" >
|
app:popupTheme="@style/ToolBarTheme.PopupOverlay" >
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/loadLayout"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/item_selector"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/TextViewNovelTitle.horizon.bold"
|
||||||
|
android:id="@+id/tvText"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:text="@string/noRecord"
|
||||||
|
/>
|
||||||
|
<!-- <LinearLayout style="@style/llGraySplit.2dp"/>-->
|
||||||
|
</LinearLayout>
|
|
@ -12,9 +12,5 @@
|
||||||
android:orderInCategory="90"
|
android:orderInCategory="90"
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_read_book"
|
|
||||||
android:title="@string/action_read_book"
|
|
||||||
android:orderInCategory="90"
|
|
||||||
app:showAsAction="ifRoom" />
|
|
||||||
</menu>
|
</menu>
|
|
@ -46,6 +46,7 @@
|
||||||
<!-- 底部导航栏高度 -->
|
<!-- 底部导航栏高度 -->
|
||||||
<dimen name="botoomNavi">42dp</dimen>
|
<dimen name="botoomNavi">42dp</dimen>
|
||||||
<dimen name="_10dp">10dp</dimen>
|
<dimen name="_10dp">10dp</dimen>
|
||||||
|
<dimen name="toolbarHeight">40dp</dimen>
|
||||||
|
|
||||||
|
|
||||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||||
|
|
|
@ -185,6 +185,7 @@
|
||||||
|
|
||||||
<string name="aboutContent">如风小说阅读是专注于提供更舒适的阅读体验,主打本地阅读,操作方式简单易上手,目前支持txt格式。</string>
|
<string name="aboutContent">如风小说阅读是专注于提供更舒适的阅读体验,主打本地阅读,操作方式简单易上手,目前支持txt格式。</string>
|
||||||
<string name="noRecord">没有数据</string>
|
<string name="noRecord">没有数据</string>
|
||||||
|
<string name="title_Activity_ChgSource">换源</string>
|
||||||
|
|
||||||
<string-array name="voicer_cloud_entries">
|
<string-array name="voicer_cloud_entries">
|
||||||
<item>小燕—女青、中英、普通话</item>
|
<item>小燕—女青、中英、普通话</item>
|
||||||
|
|
|
@ -404,7 +404,7 @@
|
||||||
<item name="android:textSize">14sp</item><!--bookdetail toolbar 展开后字体大小-->
|
<item name="android:textSize">14sp</item><!--bookdetail toolbar 展开后字体大小-->
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Toolbar"></style>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue