[android] Added more intuitive behaviour for chart - scroll, close , zoom operations

This commit is contained in:
Dmitry Donskoy 2020-03-04 16:39:46 +03:00 committed by Aleksandr Zatsepin
parent 0e21effc38
commit 1c0283a8e1
2 changed files with 38 additions and 1 deletions

View file

@ -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" />

View file

@ -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;
}
}