content: package androidx.fragment.app;
  
  import android.content.Context;
  import android.os.Bundle;
  import android.os.Handler;
  import android.util.AttributeSet;
  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;
  
  public class ListFragment extends Fragment {
      static final int INTERNAL_EMPTY_ID = 16711681;
      static final int INTERNAL_LIST_CONTAINER_ID = 16711683;
      static final int INTERNAL_PROGRESS_CONTAINER_ID = 16711682;
      ListAdapter mAdapter;
      CharSequence mEmptyText;
      View mEmptyView;
      private final Handler mHandler = new Handler();
      ListView mList;
      View mListContainer;
      boolean mListShown;
      private final AdapterView.OnItemClickListener mOnClickListener = new AdapterView.OnItemClickListener() {
          public void onItemClick(AdapterView<?> adapterView, View v, int position, long id) {
              ListFragment.this.onListItemClick((ListView) adapterView, v, position, id);
          }
      };
      View mProgressContainer;
      private final Runnable mRequestFocus = new Runnable() {
          public void run() {
              ListFragment.this.mList.focusableViewAvailable(ListFragment.this.mList);
          }
      };
      TextView mStandardEmptyView;
  
      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(INTERNAL_EMPTY_ID);
                      this.mStandardEmptyView = textView;
                      if (textView == null) {
                          this.mEmptyView = view.findViewById(16908292);
                      } else {
                          textView.setVisibility(8);
                      }
                      this.mProgressContainer = view.findViewById(INTERNAL_PROGRESS_CONTAINER_ID);
                      this.mListContainer = view.findViewById(INTERNAL_LIST_CONTAINER_ID);
                      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);
                  if (this.mAdapter != null) {
                      ListAdapter listAdapter = this.mAdapter;
                      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 shown, boolean animate) {
          ensureList();
          View view = this.mProgressContainer;
          if (view == null) {
              throw new IllegalStateException("Can't be used with a custom content view");
          } else if (this.mListShown != shown) {
              this.mListShown = shown;
              if (shown) {
                  if (animate) {
                      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 (animate) {
                  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);
          }
      }
  
      public ListAdapter getListAdapter() {
          return this.mAdapter;
      }
  
      public ListView getListView() {
          ensureList();
          return this.mList;
      }
  
      public long getSelectedItemId() {
          ensureList();
          return this.mList.getSelectedItemId();
      }
  
      public int getSelectedItemPosition() {
          ensureList();
          return this.mList.getSelectedItemPosition();
      }
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          Context requireContext = requireContext();
          FrameLayout frameLayout = new FrameLayout(requireContext);
          LinearLayout linearLayout = new LinearLayout(requireContext);
          linearLayout.setId(INTERNAL_PROGRESS_CONTAINER_ID);
          linearLayout.setOrientation(1);
          linearLayout.setVisibility(8);
          linearLayout.setGravity(17);
          linearLayout.addView(new ProgressBar(requireContext, (AttributeSet) null, 16842874), new FrameLayout.LayoutParams(-2, -2));
          frameLayout.addView(linearLayout, new FrameLayout.LayoutParams(-1, -1));
          FrameLayout frameLayout2 = new FrameLayout(requireContext);
          frameLayout2.setId(INTERNAL_LIST_CONTAINER_ID);
          TextView textView = new TextView(requireContext);
          textView.setId(INTERNAL_EMPTY_ID);
          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;
      }
  
      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(ListView l, View v, int position, long id) {
      }
  
      public void onViewCreated(View view, Bundle savedInstanceState) {
          super.onViewCreated(view, savedInstanceState);
          ensureList();
      }
  
      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(CharSequence text) {
          ensureList();
          TextView textView = this.mStandardEmptyView;
          if (textView != null) {
              textView.setText(text);
              if (this.mEmptyText == null) {
                  this.mList.setEmptyView(this.mStandardEmptyView);
              }
              this.mEmptyText = text;
              return;
          }
          throw new IllegalStateException("Can't be used with a custom content view");
      }
  
      public void setListAdapter(ListAdapter adapter) {
          boolean z = false;
          boolean z2 = this.mAdapter != null;
          this.mAdapter = adapter;
          ListView listView = this.mList;
          if (listView != null) {
              listView.setAdapter(adapter);
              if (!this.mListShown && !z2) {
                  if (requireView().getWindowToken() != null) {
                      z = true;
                  }
                  setListShown(true, z);
              }
          }
      }
  
      public void setListShown(boolean shown) {
          setListShown(shown, true);
      }
  
      public void setListShownNoAnimation(boolean shown) {
          setListShown(shown, false);
      }
  
      public void setSelection(int position) {
          ensureList();
          this.mList.setSelection(position);
      }
  }
  