85 lines
3.8 KiB
Java
85 lines
3.8 KiB
Java
package com.discord.utilities.directories;
|
|
|
|
import android.content.Context;
|
|
import androidx.annotation.DrawableRes;
|
|
import androidx.annotation.StringRes;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import c.a.y.b0;
|
|
import c.a.y.c0;
|
|
import com.discord.R;
|
|
import com.discord.api.directory.DirectoryEntry;
|
|
import com.discord.app.AppFragment;
|
|
import d0.t.m;
|
|
import d0.t.n;
|
|
import d0.t.o;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
/* compiled from: DirectoryUtils.kt */
|
|
public final class DirectoryUtils {
|
|
public static final DirectoryUtils INSTANCE = new DirectoryUtils();
|
|
private static final List<DirectoryServerMenuOptions> NON_SERVER_OWNER_MENU_OPTIONS = m.listOf(DirectoryServerMenuOptions.Report);
|
|
private static final List<DirectoryServerMenuOptions> SERVER_OWNER_MENU_OPTIONS = n.listOf((Object[]) new DirectoryServerMenuOptions[]{DirectoryServerMenuOptions.Edit, DirectoryServerMenuOptions.Remove});
|
|
|
|
/* compiled from: DirectoryUtils.kt */
|
|
public enum DirectoryServerMenuOptions {
|
|
Edit(R.string.hub_entry_update, R.drawable.ic_edit_24dp),
|
|
Remove(R.string.hub_entry_remove, R.drawable.ic_delete_24dp),
|
|
Report(R.string.report, R.drawable.ic_flag_24dp);
|
|
|
|
private final int iconRes;
|
|
private final int titleRes;
|
|
|
|
private DirectoryServerMenuOptions(@StringRes int i, @DrawableRes int i2) {
|
|
this.titleRes = i;
|
|
this.iconRes = i2;
|
|
}
|
|
|
|
public final int getIconRes() {
|
|
return this.iconRes;
|
|
}
|
|
|
|
public final int getTitleRes() {
|
|
return this.titleRes;
|
|
}
|
|
}
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
|
|
static {
|
|
DirectoryServerMenuOptions.values();
|
|
int[] iArr = new int[3];
|
|
$EnumSwitchMapping$0 = iArr;
|
|
iArr[DirectoryServerMenuOptions.Edit.ordinal()] = 1;
|
|
iArr[DirectoryServerMenuOptions.Remove.ordinal()] = 2;
|
|
iArr[DirectoryServerMenuOptions.Report.ordinal()] = 3;
|
|
}
|
|
}
|
|
|
|
private DirectoryUtils() {
|
|
}
|
|
|
|
public final void showServerOptions(AppFragment appFragment, DirectoryEntry directoryEntry, String str, boolean z2, Function0<Unit> function0) {
|
|
d0.z.d.m.checkNotNullParameter(appFragment, "fragment");
|
|
d0.z.d.m.checkNotNullParameter(directoryEntry, "directoryEntry");
|
|
d0.z.d.m.checkNotNullParameter(str, "hubName");
|
|
d0.z.d.m.checkNotNullParameter(function0, "removeGuildListener");
|
|
Context context = appFragment.getContext();
|
|
if (context != null) {
|
|
d0.z.d.m.checkNotNullExpressionValue(context, "fragment.context ?: return");
|
|
List<DirectoryServerMenuOptions> list = z2 ? SERVER_OWNER_MENU_OPTIONS : NON_SERVER_OWNER_MENU_OPTIONS;
|
|
b0.a aVar = b0.j;
|
|
FragmentManager childFragmentManager = appFragment.getChildFragmentManager();
|
|
d0.z.d.m.checkNotNullExpressionValue(childFragmentManager, "fragment.childFragmentManager");
|
|
String string = appFragment.getString(R.string.server_settings);
|
|
d0.z.d.m.checkNotNullExpressionValue(string, "fragment.getString(R.string.server_settings)");
|
|
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(list, 10));
|
|
for (DirectoryServerMenuOptions directoryServerMenuOptions : list) {
|
|
arrayList.add(new c0(appFragment.getString(directoryServerMenuOptions.getTitleRes()), null, Integer.valueOf(directoryServerMenuOptions.getIconRes()), null, null, null, null, 122));
|
|
}
|
|
aVar.a(childFragmentManager, string, arrayList, false, new DirectoryUtils$showServerOptions$2(list, context, directoryEntry, str, appFragment, function0));
|
|
}
|
|
}
|
|
}
|