forked from upstream-mirrors/OpenTracks
Add a dialog for user to choose the activty type.
By apoorvn.
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright 2013 Google Inc.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:numColumns="4"
|
||||||
|
android:paddingBottom="20dp"
|
||||||
|
android:paddingTop="20dp"
|
||||||
|
android:stretchMode="columnWidth"
|
||||||
|
android:verticalSpacing="20dp" />
|
||||||
@@ -35,12 +35,27 @@ limitations under the License.
|
|||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/track_edit_activity_type_label"
|
android:id="@+id/track_edit_activity_type_label"
|
||||||
android:text="@string/track_edit_activity_type"
|
android:text="@string/track_edit_activity_type"
|
||||||
style="@style/EditLabel.WithIcon.WithPaddingTop" />
|
style="@style/EditLabel.WithPaddingTop" />
|
||||||
<AutoCompleteTextView
|
<LinearLayout
|
||||||
android:hint="@string/track_edit_activity_type_hint"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/track_edit_activity_type"
|
android:layout_width="match_parent"
|
||||||
android:imeOptions="actionNext"
|
android:orientation="horizontal" >
|
||||||
style="@style/EditCategory" />
|
<AutoCompleteTextView
|
||||||
|
android:hint="@string/track_edit_activity_type_hint"
|
||||||
|
android:id="@+id/track_edit_activity_type"
|
||||||
|
android:imeOptions="actionNext"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
style="@style/EditCategory" />
|
||||||
|
<ImageButton
|
||||||
|
android:contentDescription="@string/activity_type_walking"
|
||||||
|
android:id="@+id/track_edit_activity_type_icon"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:src="@drawable/track_walk" />
|
||||||
|
</LinearLayout>
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/generic_description"
|
android:text="@string/generic_description"
|
||||||
style="@style/EditLabel.WithPaddingTop" />
|
style="@style/EditLabel.WithPaddingTop" />
|
||||||
|
|||||||
@@ -68,10 +68,6 @@ limitations under the License.
|
|||||||
<style name="EditLabel.WithIcon" parent="@style/TextMedium.WithIcon">
|
<style name="EditLabel.WithIcon" parent="@style/TextMedium.WithIcon">
|
||||||
<item name="android:layout_width">match_parent</item>
|
<item name="android:layout_width">match_parent</item>
|
||||||
</style>
|
</style>
|
||||||
<!-- edit label with icon, width padding top -->
|
|
||||||
<style name="EditLabel.WithIcon.WithPaddingTop">
|
|
||||||
<item name="android:paddingTop">16dp</item>
|
|
||||||
</style>
|
|
||||||
<!-- edit label with padding top -->
|
<!-- edit label with padding top -->
|
||||||
<style name="EditLabel.WithPaddingTop">
|
<style name="EditLabel.WithPaddingTop">
|
||||||
<item name="android:paddingTop">16dp</item>
|
<item name="android:paddingTop">16dp</item>
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ package com.google.android.apps.mytracks;
|
|||||||
|
|
||||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||||
import com.google.android.apps.mytracks.content.Track;
|
import com.google.android.apps.mytracks.content.Track;
|
||||||
|
import com.google.android.apps.mytracks.fragments.ChooseActivityTypeDialogFragment;
|
||||||
|
import com.google.android.apps.mytracks.fragments.ChooseActivityTypeDialogFragment.ChooseActivityTypeCaller;
|
||||||
import com.google.android.apps.mytracks.util.TrackIconUtils;
|
import com.google.android.apps.mytracks.util.TrackIconUtils;
|
||||||
import com.google.android.apps.mytracks.util.TrackNameUtils;
|
import com.google.android.apps.mytracks.util.TrackNameUtils;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
@@ -30,7 +32,7 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.AutoCompleteTextView;
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.ImageButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An activity that let's the user see and edit the user editable track meta
|
* An activity that let's the user see and edit the user editable track meta
|
||||||
@@ -38,20 +40,23 @@ import android.widget.TextView;
|
|||||||
*
|
*
|
||||||
* @author Leif Hendrik Wilden
|
* @author Leif Hendrik Wilden
|
||||||
*/
|
*/
|
||||||
public class TrackEditActivity extends AbstractMyTracksActivity {
|
public class TrackEditActivity extends AbstractMyTracksActivity
|
||||||
|
implements ChooseActivityTypeCaller {
|
||||||
|
|
||||||
public static final String EXTRA_TRACK_ID = "track_id";
|
public static final String EXTRA_TRACK_ID = "track_id";
|
||||||
public static final String EXTRA_NEW_TRACK = "new_track";
|
public static final String EXTRA_NEW_TRACK = "new_track";
|
||||||
|
|
||||||
private static final String TAG = TrackEditActivity.class.getSimpleName();
|
private static final String TAG = TrackEditActivity.class.getSimpleName();
|
||||||
|
private static final String ICON_VALUE = "icon_value";
|
||||||
|
|
||||||
private Long trackId;
|
private Long trackId;
|
||||||
private MyTracksProviderUtils myTracksProviderUtils;
|
private MyTracksProviderUtils myTracksProviderUtils;
|
||||||
private Track track;
|
private Track track;
|
||||||
|
private String iconValue;
|
||||||
|
|
||||||
private EditText name;
|
private EditText name;
|
||||||
private TextView activityTypeLabel;
|
|
||||||
private AutoCompleteTextView activityType;
|
private AutoCompleteTextView activityType;
|
||||||
|
private ImageButton activityTypeIcon;
|
||||||
private EditText description;
|
private EditText description;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -79,37 +84,50 @@ public class TrackEditActivity extends AbstractMyTracksActivity {
|
|||||||
activityType = (AutoCompleteTextView) findViewById(R.id.track_edit_activity_type);
|
activityType = (AutoCompleteTextView) findViewById(R.id.track_edit_activity_type);
|
||||||
activityType.setText(track.getCategory());
|
activityType.setText(track.getCategory());
|
||||||
|
|
||||||
activityTypeLabel = (TextView) findViewById(R.id.track_edit_activity_type_label);
|
|
||||||
setActivityTypeIcon(track.getIcon());
|
|
||||||
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
|
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
|
||||||
this, R.array.activity_types, android.R.layout.simple_dropdown_item_1line);
|
this, R.array.activity_types, android.R.layout.simple_dropdown_item_1line);
|
||||||
activityType.setAdapter(adapter);
|
activityType.setAdapter(adapter);
|
||||||
activityType.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
activityType.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
String iconValue = TrackIconUtils.getIconValue(
|
setActivityTypeIcon(TrackIconUtils.getIconValue(
|
||||||
TrackEditActivity.this, (String) activityType.getAdapter().getItem(position));
|
TrackEditActivity.this, (String) activityType.getAdapter().getItem(position)));
|
||||||
setActivityTypeIcon(iconValue);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
activityType.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
activityType.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
if (!hasFocus) {
|
if (!hasFocus) {
|
||||||
String iconValue = TrackIconUtils.getIconValue(
|
setActivityTypeIcon(TrackIconUtils.getIconValue(
|
||||||
TrackEditActivity.this, activityType.getText().toString());
|
TrackEditActivity.this, activityType.getText().toString()));
|
||||||
setActivityTypeIcon(iconValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
activityTypeIcon = (ImageButton) findViewById(R.id.track_edit_activity_type_icon);
|
||||||
|
activityTypeIcon.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
new ChooseActivityTypeDialogFragment().show(getSupportFragmentManager(),
|
||||||
|
ChooseActivityTypeDialogFragment.CHOOSE_ACTIVITY_TYPE_DIALOG_TAG);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
iconValue = null;
|
||||||
|
if (bundle != null) {
|
||||||
|
iconValue = bundle.getString(ICON_VALUE);
|
||||||
|
}
|
||||||
|
if (iconValue == null) {
|
||||||
|
iconValue = track.getIcon();
|
||||||
|
}
|
||||||
|
setActivityTypeIcon(iconValue);
|
||||||
|
|
||||||
description = (EditText) findViewById(R.id.track_edit_description);
|
description = (EditText) findViewById(R.id.track_edit_description);
|
||||||
description.setText(track.getDescription());
|
description.setText(track.getDescription());
|
||||||
|
|
||||||
Button save = (Button) findViewById(R.id.track_edit_save);
|
Button save = (Button) findViewById(R.id.track_edit_save);
|
||||||
save.setOnClickListener(new View.OnClickListener() {
|
save.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
track.setName(name.getText().toString());
|
track.setName(name.getText().toString());
|
||||||
String category = activityType.getText().toString();
|
String category = activityType.getText().toString();
|
||||||
@@ -134,7 +152,7 @@ public class TrackEditActivity extends AbstractMyTracksActivity {
|
|||||||
} else {
|
} else {
|
||||||
setTitle(R.string.menu_edit);
|
setTitle(R.string.menu_edit);
|
||||||
cancel.setOnClickListener(new View.OnClickListener() {
|
cancel.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@@ -143,6 +161,12 @@ public class TrackEditActivity extends AbstractMyTracksActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putString(ICON_VALUE, iconValue);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResId() {
|
protected int getLayoutResId() {
|
||||||
return R.layout.track_edit;
|
return R.layout.track_edit;
|
||||||
@@ -151,10 +175,16 @@ public class TrackEditActivity extends AbstractMyTracksActivity {
|
|||||||
/**
|
/**
|
||||||
* Sets the activity type icon.
|
* Sets the activity type icon.
|
||||||
*
|
*
|
||||||
* @param iconValue the icon value
|
* @param value the icon value
|
||||||
*/
|
*/
|
||||||
private void setActivityTypeIcon(String iconValue) {
|
private void setActivityTypeIcon(String value) {
|
||||||
activityTypeLabel.setCompoundDrawablesWithIntrinsicBounds(
|
iconValue = value;
|
||||||
TrackIconUtils.getIconDrawable(iconValue), 0, 0, 0);
|
activityTypeIcon.setImageResource(TrackIconUtils.getIconDrawable(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChooseActivityTypeDone(String value) {
|
||||||
|
activityType.setText(getString(TrackIconUtils.getIconActivityType(value)));
|
||||||
|
setActivityTypeIcon(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+95
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013 Google Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations under
|
||||||
|
* the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.google.android.apps.mytracks.fragments;
|
||||||
|
|
||||||
|
import com.google.android.apps.mytracks.util.TrackIconUtils;
|
||||||
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
import android.widget.GridView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A DialogFragment to choose an activity type.
|
||||||
|
*
|
||||||
|
* @author apoorvn
|
||||||
|
*/
|
||||||
|
public class ChooseActivityTypeDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for caller of this dialog fragment.
|
||||||
|
*
|
||||||
|
* @author apoorvn
|
||||||
|
*/
|
||||||
|
public interface ChooseActivityTypeCaller {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when choose activity type is done.
|
||||||
|
*/
|
||||||
|
public void onChooseActivityTypeDone(String iconValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String CHOOSE_ACTIVITY_TYPE_DIALOG_TAG = "chooseActivityType";
|
||||||
|
|
||||||
|
private ChooseActivityTypeCaller caller;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Activity activity) {
|
||||||
|
super.onAttach(activity);
|
||||||
|
try {
|
||||||
|
caller = (ChooseActivityTypeCaller) activity;
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
throw new ClassCastException(activity.toString() + " must implement "
|
||||||
|
+ ChooseActivityTypeCaller.class.getSimpleName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
GridView gridView = (GridView) getActivity()
|
||||||
|
.getLayoutInflater().inflate(R.layout.choose_activity_type, null);
|
||||||
|
|
||||||
|
final List<String> iconValues = TrackIconUtils.getAllIconValues();
|
||||||
|
List<Integer> imageIds = new ArrayList<Integer>();
|
||||||
|
for (String iconValue : iconValues) {
|
||||||
|
imageIds.add(TrackIconUtils.getIconDrawable(iconValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
ChooseActivityTypeImageAdapter imageAdapter = new ChooseActivityTypeImageAdapter(
|
||||||
|
getActivity(), imageIds);
|
||||||
|
gridView.setAdapter(imageAdapter);
|
||||||
|
gridView.setOnItemClickListener(new OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||||
|
dismiss();
|
||||||
|
caller.onChooseActivityTypeDone(iconValues.get(position));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return new AlertDialog.Builder(getActivity()).setNegativeButton(R.string.generic_cancel, null)
|
||||||
|
.setTitle(R.string.track_edit_activity_type_hint).setView(gridView).create();
|
||||||
|
}
|
||||||
|
}
|
||||||
+68
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013 Google Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations under
|
||||||
|
* the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.google.android.apps.mytracks.fragments;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Image adapter for choosing an activity type.
|
||||||
|
*
|
||||||
|
* @author apoorvn
|
||||||
|
*/
|
||||||
|
public class ChooseActivityTypeImageAdapter extends BaseAdapter {
|
||||||
|
|
||||||
|
private final Context context;
|
||||||
|
private final List<Integer> imageIds;
|
||||||
|
|
||||||
|
public ChooseActivityTypeImageAdapter(Context context, List<Integer> imageIds) {
|
||||||
|
this.context = context;
|
||||||
|
this.imageIds = imageIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return imageIds.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getItem(int position) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
ImageView imageView;
|
||||||
|
if (convertView == null) {
|
||||||
|
imageView = new ImageView(context);
|
||||||
|
} else {
|
||||||
|
imageView = (ImageView) convertView;
|
||||||
|
}
|
||||||
|
imageView.setImageResource(imageIds.get(position));
|
||||||
|
return imageView;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,8 +19,11 @@ package com.google.android.apps.mytracks.util;
|
|||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Pair;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities for track icon.
|
* Utilities for track icon.
|
||||||
@@ -40,60 +43,44 @@ public class TrackIconUtils {
|
|||||||
|
|
||||||
private TrackIconUtils() {}
|
private TrackIconUtils() {}
|
||||||
|
|
||||||
private static HashMap<String, Integer> map = new HashMap<String, Integer>();
|
private static LinkedHashMap<String, Pair<Integer, Integer>>
|
||||||
|
map = new LinkedHashMap<String, Pair<Integer, Integer>>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
map.put(AIRPLANE, R.drawable.track_airplane);
|
map.put(AIRPLANE,
|
||||||
map.put(BIKE, R.drawable.track_bike);
|
new Pair<Integer, Integer>(R.string.activity_type_airplane, R.drawable.track_airplane));
|
||||||
map.put(BOAT, R.drawable.track_boat);
|
map.put(BIKE, new Pair<Integer, Integer>(R.string.activity_type_biking, R.drawable.track_bike));
|
||||||
map.put(DRIVE, R.drawable.track_drive);
|
map.put(BOAT, new Pair<Integer, Integer>(R.string.activity_type_boat, R.drawable.track_boat));
|
||||||
map.put(RUN, R.drawable.track_run);
|
map.put(
|
||||||
map.put(SKI, R.drawable.track_ski);
|
DRIVE, new Pair<Integer, Integer>(R.string.activity_type_driving, R.drawable.track_drive));
|
||||||
map.put(SNOW_BOARDING, R.drawable.track_snow_boarding);
|
map.put(RUN, new Pair<Integer, Integer>(R.string.activity_type_running, R.drawable.track_run));
|
||||||
map.put(WALK, R.drawable.track_walk);
|
map.put(SKI, new Pair<Integer, Integer>(R.string.activity_type_skiing, R.drawable.track_ski));
|
||||||
|
map.put(SNOW_BOARDING, new Pair<Integer, Integer>(
|
||||||
|
R.string.activity_type_snow_boarding, R.drawable.track_snow_boarding));
|
||||||
|
map.put(
|
||||||
|
WALK, new Pair<Integer, Integer>(R.string.activity_type_walking, R.drawable.track_walk));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int[] airplane = new int[] {
|
private static int[] airplane = new int[] { R.string.activity_type_airplane,
|
||||||
R.string.activity_type_airplane,
|
R.string.activity_type_commercial_airplane, R.string.activity_type_rc_airplane };
|
||||||
R.string.activity_type_commercial_airplane,
|
private static int[] bike = new int[] { R.string.activity_type_biking,
|
||||||
R.string.activity_type_rc_airplane
|
R.string.activity_type_cycling, R.string.activity_type_dirt_bike,
|
||||||
};
|
R.string.activity_type_motor_bike, R.string.activity_type_mountain_biking,
|
||||||
private static int[] bike = new int[] {
|
R.string.activity_type_road_biking, R.string.activity_type_track_cycling };
|
||||||
R.string.activity_type_biking,
|
private static int[] boat = new int[] { R.string.activity_type_boat, R.string.activity_type_ferry,
|
||||||
R.string.activity_type_cycling,
|
R.string.activity_type_motor_boating, R.string.activity_type_rc_boat };
|
||||||
R.string.activity_type_dirt_bike,
|
private static int[] drive = new int[] { R.string.activity_type_atv,
|
||||||
R.string.activity_type_motor_bike,
|
R.string.activity_type_driving, R.string.activity_type_driving_bus,
|
||||||
R.string.activity_type_mountain_biking,
|
|
||||||
R.string.activity_type_road_biking,
|
|
||||||
R.string.activity_type_track_cycling };
|
|
||||||
private static int[] boat = new int[] {
|
|
||||||
R.string.activity_type_boat,
|
|
||||||
R.string.activity_type_ferry,
|
|
||||||
R.string.activity_type_motor_boating,
|
|
||||||
R.string.activity_type_rc_boat
|
|
||||||
};
|
|
||||||
private static int[] drive = new int[] {
|
|
||||||
R.string.activity_type_atv,
|
|
||||||
R.string.activity_type_driving,
|
|
||||||
R.string.activity_type_driving_bus,
|
|
||||||
R.string.activity_type_driving_car };
|
R.string.activity_type_driving_car };
|
||||||
private static int[] run = new int[] {
|
private static int[] run = new int[] { R.string.activity_type_running,
|
||||||
R.string.activity_type_running,
|
R.string.activity_type_street_running, R.string.activity_type_track_running,
|
||||||
R.string.activity_type_street_running,
|
|
||||||
R.string.activity_type_track_running,
|
|
||||||
R.string.activity_type_trail_running };
|
R.string.activity_type_trail_running };
|
||||||
private static int[] ski = new int[] {
|
private static int[] ski = new int[] {
|
||||||
R.string.activity_type_cross_country_skiing,
|
R.string.activity_type_cross_country_skiing, R.string.activity_type_skiing };
|
||||||
R.string.activity_type_skiing };
|
private static int[] snowBoarding = new int[] { R.string.activity_type_snow_boarding };
|
||||||
private static int[] snowBoarding = new int[] {
|
private static int[] walk = new int[] { R.string.activity_type_hiking,
|
||||||
R.string.activity_type_snow_boarding
|
R.string.activity_type_off_trail_hiking, R.string.activity_type_speed_walking,
|
||||||
};
|
R.string.activity_type_trail_hiking, R.string.activity_type_walking };
|
||||||
private static int[] walk = new int[] {
|
|
||||||
R.string.activity_type_hiking,
|
|
||||||
R.string.activity_type_off_trail_hiking,
|
|
||||||
R.string.activity_type_speed_walking,
|
|
||||||
R.string.activity_type_trail_hiking,
|
|
||||||
R.string.activity_type_walking };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the icon drawable.
|
* Gets the icon drawable.
|
||||||
@@ -104,8 +91,32 @@ public class TrackIconUtils {
|
|||||||
if (iconValue == null || iconValue.equals("")) {
|
if (iconValue == null || iconValue.equals("")) {
|
||||||
return R.drawable.track_walk;
|
return R.drawable.track_walk;
|
||||||
}
|
}
|
||||||
Integer drawable = map.get(iconValue);
|
Pair<Integer, Integer> pair = map.get(iconValue);
|
||||||
return drawable == null ? R.drawable.track_walk : drawable;
|
return pair == null ? R.drawable.track_walk : pair.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the icon activity type.
|
||||||
|
*
|
||||||
|
* @param iconValue the icon value
|
||||||
|
*/
|
||||||
|
public static int getIconActivityType(String iconValue) {
|
||||||
|
if (iconValue == null || iconValue.equals("")) {
|
||||||
|
return R.string.activity_type_walking;
|
||||||
|
}
|
||||||
|
Pair<Integer, Integer> pair = map.get(iconValue);
|
||||||
|
return pair == null ? R.string.activity_type_walking : pair.first;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all icon values.
|
||||||
|
*/
|
||||||
|
public static List<String> getAllIconValues() {
|
||||||
|
List<String> values = new ArrayList<String>();
|
||||||
|
for (String value : map.keySet()) {
|
||||||
|
values.add(value);
|
||||||
|
}
|
||||||
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user