Skip to content

Commit

Permalink
Added hid FAB on scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb-yun committed Jul 17, 2018
1 parent 1f146da commit f8ae4c7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/src/main/java/com/cogentworks/overwidget/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
Expand Down Expand Up @@ -39,6 +41,8 @@ public class MainActivity extends AppCompatActivity {
public DragListView mDragListView;
ArrayList<Profile> mItemArray;

FloatingActionButton fab;

boolean isBusy = false;

@Override
Expand Down Expand Up @@ -135,6 +139,20 @@ public void onItemSwipeEnded(ListSwipeItem item, ListSwipeItem.SwipeDirection sw
}
});


fab = findViewById(R.id.fab);
mDragListView.getRecyclerView().addOnScrollListener((new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (dy > 0 && fab.getVisibility() == View.VISIBLE) {
fab.hide();
} else if (dy < 0 && fab.getVisibility() != View.VISIBLE) {
fab.show();
}
}
}));

setupListRecyclerView();

isBusy = true;
Expand Down

0 comments on commit f8ae4c7

Please sign in to comment.