Initial commit
This commit is contained in:
189
sources/com/ubt/jimu/main/fragment/DiyFragment.java
Normal file
189
sources/com/ubt/jimu/main/fragment/DiyFragment.java
Normal file
@@ -0,0 +1,189 @@
|
||||
package com.ubt.jimu.main.fragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import com.alibaba.android.arouter.facade.Postcard;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.recyclelib.URecyclerView;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.entities.Constant;
|
||||
import com.ubt.jimu.diy.contract.OfficialDiyContract;
|
||||
import com.ubt.jimu.diy.model.DiyModel;
|
||||
import com.ubt.jimu.diy.presenter.OfficialDiyPresenter;
|
||||
import com.ubt.jimu.diy.view.adapter.OfficialDiyAdapter;
|
||||
import com.ubt.jimu.utils.SPUtils;
|
||||
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 com.ubtech.utils.XLog;
|
||||
import com.ubtech.view.fragment.BaseFragment;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import com.ubtrobot.ubtlib.analytics.JimuAnalytics;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class DiyFragment extends BaseFragment implements OfficialDiyContract.View, OfficialDiyAdapter.OnOfficialDiyItemClickListener, URecyclerView.LoadingListener {
|
||||
private ImageView a;
|
||||
private LoadingView b;
|
||||
private URecyclerView c;
|
||||
private OfficialDiyAdapter e;
|
||||
private OfficialDiyContract.Presenter f;
|
||||
private List<DiyModel> d = new ArrayList();
|
||||
private int g = 1;
|
||||
|
||||
private void initData() {
|
||||
this.f.queryOfficialDiy(false, this.g, 20);
|
||||
}
|
||||
|
||||
private void initView(View view) {
|
||||
this.a = (ImageView) view.findViewById(R.id.iv_create);
|
||||
this.a.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.main.fragment.DiyFragment.1
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view2) {
|
||||
SPUtils.b(Constant.Black.BLACK_MODEL_TYPE_KEY, 1);
|
||||
DiyFragment.this.q();
|
||||
JimuAnalytics.b().a("click_P5_1");
|
||||
}
|
||||
});
|
||||
this.b = (LoadingView) view.findViewById(R.id.official_diy_loading);
|
||||
this.b.setOnRetryListener(new LoadingView.RetryRequest() { // from class: com.ubt.jimu.main.fragment.DiyFragment.2
|
||||
@Override // com.ubt.jimu.widgets.LoadingView.RetryRequest
|
||||
public void OnRetryListener() {
|
||||
if (DiyFragment.this.f != null) {
|
||||
DiyFragment.this.f.queryOfficialDiy(false, 1, 20);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.c = (URecyclerView) view.findViewById(R.id.official_diy_recycleView);
|
||||
}
|
||||
|
||||
public static DiyFragment o() {
|
||||
return new DiyFragment();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void q() {
|
||||
ARouter.b().a("/diy/usercreatives").t();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.diy.contract.OfficialDiyContract.View
|
||||
public void loadCompleted() {
|
||||
this.c.y();
|
||||
this.c.z();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.diy.contract.OfficialDiyContract.View
|
||||
public void loadError() {
|
||||
this.d.clear();
|
||||
this.e.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onActivityCreated(Bundle bundle) {
|
||||
super.onActivityCreated(bundle);
|
||||
}
|
||||
|
||||
@Override // com.ubtech.view.fragment.BaseFragment, androidx.fragment.app.Fragment
|
||||
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
||||
View inflate = layoutInflater.inflate(R.layout.frag_diy_tab, (ViewGroup) null);
|
||||
initView(inflate);
|
||||
this.f = new OfficialDiyPresenter(getContext(), this, this.b);
|
||||
this.c.post(new Runnable() { // from class: com.ubt.jimu.main.fragment.a
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
DiyFragment.this.b();
|
||||
}
|
||||
});
|
||||
return inflate;
|
||||
}
|
||||
|
||||
@Override // com.recyclelib.URecyclerView.LoadingListener
|
||||
public void onLoadingMore() {
|
||||
a(this.g, 20);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.diy.view.adapter.OfficialDiyAdapter.OnOfficialDiyItemClickListener
|
||||
public void onOfficialDiyItemClick(DiyModel diyModel, int i) {
|
||||
XLog.b("DiyFragment", "onOfficialDiyItemClick position: " + i + " robot: " + diyModel);
|
||||
Postcard a = ARouter.b().a("/diy/detail");
|
||||
a.a("modelId", diyModel.getId().longValue());
|
||||
a.a("customModelId", diyModel.getCustomModelId());
|
||||
a.t();
|
||||
String str = "click_P5_2_" + String.valueOf(i + 1);
|
||||
HashMap hashMap = new HashMap();
|
||||
hashMap.put("model_id", String.valueOf(diyModel.getId()));
|
||||
ALog.a(this.TAG).d("onOfficialDiyItemClick model_id:" + diyModel.getId());
|
||||
JimuAnalytics.b().a(str, hashMap);
|
||||
}
|
||||
|
||||
@Override // com.ubtech.view.fragment.BaseFragment
|
||||
protected void onPagePause() {
|
||||
super.onPagePause();
|
||||
JimuAnalytics.b().b(getActivity(), "P5");
|
||||
}
|
||||
|
||||
@Override // com.ubtech.view.fragment.BaseFragment
|
||||
protected void onPageResume() {
|
||||
super.onPageResume();
|
||||
JimuAnalytics.b().a(getActivity(), "P5");
|
||||
}
|
||||
|
||||
@Override // com.recyclelib.URecyclerView.LoadingListener
|
||||
public void onRefreshing() {
|
||||
a(1, 20);
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
SPUtils.b(Constant.Black.BLACK_MODEL_TYPE_KEY, 0);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.diy.contract.OfficialDiyContract.View
|
||||
public void showOfficialDiy(List<DiyModel> list, int i) {
|
||||
if (list == null || list.size() == 0) {
|
||||
return;
|
||||
}
|
||||
this.g = i + 1;
|
||||
if (i == 1) {
|
||||
this.d.clear();
|
||||
this.d.addAll(list);
|
||||
} else {
|
||||
this.d.addAll(list);
|
||||
}
|
||||
this.e.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void a(int i, int i2) {
|
||||
OfficialDiyContract.Presenter presenter = this.f;
|
||||
if (presenter != null) {
|
||||
presenter.queryOfficialDiy(true, i, i2);
|
||||
}
|
||||
}
|
||||
|
||||
public /* synthetic */ void b() {
|
||||
Activity activity = this.mActivity;
|
||||
if (activity == null) {
|
||||
return;
|
||||
}
|
||||
int[] a = ScreenUtils.a(0.6666667f, this.c, activity.getResources().getDimension(R.dimen.diy_list_left), 3);
|
||||
this.e = new OfficialDiyAdapter(this.mActivity, this.d, a[1], a[0]);
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager((Context) this.mActivity, 3, 1, false);
|
||||
this.e.setListener(this);
|
||||
this.c.setLayoutManager(gridLayoutManager);
|
||||
this.c.setAdapter(this.e);
|
||||
Activity activity2 = this.mActivity;
|
||||
this.c.a(new SpaceGridItemDecoration(DisplayUtil.a(activity2, activity2.getResources().getDimension(R.dimen.diy_item_space)), 0, 3, true));
|
||||
this.c.setLoadingListener(this);
|
||||
initData();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user