-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*Update UI to allow RecyclerView to scroll underneath search box.
- Loading branch information
1 parent
84ade48
commit e5fafd4
Showing
8 changed files
with
198 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
app/src/main/java/stream/rocketnotes/ui/HideViewOnScrollListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package stream.rocketnotes.ui; | ||
|
||
import android.support.v7.widget.RecyclerView; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.view.ViewTreeObserver; | ||
|
||
public class HideViewOnScrollListener extends RecyclerView.OnScrollListener { | ||
|
||
private float alpha = 1.f; | ||
private float scrolly = 0.f; | ||
|
||
private int heightViewToHide; | ||
private final View viewToHide; | ||
|
||
public HideViewOnScrollListener(final View viewToHide) { | ||
this.viewToHide = viewToHide; | ||
|
||
heightViewToHide = viewToHide.getHeight(); | ||
if (heightViewToHide == 0) { | ||
|
||
ViewTreeObserver viewTreeObserver = viewToHide.getViewTreeObserver(); | ||
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { | ||
@Override | ||
public void onGlobalLayout() { | ||
|
||
heightViewToHide = viewToHide.getHeight(); | ||
|
||
if (heightViewToHide > 0) | ||
viewToHide.getViewTreeObserver().removeOnGlobalLayoutListener(this); | ||
} | ||
}); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | ||
super.onScrolled(recyclerView, dx, dy); | ||
|
||
scrolly += dy; | ||
|
||
Log.d("ScrollY", String.valueOf(scrolly)); | ||
Log.d("Scroll", String.valueOf(dy)); | ||
|
||
alpha = (heightViewToHide - scrolly) / heightViewToHide; | ||
|
||
if (alpha < 0.f) alpha = 0.f; | ||
if (alpha > 1.0f) alpha = 1.f; | ||
|
||
if (dy < 0 && scrolly > heightViewToHide) { | ||
alpha = 0.f; | ||
} | ||
|
||
viewToHide.setAlpha(alpha); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/stream/rocketnotes/ui/MoveViewOnScrollListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package stream.rocketnotes.ui; | ||
|
||
import android.support.v7.widget.RecyclerView; | ||
import android.util.Log; | ||
import android.view.View; | ||
|
||
public class MoveViewOnScrollListener extends RecyclerView.OnScrollListener { | ||
|
||
private float alpha = 1f; | ||
private float scrollY = 0f; | ||
private float scrollThreshold; | ||
|
||
private int heightViewToHide; | ||
private final View mView; | ||
|
||
public MoveViewOnScrollListener(final View view) { | ||
this.mView = view; | ||
|
||
scrollThreshold = view.getY(); | ||
Log.d("Threshhold", String.valueOf(scrollThreshold)); | ||
} | ||
|
||
@Override | ||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | ||
super.onScrolled(recyclerView, dx, dy); | ||
|
||
scrollY += dy; | ||
|
||
if (scrollY < scrollThreshold) | ||
{ | ||
mView.setTranslationY(dy); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout | ||
android:id="@+id/search_layout" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<FrameLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<android.support.v7.widget.RecyclerView | ||
android:id="@+id/rv_filter" | ||
android:layout_width="match_parent" | ||
android:layout_height="@dimen/msv_filter_rv_height" | ||
android:paddingLeft="6dp" | ||
android:paddingRight="6dp" | ||
android:paddingBottom="6dp" | ||
android:background="@color/colorPrimary"/> | ||
|
||
<View | ||
android:layout_width="match_parent" | ||
android:layout_height="1dip" | ||
android:layout_gravity="bottom" | ||
android:background="#FFFFFF" | ||
android:backgroundTint="#10000000"/> | ||
</FrameLayout> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/search_layout" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:clipChildren="false"> | ||
|
||
<android.support.v7.widget.RecyclerView | ||
android:id="@+id/rv_filter" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:paddingLeft="6dp" | ||
android:paddingRight="6dp" | ||
android:paddingBottom="6dp" | ||
android:background="@color/transparent" | ||
android:clipChildren="false"/> | ||
|
||
<!--<View--> | ||
<!--android:layout_width="match_parent"--> | ||
<!--android:layout_height="1dip"--> | ||
<!--android:layout_gravity="bottom"--> | ||
<!--android:background="#FFFFFF"--> | ||
<!--android:backgroundTint="#10000000"/>--> | ||
</FrameLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_margin="@dimen/msv_filter_margin" | ||
android:layout_width="wrap_content" | ||
android:layout_height="@dimen/msv_filter_height" | ||
android:background="@drawable/msv_filter_background" | ||
android:gravity="center"> | ||
|
||
<de.hdodenhof.circleimageview.CircleImageView | ||
android:id="@+id/civ_icon" | ||
android:layout_width="@dimen/msv_filter_height" | ||
android:layout_height="@dimen/msv_filter_height"/> | ||
|
||
<TextView | ||
android:id="@android:id/text1" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginLeft="@dimen/msv_horizontal_margin" | ||
tools:text="Prova" | ||
android:theme="@style/MSV_FilterTextName"/> | ||
|
||
<ImageView | ||
android:id="@android:id/closeButton" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginRight="@dimen/msv_filter_close_button_horizontal_margin" | ||
android:layout_marginLeft="@dimen/msv_filter_close_button_horizontal_margin" | ||
android:src="@drawable/ic_close_circle_grey600_24dp"/> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="wrap_content" | ||
android:layout_height="@dimen/msv_filter_height" | ||
android:layout_margin="@dimen/msv_filter_margin" | ||
android:background="@drawable/msv_filter_background" | ||
android:gravity="center" | ||
android:elevation="4dp"> | ||
|
||
<de.hdodenhof.circleimageview.CircleImageView | ||
android:id="@+id/civ_icon" | ||
android:layout_width="@dimen/msv_filter_height" | ||
android:layout_height="@dimen/msv_filter_height"/> | ||
|
||
<TextView | ||
android:id="@android:id/text1" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginLeft="@dimen/msv_horizontal_margin" | ||
tools:text="Prova" | ||
android:theme="@style/MSV_FilterTextName"/> | ||
|
||
<ImageView | ||
android:id="@android:id/closeButton" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginRight="@dimen/msv_filter_close_button_horizontal_margin" | ||
android:layout_marginLeft="@dimen/msv_filter_close_button_horizontal_margin" | ||
android:src="@drawable/ic_close_circle_grey600_24dp"/> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters