package com.ubt.jimu.diy.view.fragment; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import androidx.cardview.widget.CardView; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentPagerAdapter; import androidx.viewpager.widget.ViewPager; import butterknife.ButterKnife; import butterknife.Unbinder; import com.ubt.jimu.JimuApplication; import com.ubt.jimu.R; import com.ubt.jimu.base.entities.Constant; import com.ubt.jimu.diy.view.adapter.FragmentViewPagerAdapter; import com.ubt.jimu.diy.view.adapter.UserDiyAdapter; import com.ubt.jimu.utils.CustomViewPager; import com.ubt.jimu.utils.LogUtils; import com.ubt.jimu.utils.SPUtils; import com.ubtech.view.fragment.BaseFragment; import java.util.ArrayList; import java.util.List; /* loaded from: classes2.dex */ public class DiyCenterFragment extends BaseFragment implements ViewPager.OnPageChangeListener, View.OnClickListener { private static final String ARG_PARAM1 = "param1"; private static final String ARG_PARAM2 = "param2"; private FragmentPagerAdapter adapter; protected CardView cv_diy_guide; protected FrameLayout fl_diy_guide; protected FrameLayout fl_guide_pop_title; protected ImageView im_diy_guide_content; protected ImageView im_guide_diy_1; protected ImageView im_guide_diy_cancel; protected ImageView im_guide_diy_title; protected ImageView im_official_demo_guide; protected ImageView imgBack; protected ImageView imgNewRobot; private boolean isShowGuide; private Unbinder mBind; private View mGuideView; private OnFragmentInteractionListener mListener; private String mParam1; private String mParam2; private View mView; private OfficialDiyFragment officialDiyFragment; private int position; protected RelativeLayout rl_diy_guide; protected RelativeLayout rl_gaussian_blur_layout; protected RelativeLayout rl_guide_my_title; private boolean titleGuideIsShow; protected ImageView tvEdit; protected TextView tvOfficialDiy; protected ImageView tvPublishHistory; protected TextView tvUserDiy; protected TextView tv_guide_pop_text; protected TextView tv_guide_title; protected TextView tv_guide_title_my; private UserDiyFragment userDiyFragment; protected CustomViewPager viewPager; protected ViewStub viewStub; private boolean isEdit = false; private List fragmentArray = new ArrayList(); public interface OnFragmentInteractionListener { void onDiyCenterBackClick(); void onPublishListClick(); void onUserDiyEditClick(); void onUserDiyPublishHistoryClick(); } private void initData() { this.tvUserDiy.setBackgroundResource(JimuApplication.l().i() ? R.drawable.diy_tab_bg_my : R.drawable.diy_tab_bg_my_phone); this.tvUserDiy.setEnabled(SPUtils.a(Constant.NoviceGuide.OFFICIAL_DIY_GUIDE_ON_CLOCK)); this.tvOfficialDiy.setBackgroundResource(JimuApplication.l().i() ? R.drawable.diy_tab_bg_official : R.drawable.diy_tab_bg_official_phone); this.imgBack.setEnabled(SPUtils.a(Constant.NoviceGuide.OFFICIAL_DIY_GUIDE_ON_CLOCK)); } private void initView() { boolean a = SPUtils.a(Constant.NoviceGuide.OFFICIAL_DIY_GUIDE_ON_CLOCK); this.viewPager.setScanScroll(a); if (a) { return; } this.mGuideView = this.viewStub.inflate(); this.im_official_demo_guide = (ImageView) this.mGuideView.findViewById(R.id.im_official_demo_guide); this.im_guide_diy_1 = (ImageView) this.mGuideView.findViewById(R.id.im_guide_diy_1); this.tv_guide_title = (TextView) this.mGuideView.findViewById(R.id.tv_guide_title); this.im_guide_diy_cancel = (ImageView) this.mGuideView.findViewById(R.id.im_guide_diy_cancel); this.cv_diy_guide = (CardView) this.mGuideView.findViewById(R.id.cv_diy_guide); this.rl_diy_guide = (RelativeLayout) this.mGuideView.findViewById(R.id.rl_diy_guide); this.tv_guide_title_my = (TextView) this.mGuideView.findViewById(R.id.tv_guide_title_my); this.tv_guide_pop_text = (TextView) this.mGuideView.findViewById(R.id.tv_guide_pop_text); this.im_diy_guide_content = (ImageView) this.mGuideView.findViewById(R.id.im_diy_guide_content); this.fl_diy_guide = (FrameLayout) this.mGuideView.findViewById(R.id.fl_diy_guide); this.rl_gaussian_blur_layout = (RelativeLayout) this.mGuideView.findViewById(R.id.rl_gaussian_blur_layout); LogUtils.c("rl_gaussian_blur_layout:" + this.rl_gaussian_blur_layout); this.imgNewRobot = (ImageView) this.mGuideView.findViewById(R.id.imgNewRobot); this.rl_guide_my_title = (RelativeLayout) this.mGuideView.findViewById(R.id.rl_guide_my_title); this.im_guide_diy_title = (ImageView) this.mGuideView.findViewById(R.id.im_guide_diy_title); this.fl_guide_pop_title = (FrameLayout) this.mGuideView.findViewById(R.id.fl_guide_pop_title); this.rl_gaussian_blur_layout.setOnClickListener(this); this.im_guide_diy_cancel.setOnClickListener(this); } private void isEditState(boolean z) { if (z) { this.tvEdit.setImageResource(R.drawable.diy_step_cancel); this.tvPublishHistory.setImageResource(R.drawable.diy_step_delete); this.tvPublishHistory.setVisibility(0); } else { this.tvPublishHistory.setVisibility(4); this.tvEdit.setImageResource(R.drawable.diy_tab_icon_edit_nor); this.tvPublishHistory.setImageResource(R.drawable.diy_tab_icon_history); } } public static DiyCenterFragment newInstance(String str, String str2) { DiyCenterFragment diyCenterFragment = new DiyCenterFragment(); Bundle bundle = new Bundle(); bundle.putString(ARG_PARAM1, str); bundle.putString(ARG_PARAM2, str2); diyCenterFragment.setArguments(bundle); return diyCenterFragment; } private void select(TextView textView, boolean z) { textView.setTextColor(getResources().getColor(z ? R.color.txt_FEAA06 : android.R.color.white)); } @Override // androidx.fragment.app.Fragment public void onActivityResult(int i, int i2, Intent intent) { super.onActivityResult(i, i2, intent); this.userDiyFragment.onActivityResult(i, i2, intent); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.ubtech.view.fragment.BaseFragment, androidx.fragment.app.Fragment public void onAttach(Context context) { super.onAttach(context); LogUtils.c("onAttachonAttachonAttachonAttach"); if (context instanceof OnFragmentInteractionListener) { this.mListener = (OnFragmentInteractionListener) context; } } protected void onBack(View view) { OnFragmentInteractionListener onFragmentInteractionListener = this.mListener; if (onFragmentInteractionListener != null) { onFragmentInteractionListener.onDiyCenterBackClick(); } } @Override // android.view.View.OnClickListener public void onClick(View view) { } @Override // com.ubtech.view.fragment.BaseFragment, 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 // com.ubtech.view.fragment.BaseFragment, androidx.fragment.app.Fragment public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { this.mView = layoutInflater.inflate(R.layout.fragment_diy_center, viewGroup, false); this.mBind = ButterKnife.a(this, this.mView); this.userDiyFragment = UserDiyFragment.newInstance("", ""); this.officialDiyFragment = OfficialDiyFragment.newInstance("", ""); this.fragmentArray.add(this.officialDiyFragment); this.fragmentArray.add(this.userDiyFragment); this.adapter = new FragmentViewPagerAdapter(getFragmentManager(), this.fragmentArray); this.viewPager.setAdapter(this.adapter); this.viewPager.a(this); select(false); initView(); initData(); return this.mView; } @Override // androidx.fragment.app.Fragment public void onDestroyView() { this.mBind.unbind(); super.onDestroyView(); } @Override // androidx.fragment.app.Fragment public void onDetach() { super.onDetach(); this.mListener = null; } protected void onEdit(View view) { UserDiyFragment userDiyFragment; UserDiyAdapter userDiyAdapter; OnFragmentInteractionListener onFragmentInteractionListener = this.mListener; if (onFragmentInteractionListener != null) { onFragmentInteractionListener.onUserDiyEditClick(); } int i = this.position; if (i == 0 || i != 1 || (userDiyFragment = this.userDiyFragment) == null || (userDiyAdapter = userDiyFragment.adapter) == null) { return; } this.isEdit = true ^ this.isEdit; userDiyAdapter.setEditState(this.isEdit); isEditState(this.isEdit); } @Override // androidx.fragment.app.Fragment public void onHiddenChanged(boolean z) { super.onHiddenChanged(z); boolean a = SPUtils.a(Constant.NoviceGuide.TITLE_NOVICE_GUIDE_KEY); boolean a2 = SPUtils.a(Constant.NoviceGuide.OFFICIAL_DIY_GUIDE_ON_CLOCK); LogUtils.c("hidden:" + z + " isShow:" + a + " aBoolean:" + a2); if (!a && !z && a2) { try { this.imgBack.setEnabled(true); } catch (Exception e) { e.printStackTrace(); } } LogUtils.c("onHiddenChanged_1:" + z); } protected void onOfficialDiyTab(View view) { select(false); SPUtils.b(Constant.Black.BLACK_MODEL_TYPE_KEY, 0); this.viewPager.setCurrentItem(0); } @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) { } @Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener public void onPageSelected(int i) { this.position = i; if (i == 0) { select(false); } else { select(true); isEditState(this.isEdit); } } protected void onPublishHistory(View view) { if (this.isEdit) { this.userDiyFragment.adapter.isDeleteItem(); } } protected void onUserDiyTab(View view) { SPUtils.b(Constant.Black.BLACK_MODEL_TYPE_KEY, 1); this.viewPager.setCurrentItem(1); } private void select(boolean z) { if (z) { select(this.tvUserDiy, true); select(this.tvOfficialDiy, false); this.tvEdit.setVisibility(0); this.tvPublishHistory.setVisibility(0); return; } select(this.tvUserDiy, false); select(this.tvOfficialDiy, true); this.tvEdit.setVisibility(4); this.tvPublishHistory.setVisibility(4); } }