213 lines
8.2 KiB
Java
213 lines
8.2 KiB
Java
package com.discord.tooltips;
|
|
|
|
import android.content.SharedPreferences;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import androidx.annotation.MainThread;
|
|
import androidx.core.view.ViewCompat;
|
|
import c.a.j.a;
|
|
import c.a.j.b;
|
|
import c.a.j.c;
|
|
import c.a.j.e;
|
|
import c.a.j.f;
|
|
import c.a.w.d;
|
|
import com.discord.floating_view_manager.FloatingViewGravity;
|
|
import d0.g;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import java.lang.ref.WeakReference;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import java.util.Set;
|
|
import kotlin.Lazy;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
/* compiled from: TooltipManager.kt */
|
|
public class TooltipManager {
|
|
public Map<String, Integer> a;
|
|
public final c.a.w.a b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final Set<String> f2107c;
|
|
public final int d;
|
|
public final c.a.j.a e;
|
|
|
|
/* compiled from: TooltipManager.kt */
|
|
public static class Tooltip {
|
|
private final String cacheKey;
|
|
private final String tooltipName;
|
|
|
|
public Tooltip(String str, String str2) {
|
|
m.checkNotNullParameter(str2, "tooltipName");
|
|
this.cacheKey = str;
|
|
this.tooltipName = str2;
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ Tooltip(String str, String str2, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this((i & 1) != 0 ? null : str, str2);
|
|
}
|
|
|
|
public final String getCacheKey() {
|
|
return this.cacheKey;
|
|
}
|
|
|
|
public final String getTooltipName() {
|
|
return this.tooltipName;
|
|
}
|
|
}
|
|
|
|
/* compiled from: TooltipManager.kt */
|
|
public static final class a {
|
|
public static WeakReference<TooltipManager> a;
|
|
public static final Lazy b = g.lazy(C0176a.i);
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public static final Lazy f2108c = g.lazy(b.i);
|
|
public static final a d = null;
|
|
|
|
/* compiled from: TooltipManager.kt */
|
|
/* renamed from: com.discord.tooltips.TooltipManager$a$a reason: collision with other inner class name */
|
|
public static final class C0176a extends o implements Function0<c.a.w.a> {
|
|
public static final C0176a i = new C0176a();
|
|
|
|
public C0176a() {
|
|
super(0);
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
@Override // kotlin.jvm.functions.Function0
|
|
/* renamed from: invoke */
|
|
public c.a.w.a mo1invoke() {
|
|
return new c.a.w.a(null, 1);
|
|
}
|
|
}
|
|
|
|
/* compiled from: TooltipManager.kt */
|
|
public static final class b extends o implements Function0<Set<String>> {
|
|
public static final b i = new b();
|
|
|
|
public b() {
|
|
super(0);
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
@Override // kotlin.jvm.functions.Function0
|
|
/* renamed from: invoke */
|
|
public Set<String> mo1invoke() {
|
|
return new LinkedHashSet();
|
|
}
|
|
}
|
|
}
|
|
|
|
public TooltipManager(c.a.w.a aVar, Set set, int i, c.a.j.a aVar2, int i2) {
|
|
i = (i2 & 4) != 0 ? 1 : i;
|
|
m.checkNotNullParameter(aVar, "acknowledgedTooltipsCache");
|
|
m.checkNotNullParameter(set, "shownTooltipNames");
|
|
m.checkNotNullParameter(aVar2, "floatingViewManager");
|
|
this.b = aVar;
|
|
this.f2107c = set;
|
|
this.d = i;
|
|
this.e = aVar2;
|
|
aVar2.a = new d(this);
|
|
this.a = new LinkedHashMap();
|
|
}
|
|
|
|
public static /* synthetic */ void e(TooltipManager tooltipManager, View view, View view2, Tooltip tooltip, FloatingViewGravity floatingViewGravity, int i, int i2, boolean z2, Observable observable, int i3, Object obj) {
|
|
tooltipManager.d(view, view2, tooltip, (i3 & 8) != 0 ? FloatingViewGravity.TOP : floatingViewGravity, (i3 & 16) != 0 ? 0 : i, (i3 & 32) != 0 ? 0 : i2, (i3 & 64) != 0 ? false : z2, observable);
|
|
}
|
|
|
|
@MainThread
|
|
public final void a(Tooltip tooltip) {
|
|
m.checkNotNullParameter(tooltip, "tooltip");
|
|
c(tooltip);
|
|
String cacheKey = tooltip.getCacheKey();
|
|
if (cacheKey != null) {
|
|
c.a.w.a aVar = this.b;
|
|
Objects.requireNonNull(aVar);
|
|
m.checkNotNullParameter(cacheKey, "tooltipCacheKey");
|
|
if (!aVar.a.getBoolean(cacheKey, false)) {
|
|
c.a.w.a aVar2 = this.b;
|
|
Objects.requireNonNull(aVar2);
|
|
m.checkNotNullParameter(cacheKey, "tooltipCacheKey");
|
|
SharedPreferences.Editor edit = aVar2.a.edit();
|
|
m.checkExpressionValueIsNotNull(edit, "editor");
|
|
edit.putBoolean(cacheKey, true);
|
|
edit.apply();
|
|
}
|
|
}
|
|
}
|
|
|
|
@MainThread
|
|
public final boolean b(Tooltip tooltip, boolean z2) {
|
|
m.checkNotNullParameter(tooltip, "tooltip");
|
|
String cacheKey = tooltip.getCacheKey();
|
|
if (cacheKey != null) {
|
|
c.a.w.a aVar = this.b;
|
|
Objects.requireNonNull(aVar);
|
|
m.checkNotNullParameter(cacheKey, "tooltipCacheKey");
|
|
boolean z3 = aVar.a.getBoolean(cacheKey, false);
|
|
boolean contains = this.f2107c.contains(tooltip.getTooltipName());
|
|
int size = this.f2107c.size();
|
|
if (z3) {
|
|
return false;
|
|
}
|
|
if (!contains && !z2 && size >= this.d) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@MainThread
|
|
public final void c(Tooltip tooltip) {
|
|
m.checkNotNullParameter(tooltip, "tooltip");
|
|
Integer num = this.a.get(tooltip.getTooltipName());
|
|
if (num != null) {
|
|
this.e.b(num.intValue());
|
|
}
|
|
}
|
|
|
|
@MainThread
|
|
public final void d(View view, View view2, Tooltip tooltip, FloatingViewGravity floatingViewGravity, int i, int i2, boolean z2, Observable<Unit> observable) {
|
|
m.checkNotNullParameter(view, "anchorView");
|
|
m.checkNotNullParameter(view2, "tooltipView");
|
|
m.checkNotNullParameter(tooltip, "tooltip");
|
|
m.checkNotNullParameter(floatingViewGravity, "tooltipGravity");
|
|
m.checkNotNullParameter(observable, "componentPausedObservable");
|
|
if (b(tooltip, z2)) {
|
|
c(tooltip);
|
|
this.f2107c.add(tooltip.getTooltipName());
|
|
this.a.put(tooltip.getTooltipName(), Integer.valueOf(view2.getId()));
|
|
c.a.j.a aVar = this.e;
|
|
Objects.requireNonNull(aVar);
|
|
m.checkNotNullParameter(view, "anchorView");
|
|
m.checkNotNullParameter(view2, "floatingView");
|
|
m.checkNotNullParameter(floatingViewGravity, "floatingViewGravity");
|
|
m.checkNotNullParameter(observable, "componentPausedObservable");
|
|
View rootView = view.getRootView();
|
|
Objects.requireNonNull(rootView, "null cannot be cast to non-null type android.view.ViewGroup");
|
|
ViewGroup viewGroup = (ViewGroup) rootView;
|
|
view2.setVisibility(4);
|
|
if (!aVar.b.containsKey(Integer.valueOf(view2.getId()))) {
|
|
viewGroup.addView(view2);
|
|
}
|
|
if (!ViewCompat.isLaidOut(view2) || view2.isLayoutRequested()) {
|
|
view2.addOnLayoutChangeListener(new b(aVar, view, view2, floatingViewGravity, i, i2));
|
|
} else if (!ViewCompat.isLaidOut(view) || view.isLayoutRequested()) {
|
|
view.addOnLayoutChangeListener(new c(aVar, view, view2, floatingViewGravity, i, i2));
|
|
} else {
|
|
c.a.j.a.a(aVar, view2, view, floatingViewGravity, i, i2);
|
|
view2.setVisibility(0);
|
|
}
|
|
f fVar = new f(aVar, view2, view, floatingViewGravity, i, i2);
|
|
viewGroup.getViewTreeObserver().addOnPreDrawListener(fVar);
|
|
aVar.b.put(Integer.valueOf(view2.getId()), new a.C0025a(view2, viewGroup, fVar));
|
|
observable.Z(1).W(new c.a.j.d(aVar, view2), new e(aVar));
|
|
}
|
|
}
|
|
}
|