整点视频 v3.3.0版本的 MD5 值为:cba0457dc37421eed445b30f92de25d3
以下内容为反编译后的 NewsTypeFragment.java 源代码,内容仅作参考
package com.kc.openset.news;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.kc.openset.OSETInformationListener;
import com.kc.openset.OSETVideoContent;
import com.kc.openset.OSETVideoContentListener;
import com.kc.openset.R;
import com.kc.openset.ad.OSETInformationCache;
import com.kc.openset.ad.OSETRewardVideoCache;
import com.kc.openset.listener.OSETNativeAd;
import com.kc.openset.listener.OSETNewsClickListener;
import com.kc.openset.util.m;
import com.kc.openset.view.srl.api.RefreshLayout;
import com.kc.openset.view.srl.listener.OnLoadMoreListener;
import com.kc.openset.view.srl.listener.OnRefreshListener;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
import org.json.JSONException;
public class NewsTypeFragment extends BaseFragment {
private RecyclerView a;
private String b;
private com.kc.openset.news.b d;
private String f;
private RefreshLayout g;
private int h;
private String i;
private StartTimeListener j;
private int k;
private int l;
private OSETNewsClickListener m;
private int s;
private List<com.kc.openset.bean.e> c = new ArrayList();
private int e = 0;
private boolean n = false;
private Timer o = new Timer();
private final Handler p = new h(Looper.getMainLooper());
private final Handler q = new i(Looper.getMainLooper());
final Handler r = new j(Looper.getMainLooper());
public class a extends OSETVideoContentListener {
a() {
}
@Override
public void loadSuccess(View view) {
super.loadSuccess(view);
NewsTypeFragment.this.c.add(new com.kc.openset.bean.e(view));
NewsTypeFragment.this.r.sendEmptyMessage(5);
NewsTypeFragment.this.r.sendEmptyMessage(2);
}
@Override
public void onError(String str, String str2) {
m.c("showVideoContentError", "code:" + str + "---message:" + str2);
NewsTypeFragment.this.r.sendEmptyMessage(2);
}
@Override
public void toVideoPage() {
super.toVideoPage();
if (NewsTypeFragment.this.m != null) {
NewsTypeFragment.this.m.onItemClick(true);
}
}
}
class b implements OnRefreshListener {
b() {
}
@Override
public void onRefresh(RefreshLayout refreshLayout) {
NewsTypeFragment.this.a(true);
}
}
class c implements OnLoadMoreListener {
c() {
}
@Override
public void onLoadMore(RefreshLayout refreshLayout) {
NewsTypeFragment.this.a(false);
}
}
class d implements RecycleItemListener {
d() {
}
@Override
public void onItemClick(int i) {
NewsTypeFragment.this.j.startActivityDetials((com.kc.openset.bean.e) NewsTypeFragment.this.c.get(i));
NewsTypeFragment.this.j.start();
if (NewsTypeFragment.this.m != null) {
NewsTypeFragment.this.m.onItemClick(false);
}
}
}
class e extends RecyclerView.OnScrollListener {
e() {
}
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int i) {
super.onScrollStateChanged(recyclerView, i);
if (i != 0) {
NewsTypeFragment.this.j.start();
NewsTypeFragment.this.e();
}
}
}
public class f extends TimerTask {
f() {
}
@Override
public void run() {
NewsTypeFragment.this.j.onStopScroll();
}
}
public class g implements Callback {
final boolean a;
g(boolean z) {
this.a = z;
}
@Override
public void onFailure(Call call, IOException iOException) {
Message message = new Message();
message.obj = "网络请求失败";
NewsTypeFragment.this.p.sendMessage(message);
}
@Override
public void onResponse(Call call, Response response) {
String string = response.body().string();
response.close();
m.f("res", string);
try {
com.kc.openset.bean.a b = com.kc.openset.news.a.b(string);
if (b.a() == null) {
Message message = new Message();
message.obj = b.b();
NewsTypeFragment.this.p.sendMessage(message);
return;
}
if (this.a) {
NewsTypeFragment.this.c.clear();
NewsTypeFragment.this.r.sendEmptyMessage(3);
}
NewsTypeFragment.this.l = b.a().size();
NewsTypeFragment.this.c.addAll(b.a());
NewsTypeFragment.this.r.sendEmptyMessage(5);
NewsTypeFragment.this.r.sendEmptyMessage(1);
NewsTypeFragment.this.q.sendEmptyMessage(1);
NewsTypeFragment.this.e = b.c();
m.f("NewsTypeFragment", "getData: " + b.a().size() + ", batch: " + NewsTypeFragment.this.e);
} catch (JSONException e) {
e.printStackTrace();
Message message2 = new Message();
message2.obj = "解析数据失败";
NewsTypeFragment.this.p.sendMessage(message2);
}
}
}
class h extends Handler {
h(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message message) {
super.handleMessage(message);
Toast.makeText(NewsTypeFragment.this.context, message.obj.toString(), 0);
NewsTypeFragment.this.n = false;
NewsTypeFragment.this.g.finishLoadMore();
NewsTypeFragment.this.g.finishRefresh();
}
}
class i extends Handler {
i(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message message) {
super.handleMessage(message);
NewsTypeFragment.this.b();
}
}
class j extends Handler {
j(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message message) {
super.handleMessage(message);
int i = message.what;
if (i == 1) {
if (NewsTypeFragment.this.i.equals("")) {
NewsTypeFragment.this.r.sendEmptyMessage(2);
} else {
NewsTypeFragment.this.c();
}
} else if (i == 2) {
NewsTypeFragment.this.n = false;
NewsTypeFragment.this.g.finishLoadMore();
NewsTypeFragment.this.g.finishRefresh();
} else if (i == 3) {
NewsTypeFragment.this.d.notifyDataSetChanged();
} else if (i != 5) {
} else {
Log.e("aaaaa", "beginIndex, " + NewsTypeFragment.this.k + "---data.size() - beginIndex" + (NewsTypeFragment.this.c.size() - NewsTypeFragment.this.k));
NewsTypeFragment.this.d.notifyItemRangeChanged(NewsTypeFragment.this.k, NewsTypeFragment.this.c.size() - NewsTypeFragment.this.k);
}
}
}
public void a(boolean z) {
if (this.n) {
return;
}
if (z) {
System.gc();
}
this.n = true;
HashMap hashMap = new HashMap();
hashMap.put("category", this.b);
hashMap.put("batch", Integer.valueOf(this.e));
hashMap.put("appKey", com.kc.openset.a.w);
hashMap.put("ModuleId", this.f);
com.kc.openset.b.a(this.context, "http://content-api.shenshiads.com/content/toutiao", hashMap, new g(z));
}
public void b() {
final boolean z = this.l / this.h == 0;
this.s = 0;
OSETInformationCache.getInstance().setWidth(this.a.getWidth()).setHeight(0).setPosId(this.f).setOSETVideoListener(new OSETInformationListener() {
@Override
public void loadSuccess(OSETNativeAd oSETNativeAd) {
m.f("NewsTypeFragment", "信息流广告加载成功");
View expressView = oSETNativeAd.getExpressView();
if (z) {
NewsTypeFragment.this.c.add(new com.kc.openset.bean.e(expressView));
NewsTypeFragment.this.r.sendEmptyMessage(5);
} else if (NewsTypeFragment.this.k + (NewsTypeFragment.this.s * (NewsTypeFragment.this.h + 1)) + NewsTypeFragment.this.h >= NewsTypeFragment.this.c.size()) {
NewsTypeFragment.this.r.sendEmptyMessage(1);
} else {
List list = NewsTypeFragment.this.c;
NewsTypeFragment newsTypeFragment = NewsTypeFragment.this;
list.add(newsTypeFragment.k += NewsTypeFragment.this.h, new com.kc.openset.bean.e(expressView));
NewsTypeFragment.this.r.sendEmptyMessage(5);
NewsTypeFragment.i(NewsTypeFragment.this);
if (NewsTypeFragment.this.k + NewsTypeFragment.this.s < NewsTypeFragment.this.c.size()) {
NewsTypeFragment.this.b();
}
}
}
@Override
public void onClick(View view) {
if (NewsTypeFragment.this.m != null) {
NewsTypeFragment.this.m.onItemClick(true);
}
}
@Override
public void onClose(View view) {
}
@Override
public void onError(String str, String str2) {
m.f("NewsTypeFragment", "信息流广告加载失败");
NewsTypeFragment.this.r.sendEmptyMessage(1);
}
@Override
public void onRenderFail(View view) {
}
@Override
public void onRenderSuccess(View view) {
}
@Override
public void onShow(View view) {
}
@Override
public void onVideoPlayError(View view, String str, String str2) {
}
}).loadAd(getActivity());
}
public void c() {
OSETVideoContent.getInstance().showVideoContentForView(getActivity(), this.i, new a());
}
private void d() {
this.a.setLayoutManager(new LinearLayoutManager(getContext(), 1, false));
}
public void e() {
try {
this.o.cancel();
} catch (Exception unused) {
}
Timer timer = new Timer();
this.o = timer;
timer.schedule(new f(), 3000L);
}
static int i(NewsTypeFragment newsTypeFragment) {
int i2 = newsTypeFragment.s;
newsTypeFragment.s = i2 + 1;
return i2;
}
public NewsTypeFragment a(OSETNewsClickListener oSETNewsClickListener) {
this.m = oSETNewsClickListener;
return this;
}
public NewsTypeFragment a(String str, String str2, int i2, String str3, StartTimeListener startTimeListener) {
this.f = str2;
this.b = str;
this.h = i2;
this.i = str3;
this.j = startTimeListener;
return this;
}
public void a() {
OSETInformationCache.getInstance().destroy();
}
@Override
public int getLayoutId() {
return R.layout.oset_fragment_item_information_type;
}
@Override
public void initView(View view) {
this.a = (RecyclerView) view.findViewById(R.id.lv);
RefreshLayout refreshLayout = (RefreshLayout) view.findViewById(R.id.srl);
this.g = refreshLayout;
refreshLayout.setOnRefreshListener(new b());
this.g.setOnLoadMoreListener(new c());
com.kc.openset.news.b bVar = new com.kc.openset.news.b(getContext(), this.c, new d());
this.d = bVar;
this.a.setAdapter(bVar);
d();
this.a.addOnScrollListener(new e());
a(true);
}
@Override
public void onDestroyView() {
super.onDestroyView();
OSETRewardVideoCache.getInstance().destroy();
}
}