Browse Source

fab prep

renovate/org.robolectric-robolectric-4.x
Austin Huang 4 years ago
parent
commit
7ba116584b
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 61
      app/src/main/java/awais/instagrabber/animations/FabAnimation.java
  2. 20
      app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java

61
app/src/main/java/awais/instagrabber/animations/FabAnimation.java

@ -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);
}
}

20
app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java

@ -39,6 +39,7 @@ import awais.instagrabber.R;
import awais.instagrabber.activities.MainActivity; import awais.instagrabber.activities.MainActivity;
import awais.instagrabber.adapters.FeedAdapterV2; import awais.instagrabber.adapters.FeedAdapterV2;
import awais.instagrabber.adapters.FeedStoriesAdapter; import awais.instagrabber.adapters.FeedStoriesAdapter;
import awais.instagrabber.animations.FabAnimation;
import awais.instagrabber.asyncs.FeedPostFetchService; import awais.instagrabber.asyncs.FeedPostFetchService;
import awais.instagrabber.customviews.PrimaryActionModeCallback; import awais.instagrabber.customviews.PrimaryActionModeCallback;
import awais.instagrabber.databinding.FragmentFeedBinding; import awais.instagrabber.databinding.FragmentFeedBinding;
@ -68,6 +69,7 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
private FragmentFeedBinding binding; private FragmentFeedBinding binding;
private StoriesService storiesService; private StoriesService storiesService;
private boolean shouldRefresh = true; private boolean shouldRefresh = true;
private final boolean isRotate = false;
private FeedStoriesViewModel feedStoriesViewModel; private FeedStoriesViewModel feedStoriesViewModel;
private boolean storiesFetching; private boolean storiesFetching;
private ActionMode actionMode; 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) { public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
if (!shouldRefresh) return; if (!shouldRefresh) return;
binding.feedSwipeRefreshLayout.setOnRefreshListener(this); 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(); setupFeedStories();
setupFeed(); setupFeed();
shouldRefresh = false; shouldRefresh = false;

Loading…
Cancel
Save