柬埔寨通 v6.1.5版本的 MD5 值为:9b68581ac30883219d6a25858a099d6b
以下内容为反编译后的 InforStaggeredFragment.java 源代码,内容仅作参考
package net.duohuo.magappx.info;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import com.alibaba.fastjson.JSONArray;
import com.github.jdsjlzx.interfaces.OnLoadMoreListener;
import com.github.jdsjlzx.interfaces.OnRefreshListener;
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;
import com.jianpuzhaitong.forum.R;
import com.nineoldandroids.animation.Animator;
import com.nineoldandroids.animation.AnimatorListenerAdapter;
import com.nineoldandroids.animation.ValueAnimator;
import com.nineoldandroids.view.ViewHelper;
import java.util.List;
import net.duohuo.core.adapter.DataPage;
import net.duohuo.core.annotation.FragmentSchemeName;
import net.duohuo.core.fresco.FrescoImageView;
import net.duohuo.core.ioc.Ioc;
import net.duohuo.core.net.Task;
import net.duohuo.core.util.IUtil;
import net.duohuo.core.util.SafeJsonUtil;
import net.duohuo.magappx.API;
import net.duohuo.magappx.DataPageRecycleAdapter;
import net.duohuo.magappx.UrlScheme;
import net.duohuo.magappx.common.dataview.model.PicAd;
import net.duohuo.magappx.common.service.ConfigService;
import net.duohuo.magappx.common.util.FilterUtil;
import net.duohuo.magappx.common.view.MagLoadingFooter;
import net.duohuo.magappx.common.view.MagScollerRecyclerView;
import net.duohuo.magappx.common.view.refreshview.MagRefreshHeader;
import net.duohuo.magappx.main.indextab.TabFragment;
import net.duohuo.magappx.video.viewholder.ShortVideoViewHolder;
@FragmentSchemeName("infoWaterfallList")
public class InforStaggeredFragment extends TabFragment {
private static final int REQUEST_COUNT = 10;
FrescoImageView floatAdV;
DataPageRecycleAdapter recycleAdapter;
private JSONArray totalArray;
MagScollerRecyclerView mRecyclerView = null;
LRecyclerViewAdapter mLRecyclerViewAdapter = null;
boolean isSwitchining = false;
boolean isSwitchOuting = false;
boolean isSwitchShow = true;
boolean isScrolling = false;
@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
return layoutInflater.inflate(R.layout.infor_with_ad_staggered, (ViewGroup) null);
}
@Override
public void onActivityCreated(Bundle bundle) {
super.onActivityCreated(bundle);
MagScollerRecyclerView magScollerRecyclerView = (MagScollerRecyclerView) getView().findViewById(R.id.list);
this.mRecyclerView = magScollerRecyclerView;
magScollerRecyclerView.setRefreshHeader(new MagRefreshHeader(getActivity()));
this.mRecyclerView.setLoadMoreFooter(new MagLoadingFooter(getActivity()));
String string = getArguments().getString("channel_id");
this.recycleAdapter = new DataPageRecycleAdapter(getActivity(), TextUtils.isEmpty(string) ? "https://app.jpztong.com/mag/info/v3/info/infoListByCatId" : API.Info.channelInfo) {
@Override
public DataPageRecycleAdapter.MagViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
return new ShortVideoViewHolder(viewGroup.getContext());
}
};
if (!TextUtils.isEmpty(getArguments().getString("uniqid"))) {
this.recycleAdapter.param("uniqid", getArguments().getString("uniqid"));
this.recycleAdapter.param("tab", getArguments().getString("position"));
}
this.recycleAdapter.param("cat_id", getArguments().getString("cat_id"));
this.recycleAdapter.param("waterfall", "1");
if (!TextUtils.isEmpty(string)) {
this.recycleAdapter.param("channel_id", string);
}
this.recycleAdapter.param("is_app_first", 1);
this.recycleAdapter.cache();
this.recycleAdapter.refresh();
this.mRecyclerView.setPullRefreshEnabled(getArguments().getBoolean("refreshable", true));
LRecyclerViewAdapter lRecyclerViewAdapter = new LRecyclerViewAdapter(this.recycleAdapter);
this.mLRecyclerViewAdapter = lRecyclerViewAdapter;
this.mRecyclerView.setAdapter(lRecyclerViewAdapter);
this.recycleAdapter.addOnLoadSuccessCallBack(new DataPage.OnLoadSuccessCallBack() {
@Override
public void onLoadSuccess(Task task, int i) {
InforStaggeredFragment.this.mRecyclerView.refreshComplete(10);
if (i == 1) {
InforStaggeredFragment.this.totalArray = (JSONArray) task.getResult().get("totalList");
}
if (!task.getResult().isCache()) {
InforStaggeredFragment.this.recycleAdapter.param("is_app_first", -1);
}
if (task.getResult().getList().size() < 10) {
InforStaggeredFragment.this.mRecyclerView.setNoMore(true);
} else {
InforStaggeredFragment.this.mRecyclerView.setNoMore(false);
}
InforStaggeredFragment.this.setFragmentTitle(i, SafeJsonUtil.getString(task.getResult().json(), "cat_name"));
}
});
StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, 1);
staggeredGridLayoutManager.setOrientation(1);
staggeredGridLayoutManager.setGapStrategy(0);
this.mRecyclerView.setLayoutManager(staggeredGridLayoutManager);
this.mRecyclerView.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
InforStaggeredFragment.this.recycleAdapter.refresh();
}
});
this.mRecyclerView.setOnLoadMoreListener(new OnLoadMoreListener() {
@Override
public void onLoadMore() {
InforStaggeredFragment.this.recycleAdapter.next();
}
});
this.recycleAdapter.setOnLoadPageListener(new DataPage.OnLoadPageListener() {
@Override
public void onLoadPageListener(int i) {
if (i > 1) {
InforStaggeredFragment.this.recycleAdapter.param("content_id", FilterUtil.filterVideoIds(i, InforStaggeredFragment.this.totalArray));
}
}
});
if (TextUtils.isEmpty(getArguments().getString("_page"))) {
return;
}
this.floatAdV = (FrescoImageView) getView().findViewById(R.id.float_ad);
loadAd();
this.mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int i) {
super.onScrollStateChanged(recyclerView, i);
if (i == 0) {
InforStaggeredFragment.this.switchIn();
InforStaggeredFragment.this.isScrolling = false;
} else {
InforStaggeredFragment.this.switchOut();
InforStaggeredFragment.this.isScrolling = true;
}
}
});
}
public void switchIn() {
if (this.isSwitchShow || this.isSwitchOuting || this.isSwitchining || isDetached()) {
return;
}
this.isSwitchining = true;
ValueAnimator ofFloat = ValueAnimator.ofFloat(-IUtil.dip2px(getActivity(), 50.0f), 0.0f);
ofFloat.setTarget(this.floatAdV);
ofFloat.setDuration(300L).start();
ofFloat.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
super.onAnimationEnd(animator);
InforStaggeredFragment.this.isSwitchShow = true;
InforStaggeredFragment.this.isSwitchining = false;
if (InforStaggeredFragment.this.isScrolling) {
InforStaggeredFragment.this.switchOut();
}
}
});
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
ViewHelper.setTranslationX(InforStaggeredFragment.this.floatAdV, (-((Float) valueAnimator.getAnimatedValue()).floatValue()) * 3.0f);
}
});
}
public void switchOut() {
if (!this.isSwitchShow || this.isSwitchOuting || this.isSwitchining || isDetached()) {
return;
}
this.isSwitchOuting = true;
ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, -IUtil.dip2px(getActivity(), 50.0f));
ofFloat.setTarget(this.floatAdV);
ofFloat.setDuration(300L).start();
ofFloat.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
super.onAnimationEnd(animator);
InforStaggeredFragment.this.isSwitchShow = false;
InforStaggeredFragment.this.isSwitchOuting = false;
if (InforStaggeredFragment.this.isScrolling) {
return;
}
InforStaggeredFragment.this.switchIn();
}
});
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
ViewHelper.setTranslationX(InforStaggeredFragment.this.floatAdV, (-((Float) valueAnimator.getAnimatedValue()).floatValue()) * 3.0f);
}
});
}
public void loadAd() {
((ConfigService) Ioc.get(ConfigService.class)).loadAd("index_floating", new Task<List<PicAd>>() {
@Override
public void onResult(List<PicAd> list) {
if (list == null || list.size() <= 0) {
return;
}
try {
final PicAd picAd = list.get(0);
InforStaggeredFragment.this.floatAdV.loadView(picAd.getPics().get(0).getUrl(), R.color.transparent);
InforStaggeredFragment.this.floatAdV.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
UrlScheme.toUrl(InforStaggeredFragment.this.getActivity(), picAd.getLink());
}
});
} catch (Exception unused) {
}
}
});
}
@Override
public DataPageRecycleAdapter getDataPageRecycleAdapter() {
return this.recycleAdapter;
}
@Override
public void refresh() {
MagScollerRecyclerView magScollerRecyclerView = this.mRecyclerView;
if (magScollerRecyclerView != null) {
if (magScollerRecyclerView.isOnTop()) {
this.mRecyclerView.forceToRefresh();
} else {
this.mRecyclerView.smoothScrollToPosition(0);
}
}
}
}