Test adding scroll
This commit is contained in:
parent
70fc627f2d
commit
6ea6b95928
4 changed files with 179 additions and 72 deletions
11
OsmAnd/res/layout/gpx_split_segments_empty_header.xml
Normal file
11
OsmAnd/res/layout/gpx_split_segments_empty_header.xml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -1,61 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:background="?attr/bg_color"
|
|
||||||
android:paddingLeft="16dp"
|
|
||||||
android:paddingRight="16dp">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/header_split_image"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
tools:src="@drawable/ic_action_split_interval"
|
|
||||||
android:layout_marginBottom="12dp"
|
|
||||||
android:layout_marginTop="12dp"
|
|
||||||
android:layout_marginRight="16dp"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/split_interval_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="?attr/selectableItemBackground">
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
|
||||||
android:id="@+id/split_interval_title"
|
|
||||||
android:background="@null"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
android:text="Split interval:"/>
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
|
||||||
android:id="@+id/split_interval_text"
|
|
||||||
android:background="@null"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:gravity="right"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
tools:text="10 km"/>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/split_interval_arrow"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:src="@drawable/ic_action_arrow_drop_down"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
86
OsmAnd/res/layout/split_segments_layout.xml
Normal file
86
OsmAnd/res/layout/split_segments_layout.xml
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@android:id/list"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginLeft="0dp"
|
||||||
|
android:layout_marginRight="0dp"
|
||||||
|
android:layout_marginTop="0dp"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/header_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:background="?attr/bg_color"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/header_split_image"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
tools:src="@drawable/ic_action_split_interval"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:layout_marginRight="16dp"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/split_interval_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/selectableItemBackground">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/split_interval_title"
|
||||||
|
android:background="@null"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
android:text="Split interval:"/>
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/split_interval_text"
|
||||||
|
android:background="@null"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:gravity="right"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
tools:text="10 km"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/split_interval_arrow"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:src="@drawable/ic_action_arrow_drop_down"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<include layout="@layout/card_bottom_divider"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
|
@ -1,19 +1,22 @@
|
||||||
package net.osmand.plus.myplaces;
|
package net.osmand.plus.myplaces;
|
||||||
|
|
||||||
|
import android.animation.Animator;
|
||||||
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.widget.ListPopupWindow;
|
import android.support.v7.widget.ListPopupWindow;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AbsListView;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -82,22 +85,96 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
View view = getActivity().getLayoutInflater().inflate(R.layout.update_index, container, false);
|
final View view = getActivity().getLayoutInflater().inflate(R.layout.split_segments_layout, container, false);
|
||||||
view.findViewById(R.id.header_layout).setVisibility(View.GONE);
|
|
||||||
|
|
||||||
ListView listView = (ListView) view.findViewById(android.R.id.list);
|
ListView listView = (ListView) view.findViewById(android.R.id.list);
|
||||||
listView.setDivider(null);
|
listView.setDivider(null);
|
||||||
listView.setDividerHeight(0);
|
listView.setDividerHeight(0);
|
||||||
|
|
||||||
adapter = new SplitSegmentsAdapter(new ArrayList<GpxDisplayItem>());
|
adapter = new SplitSegmentsAdapter(new ArrayList<GpxDisplayItem>());
|
||||||
headerView = getActivity().getLayoutInflater().inflate(R.layout.gpx_split_segments_header, null, false);
|
headerView = view.findViewById(R.id.header_layout);
|
||||||
((ImageView) headerView.findViewById(R.id.header_split_image)).setImageDrawable(ic.getIcon(R.drawable.ic_action_split_interval, app.getSettings().isLightContent() ? R.color.icon_color : 0));
|
((ImageView) headerView.findViewById(R.id.header_split_image)).setImageDrawable(ic.getIcon(R.drawable.ic_action_split_interval, app.getSettings().isLightContent() ? R.color.icon_color : 0));
|
||||||
|
|
||||||
listView.addHeaderView(headerView);
|
listView.addHeaderView(getActivity().getLayoutInflater().inflate(R.layout.gpx_split_segments_empty_header, null, false));
|
||||||
listView.addFooterView(getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, null, false));
|
listView.addFooterView(getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, null, false));
|
||||||
updateHeader();
|
updateHeader();
|
||||||
|
updateContent();
|
||||||
|
|
||||||
setListAdapter(adapter);
|
setListAdapter(adapter);
|
||||||
|
|
||||||
|
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||||
|
|
||||||
|
int initialYPos;
|
||||||
|
boolean changed;
|
||||||
|
int visibility = View.VISIBLE;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||||
|
initialYPos = -1;
|
||||||
|
changed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onScroll(AbsListView absListView, int i, int i1, int i2) {
|
||||||
|
View c = absListView.getChildAt(0);
|
||||||
|
if (c != null) {
|
||||||
|
int currentYPos = -c.getTop() + absListView.getFirstVisiblePosition() * c.getHeight();
|
||||||
|
if (initialYPos == -1) {
|
||||||
|
initialYPos = currentYPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentYPos < headerView.getHeight() && visibility == View.GONE) {
|
||||||
|
changed = false;
|
||||||
|
initialYPos = currentYPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentYPos < initialYPos && !changed && visibility == View.GONE) {
|
||||||
|
if (currentYPos < headerView.getHeight()) {
|
||||||
|
headerView.setTranslationY(currentYPos - headerView.getHeight());
|
||||||
|
} else {
|
||||||
|
headerView.animate().translationY(0);
|
||||||
|
visibility = View.VISIBLE;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
} else if (currentYPos > initialYPos && !changed && visibility == View.VISIBLE) {
|
||||||
|
if (currentYPos < headerView.getHeight()) {
|
||||||
|
headerView.setTranslationY(-currentYPos);
|
||||||
|
} else {
|
||||||
|
headerView.animate().translationY(-headerView.getHeight());
|
||||||
|
visibility = View.GONE;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.d("onScroll", "currentYpos: " + currentYPos);
|
||||||
|
Log.d("onScroll", "visibility: " + visibility);
|
||||||
|
Log.d("onScroll", "headerView.getHeight(): " + headerView.getHeight());
|
||||||
|
Log.d("onScroll", "headerView.getTranslationY(): " + headerView.getTranslationY());
|
||||||
|
// if (headerView.getHeight() != 0) {
|
||||||
|
// if (visibility == View.VISIBLE) {
|
||||||
|
// if (currentYPos < headerView.getHeight()) {
|
||||||
|
// headerView.setTranslationY(-currentYPos);
|
||||||
|
// } else if (!changed) {
|
||||||
|
// headerView.animate().translationY(-headerView.getHeight());
|
||||||
|
// visibility = View.GONE;
|
||||||
|
// changed = true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (visibility == View.GONE) {
|
||||||
|
// if (currentYPos < headerView.getHeight()) {
|
||||||
|
// headerView.setTranslationY(currentYPos - headerView.getHeight());
|
||||||
|
// } else if (!changed) {
|
||||||
|
// headerView.animate().translationY(0);
|
||||||
|
// visibility = View.VISIBLE;
|
||||||
|
// changed = true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,12 +222,6 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
updateContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateContent() {
|
public void updateContent() {
|
||||||
adapter.clear();
|
adapter.clear();
|
||||||
adapter.setNotifyOnChange(false);
|
adapter.setNotifyOnChange(false);
|
||||||
|
|
Loading…
Reference in a new issue