|
|
@@ -23,6 +23,7 @@ import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.Lp;
|
|
|
import com.sheep.gamegroup.module.ad_htxd.model.ArticleAd;
|
|
|
import com.sheep.gamegroup.util.CommonUtil;
|
|
|
+import com.sheep.gamegroup.util.DataUtil;
|
|
|
import com.sheep.gamegroup.util.DownloadUtil;
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
|
@@ -58,6 +59,7 @@ import static android.content.Intent.ACTION_PACKAGE_REMOVED;
|
|
|
public class FgtFindChild extends BaseListFragment5<Article> {
|
|
|
|
|
|
private int type;
|
|
|
+ private boolean showAd;
|
|
|
|
|
|
@Override
|
|
|
public void initView() {
|
|
|
@@ -67,7 +69,7 @@ public class FgtFindChild extends BaseListFragment5<Article> {
|
|
|
|
|
|
@Override
|
|
|
protected RecyclerView.Adapter getAdapter() {
|
|
|
- return new CommonRecycler(ArticleAd.showAd ? allList : list);
|
|
|
+ return new CommonRecycler(showAd ? allList : list);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -85,24 +87,21 @@ public class FgtFindChild extends BaseListFragment5<Article> {
|
|
|
return Article.class;
|
|
|
}
|
|
|
|
|
|
- private List<Article> allList = new ArrayList<>();
|
|
|
+ private List<Article> allList = new ArrayList<>();//显示广告时使用allList,否则使用list
|
|
|
|
|
|
@Override
|
|
|
protected void loadList(List<Article> addList) {
|
|
|
- if(ArticleAd.showAd) {
|
|
|
+ if (showAd) {
|
|
|
ListUtil.addAll(allList, addList);
|
|
|
- if (ListUtil.size(addList) == per_page) {
|
|
|
- ArticleAd.fetchNativeData(articleAd -> {
|
|
|
- if (ListUtil.getLast(allList, per_page - ArticleAd.INDEX) instanceof ArticleAd) {//倒数第几个不是广告的情况下才添加
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- return ListUtil.addLastIndex(allList, articleAd, per_page - ArticleAd.INDEX);
|
|
|
- }
|
|
|
- }, aBoolean -> {
|
|
|
- if (aBoolean) {
|
|
|
- notifyDataSetChanged();
|
|
|
- }
|
|
|
- });
|
|
|
+ if (1 == page) {
|
|
|
+ Article item = ListUtil.getItem(allList, ArticleAd.INDEX);
|
|
|
+ if (!(item instanceof ArticleAd)) {//倒数第几个不是广告的情况下才添加
|
|
|
+ ArticleAd.fetchNativeData(articleAd -> ListUtil.insertIndex(allList, articleAd, ArticleAd.INDEX), ok -> {
|
|
|
+ if (ok) {
|
|
|
+ notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
super.loadList(addList);
|
|
|
@@ -110,15 +109,15 @@ public class FgtFindChild extends BaseListFragment5<Article> {
|
|
|
|
|
|
@Override
|
|
|
public void clear() {
|
|
|
- if(ArticleAd.showAd)
|
|
|
+ if (showAd)
|
|
|
allList.clear();
|
|
|
super.clear();
|
|
|
}
|
|
|
|
|
|
- public static FgtFindChild newInstance(int type) {
|
|
|
+ public static FgtFindChild newInstance(ArticleTag articleTag) {
|
|
|
FgtFindChild fgt = new FgtFindChild();
|
|
|
Bundle bundle = new Bundle();
|
|
|
- bundle.putInt("type", type);
|
|
|
+ DataUtil.putObject(bundle, articleTag);
|
|
|
fgt.setArguments(bundle);
|
|
|
return fgt;
|
|
|
}
|
|
|
@@ -266,7 +265,11 @@ public class FgtFindChild extends BaseListFragment5<Article> {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
Bundle bundle = getArguments();
|
|
|
if (bundle != null) {
|
|
|
- type = bundle.getInt("type", 0);
|
|
|
+ ArticleTag articleTag = DataUtil.getObject(bundle, ArticleTag.class);
|
|
|
+ if (articleTag != null) {
|
|
|
+ type = articleTag.getId();
|
|
|
+ showAd = ArticleAd.showAd && TextUtils.equals(articleTag.getName(), "资讯");//只有资讯才显示
|
|
|
+ }
|
|
|
}
|
|
|
EventBus.getDefault().register(this);
|
|
|
}
|
|
|
@@ -332,7 +335,7 @@ public class FgtFindChild extends BaseListFragment5<Article> {
|
|
|
|
|
|
@Override
|
|
|
public int getItemViewType(int position) {
|
|
|
- Article article = (ArticleAd.showAd ? allList : list).get(position);
|
|
|
+ Article article = (showAd ? allList : list).get(position);
|
|
|
return article.getType();
|
|
|
}
|
|
|
|