AndroidX lib refactor
This commit is contained in:
parent
08f0b5e76e
commit
a8dfe106bb
233 changed files with 3254 additions and 9769 deletions
|
@ -4,7 +4,7 @@ import com.google.android.material.appbar.AppBarLayout;
|
|||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
* https://stackoverflow.com/a/33891727
|
||||
* https://stackoverflow.com/a/33891727
|
||||
*/
|
||||
|
||||
public abstract class AppBarStateChangeListener implements AppBarLayout.OnOffsetChangedListener {
|
||||
|
|
|
@ -1,104 +0,0 @@
|
|||
package code.name.monkey.retromusic.misc;
|
||||
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.View;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import butterknife.BindInt;
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.util.RetroUtil;
|
||||
|
||||
/**
|
||||
* {@link View.OnClickListener} used to translate the product grid sheet downward on
|
||||
* the Y-axis when the navigation icon in the toolbar is pressed.
|
||||
*/
|
||||
public class NavigationIconClickListener implements View.OnClickListener {
|
||||
|
||||
private final AnimatorSet animatorSet = new AnimatorSet();
|
||||
@BindInt(R.integer.options_height)
|
||||
int options;
|
||||
private Context context;
|
||||
private View sheet, menu;
|
||||
private Interpolator interpolator;
|
||||
private int height;
|
||||
private boolean backdropShown = false;
|
||||
private Drawable openIcon;
|
||||
private Drawable closeIcon;
|
||||
|
||||
public NavigationIconClickListener(Context context, View sheet, View menu, @Nullable Interpolator interpolator) {
|
||||
this(context, sheet, menu, interpolator, null, null);
|
||||
}
|
||||
|
||||
public NavigationIconClickListener(Context context, View sheet, View menu, @Nullable Interpolator interpolator,
|
||||
@Nullable Drawable openIcon, @Nullable Drawable closeIcon) {
|
||||
this.context = context;
|
||||
this.sheet = sheet;
|
||||
this.menu = menu;
|
||||
this.interpolator = interpolator;
|
||||
this.openIcon = openIcon;
|
||||
this.closeIcon = closeIcon;
|
||||
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
height = displayMetrics.heightPixels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
backdropShown = !backdropShown;
|
||||
|
||||
// Cancel the existing animations
|
||||
animatorSet.removeAllListeners();
|
||||
animatorSet.end();
|
||||
animatorSet.cancel();
|
||||
|
||||
if (!(view instanceof ImageView)) {
|
||||
throw new IllegalArgumentException("updateIcon() must be called on an ImageView");
|
||||
}
|
||||
updateIcon((ImageView) view);
|
||||
final int translateY = (int) RetroUtil.convertDpToPixel(getHeight(view.getContext()), view.getContext());
|
||||
|
||||
ObjectAnimator animator = ObjectAnimator.ofFloat(sheet, "translationY", backdropShown ? translateY : 0);
|
||||
animator.setDuration(500);
|
||||
if (interpolator != null) {
|
||||
animator.setInterpolator(interpolator);
|
||||
}
|
||||
animatorSet.play(animator);
|
||||
animator.start();
|
||||
}
|
||||
|
||||
private int getHeight(Context context) {
|
||||
Resources resources = context.getResources();
|
||||
if (RetroUtil.isLandscape(resources)) {
|
||||
return 3 * 48;
|
||||
} else if (RetroUtil.isTablet(resources)) {
|
||||
if (RetroUtil.isLandscape(resources)) {
|
||||
return 48;
|
||||
} else {
|
||||
return 2 * 48;
|
||||
}
|
||||
} else
|
||||
return 5 * 48;
|
||||
}
|
||||
|
||||
private void updateIcon(ImageView view) {
|
||||
if (openIcon != null && closeIcon != null) {
|
||||
view.setImageTintList(ColorStateList.valueOf(ATHUtil.resolveColor(context, R.attr.iconColor)));
|
||||
if (backdropShown) {
|
||||
view.setImageDrawable(closeIcon);
|
||||
} else {
|
||||
view.setImageDrawable(openIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,15 +2,17 @@ package code.name.monkey.retromusic.misc;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
/*Don't delete even if its not showing not using*/
|
||||
public class ScrollAwareFABBehavior extends CoordinatorLayout.Behavior<FloatingActionButton> {
|
||||
private static final String TAG = "ScrollingFABBehavior";
|
||||
|
@ -71,40 +73,4 @@ public class ScrollAwareFABBehavior extends CoordinatorLayout.Behavior<FloatingA
|
|||
}
|
||||
return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL;
|
||||
}
|
||||
}
|
||||
/*extends FloatingActionButton.Behavior {
|
||||
|
||||
public ScrollAwareFABBehavior(Context context, AttributeSet attrs) {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onStartNestedScroll(@NonNull final CoordinatorLayout coordinatorLayout,
|
||||
@NonNull final FloatingActionButton child,
|
||||
@NonNull final View directTargetChild,
|
||||
@NonNull final View target,
|
||||
final int nestedScrollAxes) {
|
||||
// Ensure we react to vertical scrolling
|
||||
return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL
|
||||
|| super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout,
|
||||
@NonNull FloatingActionButton child,
|
||||
@NonNull View target,
|
||||
int dxConsumed,
|
||||
int dyConsumed,
|
||||
int dxUnconsumed,
|
||||
int dyUnconsumed) {
|
||||
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed,
|
||||
dyUnconsumed);
|
||||
|
||||
if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) {
|
||||
child.hide();
|
||||
} else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
|
||||
child.show();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue