|
@@ -53,7 +53,7 @@ public class FgtPromoteGoodsList extends BaseFragment implements ILoadMore, IRef
|
|
|
|
|
|
|
|
|
|
|
|
|
private void notifyDataSetChanged() {
|
|
private void notifyDataSetChanged() {
|
|
|
- if(empty_view == null || view_list == null){
|
|
|
|
|
|
|
+ if (empty_view == null || view_list == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
ViewUtil.notifyDataSetChanged(view_list);
|
|
ViewUtil.notifyDataSetChanged(view_list);
|
|
@@ -84,6 +84,7 @@ public class FgtPromoteGoodsList extends BaseFragment implements ILoadMore, IRef
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private AdpPromoteGoods adapter;
|
|
private AdpPromoteGoods adapter;
|
|
|
|
|
+
|
|
|
public void initView() {
|
|
public void initView() {
|
|
|
if (activity == null) {
|
|
if (activity == null) {
|
|
|
return;
|
|
return;
|
|
@@ -126,13 +127,14 @@ public class FgtPromoteGoodsList extends BaseFragment implements ILoadMore, IRef
|
|
|
}
|
|
}
|
|
|
notifyDataSetChanged();
|
|
notifyDataSetChanged();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
private int page = 1;
|
|
private int page = 1;
|
|
|
private int per_page = DataUtil.PER_PAGE;
|
|
private int per_page = DataUtil.PER_PAGE;
|
|
|
|
|
|
|
|
public void mInitData() {
|
|
public void mInitData() {
|
|
|
CommonUtil.getInstance().resetEmptyView(empty_view);
|
|
CommonUtil.getInstance().resetEmptyView(empty_view);
|
|
|
//先加载缓存
|
|
//先加载缓存
|
|
|
- if(isFirstCache) {
|
|
|
|
|
|
|
+ if (isFirstCache) {
|
|
|
getReleaseFromACache();
|
|
getReleaseFromACache();
|
|
|
}
|
|
}
|
|
|
//再加载网络数据
|
|
//再加载网络数据
|
|
@@ -149,7 +151,7 @@ public class FgtPromoteGoodsList extends BaseFragment implements ILoadMore, IRef
|
|
|
private void getReleaseFromACache() {
|
|
private void getReleaseFromACache() {
|
|
|
try {
|
|
try {
|
|
|
GetPromoteGoodsUrl getPromoteGoodsUrl = DataUtil.getInstance().getCacheResult(getKey(), GetPromoteGoodsUrl.class);
|
|
GetPromoteGoodsUrl getPromoteGoodsUrl = DataUtil.getInstance().getCacheResult(getKey(), GetPromoteGoodsUrl.class);
|
|
|
- if(getPromoteGoodsUrl != null){
|
|
|
|
|
|
|
+ if (getPromoteGoodsUrl != null) {
|
|
|
adapter.setBaseUrl(getPromoteGoodsUrl.getGoods_url());
|
|
adapter.setBaseUrl(getPromoteGoodsUrl.getGoods_url());
|
|
|
ListUtil.addAllItem(list, getPromoteGoodsUrl.getList());
|
|
ListUtil.addAllItem(list, getPromoteGoodsUrl.getList());
|
|
|
}
|
|
}
|
|
@@ -166,27 +168,28 @@ public class FgtPromoteGoodsList extends BaseFragment implements ILoadMore, IRef
|
|
|
//从网络获取发布的任务列表
|
|
//从网络获取发布的任务列表
|
|
|
private void getReleaseFromNetWork() {
|
|
private void getReleaseFromNetWork() {
|
|
|
SheepApp.getInstance().getNetComponent().getApiService().getYfShopPromoteGoods(page, per_page)
|
|
SheepApp.getInstance().getNetComponent().getApiService().getYfShopPromoteGoods(page, per_page)
|
|
|
- .subscribeOn(Schedulers.io())
|
|
|
|
|
- .observeOn(AndroidSchedulers.mainThread())
|
|
|
|
|
- .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onNext(BaseMessage baseMessage) {
|
|
|
|
|
- boolean isNewData = DataUtil.getInstance().isNewData(getKey());
|
|
|
|
|
- if (isNewData || !isFirstCache) {
|
|
|
|
|
- GetPromoteGoodsUrl getPromoteGoodsUrl = baseMessage.getData(GetPromoteGoodsUrl.class);
|
|
|
|
|
- if(getPromoteGoodsUrl != null){
|
|
|
|
|
- adapter.setBaseUrl(getPromoteGoodsUrl.getGoods_url());
|
|
|
|
|
- ListUtil.addAllItem(list, getPromoteGoodsUrl.getList());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- notifyDataSetChanged();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onError(BaseMessage baseMessage) {
|
|
|
|
|
- notifyDataSetChanged();
|
|
|
|
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
|
|
+ boolean isNewData = DataUtil.getInstance().isNewData(getKey());
|
|
|
|
|
+ if (isNewData || !isFirstCache) {
|
|
|
|
|
+ GetPromoteGoodsUrl getPromoteGoodsUrl = baseMessage.getData(GetPromoteGoodsUrl.class);
|
|
|
|
|
+ if (getPromoteGoodsUrl != null) {
|
|
|
|
|
+ if (adapter == null) return;
|
|
|
|
|
+ adapter.setBaseUrl(getPromoteGoodsUrl.getGoods_url());
|
|
|
|
|
+ ListUtil.addAllItem(list, getPromoteGoodsUrl.getList());
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ notifyDataSetChanged();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
|
|
+ notifyDataSetChanged();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public int getDataCount() {
|
|
public int getDataCount() {
|
|
@@ -194,6 +197,7 @@ public class FgtPromoteGoodsList extends BaseFragment implements ILoadMore, IRef
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private boolean noMore = false;
|
|
private boolean noMore = false;
|
|
|
|
|
+
|
|
|
public boolean isNoMore() {
|
|
public boolean isNoMore() {
|
|
|
return noMore;
|
|
return noMore;
|
|
|
}
|
|
}
|
|
@@ -201,7 +205,7 @@ public class FgtPromoteGoodsList extends BaseFragment implements ILoadMore, IRef
|
|
|
|
|
|
|
|
//加载完成时更新header或footer
|
|
//加载完成时更新header或footer
|
|
|
protected void refreshOrLoadMoreComplete() {
|
|
protected void refreshOrLoadMoreComplete() {
|
|
|
- if(smartRefreshLayout != null && getUserVisibleHint()) {
|
|
|
|
|
|
|
+ if (smartRefreshLayout != null && getUserVisibleHint()) {
|
|
|
if (page == 1) {
|
|
if (page == 1) {
|
|
|
smartRefreshLayout.finishRefresh();
|
|
smartRefreshLayout.finishRefresh();
|
|
|
} else {
|
|
} else {
|
|
@@ -209,9 +213,10 @@ public class FgtPromoteGoodsList extends BaseFragment implements ILoadMore, IRef
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
//重新设置ViewPager的高度
|
|
//重新设置ViewPager的高度
|
|
|
protected void resetViewPagerHeight() {
|
|
protected void resetViewPagerHeight() {
|
|
|
- if(viewPager != null && getUserVisibleHint()){
|
|
|
|
|
|
|
+ if (viewPager != null && getUserVisibleHint()) {
|
|
|
int count = getDataCount();
|
|
int count = getDataCount();
|
|
|
ViewGroup.LayoutParams params = viewPager.getLayoutParams();
|
|
ViewGroup.LayoutParams params = viewPager.getLayoutParams();
|
|
|
params.height = count == 0 ? G.HEIGHT / 2 : count * getItemHeight();
|
|
params.height = count == 0 ? G.HEIGHT / 2 : count * getItemHeight();
|
|
@@ -224,16 +229,17 @@ public class FgtPromoteGoodsList extends BaseFragment implements ILoadMore, IRef
|
|
|
public void setUserVisibleHint(boolean isVisibleToUser) {
|
|
public void setUserVisibleHint(boolean isVisibleToUser) {
|
|
|
super.setUserVisibleHint(isVisibleToUser);
|
|
super.setUserVisibleHint(isVisibleToUser);
|
|
|
resetViewPagerHeight();
|
|
resetViewPagerHeight();
|
|
|
- if(smartRefreshLayout != null && getUserVisibleHint()) {
|
|
|
|
|
|
|
+ if (smartRefreshLayout != null && getUserVisibleHint()) {
|
|
|
smartRefreshLayout.setNoMoreData(noMore);
|
|
smartRefreshLayout.setNoMoreData(noMore);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- protected int getItemHeight(){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ protected int getItemHeight() {
|
|
|
return G.getRealPix(140);
|
|
return G.getRealPix(140);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//是否显示无数据占位图
|
|
//是否显示无数据占位图
|
|
|
- protected void updateEmptyView(){
|
|
|
|
|
|
|
+ protected void updateEmptyView() {
|
|
|
boolean showEmpty = list.isEmpty();
|
|
boolean showEmpty = list.isEmpty();
|
|
|
CommonUtil.getInstance().updateEmptyView(empty_view, showEmpty);
|
|
CommonUtil.getInstance().updateEmptyView(empty_view, showEmpty);
|
|
|
}
|
|
}
|