93 lines
3.0 KiB
Java
93 lines
3.0 KiB
Java
|
package com.scb.phone.view.custom;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.util.AttributeSet;
|
||
|
import android.view.MotionEvent;
|
||
|
import android.view.View;
|
||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||
|
import o.C6583cXR;
|
||
|
|
||
|
/* loaded from: classes5.dex */
|
||
|
public class DraggableFloatingActionButton extends FloatingActionButton implements View.OnTouchListener {
|
||
|
private float f;
|
||
|
private float g;
|
||
|
private float h;
|
||
|
private float k;
|
||
|
private float l;
|
||
|
private int m;
|
||
|
private float n;
|
||
|
|
||
|
/* renamed from: o, reason: collision with root package name */
|
||
|
private float f8015o;
|
||
|
private float p;
|
||
|
|
||
|
public DraggableFloatingActionButton(Context context) {
|
||
|
super(context);
|
||
|
b();
|
||
|
}
|
||
|
|
||
|
public DraggableFloatingActionButton(Context context, AttributeSet attributeSet) {
|
||
|
super(context, attributeSet);
|
||
|
b();
|
||
|
}
|
||
|
|
||
|
public DraggableFloatingActionButton(Context context, AttributeSet attributeSet, int i) {
|
||
|
super(context, attributeSet, i);
|
||
|
b();
|
||
|
}
|
||
|
|
||
|
private void b() {
|
||
|
this.l = C6583cXR.d(16, getContext());
|
||
|
this.p = C6583cXR.d(24, getContext());
|
||
|
setOnTouchListener(this);
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View.OnTouchListener
|
||
|
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||
|
int action = motionEvent.getAction();
|
||
|
if (action == 0) {
|
||
|
this.f = motionEvent.getRawX();
|
||
|
this.k = motionEvent.getRawY();
|
||
|
this.g = view.getX() - this.f;
|
||
|
this.h = view.getY() - this.k;
|
||
|
return true;
|
||
|
}
|
||
|
if (action == 1) {
|
||
|
float rawX = motionEvent.getRawX();
|
||
|
float rawY = motionEvent.getRawY();
|
||
|
float f = this.f;
|
||
|
float f2 = this.k;
|
||
|
if (Math.abs(rawX - f) < 10.0f && Math.abs(rawY - f2) < 10.0f) {
|
||
|
return performClick();
|
||
|
}
|
||
|
if (this.f8015o >= this.m / 2) {
|
||
|
view.animate().x(this.m - this.l).y(this.n).setDuration(200L).start();
|
||
|
} else {
|
||
|
view.animate().x(this.l).y(this.n).setDuration(200L).start();
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
if (action != 2) {
|
||
|
return super.onTouchEvent(motionEvent);
|
||
|
}
|
||
|
View view2 = (View) view.getParent();
|
||
|
int width = view.getWidth();
|
||
|
int height = view.getHeight();
|
||
|
int width2 = view2.getWidth();
|
||
|
int height2 = view2.getHeight();
|
||
|
this.m = width2 - width;
|
||
|
float rawX2 = motionEvent.getRawX() + this.g;
|
||
|
this.f8015o = rawX2;
|
||
|
float max = Math.max(this.l, rawX2);
|
||
|
this.f8015o = max;
|
||
|
this.f8015o = Math.min(this.m - this.l, max);
|
||
|
float rawY2 = motionEvent.getRawY() + this.h;
|
||
|
this.n = rawY2;
|
||
|
float max2 = Math.max(this.p + this.l, rawY2);
|
||
|
this.n = max2;
|
||
|
this.n = Math.min((height2 - height) - this.l, max2);
|
||
|
view.animate().x(this.f8015o).y(this.n).setDuration(0L).start();
|
||
|
return true;
|
||
|
}
|
||
|
}
|