40 lines
1.8 KiB
Java
40 lines
1.8 KiB
Java
package c.i.a.g.i;
|
|
|
|
import android.graphics.RectF;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.view.View;
|
|
import androidx.annotation.FloatRange;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import com.google.android.material.animation.AnimationUtils;
|
|
import com.google.android.material.internal.ViewUtils;
|
|
import com.google.android.material.tabs.TabLayout;
|
|
/* compiled from: TabIndicatorInterpolator */
|
|
public class b {
|
|
public static RectF a(TabLayout tabLayout, @Nullable View view) {
|
|
if (view == null) {
|
|
return new RectF();
|
|
}
|
|
if (tabLayout.isTabIndicatorFullWidth() || !(view instanceof TabLayout.TabView)) {
|
|
return new RectF((float) view.getLeft(), (float) view.getTop(), (float) view.getRight(), (float) view.getBottom());
|
|
}
|
|
TabLayout.TabView tabView = (TabLayout.TabView) view;
|
|
int contentWidth = tabView.getContentWidth();
|
|
int contentHeight = tabView.getContentHeight();
|
|
int dpToPx = (int) ViewUtils.dpToPx(tabView.getContext(), 24);
|
|
if (contentWidth < dpToPx) {
|
|
contentWidth = dpToPx;
|
|
}
|
|
int right = (tabView.getRight() + tabView.getLeft()) / 2;
|
|
int bottom = (tabView.getBottom() + tabView.getTop()) / 2;
|
|
int i = contentWidth / 2;
|
|
return new RectF((float) (right - i), (float) (bottom - (contentHeight / 2)), (float) (i + right), (float) ((right / 2) + bottom));
|
|
}
|
|
|
|
public void b(TabLayout tabLayout, View view, View view2, @FloatRange(from = 0.0d, to = 1.0d) float f, @NonNull Drawable drawable) {
|
|
RectF a = a(tabLayout, view);
|
|
RectF a2 = a(tabLayout, view2);
|
|
drawable.setBounds(AnimationUtils.lerp((int) a.left, (int) a2.left, f), drawable.getBounds().top, AnimationUtils.lerp((int) a.right, (int) a2.right, f), drawable.getBounds().bottom);
|
|
}
|
|
}
|