display opposite length unit (feet <-> meter) on touch and hold gesture (see #12)
This commit is contained in:
parent
a415b33fdc
commit
a5292bfc0f
2 changed files with 25 additions and 24 deletions
|
@ -243,22 +243,23 @@ public class MainActivityTrackFragment extends Fragment implements AdapterView.O
|
||||||
mStatisticsSheetBehavior = BottomSheetBehavior.from(mStatisticsSheet);
|
mStatisticsSheetBehavior = BottomSheetBehavior.from(mStatisticsSheet);
|
||||||
mStatisticsSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
mStatisticsSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||||
mStatisticsSheetBehavior.setBottomSheetCallback(getStatisticsSheetCallback());
|
mStatisticsSheetBehavior.setBottomSheetCallback(getStatisticsSheetCallback());
|
||||||
mStatisticsView.setOnClickListener(new View.OnClickListener() {
|
// todo attach listener to title and (i)icon
|
||||||
@Override
|
// mStatisticsView.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View view) {
|
// @Override
|
||||||
if (mStatisticsSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
|
// public void onClick(View view) {
|
||||||
mStatisticsSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
// if (mStatisticsSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
|
||||||
} else {
|
// mStatisticsSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||||
mStatisticsSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
// } else {
|
||||||
}
|
// mStatisticsSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||||
}
|
// }
|
||||||
});
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
// attach listener for taps on elevation views
|
// attach listener for taps on elevation views
|
||||||
attachTapListenerToElevationViews();
|
attachTapListenerToElevationViews();
|
||||||
|
|
||||||
// // attach listener for taps on statistics // TODO uncomment
|
// attach listener for taps on statistics // TODO uncomment
|
||||||
// attachTapListenerToStatisticsSheet();
|
attachTapListenerToStatisticsSheet();
|
||||||
|
|
||||||
return mRootView;
|
return mRootView;
|
||||||
}
|
}
|
||||||
|
@ -605,19 +606,17 @@ public class MainActivityTrackFragment extends Fragment implements AdapterView.O
|
||||||
mStatisticsView.setOnTouchListener(new View.OnTouchListener() {
|
mStatisticsView.setOnTouchListener(new View.OnTouchListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
if(event.getAction() == MotionEvent.ACTION_DOWN){
|
// todo describe
|
||||||
displayOppositeLengthUnits();
|
if (mStatisticsSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
|
||||||
return true;
|
if (event.getAction() == MotionEvent.ACTION_DOWN){
|
||||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
displayOppositeLengthUnits();
|
||||||
displayCurrentLengthUnits();
|
return true;
|
||||||
|
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||||
if (mStatisticsSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
|
displayCurrentLengthUnits();
|
||||||
mStatisticsSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
return true;
|
||||||
} else {
|
|
||||||
mStatisticsSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
return true;
|
displayCurrentLengthUnits();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/statistics_view"
|
android:id="@+id/statistics_view"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue