forked from organicmaps/organicmaps
[android] Added more intuitive behaviour for chart - scroll, close , zoom operations
This commit is contained in:
parent
0e21effc38
commit
1c0283a8e1
2 changed files with 38 additions and 1 deletions
|
@ -5,7 +5,7 @@
|
|||
android:layout_height="@dimen/elevation_profile_height"
|
||||
android:background="?cardBackground"
|
||||
android:orientation="vertical">
|
||||
<com.github.mikephil.charting.charts.LineChart
|
||||
<com.mapswithme.maps.widget.placepage.ElevationProfileChart
|
||||
android:id="@+id/elevation_profile_chart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package com.mapswithme.maps.widget.placepage;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
|
||||
public class ElevationProfileChart extends LineChart
|
||||
{
|
||||
public ElevationProfileChart(Context context)
|
||||
{
|
||||
super(context);
|
||||
}
|
||||
|
||||
public ElevationProfileChart(Context context, AttributeSet attrs)
|
||||
{
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public ElevationProfileChart(Context context, AttributeSet attrs, int defStyle)
|
||||
{
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev)
|
||||
{
|
||||
getParent().requestDisallowInterceptTouchEvent(true);
|
||||
return hasZoom() || super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
|
||||
private boolean hasZoom()
|
||||
{
|
||||
return getScaleX() < 1 || getScaleY() < 1;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue