package androidx.fragment.app; import android.content.Context; import android.os.Bundle; import android.os.Handler; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.animation.AnimationUtils; import android.widget.AdapterView; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.ProgressBar; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; public class ListFragment extends Fragment { public static final int INTERNAL_EMPTY_ID = 16711681; public static final int INTERNAL_LIST_CONTAINER_ID = 16711683; public static final int INTERNAL_PROGRESS_CONTAINER_ID = 16711682; public ListAdapter mAdapter; public CharSequence mEmptyText; public View mEmptyView; private final Handler mHandler = new Handler(); public ListView mList; public View mListContainer; public boolean mListShown; private final AdapterView.OnItemClickListener mOnClickListener = new AnonymousClass2(); public View mProgressContainer; private final Runnable mRequestFocus = new AnonymousClass1(); public TextView mStandardEmptyView; /* renamed from: androidx.fragment.app.ListFragment$1 reason: invalid class name */ public class AnonymousClass1 implements Runnable { public AnonymousClass1() { } @Override // java.lang.Runnable public void run() { ListView listView = ListFragment.this.mList; listView.focusableViewAvailable(listView); } } /* renamed from: androidx.fragment.app.ListFragment$2 reason: invalid class name */ public class AnonymousClass2 implements AdapterView.OnItemClickListener { public AnonymousClass2() { } @Override // android.widget.AdapterView.OnItemClickListener public void onItemClick(AdapterView adapterView, View view, int i, long j) { ListFragment.this.onListItemClick((ListView) adapterView, view, i, j); } } private void ensureList() { if (this.mList == null) { View view = getView(); if (view != null) { if (view instanceof ListView) { this.mList = (ListView) view; } else { TextView textView = (TextView) view.findViewById(16711681); this.mStandardEmptyView = textView; if (textView == null) { this.mEmptyView = view.findViewById(16908292); } else { textView.setVisibility(8); } this.mProgressContainer = view.findViewById(16711682); this.mListContainer = view.findViewById(16711683); View findViewById = view.findViewById(16908298); if (findViewById instanceof ListView) { ListView listView = (ListView) findViewById; this.mList = listView; View view2 = this.mEmptyView; if (view2 != null) { listView.setEmptyView(view2); } else { CharSequence charSequence = this.mEmptyText; if (charSequence != null) { this.mStandardEmptyView.setText(charSequence); this.mList.setEmptyView(this.mStandardEmptyView); } } } else if (findViewById == null) { throw new RuntimeException("Your content must have a ListView whose id attribute is 'android.R.id.list'"); } else { throw new RuntimeException("Content has view with id attribute 'android.R.id.list' that is not a ListView class"); } } this.mListShown = true; this.mList.setOnItemClickListener(this.mOnClickListener); ListAdapter listAdapter = this.mAdapter; if (listAdapter != null) { this.mAdapter = null; setListAdapter(listAdapter); } else if (this.mProgressContainer != null) { setListShown(false, false); } this.mHandler.post(this.mRequestFocus); return; } throw new IllegalStateException("Content view not yet created"); } } private void setListShown(boolean z2, boolean z3) { ensureList(); View view = this.mProgressContainer; if (view == null) { throw new IllegalStateException("Can't be used with a custom content view"); } else if (this.mListShown != z2) { this.mListShown = z2; if (z2) { if (z3) { view.startAnimation(AnimationUtils.loadAnimation(getContext(), 17432577)); this.mListContainer.startAnimation(AnimationUtils.loadAnimation(getContext(), 17432576)); } else { view.clearAnimation(); this.mListContainer.clearAnimation(); } this.mProgressContainer.setVisibility(8); this.mListContainer.setVisibility(0); return; } if (z3) { view.startAnimation(AnimationUtils.loadAnimation(getContext(), 17432576)); this.mListContainer.startAnimation(AnimationUtils.loadAnimation(getContext(), 17432577)); } else { view.clearAnimation(); this.mListContainer.clearAnimation(); } this.mProgressContainer.setVisibility(0); this.mListContainer.setVisibility(8); } } @Nullable public ListAdapter getListAdapter() { return this.mAdapter; } @NonNull public ListView getListView() { ensureList(); return this.mList; } public long getSelectedItemId() { ensureList(); return this.mList.getSelectedItemId(); } public int getSelectedItemPosition() { ensureList(); return this.mList.getSelectedItemPosition(); } @Override // androidx.fragment.app.Fragment @Nullable public View onCreateView(@NonNull LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) { Context requireContext = requireContext(); FrameLayout frameLayout = new FrameLayout(requireContext); LinearLayout linearLayout = new LinearLayout(requireContext); linearLayout.setId(16711682); linearLayout.setOrientation(1); linearLayout.setVisibility(8); linearLayout.setGravity(17); linearLayout.addView(new ProgressBar(requireContext, null, 16842874), new FrameLayout.LayoutParams(-2, -2)); frameLayout.addView(linearLayout, new FrameLayout.LayoutParams(-1, -1)); FrameLayout frameLayout2 = new FrameLayout(requireContext); frameLayout2.setId(16711683); TextView textView = new TextView(requireContext); textView.setId(16711681); textView.setGravity(17); frameLayout2.addView(textView, new FrameLayout.LayoutParams(-1, -1)); ListView listView = new ListView(requireContext); listView.setId(16908298); listView.setDrawSelectorOnTop(false); frameLayout2.addView(listView, new FrameLayout.LayoutParams(-1, -1)); frameLayout.addView(frameLayout2, new FrameLayout.LayoutParams(-1, -1)); frameLayout.setLayoutParams(new FrameLayout.LayoutParams(-1, -1)); return frameLayout; } @Override // androidx.fragment.app.Fragment public void onDestroyView() { this.mHandler.removeCallbacks(this.mRequestFocus); this.mList = null; this.mListShown = false; this.mListContainer = null; this.mProgressContainer = null; this.mEmptyView = null; this.mStandardEmptyView = null; super.onDestroyView(); } public void onListItemClick(@NonNull ListView listView, @NonNull View view, int i, long j) { } @Override // androidx.fragment.app.Fragment public void onViewCreated(@NonNull View view, @Nullable Bundle bundle) { super.onViewCreated(view, bundle); ensureList(); } @NonNull public final ListAdapter requireListAdapter() { ListAdapter listAdapter = getListAdapter(); if (listAdapter != null) { return listAdapter; } throw new IllegalStateException("ListFragment " + this + " does not have a ListAdapter."); } public void setEmptyText(@Nullable CharSequence charSequence) { ensureList(); TextView textView = this.mStandardEmptyView; if (textView != null) { textView.setText(charSequence); if (this.mEmptyText == null) { this.mList.setEmptyView(this.mStandardEmptyView); } this.mEmptyText = charSequence; return; } throw new IllegalStateException("Can't be used with a custom content view"); } public void setListAdapter(@Nullable ListAdapter listAdapter) { boolean z2 = false; boolean z3 = this.mAdapter != null; this.mAdapter = listAdapter; ListView listView = this.mList; if (listView != null) { listView.setAdapter(listAdapter); if (!this.mListShown && !z3) { if (requireView().getWindowToken() != null) { z2 = true; } setListShown(true, z2); } } } public void setListShown(boolean z2) { setListShown(z2, true); } public void setListShownNoAnimation(boolean z2) { setListShown(z2, false); } public void setSelection(int i) { ensureList(); this.mList.setSelection(i); } }