package com.ubt.jimu.diy.view.fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.ubt.jimu.R; import com.ubt.jimu.base.db.diy.DiyDBModel; import com.ubt.jimu.base.db.diy.DiyHelper; import com.ubt.jimu.base.db.diy.DiyStep2Helper; import com.ubt.jimu.base.db.diy.DiyStep2Model; import com.ubt.jimu.base.event.BaseEvent; import com.ubt.jimu.diy.model.DiyPartModel; import com.ubt.jimu.diy.view.Diy4BuildActivity; import com.ubt.jimu.diy.view.adapter.PartAllAdapter; import com.ubt.jimu.utils.SPUtils; import com.ubt.jimu.widgets.TitleDiyView; import com.ubtech.utils.StringUtils; import com.ubtech.view.fragment.BaseFragment; import java.util.ArrayList; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; /* loaded from: classes2.dex */ public class DiyPartAllFragment extends BaseFragment { public int count = 0; private ImageView mImgSure; private RecyclerView mRyPartAll; private TitleDiyView mTitle; private String mUuid; private void bindClick() { this.mImgSure.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.diy.view.fragment.DiyPartAllFragment.1 @Override // android.view.View.OnClickListener public void onClick(View view) { DiyStep2Model queryForUUid = DiyStep2Helper.getInstance().queryForUUid(DiyPartAllFragment.this.mUuid); queryForUUid.setStep4state(1); DiyStep2Helper.getInstance().insertData(queryForUUid); DiyDBModel queryForUUid2 = DiyHelper.getInstance().queryForUUid(DiyPartAllFragment.this.mUuid); queryForUUid2.setStep2state(1); DiyHelper.getInstance().insertData(queryForUUid2); Diy4BuildActivity.start(((BaseFragment) DiyPartAllFragment.this).mActivity, ProductBuildFragment.class.getSimpleName()); } }); } public static DiyPartAllFragment create(int i, String str) { DiyPartAllFragment diyPartAllFragment = new DiyPartAllFragment(); Bundle bundle = new Bundle(); bundle.putString(BuildStepFragment.UUID, str); bundle.putInt("count", i); diyPartAllFragment.setArguments(bundle); return diyPartAllFragment; } private void initData() { ArrayList arrayList = new ArrayList(); this.mUuid = getArguments().getString(BuildStepFragment.UUID); int i = 0; while (i < 4) { i++; arrayList.add(Integer.valueOf(i)); } ArrayList arrayList2 = (ArrayList) SPUtils.c(StringUtils.a(this.mUuid, "Elect")); ArrayList arrayList3 = (ArrayList) SPUtils.c(StringUtils.a(this.mUuid, "connection")); ArrayList arrayList4 = (ArrayList) SPUtils.c(StringUtils.a(this.mUuid, "decorate")); ArrayList arrayList5 = (ArrayList) SPUtils.c(StringUtils.a(this.mUuid, "line")); this.count = getArguments().getInt("count"); ArrayList arrayList6 = new ArrayList(); ArrayList arrayList7 = new ArrayList(); ArrayList arrayList8 = new ArrayList(); ArrayList arrayList9 = new ArrayList(); for (int i2 = 0; i2 < arrayList2.size(); i2++) { if (((DiyPartModel) arrayList2.get(i2)).getCount() != 0) { arrayList6.add(arrayList2.get(i2)); } } for (int i3 = 0; i3 < arrayList3.size(); i3++) { if (((DiyPartModel) arrayList3.get(i3)).getCount() != 0) { arrayList7.add(arrayList3.get(i3)); } } for (int i4 = 0; i4 < arrayList4.size(); i4++) { if (((DiyPartModel) arrayList4.get(i4)).getCount() != 0) { arrayList8.add(arrayList4.get(i4)); } } for (int i5 = 0; i5 < arrayList5.size(); i5++) { if (((DiyPartModel) arrayList5.get(i5)).getCount() != 0) { arrayList9.add(arrayList5.get(i5)); } } this.mTitle.setDiyTitle(String.format(this.mActivity.getString(R.string.diy_part_count), String.valueOf(this.count))); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this.mActivity, 1, false); PartAllAdapter partAllAdapter = new PartAllAdapter(this.mActivity, arrayList, arrayList6, arrayList7, arrayList8, arrayList9, this.mRyPartAll, true); this.mRyPartAll.setLayoutManager(linearLayoutManager); this.mRyPartAll.setAdapter(partAllAdapter); this.mRyPartAll.a(new DividerItemDecoration(this.mActivity, 1)); } private void initView(View view) { this.mTitle = (TitleDiyView) view.findViewById(R.id.title); this.mRyPartAll = (RecyclerView) view.findViewById(R.id.ry_part_all); this.mImgSure = (ImageView) view.findViewById(R.id.img_sure); } @Override // com.ubtech.view.fragment.BaseFragment, androidx.fragment.app.Fragment public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { EventBus.b().c(this); return layoutInflater.inflate(R.layout.fragment_part_all, viewGroup, false); } @Override // androidx.fragment.app.Fragment public void onDestroyView() { super.onDestroyView(); EventBus.b().d(this); } @Subscribe public void onEventNotifyCount(BaseEvent baseEvent) { if (baseEvent.getType() == 3) { this.count += Integer.parseInt(baseEvent.getMsg()); this.mTitle.setDiyTitle(String.format(this.mActivity.getString(R.string.diy_part_count), String.valueOf(this.count))); } } @Override // androidx.fragment.app.Fragment public void onViewCreated(View view, Bundle bundle) { super.onViewCreated(view, bundle); initView(view); initData(); bindClick(); } }