335 lines
13 KiB
Java
335 lines
13 KiB
Java
package com.ubt.jimu.community.view;
|
|
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
import android.os.Handler;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import androidx.recyclerview.widget.GridLayoutManager;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import androidx.viewpager.widget.ViewPager;
|
|
import butterknife.ButterKnife;
|
|
import com.recyclelib.URecyclerView;
|
|
import com.ubt.jimu.BaseActivity;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.base.entities.FavouriteBean;
|
|
import com.ubt.jimu.base.http.ApiObserver;
|
|
import com.ubt.jimu.base.http.manager.CommunityManager;
|
|
import com.ubt.jimu.community.view.HotLaststActivity;
|
|
import com.ubt.jimu.community.view.adapter.HotAdapter;
|
|
import com.ubt.jimu.community.view.adapter.HotPagerAdapter;
|
|
import com.ubt.jimu.utils.LogUtils;
|
|
import com.ubt.jimu.utils.smartScaleTool.ScreenUtils;
|
|
import com.ubt.jimu.widgets.LoadingView;
|
|
import com.ubt.jimu.widgets.SpaceGridItemDecoration;
|
|
import com.ubtech.utils.DisplayUtil;
|
|
import io.reactivex.disposables.CompositeDisposable;
|
|
import io.reactivex.disposables.Disposable;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class HotLaststActivity extends BaseActivity {
|
|
private URecyclerView c;
|
|
private HotAdapter d;
|
|
private HotAdapter e;
|
|
private URecyclerView f;
|
|
private List<RecyclerView> g;
|
|
private ApiObserver h;
|
|
private ApiObserver i;
|
|
private List<FavouriteBean.RecordsBean> j;
|
|
private List<FavouriteBean.RecordsBean> k;
|
|
LinearLayout llHotTitle;
|
|
LoadingView mLoading;
|
|
TextView tvHot;
|
|
TextView tvLastst;
|
|
ImageView tvReturn;
|
|
ImageView tvScroll;
|
|
ViewPager vpHot;
|
|
private Handler a = new Handler();
|
|
private boolean b = true;
|
|
private int l = 1;
|
|
private int m = 1;
|
|
private CompositeDisposable n = new CompositeDisposable();
|
|
|
|
private void E0() {
|
|
this.c = new URecyclerView(this);
|
|
this.c.setLayoutParams(new RecyclerView.LayoutParams(-1, -1));
|
|
this.d = new HotAdapter(this, "hot", this.k, this.c);
|
|
this.c.setLayoutManager(new GridLayoutManager((Context) this, 4, 1, false));
|
|
this.c.setAdapter(this.d);
|
|
this.c.a(new SpaceGridItemDecoration(DisplayUtil.a(this, getResources().getDimension(R.dimen.card_margin_top)), 0, 4, true));
|
|
this.i = new AnonymousClass4(this.mLoading);
|
|
loadComplete(this.c, this.i);
|
|
this.c.setLoadingListener(new URecyclerView.LoadingListener() { // from class: com.ubt.jimu.community.view.HotLaststActivity.5
|
|
@Override // com.recyclelib.URecyclerView.LoadingListener
|
|
public void onLoadingMore() {
|
|
HotLaststActivity.b(HotLaststActivity.this);
|
|
HotLaststActivity.this.I0();
|
|
}
|
|
|
|
@Override // com.recyclelib.URecyclerView.LoadingListener
|
|
public void onRefreshing() {
|
|
HotLaststActivity.this.l = 1;
|
|
HotLaststActivity.this.I0();
|
|
}
|
|
});
|
|
this.g.add(this.c);
|
|
}
|
|
|
|
private void F0() {
|
|
this.f = new URecyclerView(this);
|
|
this.f.setLayoutParams(new RecyclerView.LayoutParams(-1, -1));
|
|
this.e = new HotAdapter(this, "new", this.j, this.f);
|
|
this.f.setLayoutManager(new GridLayoutManager(this, 4));
|
|
this.f.setAdapter(this.e);
|
|
this.f.a(new SpaceGridItemDecoration(DisplayUtil.a(this, getResources().getDimension(R.dimen.card_margin_top)), 0, 4, true));
|
|
this.g.add(this.f);
|
|
this.h = new ApiObserver<FavouriteBean>(this.mLoading) { // from class: com.ubt.jimu.community.view.HotLaststActivity.6
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(FavouriteBean favouriteBean) {
|
|
LogUtils.c(favouriteBean.toString());
|
|
if (favouriteBean.getRecords() == null || favouriteBean.getRecords().size() <= 0) {
|
|
HotLaststActivity.this.f.setNoMore(true);
|
|
return;
|
|
}
|
|
if (HotLaststActivity.this.m == 1) {
|
|
HotLaststActivity.this.j.clear();
|
|
}
|
|
HotLaststActivity.this.j.addAll(favouriteBean.getRecords());
|
|
HotLaststActivity.this.e.notifyDataSetChanged();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
super.onSubscribe(disposable);
|
|
HotLaststActivity.this.n.b(disposable);
|
|
}
|
|
};
|
|
loadComplete(this.f, this.h);
|
|
}
|
|
|
|
private void G0() {
|
|
this.vpHot.setAdapter(new HotPagerAdapter(this, this.g));
|
|
this.vpHot.a(new ViewPager.OnPageChangeListener() { // from class: com.ubt.jimu.community.view.HotLaststActivity.3
|
|
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
|
public void onPageScrollStateChanged(int i) {
|
|
}
|
|
|
|
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
|
public void onPageScrolled(int i, float f, int i2) {
|
|
HotLaststActivity.this.tvHot.getLocationInWindow(new int[2]);
|
|
HotLaststActivity.this.tvScroll.setX(r4[0] + ((f + i) * HotLaststActivity.this.tvHot.getWidth()));
|
|
}
|
|
|
|
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
|
public void onPageSelected(int i) {
|
|
HotLaststActivity.this.l(i);
|
|
}
|
|
});
|
|
}
|
|
|
|
private void H0() {
|
|
this.c.setLoadingMoreEnabled(true);
|
|
this.c.setLoadingListener(new URecyclerView.LoadingListener() { // from class: com.ubt.jimu.community.view.HotLaststActivity.1
|
|
@Override // com.recyclelib.URecyclerView.LoadingListener
|
|
public void onLoadingMore() {
|
|
HotLaststActivity.b(HotLaststActivity.this);
|
|
HotLaststActivity.this.I0();
|
|
}
|
|
|
|
@Override // com.recyclelib.URecyclerView.LoadingListener
|
|
public void onRefreshing() {
|
|
HotLaststActivity.this.l = 1;
|
|
HotLaststActivity.this.I0();
|
|
}
|
|
});
|
|
this.f.setLoadingListener(new URecyclerView.LoadingListener() { // from class: com.ubt.jimu.community.view.HotLaststActivity.2
|
|
@Override // com.recyclelib.URecyclerView.LoadingListener
|
|
public void onLoadingMore() {
|
|
HotLaststActivity.i(HotLaststActivity.this);
|
|
HotLaststActivity.this.J0();
|
|
}
|
|
|
|
@Override // com.recyclelib.URecyclerView.LoadingListener
|
|
public void onRefreshing() {
|
|
HotLaststActivity.this.m = 1;
|
|
HotLaststActivity.this.J0();
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void I0() {
|
|
this.i.refreshOrLoad(true);
|
|
CommunityManager.create().hot(this.l, this.i);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void J0() {
|
|
this.h.refreshOrLoad(true);
|
|
CommunityManager.create().lastest(this.m, this.h);
|
|
}
|
|
|
|
static /* synthetic */ int b(HotLaststActivity hotLaststActivity) {
|
|
int i = hotLaststActivity.l;
|
|
hotLaststActivity.l = i + 1;
|
|
return i;
|
|
}
|
|
|
|
private void bindClick() {
|
|
this.tvHot.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.community.view.e
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
HotLaststActivity.this.a(view);
|
|
}
|
|
});
|
|
this.tvLastst.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.community.view.c
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
HotLaststActivity.this.b(view);
|
|
}
|
|
});
|
|
this.tvReturn.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.community.view.b
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
HotLaststActivity.this.c(view);
|
|
}
|
|
});
|
|
}
|
|
|
|
private void configWidth() {
|
|
this.f.post(new Runnable() { // from class: com.ubt.jimu.community.view.HotLaststActivity.7
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
int[] a = ScreenUtils.a(0.9111111f, HotLaststActivity.this.f, 0.0f, 4);
|
|
HotLaststActivity.this.e.setWh(a);
|
|
HotLaststActivity.this.e.notifyDataSetChanged();
|
|
HotLaststActivity.this.d.setWh(a);
|
|
HotLaststActivity.this.d.notifyDataSetChanged();
|
|
}
|
|
});
|
|
}
|
|
|
|
static /* synthetic */ int i(HotLaststActivity hotLaststActivity) {
|
|
int i = hotLaststActivity.m;
|
|
hotLaststActivity.m = i + 1;
|
|
return i;
|
|
}
|
|
|
|
private void initData() {
|
|
this.tvScroll.post(new Runnable() { // from class: com.ubt.jimu.community.view.d
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
HotLaststActivity.this.D0();
|
|
}
|
|
});
|
|
this.k = new ArrayList();
|
|
this.j = new ArrayList();
|
|
this.g = new ArrayList();
|
|
}
|
|
|
|
public /* synthetic */ void D0() {
|
|
ViewGroup.LayoutParams layoutParams = this.tvScroll.getLayoutParams();
|
|
layoutParams.width = this.tvHot.getWidth();
|
|
this.tvScroll.setLayoutParams(layoutParams);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.core.app.ComponentActivity, android.app.Activity
|
|
protected void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
setContentView(R.layout.activity_hot_lastst);
|
|
ButterKnife.a(this);
|
|
initData();
|
|
E0();
|
|
F0();
|
|
G0();
|
|
bindClick();
|
|
CommunityManager.create().hot(this.l, this.i);
|
|
CommunityManager.create().lastest(this.m, this.h);
|
|
configWidth();
|
|
H0();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
|
protected void onDestroy() {
|
|
super.onDestroy();
|
|
this.n.dispose();
|
|
this.n.a();
|
|
this.a.removeCallbacksAndMessages(null);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity
|
|
public void relayout() {
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void l(int i) {
|
|
if (i == 0) {
|
|
this.tvHot.setTextColor(getResources().getColor(R.color.theme_txt_orange));
|
|
this.tvLastst.setTextColor(getResources().getColor(R.color.txt_24A8FF));
|
|
} else {
|
|
this.tvHot.setTextColor(getResources().getColor(R.color.txt_24A8FF));
|
|
this.tvLastst.setTextColor(getResources().getColor(R.color.theme_txt_orange));
|
|
}
|
|
}
|
|
|
|
public /* synthetic */ void b(View view) {
|
|
this.vpHot.setCurrentItem(1);
|
|
}
|
|
|
|
public /* synthetic */ void c(View view) {
|
|
finish();
|
|
}
|
|
|
|
public /* synthetic */ void a(View view) {
|
|
this.vpHot.setCurrentItem(0);
|
|
}
|
|
|
|
/* renamed from: com.ubt.jimu.community.view.HotLaststActivity$4, reason: invalid class name */
|
|
class AnonymousClass4 extends ApiObserver<FavouriteBean> {
|
|
AnonymousClass4(LoadingView loadingView) {
|
|
super(loadingView);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(FavouriteBean favouriteBean) {
|
|
LogUtils.c(favouriteBean.toString());
|
|
if (favouriteBean.getRecords() == null || favouriteBean.getRecords().size() <= 0) {
|
|
HotLaststActivity.this.c.setNoMore(true);
|
|
return;
|
|
}
|
|
if (HotLaststActivity.this.l == 1) {
|
|
HotLaststActivity.this.k.clear();
|
|
}
|
|
if (HotLaststActivity.this.b) {
|
|
HotLaststActivity.this.mLoading.g();
|
|
HotLaststActivity.this.a.postDelayed(new Runnable() { // from class: com.ubt.jimu.community.view.a
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
HotLaststActivity.AnonymousClass4.this.a();
|
|
}
|
|
}, 1000L);
|
|
HotLaststActivity.this.b = false;
|
|
}
|
|
HotLaststActivity.this.k.addAll(favouriteBean.getRecords());
|
|
HotLaststActivity.this.d.notifyDataSetChanged();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
super.onSubscribe(disposable);
|
|
HotLaststActivity.this.n.b(disposable);
|
|
}
|
|
|
|
public /* synthetic */ void a() {
|
|
HotLaststActivity.this.mLoading.b();
|
|
}
|
|
}
|
|
}
|