Add scroll
This commit is contained in:
parent
631a82149e
commit
aa93e8e8b6
1 changed files with 16 additions and 9 deletions
|
@ -11,6 +11,7 @@ import android.support.v7.widget.ListPopupWindow;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
|
@ -60,6 +61,7 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
private TIntArrayList timeSplit = new TIntArrayList();
|
private TIntArrayList timeSplit = new TIntArrayList();
|
||||||
private int selectedSplitInterval;
|
private int selectedSplitInterval;
|
||||||
private IconsCache ic;
|
private IconsCache ic;
|
||||||
|
private float listViewYPos;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
@ -87,7 +89,7 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
final View view = getActivity().getLayoutInflater().inflate(R.layout.split_segments_layout, container, false);
|
final View view = getActivity().getLayoutInflater().inflate(R.layout.split_segments_layout, container, false);
|
||||||
|
|
||||||
ListView listView = (ListView) view.findViewById(android.R.id.list);
|
final ListView listView = (ListView) view.findViewById(android.R.id.list);
|
||||||
listView.setDivider(null);
|
listView.setDivider(null);
|
||||||
listView.setDividerHeight(0);
|
listView.setDividerHeight(0);
|
||||||
|
|
||||||
|
@ -123,33 +125,38 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
initialYPos = currentYPos;
|
initialYPos = currentYPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentYPos < headerView.getHeight() && visibility == View.GONE) {
|
if (currentYPos < headerView.getHeight() && changed && visibility == View.GONE) {
|
||||||
changed = false;
|
changed = false;
|
||||||
initialYPos = currentYPos;
|
initialYPos = currentYPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (currentYPos < initialYPos && !changed && visibility == View.GONE) {
|
if (currentYPos < initialYPos && !changed && visibility == View.GONE) {
|
||||||
if (currentYPos < headerView.getHeight()) {
|
if (currentYPos <= headerView.getHeight()) {
|
||||||
headerView.setTranslationY(currentYPos - headerView.getHeight());
|
headerView.clearAnimation();
|
||||||
|
headerView.setTranslationY(-currentYPos);
|
||||||
} else {
|
} else {
|
||||||
|
headerView.clearAnimation();
|
||||||
headerView.animate().translationY(0);
|
headerView.animate().translationY(0);
|
||||||
visibility = View.VISIBLE;
|
visibility = View.VISIBLE;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
} else if (currentYPos > initialYPos && !changed && visibility == View.VISIBLE) {
|
} else if (currentYPos > initialYPos && !changed && visibility == View.VISIBLE) {
|
||||||
if (currentYPos < headerView.getHeight()) {
|
if (currentYPos <= headerView.getHeight()) {
|
||||||
|
headerView.clearAnimation();
|
||||||
headerView.setTranslationY(-currentYPos);
|
headerView.setTranslationY(-currentYPos);
|
||||||
} else {
|
} else {
|
||||||
|
headerView.clearAnimation();
|
||||||
headerView.animate().translationY(-headerView.getHeight());
|
headerView.animate().translationY(-headerView.getHeight());
|
||||||
visibility = View.GONE;
|
visibility = View.GONE;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d("onScroll", "currentYpos: " + currentYPos);
|
// Log.d("onScroll", "currentYpos: " + currentYPos);
|
||||||
Log.d("onScroll", "visibility: " + visibility);
|
// Log.d("onScroll", "visibility: " + visibility);
|
||||||
Log.d("onScroll", "headerView.getHeight(): " + headerView.getHeight());
|
// Log.d("onScroll", "headerView.getHeight(): " + headerView.getHeight());
|
||||||
Log.d("onScroll", "headerView.getTranslationY(): " + headerView.getTranslationY());
|
// Log.d("onScroll", "headerView.getTranslationY(): " + headerView.getTranslationY());
|
||||||
// if (headerView.getHeight() != 0) {
|
// if (headerView.getHeight() != 0) {
|
||||||
// if (visibility == View.VISIBLE) {
|
// if (visibility == View.VISIBLE) {
|
||||||
// if (currentYPos < headerView.getHeight()) {
|
// if (currentYPos < headerView.getHeight()) {
|
||||||
|
|
Loading…
Reference in a new issue