94 lines
3.1 KiB
Java
94 lines
3.1 KiB
Java
package androidx.core.app;
|
|
|
|
import android.app.Activity;
|
|
import android.content.ComponentName;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.pm.PackageManager;
|
|
import android.os.Bundle;
|
|
import android.util.Log;
|
|
import androidx.core.content.ContextCompat;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class TaskStackBuilder implements Iterable<Intent> {
|
|
private final ArrayList<Intent> a = new ArrayList<>();
|
|
private final Context b;
|
|
|
|
public interface SupportParentable {
|
|
Intent getSupportParentActivityIntent();
|
|
}
|
|
|
|
private TaskStackBuilder(Context context) {
|
|
this.b = context;
|
|
}
|
|
|
|
public static TaskStackBuilder a(Context context) {
|
|
return new TaskStackBuilder(context);
|
|
}
|
|
|
|
@Override // java.lang.Iterable
|
|
@Deprecated
|
|
public Iterator<Intent> iterator() {
|
|
return this.a.iterator();
|
|
}
|
|
|
|
public TaskStackBuilder a(Intent intent) {
|
|
this.a.add(intent);
|
|
return this;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public TaskStackBuilder a(Activity activity) {
|
|
Intent supportParentActivityIntent = activity instanceof SupportParentable ? ((SupportParentable) activity).getSupportParentActivityIntent() : null;
|
|
if (supportParentActivityIntent == null) {
|
|
supportParentActivityIntent = NavUtils.a(activity);
|
|
}
|
|
if (supportParentActivityIntent != null) {
|
|
ComponentName component = supportParentActivityIntent.getComponent();
|
|
if (component == null) {
|
|
component = supportParentActivityIntent.resolveActivity(this.b.getPackageManager());
|
|
}
|
|
a(component);
|
|
a(supportParentActivityIntent);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
public TaskStackBuilder a(ComponentName componentName) {
|
|
int size = this.a.size();
|
|
try {
|
|
Intent a = NavUtils.a(this.b, componentName);
|
|
while (a != null) {
|
|
this.a.add(size, a);
|
|
a = NavUtils.a(this.b, a.getComponent());
|
|
}
|
|
return this;
|
|
} catch (PackageManager.NameNotFoundException e) {
|
|
Log.e("TaskStackBuilder", "Bad ComponentName while traversing activity parent metadata");
|
|
throw new IllegalArgumentException(e);
|
|
}
|
|
}
|
|
|
|
public void a() {
|
|
a((Bundle) null);
|
|
}
|
|
|
|
public void a(Bundle bundle) {
|
|
if (!this.a.isEmpty()) {
|
|
ArrayList<Intent> arrayList = this.a;
|
|
Intent[] intentArr = (Intent[]) arrayList.toArray(new Intent[arrayList.size()]);
|
|
intentArr[0] = new Intent(intentArr[0]).addFlags(268484608);
|
|
if (ContextCompat.a(this.b, intentArr, bundle)) {
|
|
return;
|
|
}
|
|
Intent intent = new Intent(intentArr[intentArr.length - 1]);
|
|
intent.addFlags(268435456);
|
|
this.b.startActivity(intent);
|
|
return;
|
|
}
|
|
throw new IllegalStateException("No intents added to TaskStackBuilder; cannot startActivities");
|
|
}
|
|
}
|