fab added

This commit is contained in:
Korusn Oleksandr 2016-12-21 19:57:15 +02:00
parent 86ba0403f8
commit 4c71648a73
3 changed files with 43 additions and 17 deletions

View file

@ -1,20 +1,32 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout
android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/custom_toolbar" android:id="@+id/custom_toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:background="@color/actionbar_light_color" android:layout_height="?android:attr/actionBarSize"
android:layout_height="?android:attr/actionBarSize"/> android:background="@color/actionbar_light_color"/>
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view" android:id="@+id/recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_below="@id/custom_toolbar"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/ctx_menu_info_view_bg" android:background="?attr/ctx_menu_info_view_bg"
/> android:clipToPadding="false"
android:paddingTop="16dp"/>
</LinearLayout> <android.support.design.widget.FloatingActionButton
android:id="@+id/fabButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:src="@drawable/map_quick_action"/>
</RelativeLayout>

View file

@ -2,18 +2,16 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="40dp"
android:layout_marginTop="16dp"
android:paddingBottom="8dp"
android:paddingLeft="16dp" android:paddingLeft="16dp"
android:background="?attr/bg_color"
android:paddingRight="16dp" android:paddingRight="16dp"
android:paddingTop="8dp"> android:background="?attr/bg_color">
<TextView <TextView
android:id="@+id/header" android:id="@+id/header"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size" android:textSize="@dimen/default_sub_text_size"
tools:text="Screen 1"/> tools:text="Screen 1"/>

View file

@ -5,6 +5,7 @@ import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v4.view.MotionEventCompat; import android.support.v4.view.MotionEventCompat;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
@ -22,7 +23,6 @@ import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.base.BaseOsmAndFragment;
@ -30,6 +30,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static android.R.attr.scrollY;
import static android.util.TypedValue.COMPLEX_UNIT_DIP; import static android.util.TypedValue.COMPLEX_UNIT_DIP;
import static net.osmand.plus.R.id.toolbar; import static net.osmand.plus.R.id.toolbar;
@ -40,9 +41,10 @@ import static net.osmand.plus.R.id.toolbar;
public class QuickActionListFragment extends BaseOsmAndFragment { public class QuickActionListFragment extends BaseOsmAndFragment {
public static final String TAG = QuickActionListFragment.class.getSimpleName(); public static final String TAG = QuickActionListFragment.class.getSimpleName();
RecyclerView quickActionRV;
QuickActionAdapter adapter; QuickActionAdapter adapter;
ItemTouchHelper touchHelper; ItemTouchHelper touchHelper;
RecyclerView quickActionRV;
FloatingActionButton fab;
@Nullable @Nullable
@Override @Override
@ -68,9 +70,23 @@ public class QuickActionListFragment extends BaseOsmAndFragment {
ItemTouchHelper.Callback touchHelperCallback = new QuickActionItemTouchHelperCallback(adapter); ItemTouchHelper.Callback touchHelperCallback = new QuickActionItemTouchHelperCallback(adapter);
touchHelper = new ItemTouchHelper(touchHelperCallback); touchHelper = new ItemTouchHelper(touchHelperCallback);
touchHelper.attachToRecyclerView(quickActionRV); touchHelper.attachToRecyclerView(quickActionRV);
adapter.addItems(createMockDada()); adapter.addItems(createMockDada());
fab = (FloatingActionButton) view.findViewById(R.id.fabButton);
quickActionRV.setOnScrollListener(new RecyclerView.OnScrollListener() {
});
quickActionRV.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (dy > 0 && fab.getVisibility() == View.VISIBLE)
fab.hide();
else if (dy < 0 && fab.getVisibility() != View.VISIBLE)
fab.show();
}
});
Toolbar toolbar = (Toolbar) view.findViewById(R.id.custom_toolbar); Toolbar toolbar = (Toolbar) view.findViewById(R.id.custom_toolbar);
Drawable back = getMyApplication().getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha); Drawable back = getMyApplication().getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
back.setColorFilter(ContextCompat.getColor(getContext(), R.color.color_white), PorterDuff.Mode.MULTIPLY); back.setColorFilter(ContextCompat.getColor(getContext(), R.color.color_white), PorterDuff.Mode.MULTIPLY);