jimu-decompiled/sources/com/ubt/jimu/diy/view/fragment/OfficialDiyFragment.java
2025-05-13 19:24:51 +02:00

212 lines
8.1 KiB
Java

package com.ubt.jimu.diy.view.fragment;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import androidx.recyclerview.widget.GridLayoutManager;
import butterknife.ButterKnife;
import butterknife.Unbinder;
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.SpaceItemDecoration;
import com.ubtech.utils.DisplayUtil;
import com.ubtech.view.fragment.LazyLoadFragment;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes2.dex */
public class OfficialDiyFragment extends LazyLoadFragment implements OfficialDiyAdapter.OnOfficialDiyItemClickListener, URecyclerView.LoadingListener, OfficialDiyContract.View {
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
private OfficialDiyAdapter adapter;
private OnOfficialDiyFragmentInteractionListener listener;
private Unbinder mBind;
private GridLayoutManager mGd;
protected LoadingView mLoadingView;
private ViewTreeObserver.OnGlobalLayoutListener mOnGlobalLayoutListener;
private String mParam1;
private String mParam2;
private NoviceGuideListener noviceGuideListener;
private List<DiyModel> officialDiyRobots = new ArrayList();
private int pageNumber = 1;
private final int pageSize = 20;
private OfficialDiyContract.Presenter presenter;
protected URecyclerView recyclerView;
public interface NoviceGuideListener {
void startNoviceGuideListener(List<DiyModel> list, GridLayoutManager gridLayoutManager);
}
public interface NoviceGuideListenerOnItemListener {
void onOfficialDiyItemClickNoviceGuide(DiyModel diyModel, int i);
}
public interface OnOfficialDiyFragmentInteractionListener {
void onOfficialDiyItemClick(DiyModel diyModel, int i);
}
private void iniData() {
this.presenter.queryOfficialDiy(false, this.pageNumber, 20);
}
public static OfficialDiyFragment newInstance(String str, String str2) {
OfficialDiyFragment officialDiyFragment = new OfficialDiyFragment();
Bundle bundle = new Bundle();
bundle.putString(ARG_PARAM1, str);
bundle.putString(ARG_PARAM2, str2);
officialDiyFragment.setArguments(bundle);
return officialDiyFragment;
}
public /* synthetic */ void b() {
int[] a = ScreenUtils.a(0.76666665f, this.recyclerView, this.mActivity.getResources().getDimension(R.dimen.diy_edit_list_left), 3);
this.recyclerView.a(new SpaceItemDecoration(DisplayUtil.a(getContext(), this.mActivity.getResources().getDimension(R.dimen.diy_edit_list_bottom)), DisplayUtil.a(getContext(), this.mActivity.getResources().getDimension(R.dimen.diy_edit_list_left)), 3, true));
this.adapter = new OfficialDiyAdapter(getContext(), this.officialDiyRobots, a[1], a[0]);
this.mGd = new GridLayoutManager(getContext(), 3);
this.adapter.setListener(this);
this.recyclerView.setLayoutManager(this.mGd);
this.recyclerView.setAdapter(this.adapter);
this.recyclerView.setLoadingListener(this);
iniData();
}
@Override // com.ubt.jimu.diy.contract.OfficialDiyContract.View
public void loadCompleted() {
this.recyclerView.y();
this.recyclerView.z();
}
@Override // com.ubtech.view.fragment.LazyLoadFragment
protected void loadData() {
}
@Override // com.ubt.jimu.diy.contract.OfficialDiyContract.View
public void loadError() {
this.recyclerView.y();
this.recyclerView.z();
}
public /* synthetic */ void o() {
this.adapter.notifyDataSetChanged();
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.ubtech.view.fragment.LazyLoadFragment, androidx.fragment.app.Fragment
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnOfficialDiyFragmentInteractionListener) {
this.listener = (OnOfficialDiyFragmentInteractionListener) context;
}
}
@Override // androidx.fragment.app.Fragment
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
if (getArguments() != null) {
this.mParam1 = getArguments().getString(ARG_PARAM1);
this.mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override // androidx.fragment.app.Fragment
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
View inflate = layoutInflater.inflate(R.layout.fragment_official_diy, viewGroup, false);
this.mBind = ButterKnife.a(this, inflate);
this.presenter = new OfficialDiyPresenter(getContext(), this, this.mLoadingView);
this.recyclerView.post(new Runnable() { // from class: com.ubt.jimu.diy.view.fragment.d
@Override // java.lang.Runnable
public final void run() {
OfficialDiyFragment.this.b();
}
});
this.recyclerView.postDelayed(new Runnable() { // from class: com.ubt.jimu.diy.view.fragment.c
@Override // java.lang.Runnable
public final void run() {
OfficialDiyFragment.this.o();
}
}, 2000L);
return inflate;
}
@Override // androidx.fragment.app.Fragment
public void onDestroyView() {
super.onDestroyView();
this.mBind.unbind();
}
@Override // androidx.fragment.app.Fragment
public void onDetach() {
super.onDetach();
this.listener = null;
}
@Override // androidx.fragment.app.Fragment
public void onHiddenChanged(boolean z) {
super.onHiddenChanged(z);
}
@Override // com.recyclelib.URecyclerView.LoadingListener
public void onLoadingMore() {
this.presenter.queryOfficialDiy(true, this.pageNumber, 20);
}
@Override // com.ubt.jimu.diy.view.adapter.OfficialDiyAdapter.OnOfficialDiyItemClickListener
public void onOfficialDiyItemClick(DiyModel diyModel, int i) {
if (i == 0) {
SPUtils.a("COURSE_GUIDE_SHOW_KEY", true);
SPUtils.a(Constant.NoviceGuide.OFFICIAL_DIY_GUIDE_ON_CLOCK, true);
this.adapter.notifyDataSetChanged();
}
OnOfficialDiyFragmentInteractionListener onOfficialDiyFragmentInteractionListener = this.listener;
if (onOfficialDiyFragmentInteractionListener != null) {
onOfficialDiyFragmentInteractionListener.onOfficialDiyItemClick(diyModel, i);
}
}
@Override // com.recyclelib.URecyclerView.LoadingListener
public void onRefreshing() {
this.presenter.queryOfficialDiy(true, 1, 20);
}
public void setNoviceGuideListener(NoviceGuideListener noviceGuideListener) {
this.noviceGuideListener = noviceGuideListener;
}
@Override // com.ubt.jimu.diy.contract.OfficialDiyContract.View
public void showOfficialDiy(List<DiyModel> list, int i) {
if (list == null || list.size() == 0) {
return;
}
this.pageNumber = i + 1;
if (i == 1) {
this.officialDiyRobots.clear();
this.officialDiyRobots.addAll(list);
} else {
this.officialDiyRobots.addAll(list);
}
this.adapter.notifyDataSetChanged();
boolean a = SPUtils.a(Constant.NoviceGuide.OFFICIAL_DIY_GUIDE_ON_CLOCK);
NoviceGuideListener noviceGuideListener = this.noviceGuideListener;
if (noviceGuideListener == null || a) {
return;
}
noviceGuideListener.startNoviceGuideListener(this.officialDiyRobots, this.mGd);
}
@Override // com.ubtech.view.BaseView
public void setPresenter(OfficialDiyContract.Presenter presenter) {
this.presenter = presenter;
}
}