forked from upstream-mirrors/OpenTracks
Cleanup.
This commit is contained in:
@@ -449,8 +449,7 @@ public class ChartView extends View {
|
|||||||
synchronized (waypoints) {
|
synchronized (waypoints) {
|
||||||
for (int i = 0; i < waypoints.size(); i++) {
|
for (int i = 0; i < waypoints.size(); i++) {
|
||||||
Waypoint waypoint = waypoints.get(i);
|
Waypoint waypoint = waypoints.get(i);
|
||||||
int distance = Math.abs(
|
int distance = Math.abs(getX(getWaypointXValue(waypoint)) - (int) event.getX() - getScrollX());
|
||||||
getX(getWaypointXValue(waypoint)) - (int) event.getX() - getScrollX());
|
|
||||||
if (distance < minDistance) {
|
if (distance < minDistance) {
|
||||||
minDistance = distance;
|
minDistance = distance;
|
||||||
nearestWaypoint = waypoint;
|
nearestWaypoint = waypoint;
|
||||||
|
|||||||
+11
-19
@@ -16,12 +16,12 @@
|
|||||||
|
|
||||||
package de.dennisguse.opentracks.fragments;
|
package de.dennisguse.opentracks.fragments;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
@@ -57,8 +57,8 @@ public class ChooseActivityTypeDialogFragment extends DialogFragment {
|
|||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dialog getDialog(final Activity activity, final String category, final ChooseActivityTypeCaller caller) {
|
public static Dialog getDialog(final Context context, final String category, final ChooseActivityTypeCaller caller) {
|
||||||
View view = activity.getLayoutInflater().inflate(R.layout.choose_activity_type, null);
|
View view = LayoutInflater.from(context).inflate(R.layout.choose_activity_type, null);
|
||||||
GridView gridView = view.findViewById(R.id.choose_activity_type_grid_view);
|
GridView gridView = view.findViewById(R.id.choose_activity_type_grid_view);
|
||||||
|
|
||||||
List<Integer> imageIds = new ArrayList<>();
|
List<Integer> imageIds = new ArrayList<>();
|
||||||
@@ -69,16 +69,16 @@ public class ChooseActivityTypeDialogFragment extends DialogFragment {
|
|||||||
final ChooseActivityTypeImageAdapter imageAdapter = new ChooseActivityTypeImageAdapter(imageIds);
|
final ChooseActivityTypeImageAdapter imageAdapter = new ChooseActivityTypeImageAdapter(imageIds);
|
||||||
gridView.setAdapter(imageAdapter);
|
gridView.setAdapter(imageAdapter);
|
||||||
|
|
||||||
final AlertDialog alertDialog = new AlertDialog.Builder(activity).setTitle(R.string.track_edit_activity_type_hint).setView(view).create();
|
final AlertDialog alertDialog = new AlertDialog.Builder(context).setTitle(R.string.track_edit_activity_type_hint).setView(view).create();
|
||||||
alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onShow(DialogInterface dialog) {
|
public void onShow(DialogInterface dialog) {
|
||||||
int position = getPosition(activity, category);
|
int position = getPosition(context, category);
|
||||||
if (position != -1) {
|
if (position != -1) {
|
||||||
imageAdapter.setSelected(position);
|
imageAdapter.setSelected(position);
|
||||||
imageAdapter.notifyDataSetChanged();
|
imageAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
DialogUtils.setDialogTitleDivider(activity, alertDialog);
|
DialogUtils.setDialogTitleDivider(context, alertDialog);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -92,25 +92,17 @@ public class ChooseActivityTypeDialogFragment extends DialogFragment {
|
|||||||
return alertDialog;
|
return alertDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getPosition(Activity activity, String category) {
|
private static int getPosition(Context context, String category) {
|
||||||
if (category == null) {
|
if (category == null) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
String iconValue = TrackIconUtils.getIconValue(activity, category);
|
String iconValue = TrackIconUtils.getIconValue(context, category);
|
||||||
if (iconValue.equals("")) {
|
|
||||||
return -1;
|
return TrackIconUtils.getAllIconValues().indexOf(iconValue);
|
||||||
}
|
|
||||||
List<String> iconValues = TrackIconUtils.getAllIconValues();
|
|
||||||
for (int i = 0; i < iconValues.size(); i++) {
|
|
||||||
if (iconValues.get(i).equals(iconValue)) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(@NonNull Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
try {
|
try {
|
||||||
caller = (ChooseActivityTypeCaller) context;
|
caller = (ChooseActivityTypeCaller) context;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="239dp"
|
android:layout_height="239dp"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
|
android:contentDescription="@string/app_name"
|
||||||
android:src="@drawable/ic_logo_color_24dp" />
|
android:src="@drawable/ic_logo_color_24dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
Reference in New Issue
Block a user