Commit cc8e5c3f authored by Varun Patil's avatar Varun Patil

Hide edit event fab on scroll

parent 51ddf0de
...@@ -15,6 +15,7 @@ import android.os.Bundle; ...@@ -15,6 +15,7 @@ import android.os.Bundle;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
...@@ -230,10 +231,18 @@ public class EventFragment extends BackHandledFragment { ...@@ -230,10 +231,18 @@ public class EventFragment extends BackHandledFragment {
}); });
mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime); mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);
FloatingActionButton fab = (FloatingActionButton) getView().findViewById(R.id.edit_fab); final FloatingActionButton fab = (FloatingActionButton) getView().findViewById(R.id.edit_fab);
if (((MainActivity) getActivity()).editEventAccess(event)) { if (((MainActivity) getActivity()).editEventAccess(event)) {
fab.setVisibility(View.VISIBLE); fab.setVisibility(View.VISIBLE);
NestedScrollView nsv = (NestedScrollView) getView().findViewById(R.id.event_scrollview);
nsv.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
if (scrollY > oldScrollY) fab.hide();
else fab.show();
}
});
} }
fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(new View.OnClickListener() {
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<ScrollView <android.support.v4.widget.NestedScrollView
android:id="@+id/event_scrollview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
...@@ -213,7 +214,7 @@ ...@@ -213,7 +214,7 @@
android:layout_marginTop="10dp" /> android:layout_marginTop="10dp" />
</LinearLayout> </LinearLayout>
</ScrollView> </android.support.v4.widget.NestedScrollView>
</LinearLayout> </LinearLayout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment