Updated currently showing on map
This commit is contained in:
parent
494b0c2652
commit
1568c96e9e
3 changed files with 121 additions and 56 deletions
|
@ -51,10 +51,18 @@
|
||||||
android:id="@+id/turn_off_all"
|
android:id="@+id/turn_off_all"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
style="?attr/dashboardGeneralButtonStyle"
|
||||||
|
android:textColor="@color/color_distance"
|
||||||
android:text="@string/turn_off_all"/>
|
android:text="@string/turn_off_all"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?attr/dashboard_divider"/>
|
||||||
|
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/gpx_on_map"
|
android:id="@+id/gpx_on_map"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -100,12 +100,7 @@
|
||||||
android:src="@drawable/ic_action_gsave_dark"/>
|
android:src="@drawable/ic_action_gsave_dark"/>
|
||||||
|
|
||||||
|
|
||||||
<CheckBox
|
<include layout="@layout/check_item_rel" />
|
||||||
android:id="@+id/check"
|
|
||||||
android:layout_width="@dimen/list_item_height"
|
|
||||||
android:layout_height="@dimen/list_item_height"
|
|
||||||
android:focusable="false"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ import android.widget.Filter;
|
||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -82,8 +83,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
private List<GpxInfo> selectedItems = new ArrayList<>();
|
private List<GpxInfo> selectedItems = new ArrayList<>();
|
||||||
private ActionMode actionMode;
|
private ActionMode actionMode;
|
||||||
private LoadGpxTask asyncLoader;
|
private LoadGpxTask asyncLoader;
|
||||||
private GpxIndexesAdapter listAdapter;
|
private GpxIndexesAdapter allGpxAdapter;
|
||||||
private ShowedOnMapAdapter showOnMapAdapter;
|
private ShowedOnMapAdapter showOnMapGpxAdapter;
|
||||||
MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
|
MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
|
||||||
private LoadLocalIndexDescriptionTask descriptionLoader;
|
private LoadLocalIndexDescriptionTask descriptionLoader;
|
||||||
private ContextMenuAdapter optionsMenuAdapter;
|
private ContextMenuAdapter optionsMenuAdapter;
|
||||||
|
@ -102,8 +103,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
asyncLoader = new LoadGpxTask();
|
asyncLoader = new LoadGpxTask();
|
||||||
selectedGpxHelper = ((OsmandApplication) activity.getApplication()).getSelectedGpxHelper();
|
selectedGpxHelper = ((OsmandApplication) activity.getApplication()).getSelectedGpxHelper();
|
||||||
savingTrackHelper = ((OsmandApplication) activity.getApplication()).getSavingTrackHelper();
|
savingTrackHelper = ((OsmandApplication) activity.getApplication()).getSavingTrackHelper();
|
||||||
listAdapter = new GpxIndexesAdapter(getActivity());
|
allGpxAdapter = new GpxIndexesAdapter(getActivity());
|
||||||
setAdapter(listAdapter);
|
setAdapter(allGpxAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GpxInfo> getSelectedItems() {
|
public List<GpxInfo> getSelectedItems() {
|
||||||
|
@ -123,8 +124,14 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
private void createShowedOnMapsView(View v) {
|
private void createShowedOnMapsView(View v) {
|
||||||
ListView onMap = (ListView) v.findViewById(R.id.gpx_on_map);
|
ListView onMap = (ListView) v.findViewById(R.id.gpx_on_map);
|
||||||
showOnMapAdapter = new ShowedOnMapAdapter(getActivity(), R.layout.dash_gpx_track_item);
|
showOnMapGpxAdapter = new ShowedOnMapAdapter(getActivity(), R.layout.dash_gpx_track_item);
|
||||||
onMap.setAdapter(showOnMapAdapter);
|
onMap.setAdapter(showOnMapGpxAdapter);
|
||||||
|
v.findViewById(R.id.turn_off_all).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
showOnMapGpxAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -140,11 +147,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (visibility) {
|
//temporary hiding this view
|
||||||
|
v.findViewById(R.id.show_on_map).setVisibility(View.GONE);
|
||||||
|
/* if (visibility) {
|
||||||
v.findViewById(R.id.on_map_layout).setVisibility(View.VISIBLE);
|
v.findViewById(R.id.on_map_layout).setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
v.findViewById(R.id.on_map_layout).setVisibility(View.GONE);
|
v.findViewById(R.id.on_map_layout).setVisibility(View.GONE);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCurrentTrack(View v) {
|
private void updateCurrentTrack(View v) {
|
||||||
|
@ -257,13 +266,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextSubmit(String query) {
|
public boolean onQueryTextSubmit(String query) {
|
||||||
listAdapter.getFilter().filter(query);
|
allGpxAdapter.getFilter().filter(query);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextChange(String newText) {
|
public boolean onQueryTextChange(String newText) {
|
||||||
listAdapter.getFilter().filter(newText);
|
allGpxAdapter.getFilter().filter(newText);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -394,7 +403,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
private void openShowOnMapMode() {
|
private void openShowOnMapMode() {
|
||||||
enableSelectionMode(true);
|
enableSelectionMode(true);
|
||||||
selectedItems.clear();
|
selectedItems.clear();
|
||||||
final Set<GpxInfo> originalSelectedItems = listAdapter.getSelectedGpx();
|
final Set<GpxInfo> originalSelectedItems = allGpxAdapter.getSelectedGpx();
|
||||||
selectedItems.addAll(originalSelectedItems);
|
selectedItems.addAll(originalSelectedItems);
|
||||||
actionMode = getActionBarActivity().startSupportActionMode(new ActionMode.Callback() {
|
actionMode = getActionBarActivity().startSupportActionMode(new ActionMode.Callback() {
|
||||||
|
|
||||||
|
@ -435,11 +444,11 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
enableSelectionMode(false);
|
enableSelectionMode(false);
|
||||||
getView().findViewById(R.id.memory_size).setVisibility(View.GONE);
|
getView().findViewById(R.id.memory_size).setVisibility(View.GONE);
|
||||||
runSelection(false);
|
runSelection(false);
|
||||||
listAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
listAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -451,7 +460,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
value = value.substring(0, value.length() - 3);
|
value = value.substring(0, value.length() - 3);
|
||||||
}
|
}
|
||||||
final String actionButton = value;
|
final String actionButton = value;
|
||||||
if (listAdapter.getGroupCount() == 0) {
|
if (allGpxAdapter.getGroupCount() == 0) {
|
||||||
AccessibleToast.makeText(getActivity(), app.getString(R.string.local_index_no_items_to_do, actionButton.toLowerCase()), Toast.LENGTH_SHORT).show();
|
AccessibleToast.makeText(getActivity(), app.getString(R.string.local_index_no_items_to_do, actionButton.toLowerCase()), Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -496,7 +505,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
public void onDestroyActionMode(ActionMode mode) {
|
public void onDestroyActionMode(ActionMode mode) {
|
||||||
enableSelectionMode(false);
|
enableSelectionMode(false);
|
||||||
getView().findViewById(R.id.memory_size).setVisibility(View.GONE);
|
getView().findViewById(R.id.memory_size).setVisibility(View.GONE);
|
||||||
listAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -505,7 +514,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
((TextView) getView().findViewById(R.id.memory_size)).setText(R.string.local_index_upload_gpx_description);
|
((TextView) getView().findViewById(R.id.memory_size)).setText(R.string.local_index_upload_gpx_description);
|
||||||
((TextView) getView().findViewById(R.id.memory_size)).setVisibility(View.VISIBLE);
|
((TextView) getView().findViewById(R.id.memory_size)).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
listAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renameFile(GpxInfo info) {
|
private void renameFile(GpxInfo info) {
|
||||||
|
@ -555,7 +564,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
loadGpxAsync(info, resId == R.string.local_index_select_gpx_file);
|
loadGpxAsync(info, resId == R.string.local_index_select_gpx_file);
|
||||||
} else {
|
} else {
|
||||||
getMyApplication().getSelectedGpxHelper().selectGpxFile(info.gpx, resId == R.string.local_index_select_gpx_file, true);
|
getMyApplication().getSelectedGpxHelper().selectGpxFile(info.gpx, resId == R.string.local_index_select_gpx_file, true);
|
||||||
listAdapter.notifyDataSetChanged();
|
showOnMapGpxAdapter.addGpxInfo(info);
|
||||||
|
|
||||||
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
selectedGpxHelper.runUiListeners();
|
selectedGpxHelper.runUiListeners();
|
||||||
}
|
}
|
||||||
} else if (resId == R.string.local_index_mi_delete) {
|
} else if (resId == R.string.local_index_mi_delete) {
|
||||||
|
@ -615,6 +626,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
e = false;
|
e = false;
|
||||||
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(info.gpx);
|
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(info.gpx);
|
||||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||||
|
if (showOnMapGpxAdapter.getCount() == 0) {
|
||||||
|
setShowedOnMapVisibility(true);
|
||||||
|
}
|
||||||
|
showOnMapGpxAdapter.addGpxInfo(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e) {
|
if (e) {
|
||||||
|
@ -644,37 +659,37 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
((ActionBarActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(true);
|
((ActionBarActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(true);
|
||||||
listAdapter.clear();
|
allGpxAdapter.clear();
|
||||||
if (showOnMapAdapter != null) {
|
if (showOnMapGpxAdapter != null) {
|
||||||
showOnMapAdapter.clear();
|
showOnMapGpxAdapter.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onProgressUpdate(GpxInfo... values) {
|
protected void onProgressUpdate(GpxInfo... values) {
|
||||||
for (GpxInfo v : values) {
|
for (GpxInfo v : values) {
|
||||||
listAdapter.addLocalIndexInfo(v);
|
allGpxAdapter.addLocalIndexInfo(v);
|
||||||
if (selectedGpxHelper.getSelectedFileByName(v.getFileName()) != null) {
|
if (selectedGpxHelper.getSelectedFileByName(v.getFileName()) != null) {
|
||||||
showOnMapAdapter.add(v);
|
showOnMapGpxAdapter.addGpxInfo(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showOnMapAdapter.notifyDataSetChanged();
|
showOnMapGpxAdapter.notifyDataSetChanged();
|
||||||
listAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResult(List<GpxInfo> result) {
|
public void setResult(List<GpxInfo> result) {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
listAdapter.clear();
|
allGpxAdapter.clear();
|
||||||
showOnMapAdapter.clear();
|
showOnMapGpxAdapter.clear();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
for (GpxInfo v : result) {
|
for (GpxInfo v : result) {
|
||||||
listAdapter.addLocalIndexInfo(v);
|
allGpxAdapter.addLocalIndexInfo(v);
|
||||||
if (selectedGpxHelper.getSelectedFileByName(v.getFileName()) != null) {
|
if (selectedGpxHelper.getSelectedFileByName(v.getFileName()) != null) {
|
||||||
showOnMapAdapter.add(v);
|
showOnMapGpxAdapter.addGpxInfo(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
listAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
showOnMapAdapter.notifyDataSetChanged();
|
showOnMapGpxAdapter.notifyDataSetChanged();
|
||||||
onPostExecute(result);
|
onPostExecute(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -685,11 +700,11 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
((ActionBarActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(false);
|
((ActionBarActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(false);
|
||||||
}
|
}
|
||||||
if (listAdapter.getGroupCount() > 0) {
|
if (allGpxAdapter.getGroupCount() > 0) {
|
||||||
getExpandableListView().expandGroup(0);
|
getExpandableListView().expandGroup(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showOnMapAdapter.getCount() > 0) {
|
if (showOnMapGpxAdapter.getCount() > 0) {
|
||||||
setShowedOnMapVisibility(true);
|
setShowedOnMapVisibility(true);
|
||||||
} else {
|
} else {
|
||||||
setShowedOnMapVisibility(false);
|
setShowedOnMapVisibility(false);
|
||||||
|
@ -1082,13 +1097,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onProgressUpdate(GpxInfo... values) {
|
protected void onProgressUpdate(GpxInfo... values) {
|
||||||
listAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(GpxInfo[] result) {
|
protected void onPostExecute(GpxInfo[] result) {
|
||||||
hideProgressBar();
|
hideProgressBar();
|
||||||
listAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1118,9 +1133,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
@Override
|
@Override
|
||||||
protected void onProgressUpdate(GpxInfo... values) {
|
protected void onProgressUpdate(GpxInfo... values) {
|
||||||
for (GpxInfo g : values) {
|
for (GpxInfo g : values) {
|
||||||
listAdapter.delete(g);
|
allGpxAdapter.delete(g);
|
||||||
}
|
}
|
||||||
listAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1166,7 +1181,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
toShow = g.gpx.findPointToShow();
|
toShow = g.gpx.findPointToShow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
listAdapter.notifyDataSetInvalidated();
|
allGpxAdapter.notifyDataSetInvalidated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1218,7 +1233,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
if (info.gpx != null) {
|
if (info.gpx != null) {
|
||||||
getMyApplication().getSelectedGpxHelper().selectGpxFile(info.gpx, selected, true);
|
getMyApplication().getSelectedGpxHelper().selectGpxFile(info.gpx, selected, true);
|
||||||
listAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
selectedGpxHelper.runUiListeners();
|
selectedGpxHelper.runUiListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1254,18 +1269,18 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
@Override
|
@Override
|
||||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||||
if (results.values != null) {
|
if (results.values != null) {
|
||||||
synchronized (listAdapter) {
|
synchronized (allGpxAdapter) {
|
||||||
listAdapter.clear();
|
allGpxAdapter.clear();
|
||||||
showOnMapAdapter.clear();
|
showOnMapGpxAdapter.clear();
|
||||||
for (GpxInfo i : ((List<GpxInfo>) results.values)) {
|
for (GpxInfo i : ((List<GpxInfo>) results.values)) {
|
||||||
listAdapter.addLocalIndexInfo(i);
|
allGpxAdapter.addLocalIndexInfo(i);
|
||||||
if (selectedGpxHelper.getSelectedFileByName(i.getFileName()) != null) {
|
if (selectedGpxHelper.getSelectedFileByName(i.getFileName()) != null) {
|
||||||
showOnMapAdapter.add(i);
|
showOnMapGpxAdapter.addGpxInfo(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showOnMapAdapter.notifyDataSetChanged();
|
showOnMapGpxAdapter.notifyDataSetChanged();
|
||||||
listAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
if (constraint != null && constraint.length() > 3) {
|
if (constraint != null && constraint.length() > 3) {
|
||||||
collapseTrees(10);
|
collapseTrees(10);
|
||||||
}
|
}
|
||||||
|
@ -1287,7 +1302,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
||||||
GpxInfo item = listAdapter.getChild(groupPosition, childPosition);
|
GpxInfo item = allGpxAdapter.getChild(groupPosition, childPosition);
|
||||||
if (!selectionMode) {
|
if (!selectionMode) {
|
||||||
item.setExpanded(!item.isExpanded());
|
item.setExpanded(!item.isExpanded());
|
||||||
if (item.isExpanded()) {
|
if (item.isExpanded()) {
|
||||||
|
@ -1302,7 +1317,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
updateSelectionMode(actionMode);
|
updateSelectionMode(actionMode);
|
||||||
}
|
}
|
||||||
listAdapter.notifyDataSetInvalidated();
|
allGpxAdapter.notifyDataSetInvalidated();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1411,8 +1426,40 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void adjustShowOnMapListViewSize() {
|
||||||
|
View v = getView();
|
||||||
|
if (v == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
float size = getResources().getDimension(R.dimen.dashListItemHeight) * 3.5f;
|
||||||
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, (int) size);
|
||||||
|
getView().findViewById(R.id.gpx_on_map).setLayoutParams(params);
|
||||||
|
}
|
||||||
|
|
||||||
class ShowedOnMapAdapter extends ArrayAdapter<GpxInfo> {
|
class ShowedOnMapAdapter extends ArrayAdapter<GpxInfo> {
|
||||||
|
|
||||||
|
public void addGpxInfo(GpxInfo info) {
|
||||||
|
boolean contains = false;
|
||||||
|
for (int i = 0; i < getCount(); i++) {
|
||||||
|
if (getItem(i).equals(info)) {
|
||||||
|
contains = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (contains) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
add(info);
|
||||||
|
notifyDataSetChanged();
|
||||||
|
|
||||||
|
//if there's too many items, we need to set size of listview
|
||||||
|
if (getCount() == 4) {
|
||||||
|
adjustShowOnMapListViewSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public ShowedOnMapAdapter(Context context, int resource) {
|
public ShowedOnMapAdapter(Context context, int resource) {
|
||||||
super(context, resource);
|
super(context, resource);
|
||||||
}
|
}
|
||||||
|
@ -1425,7 +1472,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
v = inflater.inflate(R.layout.dash_gpx_track_item, parent, false);
|
v = inflater.inflate(R.layout.dash_gpx_track_item, parent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
GpxInfo gpxInfo = getItem(position);
|
final GpxInfo gpxInfo = getItem(position);
|
||||||
|
|
||||||
TextView viewName = ((TextView) v.findViewById(R.id.name));
|
TextView viewName = ((TextView) v.findViewById(R.id.name));
|
||||||
viewName.setText(gpxInfo.getName());
|
viewName.setText(gpxInfo.getName());
|
||||||
|
@ -1443,9 +1490,24 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundButton check = (CompoundButton) v.findViewById(R.id.check);
|
final CompoundButton check = (CompoundButton) v.findViewById(R.id.check_item);
|
||||||
check.setVisibility(View.VISIBLE);
|
check.setVisibility(View.VISIBLE);
|
||||||
|
if (selectedGpxHelper.getSelectedFileByName(gpxInfo.getFileName()) != null) {
|
||||||
|
check.setChecked(true);
|
||||||
|
} else {
|
||||||
|
check.setChecked(false);
|
||||||
|
}
|
||||||
|
check.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (gpxInfo.gpx == null) {
|
||||||
|
loadGpxAsync(gpxInfo, check.isChecked());
|
||||||
|
} else {
|
||||||
|
selectedGpxHelper.selectGpxFile(gpxInfo.gpx, check.isChecked(), true);
|
||||||
|
}
|
||||||
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue