Last active
July 5, 2020 06:31
-
-
Save KryptKode/57449ee5b84e178989a1daa76a5e1635 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<RelativeLayout android:orientation="vertical" android:id="@id/frequencyRl" android:clipChildren="false" | |
android:layout_width="fill_parent" android:layout_height="@dimen/mdp268"> | |
<ImageView android:id="@id/widget_top" android:layout_width="fill_parent" android:layout_height="@dimen/mdp220" | |
android:src="@drawable/bg_top" android:scaleType="centerCrop"/> | |
<ImageView android:id="@id/widget_line" android:layout_width="fill_parent" android:layout_height="wrap_content" | |
android:src="@drawable/seek_bar_progress" android:scaleType="fitXY" | |
android:layout_below="@id/widget_top"/> | |
<LinearLayout android:layout_gravity="bottom" android:orientation="horizontal" android:id="@id/frequencyTextLl" | |
android:layout_width="fill_parent" android:layout_height="wrap_content" | |
android:baselineAligned="false" android:layout_above="@id/widget_line"> | |
<androidx.appcompat.widget.AppCompatTextView android:textColor="#ffff0000" android:gravity="center" | |
android:layout_width="0.0dip" android:layout_height="wrap_content" | |
android:text="SOS" android:lines="1" | |
android:drawableBottom="@drawable/xian" | |
android:drawablePadding="@dimen/mdp8" android:layout_weight="1.0" | |
app:autoSizeMaxTextSize="14.0dip" app:autoSizeMinTextSize="6.0dip" | |
app:autoSizeTextType="uniform"/> | |
<TextView android:textSize="14.0dip" android:textColor="@color/color_hertz_unselected" android:gravity="center" | |
android:layout_width="0.0dip" android:layout_height="wrap_content" android:text="0" | |
android:drawableBottom="@drawable/xian" android:drawablePadding="@dimen/mdp8" | |
android:layout_weight="1.0"/> | |
<TextView android:textSize="14.0dip" android:textColor="@color/color_hertz_unselected" android:gravity="center" | |
android:layout_width="0.0dip" android:layout_height="wrap_content" android:text="1" | |
android:drawableBottom="@drawable/xian" android:drawablePadding="@dimen/mdp8" | |
android:layout_weight="1.0"/> | |
<TextView android:textSize="14.0dip" android:textColor="@color/color_hertz_unselected" android:gravity="center" | |
android:layout_width="0.0dip" android:layout_height="wrap_content" android:text="2" | |
android:drawableBottom="@drawable/xian" android:drawablePadding="@dimen/mdp8" | |
android:layout_weight="1.0"/> | |
<TextView android:textSize="14.0dip" android:textColor="@color/color_hertz_unselected" android:gravity="center" | |
android:layout_width="0.0dip" android:layout_height="wrap_content" android:text="3" | |
android:drawableBottom="@drawable/xian" android:drawablePadding="@dimen/mdp8" | |
android:layout_weight="1.0"/> | |
<TextView android:textSize="14.0dip" android:textColor="@color/color_hertz_unselected" android:gravity="center" | |
android:layout_width="0.0dip" android:layout_height="wrap_content" android:text="4" | |
android:drawableBottom="@drawable/xian" android:drawablePadding="@dimen/mdp8" | |
android:layout_weight="1.0"/> | |
<TextView android:textSize="14.0dip" android:textColor="@color/color_hertz_unselected" android:gravity="center" | |
android:layout_width="0.0dip" android:layout_height="wrap_content" android:text="5" | |
android:drawableBottom="@drawable/xian" android:drawablePadding="@dimen/mdp8" | |
android:layout_weight="1.0"/> | |
<TextView android:textSize="14.0dip" android:textColor="@color/color_hertz_unselected" android:gravity="center" | |
android:layout_width="0.0dip" android:layout_height="wrap_content" android:text="6" | |
android:drawableBottom="@drawable/xian" android:drawablePadding="@dimen/mdp8" | |
android:layout_weight="1.0"/> | |
<TextView android:textSize="14.0dip" android:textColor="@color/color_hertz_unselected" android:gravity="center" | |
android:layout_width="0.0dip" android:layout_height="wrap_content" android:text="7" | |
android:drawableBottom="@drawable/xian" android:drawablePadding="@dimen/mdp8" | |
android:layout_weight="1.0"/> | |
<TextView android:textSize="14.0dip" android:textColor="@color/color_hertz_unselected" android:gravity="center" | |
android:layout_width="0.0dip" android:layout_height="wrap_content" android:text="8" | |
android:drawableBottom="@drawable/xian" android:drawablePadding="@dimen/mdp8" | |
android:layout_weight="1.0"/> | |
<TextView android:textSize="14.0dip" android:textColor="@color/color_hertz_unselected" android:gravity="center" | |
android:layout_width="0.0dip" android:layout_height="wrap_content" android:text="9" | |
android:drawableBottom="@drawable/xian" android:drawablePadding="@dimen/mdp8" | |
android:layout_weight="1.0"/> | |
</LinearLayout> | |
<com.peacock.flashlight.widget.SeekFrameLayout android:id="@id/seekFl" android:clipChildren="false" | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginTop="@dimen/neg_mdp10" | |
android:layout_below="@id/widget_top"> | |
<FrameLayout android:clipChildren="false" android:layout_width="@dimen/mdp48" | |
android:layout_height="@dimen/mdp48"> | |
<ImageView android:layout_width="@dimen/mdp48" android:layout_height="@dimen/mdp48" | |
android:src="@drawable/button_circle"/> | |
<View android:layout_gravity="center" android:id="@id/v_circle_light" | |
android:background="@drawable/ic_button_circle_light" android:visibility="invisible" | |
android:layout_width="@dimen/mdp96" android:layout_height="@dimen/mdp96"/> | |
</FrameLayout> | |
</com.peacock.flashlight.widget.SeekFrameLayout> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.animation.Animator; | |
import android.animation.AnimatorListenerAdapter; | |
/* compiled from: SeekFrameLayout */ | |
class SeekBarAnimatorListenerAdapter extends AnimatorListenerAdapter { | |
final /* synthetic */ SeekFrameLayout a; | |
SeekBarAnimatorListenerAdapter(SeekFrameLayout seekFrameLayout) { | |
this.a = seekFrameLayout; | |
} | |
public void onAnimationEnd(Animator animator) { | |
SeekFrameLayout frameLayout = this.a; | |
if (frameLayout.Listener != null) { | |
frameLayout.postDelayed(new d(this), 300); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.view.GestureDetector.SimpleOnGestureListener; | |
import android.view.MotionEvent; | |
/* compiled from: SeekFrameLayout */ | |
class SeekBarGestureListener extends SimpleOnGestureListener { | |
final /* synthetic */ SeekFrameLayout seekFrameLayout; | |
SeekBarGestureListener(SeekFrameLayout seekFrameLayout) { | |
this.seekFrameLayout = seekFrameLayout; | |
} | |
public boolean onDown(MotionEvent motionEvent) { | |
return true; | |
} | |
public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) { | |
this.seekFrameLayout.getChildAt(0).animate().cancel(); | |
this.seekFrameLayout.b(-f); | |
return true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* compiled from: SeekFrameLayout */ | |
class SeekBarRunnable implements Runnable { | |
final /* synthetic */ SeekBarAnimatorListenerAdapter listenerAdapter; | |
SeekBarRunnable(SeekBarAnimatorListenerAdapter seekBarAnimatorListenerAdapter) { | |
this.listenerAdapter = seekBarAnimatorListenerAdapter; | |
} | |
public void run() { | |
SeekFrameLayout seekFrameLayout = this.listenerAdapter.a; | |
seekFrameLayout.Listener.a(seekFrameLayout.c, seekFrameLayout.g); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.animation.AnimatorListenerAdapter; | |
import android.annotation.TargetApi; | |
import android.content.Context; | |
import android.util.AttributeSet; | |
import android.view.GestureDetector; | |
import android.view.GestureDetector.OnGestureListener; | |
import android.view.MotionEvent; | |
import android.view.View; | |
import android.view.animation.DecelerateInterpolator; | |
import android.widget.FrameLayout; | |
public class SeekFrameLayout extends FrameLayout { | |
Listener Listener; | |
int b = 11; | |
int c; | |
GestureDetector gestureDetector; | |
OnGestureListener onGestureListener = new SeekBarGestureListener(this); | |
DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator(); | |
boolean g = false; | |
AnimatorListenerAdapter animatorListenerAdapter = new SeekBarAnimatorListenerAdapter(this); | |
public interface Listener { | |
void a(int i, boolean z); | |
} | |
public SeekFrameLayout(Context context) { | |
super(context); | |
init(); | |
} | |
void init() { | |
this.gestureDetector = new GestureDetector(getContext(), this.onGestureListener); | |
} | |
void b(float f) { | |
View childAt = getChildAt(0); | |
float translationX = childAt.getTranslationX() + f; | |
f = a((float) getWidth(), 0); | |
if (translationX < f) { | |
childAt.setTranslationX(f); | |
return; | |
} | |
f = a((float) getWidth(), 9); | |
if (translationX > f) { | |
childAt.setTranslationX(f); | |
} else { | |
childAt.setTranslationX(translationX); | |
} | |
} | |
protected void onSizeChanged(int i, int i2, int i3, int i4) { | |
super.onSizeChanged(i, i2, i3, i4); | |
if (getChildCount() > 0) { | |
measureChild(getChildAt(0), MeasureSpec.makeMeasureSpec(i, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(i2, MeasureSpec.EXACTLY)); | |
} | |
a((float) i, this.c, false, false); | |
} | |
public boolean onTouchEvent(MotionEvent motionEvent) { | |
this.gestureDetector.onTouchEvent(motionEvent); | |
if (motionEvent.getActionMasked() == 1) { | |
a((float) getWidth(), a(motionEvent.getX()), true, true); | |
} | |
return true; | |
} | |
public void setChildPosition(int i) { | |
a((float) getWidth(), i, true, false); | |
} | |
public void setCount(int i) { | |
this.b = i; | |
} | |
public SeekFrameLayout a(Listener listener) { | |
this.Listener = listener; | |
return this; | |
} | |
int a(float f) { | |
return Math.min(Math.max((int) (f / (((float) getWidth()) / ((float) this.b))), 0), this.b - 1); | |
} | |
float a(float f, int i) { | |
f /= (float) this.b; | |
float f2 = (((float) i) * f) + (f / 2.0f); | |
View childAt = getChildAt(0); | |
return f2 - (((float) ((MarginLayoutParams) childAt.getLayoutParams()).leftMargin) + (((float) childAt.getMeasuredWidth()) / 2.0f)); | |
} | |
public SeekFrameLayout(Context context, AttributeSet attributeSet) { | |
super(context, attributeSet); | |
init(); | |
} | |
void a(float f, int i, boolean z, boolean z2) { | |
this.g = z2; | |
View childAt = getChildAt(0); | |
f = a(f, i); | |
this.c = i; | |
if (f > 0.0f) { | |
if (z) { | |
childAt.animate().setInterpolator(this.decelerateInterpolator).translationX(f).setDuration(300).setListener(this.animatorListenerAdapter); | |
} else { | |
childAt.setTranslationX(f); | |
Listener listener = this.Listener; | |
if (listener != null) { | |
listener.a(i, z2); | |
} | |
} | |
} | |
} | |
public SeekFrameLayout(Context context, AttributeSet attributeSet, int i) { | |
super(context, attributeSet, i); | |
init(); | |
} | |
@TargetApi(21) | |
public SeekFrameLayout(Context context, AttributeSet attributeSet, int i, int i2) { | |
super(context, attributeSet, i, i2); | |
init(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment