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