184 lines
6.4 KiB
Java
184 lines
6.4 KiB
Java
|
package androidx.fragment.app;
|
||
|
|
||
|
import android.R;
|
||
|
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;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public class ListFragment extends Fragment {
|
||
|
private CharSequence a;
|
||
|
ListView b;
|
||
|
private ListAdapter c;
|
||
|
private View d;
|
||
|
private View f;
|
||
|
private View h;
|
||
|
private boolean i;
|
||
|
private TextView k;
|
||
|
private final Handler e = new Handler();
|
||
|
private final Runnable j = new Runnable(this) { // from class: androidx.fragment.app.ListFragment.4
|
||
|
final ListFragment b;
|
||
|
|
||
|
{
|
||
|
this.b = this;
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.Runnable
|
||
|
public final void run() {
|
||
|
this.b.b.focusableViewAvailable(this.b.b);
|
||
|
}
|
||
|
};
|
||
|
private final AdapterView.OnItemClickListener g = new AdapterView.OnItemClickListener(this) { // from class: androidx.fragment.app.ListFragment.1
|
||
|
final ListFragment d;
|
||
|
|
||
|
{
|
||
|
this.d = this;
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.AdapterView.OnItemClickListener
|
||
|
public final void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
|
||
|
}
|
||
|
};
|
||
|
|
||
|
@Override // androidx.fragment.app.Fragment
|
||
|
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, 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, R.attr.progressBarStyleLarge), 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(R.id.list);
|
||
|
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 onViewCreated(View view, Bundle bundle) {
|
||
|
super.onViewCreated(view, bundle);
|
||
|
c();
|
||
|
}
|
||
|
|
||
|
@Override // androidx.fragment.app.Fragment
|
||
|
public void onDestroyView() {
|
||
|
this.e.removeCallbacks(this.j);
|
||
|
this.b = null;
|
||
|
this.i = false;
|
||
|
this.h = null;
|
||
|
this.f = null;
|
||
|
this.d = null;
|
||
|
this.k = null;
|
||
|
super.onDestroyView();
|
||
|
}
|
||
|
|
||
|
private void e(boolean z, boolean z2) {
|
||
|
c();
|
||
|
View view = this.f;
|
||
|
if (view == null) {
|
||
|
throw new IllegalStateException("Can't be used with a custom content view");
|
||
|
}
|
||
|
if (this.i == z) {
|
||
|
return;
|
||
|
}
|
||
|
this.i = z;
|
||
|
if (z) {
|
||
|
if (z2) {
|
||
|
view.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.fade_out));
|
||
|
this.h.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.fade_in));
|
||
|
} else {
|
||
|
view.clearAnimation();
|
||
|
this.h.clearAnimation();
|
||
|
}
|
||
|
this.f.setVisibility(8);
|
||
|
this.h.setVisibility(0);
|
||
|
return;
|
||
|
}
|
||
|
if (z2) {
|
||
|
view.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.fade_in));
|
||
|
this.h.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.fade_out));
|
||
|
} else {
|
||
|
view.clearAnimation();
|
||
|
this.h.clearAnimation();
|
||
|
}
|
||
|
this.f.setVisibility(0);
|
||
|
this.h.setVisibility(8);
|
||
|
}
|
||
|
|
||
|
private void c() {
|
||
|
if (this.b != null) {
|
||
|
return;
|
||
|
}
|
||
|
View view = getView();
|
||
|
if (view == null) {
|
||
|
throw new IllegalStateException("Content view not yet created");
|
||
|
}
|
||
|
if (view instanceof ListView) {
|
||
|
this.b = (ListView) view;
|
||
|
} else {
|
||
|
TextView textView = (TextView) view.findViewById(16711681);
|
||
|
this.k = textView;
|
||
|
if (textView == null) {
|
||
|
this.d = view.findViewById(R.id.empty);
|
||
|
} else {
|
||
|
textView.setVisibility(8);
|
||
|
}
|
||
|
this.f = view.findViewById(16711682);
|
||
|
this.h = view.findViewById(16711683);
|
||
|
View findViewById = view.findViewById(R.id.list);
|
||
|
if (!(findViewById instanceof ListView)) {
|
||
|
if (findViewById == null) {
|
||
|
throw new RuntimeException("Your content must have a ListView whose id attribute is 'android.R.id.list'");
|
||
|
}
|
||
|
throw new RuntimeException("Content has view with id attribute 'android.R.id.list' that is not a ListView class");
|
||
|
}
|
||
|
ListView listView = (ListView) findViewById;
|
||
|
this.b = listView;
|
||
|
View view2 = this.d;
|
||
|
if (view2 != null) {
|
||
|
listView.setEmptyView(view2);
|
||
|
}
|
||
|
}
|
||
|
this.i = true;
|
||
|
this.b.setOnItemClickListener(this.g);
|
||
|
ListAdapter listAdapter = this.c;
|
||
|
if (listAdapter != null) {
|
||
|
this.c = null;
|
||
|
this.c = listAdapter;
|
||
|
ListView listView2 = this.b;
|
||
|
if (listView2 != null) {
|
||
|
listView2.setAdapter(listAdapter);
|
||
|
if (!this.i) {
|
||
|
e(true, requireView().getWindowToken() != null);
|
||
|
}
|
||
|
}
|
||
|
} else if (this.f != null) {
|
||
|
e(false, false);
|
||
|
}
|
||
|
this.e.post(this.j);
|
||
|
}
|
||
|
}
|