diff --git a/app/src/main/java/com/cogentworks/overwidget/MainActivity.java b/app/src/main/java/com/cogentworks/overwidget/MainActivity.java index 8ee3ab6..5cbb9a1 100644 --- a/app/src/main/java/com/cogentworks/overwidget/MainActivity.java +++ b/app/src/main/java/com/cogentworks/overwidget/MainActivity.java @@ -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; @@ -39,6 +41,8 @@ public class MainActivity extends AppCompatActivity { public DragListView mDragListView; ArrayList mItemArray; + FloatingActionButton fab; + boolean isBusy = false; @Override @@ -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;