Commit 60414fa73b5ac23bdb2ef0a86011bba4a79ca4cb
1 parent
17bbf4fe
- hide FAB when recyclerview scroll down
Showing
5 changed files
with
56 additions
and
4 deletions
app/src/main/java/net/devfac/userstory/FSM/StateContext.java
... | ... | @@ -467,7 +467,7 @@ public class StateContext { |
467 | 467 | } |
468 | 468 | else if( bookInfo.getAttributeValue("class").equals(Constants.BOOK_SEARCH_CLASS_BOOK_GENRE)){ |
469 | 469 | // Logger.i("BOOK GENRE : " + bookInfo.getContent() ); |
470 | - mBookSearchResult.genre = bookInfo.getContent().toString(); | |
470 | + mBookSearchResult.genre = bookInfo.getContent().toString().replace(">", ">"); | |
471 | 471 | } |
472 | 472 | } |
473 | 473 | } | ... | ... |
app/src/main/java/net/devfac/userstory/FragmentAddBook.java
... | ... | @@ -63,7 +63,7 @@ public class FragmentAddBook extends Fragment implements StateEventListener { |
63 | 63 | StateContext.getInstance(getActivity()).processEvent(Action.REQ_BOOK_SEARCH_TO_ADD, searchBookReq); |
64 | 64 | } |
65 | 65 | else if( event.getKeyCode() == KeyEvent.KEYCODE_ENTER){ |
66 | - String keyword = v.getText().toString(); | |
66 | + String keyword = v.getText().toString().replace("\n", ""); | |
67 | 67 | |
68 | 68 | SearchBookReq searchBookReq = new SearchBookReq(); |
69 | 69 | searchBookReq.keyword = keyword; |
... | ... | @@ -87,7 +87,7 @@ public class FragmentAddBook extends Fragment implements StateEventListener { |
87 | 87 | if( stateClass.equals(StateBookSearchToAdd.class)){ |
88 | 88 | switch( stateResult ){ |
89 | 89 | case BOOK_SEARCH_FAIL: |
90 | - Toast.makeText(getActivity(), "Login Fail. Try login again.", Toast.LENGTH_LONG).show(); | |
90 | + Toast.makeText(getActivity(), "BOOK search failFail. Try search again.", Toast.LENGTH_LONG).show(); | |
91 | 91 | break; |
92 | 92 | case BOOK_SEARCH_SUCCESS: |
93 | 93 | getActivity().runOnUiThread(new Runnable() { | ... | ... |
app/src/main/java/net/devfac/userstory/MainActivity.java
1 | 1 | package net.devfac.userstory; |
2 | 2 | |
3 | +import android.content.Context; | |
3 | 4 | import android.content.Intent; |
5 | +import android.content.res.TypedArray; | |
4 | 6 | import android.os.Bundle; |
5 | 7 | import android.support.design.widget.AppBarLayout; |
6 | 8 | import android.support.design.widget.CoordinatorLayout; |
... | ... | @@ -11,6 +13,7 @@ import android.support.v4.app.Fragment; |
11 | 13 | import android.support.v4.app.FragmentManager; |
12 | 14 | import android.support.v4.app.FragmentPagerAdapter; |
13 | 15 | import android.support.v4.view.ViewPager; |
16 | +import android.util.AttributeSet; | |
14 | 17 | import android.view.View; |
15 | 18 | import android.support.design.widget.NavigationView; |
16 | 19 | import android.support.v4.view.GravityCompat; | ... | ... |
app/src/main/java/net/devfac/userstory/ScrollingFABBehavior.java
0 → 100644
1 | +package net.devfac.userstory; | |
2 | + | |
3 | +import android.content.Context; | |
4 | +import android.content.res.TypedArray; | |
5 | +import android.support.design.widget.AppBarLayout; | |
6 | +import android.support.design.widget.CoordinatorLayout; | |
7 | +import android.support.design.widget.FloatingActionButton; | |
8 | +import android.util.AttributeSet; | |
9 | +import android.view.View; | |
10 | + | |
11 | +/** | |
12 | + * Created by Onether on 15. 11. 14.. | |
13 | + */ | |
14 | +public class ScrollingFABBehavior extends CoordinatorLayout.Behavior<FloatingActionButton> { | |
15 | + private int toolbarHeight; | |
16 | + | |
17 | + public ScrollingFABBehavior(Context context, AttributeSet attrs) { | |
18 | + super(context, attrs); | |
19 | + this.toolbarHeight = getToolbarHeight(context); | |
20 | + } | |
21 | + | |
22 | + @Override | |
23 | + public boolean layoutDependsOn(CoordinatorLayout parent, FloatingActionButton fab, View dependency) { | |
24 | + return dependency instanceof AppBarLayout; | |
25 | + } | |
26 | + | |
27 | + @Override | |
28 | + public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton fab, View dependency) { | |
29 | + if (dependency instanceof AppBarLayout) { | |
30 | + CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); | |
31 | + int fabBottomMargin = lp.bottomMargin; | |
32 | + int distanceToScroll = fab.getHeight() + fabBottomMargin; | |
33 | + float ratio = (float)dependency.getY()/(float)toolbarHeight; | |
34 | + fab.setTranslationY(-distanceToScroll * ratio); | |
35 | + } | |
36 | + return true; | |
37 | + } | |
38 | + | |
39 | + public static int getToolbarHeight(Context context) { | |
40 | + final TypedArray styledAttributes = context.getTheme().obtainStyledAttributes( | |
41 | + new int[]{R.attr.actionBarSize}); | |
42 | + int toolbarHeight = (int) styledAttributes.getDimension(0, 0); | |
43 | + styledAttributes.recycle(); | |
44 | + | |
45 | + return toolbarHeight; | |
46 | + } | |
47 | +} | |
48 | + | ... | ... |
app/src/main/res/layout/app_bar_main.xml
... | ... | @@ -34,6 +34,7 @@ |
34 | 34 | android:adjustViewBounds="false" |
35 | 35 | android:scaleType="center" |
36 | 36 | android:nestedScrollingEnabled="false" |
37 | - android:baselineAlignBottom="false" /> | |
37 | + android:baselineAlignBottom="false" | |
38 | + app:layout_behavior="net.devfac.userstory.ScrollingFABBehavior"/> | |
38 | 39 | |
39 | 40 | </android.support.design.widget.CoordinatorLayout> | ... | ... |