mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-26 08:37:29 +00:00
fab prep
This commit is contained in:
parent
388f9216b3
commit
7ba116584b
@ -0,0 +1,61 @@
|
||||
package awais.instagrabber.animations;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.view.View;
|
||||
|
||||
// https://medium.com/better-programming/animated-fab-button-with-more-options-2dcf7118fff6
|
||||
|
||||
public class FabAnimation {
|
||||
public static boolean rotateFab(final View v, boolean rotate) {
|
||||
v.animate().setDuration(200)
|
||||
.setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
}
|
||||
})
|
||||
.rotation(rotate ? 135f : 0f);
|
||||
return rotate;
|
||||
}
|
||||
|
||||
public static void showIn(final View v) {
|
||||
v.setVisibility(View.VISIBLE);
|
||||
v.setAlpha(0f);
|
||||
v.setTranslationY(v.getHeight());
|
||||
v.animate()
|
||||
.setDuration(200)
|
||||
.translationY(0)
|
||||
.setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
}
|
||||
})
|
||||
.alpha(1f)
|
||||
.start();
|
||||
}
|
||||
|
||||
public static void showOut(final View v) {
|
||||
v.setVisibility(View.VISIBLE);
|
||||
v.setAlpha(1f);
|
||||
v.setTranslationY(0);
|
||||
v.animate()
|
||||
.setDuration(200)
|
||||
.translationY(v.getHeight())
|
||||
.setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
v.setVisibility(View.GONE);
|
||||
super.onAnimationEnd(animation);
|
||||
}
|
||||
}).alpha(0f)
|
||||
.start();
|
||||
}
|
||||
|
||||
public static void init(final View v) {
|
||||
v.setVisibility(View.GONE);
|
||||
v.setTranslationY(v.getHeight());
|
||||
v.setAlpha(0f);
|
||||
}
|
||||
}
|
@ -39,6 +39,7 @@ import awais.instagrabber.R;
|
||||
import awais.instagrabber.activities.MainActivity;
|
||||
import awais.instagrabber.adapters.FeedAdapterV2;
|
||||
import awais.instagrabber.adapters.FeedStoriesAdapter;
|
||||
import awais.instagrabber.animations.FabAnimation;
|
||||
import awais.instagrabber.asyncs.FeedPostFetchService;
|
||||
import awais.instagrabber.customviews.PrimaryActionModeCallback;
|
||||
import awais.instagrabber.databinding.FragmentFeedBinding;
|
||||
@ -68,6 +69,7 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
|
||||
private FragmentFeedBinding binding;
|
||||
private StoriesService storiesService;
|
||||
private boolean shouldRefresh = true;
|
||||
private final boolean isRotate = false;
|
||||
private FeedStoriesViewModel feedStoriesViewModel;
|
||||
private boolean storiesFetching;
|
||||
private ActionMode actionMode;
|
||||
@ -282,6 +284,24 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
|
||||
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
|
||||
if (!shouldRefresh) return;
|
||||
binding.feedSwipeRefreshLayout.setOnRefreshListener(this);
|
||||
/*
|
||||
FabAnimation.init(binding.fabCamera);
|
||||
FabAnimation.init(binding.fabStory);
|
||||
binding.fabAdd.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
isRotate = FabAnimation.rotateFab(v, !isRotate);
|
||||
if (isRotate) {
|
||||
FabAnimation.showIn(binding.fabCamera);
|
||||
FabAnimation.showIn(binding.fabStory);
|
||||
}
|
||||
else {
|
||||
FabAnimation.showOut(binding.fabCamera);
|
||||
FabAnimation.showOut(binding.fabStory);
|
||||
}
|
||||
}
|
||||
});
|
||||
*/
|
||||
setupFeedStories();
|
||||
setupFeed();
|
||||
shouldRefresh = false;
|
||||
|
Loading…
Reference in New Issue
Block a user