shelfbook to open directly
This commit is contained in:
parent
5ddd3cd9ee
commit
62113f9d9a
|
@ -16,8 +16,8 @@ android {
|
|||
applicationId "com.novelbook.android"
|
||||
minSdkVersion 19 //target 19 Android 4.4 以下版本仅占比4.1%
|
||||
targetSdkVersion 28
|
||||
versionCode 3
|
||||
versionName "3.0"
|
||||
versionCode 5
|
||||
versionName "5.0"
|
||||
|
||||
// testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
@ -38,7 +38,8 @@ android {
|
|||
// 显示Log
|
||||
buildConfigField "boolean", "LOG_DEBUG", "true"
|
||||
buildConfigField "String", "MAIN_HOST", '"http://xiaoshuofenxiang.com/api/"'
|
||||
buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"'
|
||||
buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/g.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"'
|
||||
// buildConfigField "String", "API_HOST", '""'
|
||||
versionNameSuffix "-debug"
|
||||
minifyEnabled false
|
||||
zipAlignEnabled false
|
||||
|
@ -74,32 +75,32 @@ android {
|
|||
// googleplay {}
|
||||
qxs {
|
||||
applicationId "com.novelbook.android.qxs"
|
||||
versionName "version-a-1.0"
|
||||
versionName "vn-qxs-5.0"
|
||||
buildConfigField "String", "MAIN_HOST", '"http://chqxs.xiaoshuofenxiang.com/api/"'
|
||||
// buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/qxs.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"'
|
||||
buildConfigField "String", "API_HOST", '""'
|
||||
buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/qxs.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"'
|
||||
//buildConfigField "String", "API_HOST", '""'
|
||||
|
||||
}
|
||||
wzzw {
|
||||
applicationId "com.novelbook.android.wzzw"
|
||||
versionName "version-b-1.0"
|
||||
versionName "vn-wzzw-5.0"
|
||||
buildConfigField "String", "MAIN_HOST", '"http://chwzzw.xiaoshuofenxiang.com/api/"'
|
||||
// buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/wzzw.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"'
|
||||
buildConfigField "String", "API_HOST", '""'
|
||||
buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/wzzw.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"'
|
||||
// buildConfigField "String", "API_HOST", '""'
|
||||
}
|
||||
bo {
|
||||
applicationId "com.novelbook.android.bo"
|
||||
versionName "version-c-1.0"
|
||||
versionName "vn-bo-5.0"
|
||||
buildConfigField "String", "MAIN_HOST", '"http://chbo.xiaoshuofenxiang.com/api/"'
|
||||
// buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/bo.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"'
|
||||
buildConfigField "String", "API_HOST", '""'
|
||||
buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/bo.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"'
|
||||
// buildConfigField "String", "API_HOST", '""'
|
||||
}
|
||||
g {
|
||||
applicationId "com.novelbook.android.g"
|
||||
versionName "version-d-1.0"
|
||||
versionName "vn-g-5.0"
|
||||
buildConfigField "String", "MAIN_HOST", '"http://chg.xiaoshuofenxiang.com/api/"'
|
||||
// buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"'
|
||||
buildConfigField "String", "API_HOST", '""'
|
||||
buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/g.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\/r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\/s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\/n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\/nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\/u.xiaoshuofenxiang.com\\"]}"'
|
||||
// buildConfigField "String", "API_HOST", '""'
|
||||
}
|
||||
//批量配置
|
||||
productFlavors.all { flavor ->
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
<resources>
|
||||
<string name="app_name">A小说</string>
|
||||
|
||||
</resources>
|
|
@ -1,4 +0,0 @@
|
|||
<resources>
|
||||
<string name="app_name">B小说</string>
|
||||
|
||||
</resources>
|
|
@ -1,4 +0,0 @@
|
|||
<resources>
|
||||
<string name="app_name">C小说</string>
|
||||
|
||||
</resources>
|
|
@ -1,4 +0,0 @@
|
|||
<resources>
|
||||
<string name="app_name">D小说</string>
|
||||
|
||||
</resources>
|
|
@ -28,6 +28,7 @@ import com.novelbook.android.netutils.NetUtil;
|
|||
import com.novelbook.android.netutils.OnSuccessAndFaultListener;
|
||||
import com.novelbook.android.netutils.OnSuccessAndFaultSub;
|
||||
import com.novelbook.android.upgrade.UpdateManager;
|
||||
import com.novelbook.android.utils.CommonUtil;
|
||||
import com.novelbook.android.utils.ImageUtil;
|
||||
import com.novelbook.android.utils.MyImageLoader;
|
||||
import com.novelbook.android.utils.OnItemClickListener;
|
||||
|
@ -240,25 +241,7 @@ public abstract class Activity_base extends AppCompatActivity {
|
|||
* @param errorText
|
||||
*/
|
||||
protected void checkPermission (Activity thisActivity, String permission, int requestCode, String errorText) {
|
||||
//判断当前Activity是否已经获得了该权限
|
||||
if(ContextCompat.checkSelfPermission(thisActivity,permission) != PackageManager.PERMISSION_GRANTED) {
|
||||
//如果App的权限申请曾经被用户拒绝过,就需要在这里跟用户做出解释
|
||||
if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
|
||||
permission)) {
|
||||
Toast.makeText(this,errorText,Toast.LENGTH_SHORT).show();
|
||||
//进行权限请求
|
||||
ActivityCompat.requestPermissions(thisActivity,
|
||||
new String[]{permission},
|
||||
requestCode);
|
||||
} else {
|
||||
//进行权限请求
|
||||
ActivityCompat.requestPermissions(thisActivity,
|
||||
new String[]{permission},
|
||||
requestCode);
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
CommonUtil.checkPermission(thisActivity,permission,requestCode,errorText);
|
||||
}
|
||||
|
||||
protected void loadImageView(String url, ImageView imageView){
|
||||
|
|
|
@ -75,7 +75,7 @@ import butterknife.ButterKnife;
|
|||
*/
|
||||
public abstract class BasicFragment extends Fragment {
|
||||
|
||||
public static String TAG = "need to be replaced";
|
||||
public static String TAG = BasicFragment.class.getSimpleName();
|
||||
protected View rootView;
|
||||
protected int pageNo=1;
|
||||
protected int pageCount;
|
||||
|
@ -91,6 +91,9 @@ public abstract class BasicFragment extends Fragment {
|
|||
@Nullable
|
||||
@BindView(R.id.swipeLayout)
|
||||
SwipeRefreshLayout mSwipeRefresh;
|
||||
|
||||
int MSG_INIT_TAB =99;
|
||||
|
||||
public BasicFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
@ -150,17 +153,12 @@ public abstract class BasicFragment extends Fragment {
|
|||
Log.e(TAG, "handleMessage: filldata error ", e);
|
||||
}
|
||||
|
||||
} else if (msg.what == 2) //
|
||||
} else if (msg.what == MSG_INIT_TAB) //
|
||||
{
|
||||
|
||||
|
||||
initTabs();
|
||||
// Toast.makeText(getActivity(), "数据请求失败 ", Toast.LENGTH_LONG).show();
|
||||
} else if (msg.what == 3) {
|
||||
|
||||
// Toast.makeText(getActivity(), " ", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
|
||||
if(getActivity()!=null && !NetUtil.isNetworkConnected()){
|
||||
Toast.makeText(getActivity(),"好像没有网络啦",Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
@ -170,7 +168,9 @@ public abstract class BasicFragment extends Fragment {
|
|||
}
|
||||
};
|
||||
|
||||
void initTabs(){
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------book list adapter------------------------------------------------
|
||||
/* interface mOnItemClickListener
|
||||
|
@ -207,8 +207,13 @@ public abstract class BasicFragment extends Fragment {
|
|||
void getBookInfo(Novel novel){
|
||||
int novelId = novel.getNovelId();
|
||||
long id = novel.getId();
|
||||
Log.d(TAG, String.format("prepare book %s ,start to loading book info from host ",novel.getName()));
|
||||
// showProgressDialog(false,"正在加载...");
|
||||
PageFactory pageFactory =PageFactory.getInstance(activity ) ;
|
||||
pageFactory.initBookUtil();
|
||||
ReadActivity.openBook(novel ,activity);
|
||||
|
||||
|
||||
showProgressDialog(false,"正在加载...");
|
||||
BookSubscribe.getNovel(novel.getNovelId(),new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
|
@ -222,7 +227,7 @@ public abstract class BasicFragment extends Fragment {
|
|||
}else {
|
||||
nv.save();
|
||||
}
|
||||
|
||||
Log.d(TAG, String.format("prepare book %s ,start to loading book info from host -----------done",novel.getName()));
|
||||
Log.d(TAG, String.format("prepare book %s ,lastchapt %s, last pos %s ,开始prepare.",nv.getName(),nv.getLastReadChapt(),nv.getLastReadPos()) );
|
||||
// final Novel novel = nv;
|
||||
/* new Thread(){
|
||||
|
@ -232,12 +237,12 @@ public abstract class BasicFragment extends Fragment {
|
|||
|
||||
}
|
||||
}.start();*/
|
||||
|
||||
// ReadActivity.openBook(nv ,activity);
|
||||
// PageFactory.getInstance(activity.getApplicationContext()).prepareBook(nv ); //打开本地小说内容
|
||||
PageFactory.getInstance(activity ).prepareBook(nv ); //打开本地小说内容
|
||||
|
||||
//PageFactory.getInstance(activity ).prepareBook(nv ); //打开本地小说内容
|
||||
pageFactory.prepareBook(nv );
|
||||
Log.d(TAG, String.format("prepare book %s 开始open book.",nv.getName()) );
|
||||
ReadActivity.openBook(nv ,activity);
|
||||
|
||||
handler.sendEmptyMessage(99);
|
||||
}
|
||||
|
||||
|
@ -245,8 +250,8 @@ public abstract class BasicFragment extends Fragment {
|
|||
public void onFault(String errorMsg) {
|
||||
//失败
|
||||
Toast.makeText(getActivity(),"Novel 请求失败:"+errorMsg,Toast.LENGTH_SHORT).show();
|
||||
PageFactory.getInstance(activity ).prepareBook(novel ); //打开本地小说内容
|
||||
ReadActivity.openBook(novel ,activity);
|
||||
// PageFactory.getInstance(activity ).prepareBook(novel ); //打开本地小说内容
|
||||
// ReadActivity.openBook(novel ,activity);
|
||||
handler.sendEmptyMessage(99);
|
||||
}
|
||||
},getActivity()));
|
||||
|
|
|
@ -31,7 +31,9 @@ public class Fragment_bookStore extends BasicFragment {
|
|||
private ArrayList<BasicFragment> mFragments_cp;
|
||||
ArrayList<View> mList;
|
||||
String[] mTitle;
|
||||
|
||||
Fragment_jingxuan fragment_jingxuan;
|
||||
FragmentCates fragmentCates;
|
||||
Fragment_bangdans fragment_bangdans;
|
||||
protected void processArguments(){
|
||||
if (getArguments() != null) {
|
||||
Bundle bundle = getArguments() ;
|
||||
|
@ -56,10 +58,10 @@ public class Fragment_bookStore extends BasicFragment {
|
|||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Log.d(TAG,"Fragment_bookStore fragment onCreate ");
|
||||
if (getArguments() != null) {
|
||||
// mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
// mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
fragment_jingxuan = new Fragment_jingxuan();
|
||||
fragmentCates =FragmentCates.newInstance();
|
||||
fragment_bangdans = new Fragment_bangdans();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,17 +78,22 @@ public class Fragment_bookStore extends BasicFragment {
|
|||
}
|
||||
public void onSexSwitch(){
|
||||
if(mAdapter!=null) {
|
||||
for(BasicFragment bf: mFragments_cp){
|
||||
/* for(BasicFragment bf: mFragments_cp){
|
||||
bf.initData();
|
||||
}
|
||||
}*/
|
||||
/* for(int i=0;i<mAdapter.getCount();i++){
|
||||
((BasicFragment) mAdapter.getItem(i)).initData();
|
||||
}*/
|
||||
/* fragment_jingxuan.initData();
|
||||
fragmentCates.initData();
|
||||
fragment_bangdans.initData() ;
|
||||
|
||||
|
||||
mAdapter.notifyDataSetChanged();
|
||||
mAdapter.notifyDataSetChanged();*/
|
||||
|
||||
}
|
||||
fragment_jingxuan.initData();
|
||||
fragmentCates.initData();
|
||||
fragment_bangdans.initData() ;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -101,9 +108,9 @@ public class Fragment_bookStore extends BasicFragment {
|
|||
if(mFragments ==null || mFragments.size() ==0){
|
||||
// mTitle = new String[]{"精选", "榜单", "书单"};
|
||||
mFragments = new ArrayList<>();
|
||||
mFragments.add(new Fragment_jingxuan());
|
||||
mFragments.add(FragmentCates.newInstance());
|
||||
mFragments.add(new Fragment_bangdans());
|
||||
mFragments.add(fragment_jingxuan);
|
||||
mFragments.add(fragmentCates);
|
||||
mFragments.add(fragment_bangdans);
|
||||
mFragments_cp = new ArrayList<>();
|
||||
mFragments_cp.addAll(mFragments);
|
||||
// mFragments.add(new Fragment_shudan());
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.novelbook.android.Fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
@ -22,6 +23,7 @@ import com.novelbook.android.netsubscribe.BookSubscribe;
|
|||
import com.novelbook.android.netutils.NetUtil;
|
||||
import com.novelbook.android.netutils.OnSuccessAndFaultListener;
|
||||
import com.novelbook.android.netutils.OnSuccessAndFaultSub;
|
||||
import com.novelbook.android.utils.CommonUtil;
|
||||
import com.novelbook.android.utils.Constants;
|
||||
import com.novelbook.android.utils.GsonUtil;
|
||||
import com.novelbook.android.utils.OnItemClickListener;
|
||||
|
@ -215,11 +217,7 @@ public static final String TAG = Fragment_paihang.class.getSimpleName();
|
|||
public void initViews(){
|
||||
appBarLayout.setVisibility(View.GONE);
|
||||
if(lstNt==null) {
|
||||
// getSearchTabTtitle();
|
||||
}
|
||||
else {
|
||||
initTabs();
|
||||
}
|
||||
CommonUtil.getSearchTabTtitle(getActivity());
|
||||
showProgressDialog(false,"正在加载...");
|
||||
new Thread(){
|
||||
@Override
|
||||
|
@ -227,25 +225,28 @@ public static final String TAG = Fragment_paihang.class.getSimpleName();
|
|||
Log.d(TAG, "prepare book to load options for search" );
|
||||
while(lstNt==null){
|
||||
try {
|
||||
Thread.sleep(10);
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// initTabs();
|
||||
handler.sendEmptyMessage(2);
|
||||
|
||||
handler.sendEmptyMessage(MSG_INIT_TAB);
|
||||
}
|
||||
}.start();
|
||||
|
||||
// getSearchTabTtitle();
|
||||
//setScrollListner();
|
||||
}
|
||||
else {
|
||||
initTabs();
|
||||
}
|
||||
|
||||
initLoadMoreListener();
|
||||
//initTabs();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initTabs() {
|
||||
@Override
|
||||
void initTabs() {
|
||||
tmp=0;
|
||||
/*
|
||||
while(lstNt==null){
|
||||
|
@ -312,7 +313,7 @@ public static final String TAG = Fragment_paihang.class.getSimpleName();
|
|||
mData2.get(tab2Pos).getTabTitle() +" " +
|
||||
mData3.get(tab3Pos).getTabTitle() ;
|
||||
*/
|
||||
if(lstSex==null) return;
|
||||
if(lstSex==null || lstSex.size()==0) return;
|
||||
|
||||
pageNo=1;
|
||||
|
||||
|
@ -328,7 +329,7 @@ public static final String TAG = Fragment_paihang.class.getSimpleName();
|
|||
tvHint.setText(selectedKey);
|
||||
Log.d(TAG, String.format("tabChanged: to load data %s,pageno %s, tmp %s" , selectedKey,pageNo ,tmp));
|
||||
|
||||
if( tmp<lstProgress.length+1) return;
|
||||
if( tmp<lstProgress.length) return;
|
||||
|
||||
loadSearchData();
|
||||
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package com.novelbook.android;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.BottomNavigationView;
|
||||
|
@ -34,6 +38,7 @@ import com.novelbook.android.netutils.NetUtil;
|
|||
import com.novelbook.android.netutils.OnSuccessAndFaultListener;
|
||||
import com.novelbook.android.netutils.OnSuccessAndFaultSub;
|
||||
import com.novelbook.android.service.ServiceDownload;
|
||||
import com.novelbook.android.utils.CommonUtil;
|
||||
import com.novelbook.android.utils.Config;
|
||||
import com.novelbook.android.utils.Constants;
|
||||
import com.novelbook.android.utils.GsonUtil;
|
||||
|
@ -47,6 +52,8 @@ import java.util.Date;
|
|||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import static com.novelbook.android.FileActivity.EXTERNAL_STORAGE_REQ_CODE;
|
||||
|
||||
public class Main2Activity extends Activity_base
|
||||
implements NavigationView.OnNavigationItemSelectedListener{//} , BasicFragment.OnFragmentInteractionListener {
|
||||
public MyApp app ;
|
||||
|
@ -73,11 +80,12 @@ public class Main2Activity extends Activity_base
|
|||
protected void initViews() {
|
||||
|
||||
}
|
||||
|
||||
public static volatile Activity activityContext = null;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
NetUtil.getHostPolicy();
|
||||
super.onCreate(savedInstanceState);
|
||||
activityContext =this;
|
||||
//PageFactory.createPageFactory(this);
|
||||
app =(MyApp) getApplicationContext();
|
||||
// requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
|
||||
|
@ -85,8 +93,8 @@ public class Main2Activity extends Activity_base
|
|||
// ButterKnife.bind(this);
|
||||
|
||||
initialSexOption();
|
||||
checkUpdate(true);
|
||||
getSearchTabTtitle();
|
||||
// checkUpdate(true);
|
||||
CommonUtil.getSearchTabTtitle(this);
|
||||
|
||||
}
|
||||
|
||||
|
@ -111,6 +119,7 @@ public class Main2Activity extends Activity_base
|
|||
setupNavi();
|
||||
showHome();
|
||||
// tvUser.setText(this.getPackageName());
|
||||
|
||||
}
|
||||
|
||||
String currentActiveFragment;
|
||||
|
@ -551,39 +560,6 @@ private int bottomSelectedIndex;
|
|||
}
|
||||
|
||||
//----get master domain
|
||||
void getSearchTabTtitle(){
|
||||
|
||||
|
||||
BookSubscribe.getSearchTitles(Constants.SEX,new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
|
||||
// mFirstPage= gson.fromJson(result, FirstPage.class);
|
||||
try {
|
||||
|
||||
Constants.lstSex = GsonUtil.parserStringBlocks(result,"sex");
|
||||
Constants.lstNt =GsonUtil.parserStringBlocks(result,"nt");
|
||||
Constants.lstProgressType =GsonUtil.parserProgressType(result,"progress");
|
||||
|
||||
// initTabs();
|
||||
// loadSearchData();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "onSuccess: prepare book",e );
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFault(String errorMsg) {
|
||||
//失败
|
||||
Log.d(TAG, "error on get firstpage: " + errorMsg);
|
||||
// getSearchTabTtitle();
|
||||
handler.sendEmptyMessage(0);
|
||||
}
|
||||
},this));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,13 +36,13 @@ public class UrlFactory {
|
|||
return us.getString(index) ;//+ uri;
|
||||
}
|
||||
}
|
||||
|
||||
int value = (us == null || us.length()==0) ? index : index - us.length();
|
||||
return "";
|
||||
/*int value = (us == null || us.length()==0) ? index : index - us.length();
|
||||
|
||||
int second = 90 + 7;
|
||||
int a1 = value / 2 +1;
|
||||
int a2 = value % 2;
|
||||
return String.format("http://%s%s%s.%s%s%s%s.com", key.charAt(0), (char)(second + a2), a1, "xiao", "shuo", "fen", "xiang");
|
||||
return String.format("http://%s%s%s.%s%s%s%s.com", key.charAt(0), (char)(second + a2), a1, "xiao", "shuo", "fen", "xiang");*/
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
package com.novelbook.android.netutils;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.novelbook.android.BookActivity;
|
||||
import com.novelbook.android.Main2Activity;
|
||||
import com.novelbook.android.MyApp;
|
||||
import com.novelbook.android.netsubscribe.BookSubscribe;
|
||||
import com.novelbook.android.upgrade.UpdateManager;
|
||||
import com.novelbook.android.utils.CommonUtil;
|
||||
import com.novelbook.android.utils.Config;
|
||||
import com.novelbook.android.utils.Constants;
|
||||
|
@ -20,6 +25,8 @@ import java.util.Random;
|
|||
|
||||
import okhttp3.Call;
|
||||
|
||||
import static com.novelbook.android.FileActivity.EXTERNAL_STORAGE_REQ_CODE;
|
||||
|
||||
|
||||
/**
|
||||
* Created by 眼神 on 2018/3/27.
|
||||
|
@ -346,13 +353,31 @@ public class NetUtil {
|
|||
}, MyApp.applicationContext));
|
||||
}
|
||||
|
||||
static long lastUpgradCheck =0;
|
||||
static void initHostConstants( JSONObject jsonObject ) throws JSONException {
|
||||
Constants.announcement =jsonObject.getString("declare");
|
||||
Constants.email =jsonObject.getString("email");
|
||||
String tmp =jsonObject.getString("upgradeUrl");
|
||||
Constants.updateUrl =TextUtils.isEmpty(tmp)?Constants.updateUrl:tmp;
|
||||
// Constants.minVersion = jsonObject.getString("minVersion"); //TODO minVersion to be int type
|
||||
Constants.minVersion = jsonObject.getInt("minVersion");
|
||||
|
||||
// try {
|
||||
Constants.version = CommonUtil.getVersionCode(MyApp.applicationContext);
|
||||
if (lastUpgradCheck == 0 ||Constants.version <Constants.minVersion) {
|
||||
lastUpgradCheck = new Date().getTime();
|
||||
checkUpdate(true);
|
||||
|
||||
}
|
||||
// }catch (Exception er){
|
||||
// Log.e(TAG, "initHostConstants: update error ",er );
|
||||
// }
|
||||
}
|
||||
static void checkUpdate(boolean isSilence){
|
||||
|
||||
UpdateManager manager = new UpdateManager(Main2Activity.activityContext);
|
||||
if(isSilence)
|
||||
manager.checkUpdateSilence();
|
||||
else
|
||||
manager.checkUpdate();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ public class RetryInterceptor implements Interceptor {
|
|||
Log.d(TAG, String.format("HttpMethods intercept: response is null? %s", response == null));
|
||||
|
||||
int i=0;
|
||||
while(response==null && i<3){
|
||||
while((response==null || !response.isSuccessful() )&& i<3){
|
||||
request = chain.request();
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@ import java.net.URL;
|
|||
import java.util.HashMap;
|
||||
|
||||
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.app.Dialog;
|
||||
|
@ -33,6 +34,7 @@ import android.view.View;
|
|||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.novelbook.android.BookActivity;
|
||||
import com.novelbook.android.BuildConfig;
|
||||
import com.novelbook.android.MyApp;
|
||||
import com.novelbook.android.R;
|
||||
|
@ -52,14 +54,15 @@ import okhttp3.Request;
|
|||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
import static com.novelbook.android.FileActivity.EXTERNAL_STORAGE_REQ_CODE;
|
||||
import static com.novelbook.android.netapi.URLConstant.getRootUrl;
|
||||
import static java.lang.System.exit;
|
||||
|
||||
|
||||
public class UpdateManager {
|
||||
|
||||
public static final String TAG ="com.qiyou.UpdateManager";
|
||||
public static final String dTAG ="com.qiyou";
|
||||
public static final String TAG =UpdateManager.class.getSimpleName();
|
||||
|
||||
private static final int DOWNLOAD = 1;
|
||||
private static final int DOWNLOAD_FINISH = 2;
|
||||
private static final int showDialog =3;
|
||||
|
@ -68,10 +71,11 @@ public class UpdateManager {
|
|||
private String mSavePath;
|
||||
private int progress;
|
||||
private boolean cancelUpdate = false;
|
||||
private Context mContext;
|
||||
private Activity mContext;
|
||||
private ProgressBar mProgress;
|
||||
private Dialog mDownloadDialog;
|
||||
private boolean isForceRefresh;
|
||||
int serviceCode;
|
||||
private Handler mHandler = new Handler()
|
||||
{
|
||||
@Override
|
||||
|
@ -94,7 +98,7 @@ public class UpdateManager {
|
|||
};
|
||||
};
|
||||
|
||||
public UpdateManager(Context context)
|
||||
public UpdateManager(Activity context)
|
||||
{
|
||||
this.mContext = context;
|
||||
// app =(QiYouApplication)context;
|
||||
|
@ -195,12 +199,17 @@ public class UpdateManager {
|
|||
String packgename = mContext.getPackageName();
|
||||
mHashMap = multiHashMap.get(packgename);
|
||||
if (mHashMap != null) {
|
||||
int serviceCode = Integer.valueOf(mHashMap.get("version"));
|
||||
if(mHashMap.containsKey("miniVersion"))
|
||||
Constants.minVersion = Integer.valueOf(mHashMap.get("miniVersion"));
|
||||
serviceCode = Integer.valueOf(mHashMap.get("version"));
|
||||
if(mHashMap.containsKey("minVersion"))
|
||||
Constants.minVersion = Integer.valueOf(mHashMap.get("minVersion"));
|
||||
// need update or not
|
||||
isUpdate = serviceCode > versionCode;
|
||||
isForceRefresh = serviceCode <Constants.minVersion;
|
||||
isForceRefresh = versionCode <Constants.minVersion;
|
||||
|
||||
Log.d(TAG, String.format("processMultiTxtOnSuccess : isUpdate %s, serviceCode %s,minVersion %s,versionCode %s,isForceRefresh %s"
|
||||
,isUpdate,serviceCode,Constants.minVersion,Constants.version,isForceRefresh));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,11 +271,13 @@ public class UpdateManager {
|
|||
*/
|
||||
public int getVersionCode(Context context)
|
||||
{
|
||||
|
||||
int versionCode = 0;
|
||||
try
|
||||
{
|
||||
// 閼惧嘲褰囨潪顖欐閻楀牊婀伴崣鍑ょ礉鐎电懓绨睞ndroidManifest.xml娑撳獘ndroid:versionCode
|
||||
versionCode =(int)CommonUtil.getVersionCodeLong(context);// context.getPackageManager().getPackageInfo("com.novelbook.android", 0).versionCode;
|
||||
|
||||
/*int versionCode2 = CommonUtil.getVersionCode(context);
|
||||
long versioncode3 = CommonUtil.getVersionCodeLong(context);
|
||||
|
||||
|
@ -306,6 +317,9 @@ public class UpdateManager {
|
|||
*/
|
||||
private void showNoticeDialog()
|
||||
{
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
CommonUtil.checkPermission(mContext, Manifest.permission.WRITE_EXTERNAL_STORAGE, EXTERNAL_STORAGE_REQ_CODE, "下载更新需要此权限,请允许");
|
||||
}
|
||||
|
||||
// 閺嬪嫰锟界<EFBFBD>纭呯樈濡楋拷
|
||||
Builder builder = new Builder(mContext);
|
||||
|
@ -317,7 +331,9 @@ public class UpdateManager {
|
|||
}
|
||||
String upgradeDetails=mHashMap.get("details");
|
||||
String forceRefresh =isForceRefresh? "本地版本过低,请升级新版本\n":"";
|
||||
builder.setMessage( forceRefresh + mContext.getPackageName() + " "+getVersionCode(mContext) +" " +mContext.getString(R.string.soft_update_info) + upgradeDetails );
|
||||
builder.setMessage( forceRefresh +mContext.getPackageName() + "\n当前版本:"+getVersionCode(mContext) +"\n"
|
||||
+"最新版本:"+ serviceCode +"\n"
|
||||
+ mContext.getString(R.string.soft_update_info) + upgradeDetails );
|
||||
builder.setPositiveButton(R.string.soft_update_updatebtn, new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
|
@ -384,6 +400,7 @@ public class UpdateManager {
|
|||
*/
|
||||
private void downloadApk()
|
||||
{
|
||||
|
||||
// 閸氼垰濮╅弬鎵殠缁嬪绗呮潪鍊熻拫娴狅拷
|
||||
new downloadApkThread().start();
|
||||
}
|
||||
|
|
|
@ -1377,7 +1377,11 @@ int muluRetryCount =0;
|
|||
// isDownloadChapt =true;
|
||||
Log.d(TAG,String.format("handler msg, download %s",true) );
|
||||
}else if(msg.what==99){
|
||||
Toast.makeText(mContext,"网络拥堵,已帮您切换其它源",Toast.LENGTH_LONG).show();
|
||||
try {
|
||||
Toast.makeText(mContext, "网络拥堵,已帮您切换其它源", Toast.LENGTH_LONG).show();
|
||||
}catch (Exception e){
|
||||
Log.e(TAG, "handlerMsg:toast error ", e);
|
||||
}
|
||||
// getSiteRule();
|
||||
// pagefactory .changeChapter(getChapterNo());
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ import android.content.pm.PackageManager;
|
|||
import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
import android.os.Build;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.widget.ContentLoadingProgressBar;
|
||||
import android.text.TextUtils;
|
||||
import android.util.DisplayMetrics;
|
||||
|
@ -22,6 +24,10 @@ import android.view.Window;
|
|||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.novelbook.android.netsubscribe.BookSubscribe;
|
||||
import com.novelbook.android.netutils.OnSuccessAndFaultListener;
|
||||
import com.novelbook.android.netutils.OnSuccessAndFaultSub;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.Timestamp;
|
||||
|
@ -332,11 +338,14 @@ public class CommonUtil {
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
public static long getVersionCodeLong(Context context) {
|
||||
public static int getVersionCodeLong(Context context) {
|
||||
if(Constants.version >0){
|
||||
return Constants.version;
|
||||
}
|
||||
try {
|
||||
PackageManager manager = context.getPackageManager();
|
||||
PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
|
||||
return info.getLongVersionCode();
|
||||
Constants.version = (int) info.getLongVersionCode();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
|
@ -344,6 +353,7 @@ public class CommonUtil {
|
|||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
return Constants.version;
|
||||
}
|
||||
public static String getPackageName(Context context) {
|
||||
try {
|
||||
|
@ -513,7 +523,61 @@ public class CommonUtil {
|
|||
}
|
||||
return "";
|
||||
}
|
||||
public static void checkPermission (Activity thisActivity, String permission, int requestCode, String errorText) {
|
||||
//判断当前Activity是否已经获得了该权限
|
||||
if(ContextCompat.checkSelfPermission(thisActivity,permission) != PackageManager.PERMISSION_GRANTED) {
|
||||
//如果App的权限申请曾经被用户拒绝过,就需要在这里跟用户做出解释
|
||||
if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
|
||||
permission)) {
|
||||
Toast.makeText(thisActivity,errorText,Toast.LENGTH_SHORT).show();
|
||||
//进行权限请求
|
||||
ActivityCompat.requestPermissions(thisActivity,
|
||||
new String[]{permission},
|
||||
requestCode);
|
||||
} else {
|
||||
//进行权限请求
|
||||
ActivityCompat.requestPermissions(thisActivity,
|
||||
new String[]{permission},
|
||||
requestCode);
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void getSearchTabTtitle(Context context){
|
||||
|
||||
BookSubscribe.getSearchTitles(Constants.SEX,new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
|
||||
// mFirstPage= gson.fromJson(result, FirstPage.class);
|
||||
try {
|
||||
|
||||
Constants.lstSex = GsonUtil.parserStringBlocks(result,"sex");
|
||||
Constants.lstNt =GsonUtil.parserStringBlocks(result,"nt");
|
||||
Constants.lstProgressType =GsonUtil.parserProgressType(result,"progress");
|
||||
|
||||
// initTabs();
|
||||
// loadSearchData();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "onSuccess: prepare book",e );
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFault(String errorMsg) {
|
||||
//失败
|
||||
|
||||
// getSearchTabTtitle();
|
||||
|
||||
}
|
||||
},context));
|
||||
|
||||
}
|
||||
/* public static boolean isNavigationBarShow(){
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
Display display = getActivity().getWindowManager().getDefaultDisplay();
|
||||
|
|
|
@ -32,5 +32,6 @@ public class Constants {
|
|||
public static String announcement ="免责声明:阅读内容均来自互联网,本软件仅提供转码服务";
|
||||
public static String email ="";
|
||||
public static int minVersion =0;
|
||||
public static int version =0;
|
||||
public static String updateUrl="http://xiaoshuofenxiang.com/version.xml";;
|
||||
}
|
||||
|
|
|
@ -709,6 +709,12 @@ private void hideSysUI(){
|
|||
case FAIL:
|
||||
status = "读取错误,请稍后重试";
|
||||
mAd.showRefresh(View.VISIBLE);
|
||||
try {
|
||||
throw new Exception("error on reading");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.d(TAG, "prepare book: why fail ",e);
|
||||
}
|
||||
break;
|
||||
case NETWORKFAILE:
|
||||
status = "请开启网络";
|
||||
|
@ -1112,7 +1118,9 @@ private void hideSysUI(){
|
|||
this.mBookUtil.setNovel(book);
|
||||
this.mBookUtil.getTargetSites();
|
||||
}
|
||||
|
||||
public void initBookUtil() {
|
||||
mBookUtil = null;
|
||||
}
|
||||
/**
|
||||
* 打开书本
|
||||
* @throws IOException
|
||||
|
@ -1200,9 +1208,18 @@ private void hideSysUI(){
|
|||
chapter = params[0];
|
||||
begin = params[1];
|
||||
currentChapter = (int) chapter;
|
||||
|
||||
try {
|
||||
int slept=0;
|
||||
while(getNovel() ==null){
|
||||
Thread.sleep(10);
|
||||
slept++;
|
||||
}
|
||||
|
||||
Log.d(TAG, "prepare book:waiting for bookutil book slept "+slept*10);
|
||||
mBookUtil.openBook(getNovel(),chapter);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "prepare book: backgroud error", e);
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
@ -1695,7 +1712,6 @@ private void hideSysUI(){
|
|||
if(chaptMap!=null){
|
||||
chaptMap.clear();
|
||||
}
|
||||
//mBookUtil=null;
|
||||
currentChapter = 0;
|
||||
bookPath = "";
|
||||
bookName = "";
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
<!-- 描边 -->
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:width="1dp"
|
||||
android:color="@color/white" />
|
||||
<!-- 圆角 -->
|
||||
<corners
|
||||
android:radius="8dp" />
|
||||
android:radius="2dp" />
|
||||
<padding
|
||||
android:left="11dp"
|
||||
android:top="2dp"
|
||||
|
|
Loading…
Reference in New Issue