书架更新排序逻辑
This commit is contained in:
parent
7e820840fe
commit
6e4e60e984
|
@ -17,8 +17,8 @@ android {
|
|||
// applicationId "com.zhushou.yueshu"
|
||||
minSdkVersion 19 //target 19 Android 4.4 以下版本仅占比4.1%
|
||||
targetSdkVersion 28
|
||||
versionCode 6
|
||||
versionName "v6.0"
|
||||
versionCode 1
|
||||
versionName "v1.0"
|
||||
|
||||
// testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
@ -62,7 +62,7 @@ android {
|
|||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
// versionCode 1
|
||||
// versionName "v1.0"
|
||||
/* applicationVariants.all { variant ->
|
||||
applicationVariants.all { variant ->
|
||||
variant.outputs.all { output ->
|
||||
def outFile = output.outputFile
|
||||
if (outFile != null && outFile.name.endsWith(".apk")) {
|
||||
|
@ -71,14 +71,14 @@ android {
|
|||
outputFileName = fileName;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
signingConfig signingConfigs.releaseConfig
|
||||
}
|
||||
}
|
||||
//渠道
|
||||
productFlavors {
|
||||
// googleplay {}
|
||||
/* g {
|
||||
g {
|
||||
applicationId "com.zhushou.yueshu"
|
||||
versionName "v1.0"
|
||||
buildConfigField "String", "MAIN_HOST", '"http://g.xiaoshuofenxiang.com/api/"'
|
||||
|
@ -88,7 +88,7 @@ android {
|
|||
//批量配置
|
||||
productFlavors.all { flavor ->
|
||||
flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
|
||||
}*/
|
||||
}
|
||||
/* google {
|
||||
applicationId "com.zhushou.yueshu"
|
||||
versionName "v1.0"
|
||||
|
|
|
@ -197,8 +197,8 @@
|
|||
<meta-data
|
||||
android:name="UMENG_APPKEY"
|
||||
android:value="5cd6238a570df375c3000cc9" /> <!-- <meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}"/> -->
|
||||
<meta-data android:name="UMENG_CHANNEL" android:value="debug" />
|
||||
<!--<meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}" />-->
|
||||
<!--<meta-data android:name="UMENG_CHANNEL" android:value="debug" />-->
|
||||
<meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}" />
|
||||
<!-- google ad-->
|
||||
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
|
||||
<meta-data
|
||||
|
|
|
@ -343,7 +343,12 @@ public class CatalogFragment extends BasicFragment implements MarkActivity.Sortc
|
|||
return;
|
||||
|
||||
if (mProgressDialog2.isShowing()) {
|
||||
mProgressDialog2.dismiss();
|
||||
try {
|
||||
mProgressDialog2.dismiss();
|
||||
}catch (Exception e){
|
||||
Log.e(TAG, "hideProgressSelf: ",e );
|
||||
}
|
||||
|
||||
}
|
||||
mSwipeRefresh.setRefreshing(false);
|
||||
}
|
||||
|
|
|
@ -211,6 +211,7 @@ public class Fragment_Shelf extends BasicFragment {
|
|||
public void onFault(String errorMsg) {
|
||||
//失败
|
||||
Log.d(TAG, "error on get novel update list: " + errorMsg);
|
||||
Toast.makeText(activity,"获取更新服务失败",Toast.LENGTH_SHORT).show();
|
||||
handler.sendEmptyMessage(1);
|
||||
}
|
||||
};
|
||||
|
@ -426,7 +427,8 @@ public class Fragment_Shelf extends BasicFragment {
|
|||
if(option!= Constants.SHELF_ORDER) {
|
||||
Constants.SHELF_ORDER = option;
|
||||
config.setShelfOrderOption(option);
|
||||
getUpdatedData();
|
||||
// getUpdatedData();
|
||||
loadLocalData();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -442,6 +444,10 @@ public class Fragment_Shelf extends BasicFragment {
|
|||
|
||||
private void initDialog(int position) {
|
||||
|
||||
Log.d(TAG, "initDialog: onlongclick " + bookLists.get(position).getName() );
|
||||
|
||||
|
||||
|
||||
bottomSheetDialog = new BottomSheetDialog(this.activity);
|
||||
bottomSheetDialog.setContentView(R.layout.fragment_shelf_botoomsheetdialog);
|
||||
//给布局设置透明背景色
|
||||
|
@ -867,7 +873,10 @@ public class Fragment_Shelf extends BasicFragment {
|
|||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
||||
super.onResume();
|
||||
|
||||
loadLocalData();
|
||||
getUpdatedData();
|
||||
|
||||
if (bottomSheetDialog != null) {
|
||||
|
@ -882,6 +891,11 @@ public class Fragment_Shelf extends BasicFragment {
|
|||
MobclickAgent.onPageEnd(TAG);
|
||||
}
|
||||
|
||||
void loadLocalData(){
|
||||
loadNovelsOnShelf();
|
||||
fillData();
|
||||
}
|
||||
|
||||
//----------toutiao ad
|
||||
|
||||
|
||||
|
|
|
@ -35,31 +35,32 @@ import butterknife.BindView;
|
|||
|
||||
public class Fragment_booklist extends BasicFragment {
|
||||
public static final String TAG = Fragment_booklist.class.getSimpleName();
|
||||
private static final String EXTR_CATE ="cate" ;
|
||||
private static final String EXTR_PROGRESS ="progress" ;
|
||||
private static final String EXTR_SEARCH ="search";
|
||||
private static final String EXTR_FN ="fn" ;
|
||||
private static final String EXTR_BANGDAN ="bangdan" ;
|
||||
private static final String EXTR_HISTORY ="history" ;
|
||||
private static final String EXTR_CID ="cid" ;
|
||||
private static final String EXTR_CATE = "cate";
|
||||
private static final String EXTR_PROGRESS = "progress";
|
||||
private static final String EXTR_SEARCH = "search";
|
||||
private static final String EXTR_FN = "fn";
|
||||
private static final String EXTR_BANGDAN = "bangdan";
|
||||
private static final String EXTR_HISTORY = "history";
|
||||
private static final String EXTR_CID = "cid";
|
||||
private BookListAdapter mAdapter;
|
||||
// private BookListAdapter mAdapter;
|
||||
private List mData;;
|
||||
private List mData;
|
||||
;
|
||||
private List mMoreData;
|
||||
private String cate;
|
||||
private int progress,cid;
|
||||
private String keyWord ,fn,bangdan,history;
|
||||
private int listItem =R.layout.recycle_list_item_horizon;
|
||||
private int progress, cid;
|
||||
private String keyWord, fn, bangdan, history;
|
||||
private int listItem = R.layout.recycle_list_item_horizon;
|
||||
//private int pageNo=1;
|
||||
private int totalCount;
|
||||
// private int pageCount;
|
||||
// private int pageCount;
|
||||
@BindView(R.id.rvBooklist)
|
||||
RecyclerView mRecyclerView;
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public Fragment_booklist(String cate, int progress) {
|
||||
this.cate =cate;
|
||||
this.progress = progress;
|
||||
this.cate = cate;
|
||||
this.progress = progress;
|
||||
|
||||
|
||||
}
|
||||
|
@ -67,87 +68,95 @@ public class Fragment_booklist extends BasicFragment {
|
|||
public Fragment_booklist() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
public static Fragment_booklist newInstance(int cid,String bangdan) {
|
||||
|
||||
public static Fragment_booklist newInstance(int cid, String bangdan) {
|
||||
Fragment_booklist fragment = new Fragment_booklist();
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(EXTR_CID,cid);
|
||||
args.putString(EXTR_BANGDAN,bangdan);
|
||||
args.putInt(EXTR_CID, cid);
|
||||
args.putString(EXTR_BANGDAN, bangdan);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
public static Fragment_booklist newInstance(String fn,String bangdan) {
|
||||
|
||||
public static Fragment_booklist newInstance(String fn, String bangdan) {
|
||||
Fragment_booklist fragment = new Fragment_booklist();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(EXTR_FN,fn);
|
||||
args.putString(EXTR_BANGDAN,bangdan);
|
||||
args.putString(EXTR_FN, fn);
|
||||
args.putString(EXTR_BANGDAN, bangdan);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
public static Fragment_booklist newInstance(String noveType,int progress) {
|
||||
|
||||
public static Fragment_booklist newInstance(String noveType, int progress) {
|
||||
Fragment_booklist fragment = new Fragment_booklist();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(EXTR_CATE,noveType);
|
||||
args.putString(EXTR_CATE, noveType);
|
||||
args.putInt(EXTR_PROGRESS, progress);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public static Fragment_booklist search(String keyWord) {
|
||||
Fragment_booklist fragment = new Fragment_booklist();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(EXTR_SEARCH,keyWord);
|
||||
args.putString(EXTR_SEARCH, keyWord);
|
||||
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public static Fragment_booklist history() {
|
||||
Fragment_booklist fragment = new Fragment_booklist();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(EXTR_HISTORY,EXTR_HISTORY);
|
||||
args.putString(EXTR_HISTORY, EXTR_HISTORY);
|
||||
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
protected void processArguments(){
|
||||
|
||||
protected void processArguments() {
|
||||
if (getArguments() != null) {
|
||||
Bundle bundle = getArguments() ;
|
||||
bangdan =bundle.getString(EXTR_BANGDAN);
|
||||
fn= bundle.getString(EXTR_FN);
|
||||
cid =bundle.getInt(EXTR_CID);
|
||||
if(!TextUtils.isEmpty((fn))){
|
||||
Bundle bundle = getArguments();
|
||||
bangdan = bundle.getString(EXTR_BANGDAN);
|
||||
fn = bundle.getString(EXTR_FN);
|
||||
cid = bundle.getInt(EXTR_CID);
|
||||
if (!TextUtils.isEmpty((fn))) {
|
||||
return;
|
||||
}
|
||||
cate = bundle.getString(EXTR_CATE);
|
||||
progress = bundle.getInt(EXTR_PROGRESS);
|
||||
keyWord =bundle.getString(EXTR_SEARCH);
|
||||
history =bundle.getString(EXTR_HISTORY);
|
||||
if(!TextUtils.isEmpty(history)){
|
||||
listItem =R.layout.recycle_list_item_history;
|
||||
cate = bundle.getString(EXTR_CATE);
|
||||
progress = bundle.getInt(EXTR_PROGRESS);
|
||||
keyWord = bundle.getString(EXTR_SEARCH);
|
||||
history = bundle.getString(EXTR_HISTORY);
|
||||
if (!TextUtils.isEmpty(history)) {
|
||||
listItem = R.layout.recycle_list_item_history;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int lastPageNo =0;
|
||||
@Override
|
||||
protected void fillData() {
|
||||
int lastPageNo = 0;
|
||||
|
||||
if(mRecyclerView.getAdapter()==null) {
|
||||
@Override
|
||||
protected void fillData() {
|
||||
|
||||
if (mRecyclerView.getAdapter() == null) {
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(activity));
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(mMoreData!=null) {
|
||||
if(mMoreData.size()>0) {
|
||||
if (mMoreData != null) {
|
||||
if (mMoreData.size() > 0) {
|
||||
pageNo++;
|
||||
}
|
||||
int status =getPageCount()>= pageNo ? BookListAdapter.PULLUP_LOAD_MORE : BookListAdapter.NO_LOAD_MORE;
|
||||
// mAdapter.setPercent(pageNo/pageCount);
|
||||
int status = getPageCount() >= pageNo ? BookListAdapter.PULLUP_LOAD_MORE : BookListAdapter.NO_LOAD_MORE;
|
||||
// mAdapter.setPercent(pageNo/pageCount);
|
||||
mAdapter.AddFooterItem(mMoreData);
|
||||
mAdapter.changeMoreStatus(status);
|
||||
mMoreData.clear();
|
||||
}
|
||||
|
||||
mAdapter.setNorecord(R.string.noRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -156,54 +165,61 @@ public class Fragment_booklist extends BasicFragment {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
if(pageNo>1){
|
||||
if(lastPageNo ==pageNo){
|
||||
|
||||
if (pageNo > 1) {
|
||||
if (lastPageNo == pageNo) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
lastPageNo = pageNo;
|
||||
// int pn = pageNo;
|
||||
// int pn = pageNo;
|
||||
|
||||
if(pageNo==1) {
|
||||
noveIds = new ArrayList<Integer>();
|
||||
if (mData != null) { //下拉刷新
|
||||
mData = new ArrayList<Novel>();
|
||||
mAdapter.setData(mData);
|
||||
// loadListAd(mAdapter,1,false);
|
||||
if (pageNo == 1) {
|
||||
noveIds = new ArrayList<Integer>();
|
||||
if (mData != null) { //下拉刷新
|
||||
mData = new ArrayList<Novel>();
|
||||
mAdapter.setData(mData);
|
||||
// loadListAd(mAdapter,1,false);
|
||||
|
||||
} else {
|
||||
} else {
|
||||
|
||||
initialDataAdapter();
|
||||
}
|
||||
initialDataAdapter();
|
||||
}
|
||||
}
|
||||
|
||||
if (mAdapter != null) {
|
||||
mAdapter.setNorecord(R.string.msgLoading);
|
||||
}
|
||||
|
||||
/* if(mAdapter!=null){
|
||||
mAdapter.changeMoreStatus(BookListAdapter.LOADING_MORE);
|
||||
}*/
|
||||
mMoreData =null;
|
||||
OnSuccessAndFaultListener successAndFaultListener = new OnSuccessAndFaultListener() {
|
||||
mMoreData = null;
|
||||
OnSuccessAndFaultListener successAndFaultListener = new OnSuccessAndFaultListener() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
|
||||
// mFirstPage= gson.fromJson(result, FirstPage.class);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(result);
|
||||
setPageCount(jsonObject.getInt("pageCount")); ;
|
||||
List<Novel> list = GsonUtil. parserJsonArray(jsonObject,Constants.BLOCK_TITLE_NOVELS);
|
||||
mMoreData =new ArrayList<Novel>();
|
||||
for(Novel novel :list){
|
||||
if(!noveIds.contains(novel.getNovelId())){
|
||||
JSONObject jsonObject = new JSONObject(result);
|
||||
setPageCount(jsonObject.getInt("pageCount"));
|
||||
;
|
||||
List<Novel> list = GsonUtil.parserJsonArray(jsonObject, Constants.BLOCK_TITLE_NOVELS);
|
||||
mMoreData = new ArrayList<Novel>();
|
||||
for (Novel novel : list) {
|
||||
if (!noveIds.contains(novel.getNovelId())) {
|
||||
mMoreData.add(novel);
|
||||
noveIds.add(novel.getNovelId());
|
||||
}
|
||||
}
|
||||
if(mMoreData.size()>0){
|
||||
loadListAd(mAdapter,1,mData.size()>0);
|
||||
if (mMoreData.size() > 0) {
|
||||
loadListAd(mAdapter, 1, mData.size() > 0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(); Log.e(TAG, "onSuccess: 解析失败",e );
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "onSuccess: 解析失败", e);
|
||||
}
|
||||
handler.sendEmptyMessage(1);
|
||||
|
||||
|
@ -217,41 +233,39 @@ public class Fragment_booklist extends BasicFragment {
|
|||
}
|
||||
};
|
||||
|
||||
showProgressDialog(false,"正在加载...");
|
||||
showProgressDialog(false, "正在加载...");
|
||||
|
||||
Log.d(TAG,String.format("fn is %s",fn) );
|
||||
Log.d(TAG, String.format("fn is %s", fn));
|
||||
|
||||
if(!TextUtils.isEmpty(bangdan) && (cid >0 || !TextUtils.isEmpty(fn))){ //榜单
|
||||
// showProgressDialog(true, "正在加载榜单");
|
||||
mAdapter.setShowTop(true);
|
||||
BookSubscribe.getPaihangBangList(Constants.SEX,pageNo,cid,new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
|
||||
if (!TextUtils.isEmpty(bangdan) && (cid > 0 || !TextUtils.isEmpty(fn))) { //榜单
|
||||
// showProgressDialog(true, "正在加载榜单");
|
||||
mAdapter.setShowTop(true);
|
||||
BookSubscribe.getPaihangBangList(Constants.SEX, pageNo, cid, new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(result);
|
||||
String resultstr = jsonObject.getString("rank") ;
|
||||
setPageCount(jsonObject.getJSONObject("rank").getInt("pageCount")); ;
|
||||
List<Novel> list = GsonUtil. parserJsonArray(resultstr,Constants.BLOCK_TITLE_NOVELS);
|
||||
mMoreData =new ArrayList<Novel>();
|
||||
for(Novel novel :list){
|
||||
if(!noveIds.contains(novel.getNovelId())){
|
||||
String resultstr = jsonObject.getString("rank");
|
||||
setPageCount(jsonObject.getJSONObject("rank").getInt("pageCount"));
|
||||
;
|
||||
List<Novel> list = GsonUtil.parserJsonArray(resultstr, Constants.BLOCK_TITLE_NOVELS);
|
||||
mMoreData = new ArrayList<Novel>();
|
||||
for (Novel novel : list) {
|
||||
if (!noveIds.contains(novel.getNovelId())) {
|
||||
mMoreData.add(novel);
|
||||
noveIds.add(novel.getNovelId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Log.d(TAG, "排行榜详细 onSuccess: pageCount " + getPageCount());
|
||||
if(mMoreData.size()>0){
|
||||
loadListAd(mAdapter,1,mData.size()>0);
|
||||
if (mMoreData.size() > 0) {
|
||||
loadListAd(mAdapter, 1, mData.size() > 0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "onSuccess: 解析失败",e );
|
||||
Log.e(TAG, "onSuccess: 解析失败", e);
|
||||
}
|
||||
Log.d(TAG, "progress: progress to hide");
|
||||
handler.sendEmptyMessage(1);
|
||||
|
@ -267,24 +281,23 @@ public class Fragment_booklist extends BasicFragment {
|
|||
}, getActivity()));
|
||||
|
||||
|
||||
}else if(!TextUtils.isEmpty(fn)){ //首页 更多
|
||||
} else if (!TextUtils.isEmpty(fn)) { //首页 更多
|
||||
mAdapter.setShowTop(true);
|
||||
// showProgressDialog(true, "正在加载更多");
|
||||
BookSubscribe.getNovelPaihang(fn,pageNo,Constants.SEX,new OnSuccessAndFaultSub(successAndFaultListener, getActivity()));
|
||||
// showProgressDialog(true, "正在加载更多");
|
||||
BookSubscribe.getNovelPaihang(fn, pageNo, Constants.SEX, new OnSuccessAndFaultSub(successAndFaultListener, getActivity()));
|
||||
|
||||
}
|
||||
else if(!TextUtils.isEmpty((cate))) { //分类
|
||||
} else if (!TextUtils.isEmpty((cate))) { //分类
|
||||
mAdapter.setShowTop(true);
|
||||
// showProgressDialog(true, "正在加载分类");
|
||||
// showProgressDialog(true, "正在加载分类");
|
||||
BookSubscribe.getCateNovelList(cate, pageNo, Constants.SEX, progress, new OnSuccessAndFaultSub(successAndFaultListener, getActivity()));
|
||||
|
||||
}else if(!TextUtils.isEmpty(keyWord)){ //搜索
|
||||
// showProgressDialog(true, "正在加载搜索");
|
||||
// mAdapter.setShowTop(true);
|
||||
BookSubscribe.getSearchNovelList( keyWord,pageNo, Constants.SEX, new OnSuccessAndFaultSub(successAndFaultListener, getActivity()));
|
||||
}else if(!TextUtils.isEmpty(history)){
|
||||
loadHistory();
|
||||
}else{
|
||||
} else if (!TextUtils.isEmpty(keyWord)) { //搜索
|
||||
// showProgressDialog(true, "正在加载搜索");
|
||||
// mAdapter.setShowTop(true);
|
||||
BookSubscribe.getSearchNovelList(keyWord, pageNo, Constants.SEX, new OnSuccessAndFaultSub(successAndFaultListener, getActivity()));
|
||||
} else if (!TextUtils.isEmpty(history)) {
|
||||
loadHistory();
|
||||
} else {
|
||||
handler.sendEmptyMessage(1);
|
||||
}
|
||||
|
||||
|
@ -297,8 +310,8 @@ public class Fragment_booklist extends BasicFragment {
|
|||
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
if(mData.get(position) instanceof Novel)
|
||||
showBookDetail((Novel)mData.get(position));
|
||||
if (mData.get(position) instanceof Novel)
|
||||
showBookDetail((Novel) mData.get(position));
|
||||
// openBook(mData.get(position),mAdapter);
|
||||
}
|
||||
|
||||
|
@ -321,7 +334,7 @@ public class Fragment_booklist extends BasicFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void initViews(){
|
||||
public void initViews() {
|
||||
//mRecyclerView
|
||||
|
||||
//lv_catalogue.setFastScrollStyle(R.style.FastScrollTheme); //不起作用
|
||||
|
@ -333,6 +346,7 @@ public class Fragment_booklist extends BasicFragment {
|
|||
void initialBookList() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFTag() {
|
||||
|
||||
|
@ -341,22 +355,23 @@ public class Fragment_booklist extends BasicFragment {
|
|||
private void initLoadMoreListener() {
|
||||
|
||||
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
int lastVisibleItem ;
|
||||
int lastVisibleItem;
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
Log.d(TAG, String.format("onScrollStateChanged , state %s ,lastVisibleitem %s ,getItemCount %s,pageno %s ,getPageCount() %s",
|
||||
newState==RecyclerView.SCROLL_STATE_IDLE,lastVisibleItem,mAdapter.getItemCount(),pageNo,getPageCount()));
|
||||
Log.d(TAG, String.format("onScrollStateChanged , state %s ,lastVisibleitem %s ,getItemCount %s,pageno %s ,getPageCount() %s",
|
||||
newState == RecyclerView.SCROLL_STATE_IDLE, lastVisibleItem, mAdapter.getItemCount(), pageNo, getPageCount()));
|
||||
//判断RecyclerView的状态 是空闲时,同时,是最后一个可见的ITEM时才加载
|
||||
if(newState==RecyclerView.SCROLL_STATE_IDLE&&lastVisibleItem+1==mAdapter.getItemCount()){
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE && lastVisibleItem + 1 == mAdapter.getItemCount()) {
|
||||
|
||||
if(pageNo <= getPageCount()) {
|
||||
if (pageNo <= getPageCount()) {
|
||||
//设置正在加载更多
|
||||
mAdapter.changeMoreStatus(mAdapter.LOADING_MORE);
|
||||
|
||||
//改为网络请求
|
||||
initData();
|
||||
}else{
|
||||
} else {
|
||||
mAdapter.changeMoreStatus(mAdapter.NO_LOAD_MORE);
|
||||
}
|
||||
|
||||
|
@ -370,52 +385,52 @@ public class Fragment_booklist extends BasicFragment {
|
|||
|
||||
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||
//最后一个可见的ITEM
|
||||
lastVisibleItem=layoutManager.findLastVisibleItemPosition();
|
||||
lastVisibleItem = layoutManager.findLastVisibleItemPosition();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
void loadHistory(){
|
||||
|
||||
void loadHistory() {
|
||||
initialDataAdapter();
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
|
||||
mMoreData = Novel.getNovelsHistory();
|
||||
mMoreData = Novel.getNovelsHistory();
|
||||
setPageCount(1);
|
||||
//
|
||||
//
|
||||
handler.sendEmptyMessage(1);
|
||||
if(mMoreData!=null && mMoreData.size()>5) {
|
||||
if (mMoreData != null && mMoreData.size() > 5) {
|
||||
loadListAd(mAdapter, 1, mData.size() > 0);
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
boolean isFirstLoad =true;
|
||||
@Override
|
||||
public void onResume(){
|
||||
super.onResume();
|
||||
// pageNo=1;
|
||||
|
||||
if(!TextUtils.isEmpty(history)){
|
||||
if(isFirstLoad) {
|
||||
isFirstLoad=false;
|
||||
}else{
|
||||
initData();
|
||||
}
|
||||
boolean isFirstLoad = true;
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
// pageNo=1;
|
||||
|
||||
if (!TextUtils.isEmpty(history)) {
|
||||
if (isFirstLoad) {
|
||||
isFirstLoad = false;
|
||||
} else {
|
||||
initData();
|
||||
}
|
||||
}
|
||||
MobclickAgent.onPageStart(TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause(){
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MobclickAgent.onPageEnd(TAG);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -104,7 +104,9 @@ public static final String TAG = Fragment_paihang.class.getSimpleName();
|
|||
}
|
||||
|
||||
mAdapter.notifyDataSetChanged();
|
||||
|
||||
if(mAdapter!=null) {
|
||||
mAdapter.setNorecord(R.string.noRecord);
|
||||
}
|
||||
}
|
||||
|
||||
public static Fragment_paihang newInstance(String param1, String param2) {
|
||||
|
@ -131,15 +133,18 @@ public static final String TAG = Fragment_paihang.class.getSimpleName();
|
|||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
loadSearchData();
|
||||
}
|
||||
private void loadSearchData(){
|
||||
|
||||
try{
|
||||
if(mAdapter!=null) {
|
||||
mAdapter.setNorecord(R.string.msgLoading);
|
||||
}
|
||||
/* try{
|
||||
throw new Exception();
|
||||
}catch (Exception e){
|
||||
Log.e(TAG, "loadSearchData: ", e);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
int pn = pageNo;
|
||||
|
|
|
@ -502,11 +502,11 @@ public class BookUtil {
|
|||
|
||||
public void setChapterNo(int chapterNo) {
|
||||
|
||||
try{
|
||||
/* try{
|
||||
throw new Exception();
|
||||
}catch (Exception e){
|
||||
Log.e(TAG, "prepare book setChapterNo: who set chaptno "+ chapterNo,e );
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
this.chapterNo = chapterNo;
|
||||
|
@ -527,6 +527,9 @@ public class BookUtil {
|
|||
return mChangeChapId;
|
||||
}
|
||||
// chapterNo=1;
|
||||
if(mChapters.size()>0){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
chapterNo = chapterNo<=0 ?1 :chapterNo;
|
||||
|
||||
|
|
|
@ -187,20 +187,17 @@ public class GsonUtil {
|
|||
|
||||
//遍历JsonArray对象
|
||||
Iterator it = jsonArray.iterator();
|
||||
// int lastNoveId =0;
|
||||
List<Integer> ids = new ArrayList<Integer>();
|
||||
while (it.hasNext()) {
|
||||
JsonElement e = (JsonElement) it.next();
|
||||
//JsonElement转换为JavaBean对象
|
||||
Novel nv = (Novel) gson.fromJson(e, Novel.class);
|
||||
if(ids.contains(nv.getNovelId())){
|
||||
if (nv == null || ids.contains(nv.getNovelId())) {
|
||||
continue;
|
||||
}
|
||||
ids.add(nv.getNovelId());
|
||||
// lastNoveId =nv.getNovelId();
|
||||
if(nv!=null) {
|
||||
list.add((Novel) gson.fromJson(e, Novel.class));
|
||||
}
|
||||
list.add((Novel) gson.fromJson(e, Novel.class));
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
|
@ -8,39 +8,81 @@
|
|||
</facet>
|
||||
<facet type="android" name="Android">
|
||||
<configuration>
|
||||
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
||||
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
||||
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
|
||||
<option name="SELECTED_BUILD_VARIANT" value="gDebug" />
|
||||
<option name="ASSEMBLE_TASK_NAME" value="assembleGDebug" />
|
||||
<option name="COMPILE_JAVA_TASK_NAME" value="compileGDebugSources" />
|
||||
<afterSyncTasks>
|
||||
<task>generateDebugSources</task>
|
||||
<task>generateGDebugSources</task>
|
||||
</afterSyncTasks>
|
||||
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
||||
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
|
||||
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
|
||||
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/src/debug/res;file://$MODULE_DIR$/build/generated/res/resValues/debug" />
|
||||
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/src/debug/res;file://$MODULE_DIR$/build/generated/res/resValues/g/debug" />
|
||||
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="" />
|
||||
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/compileDebugUnitTestJavaWithJavac/classes" />
|
||||
<output url="file://$MODULE_DIR$/build/intermediates/javac/gDebug/compileGDebugJavaWithJavac/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/gDebugUnitTest/compileGDebugUnitTestJavaWithJavac/classes" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debug/compileDebugAidl/out" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debug/compileDebugRenderscript/out" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/debugAndroidTest/compileDebugAndroidTestAidl/out" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/debugAndroidTest/compileDebugAndroidTestRenderscript/out" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/g/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/gDebug/compileGDebugAidl/out" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/g/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/gDebug/compileGDebugRenderscript/out" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/g/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/g/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/gDebug/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/gDebug/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/gDebug/assets" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/gDebug/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/gDebug/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/gDebug/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/gDebug/shaders" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/g/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/aidl_source_output_dir/gDebugAndroidTest/compileGDebugAndroidTestAidl/out" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/g/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/renderscript_source_output_dir/gDebugAndroidTest/compileGDebugAndroidTestRenderscript/out" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/g/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/g/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestGDebug/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestGDebug/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestGDebug/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestGDebug/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestGDebug/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestGDebug/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestGDebug/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/g/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testGDebug/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testGDebug/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testGDebug/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testGDebug/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testGDebug/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testGDebug/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testGDebug/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/g/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/g/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/g/assets" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/g/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/g/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/g/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/g/shaders" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestG/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestG/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestG/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestG/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestG/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestG/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestG/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testG/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testG/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testG/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testG/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testG/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testG/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testG/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
|
||||
|
@ -88,26 +130,16 @@
|
|||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotation_processor_list" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/apk_list" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundle_manifest" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check_manifest_result" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/compatible_screen_manifest" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/duplicate_classes_check" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-apk" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant_app_manifest" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant_run_app_info_output_file" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant_run_main_apk_resources" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant_run_merged_manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant_run_split_apk_resources" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javac" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/legacy_multidex_aapt_derived_proguard_rules" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/legacy_multidex_main_dex_list" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint_jar" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged-not-compiled-resources" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_jni_libs" />
|
||||
|
@ -118,15 +150,11 @@
|
|||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/processed_res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard-files" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard-rules" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res_stripped" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/resources" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shader_assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/signing_config" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/split-apk" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/validate_signing_config" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||
|
|
Loading…
Reference in New Issue