Add groups tab
This commit is contained in:
parent
d4acaad187
commit
11eb486144
5 changed files with 113 additions and 3 deletions
|
@ -5,6 +5,11 @@
|
|||
android:icon="@drawable/ic_map"
|
||||
android:title="@string/osm_live_active"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_groups"
|
||||
android:icon="@drawable/ic_action_group2"
|
||||
android:title="@string/shared_string_groups" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_history"
|
||||
android:icon="@drawable/ic_action_history2"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="shared_string_groups">Groups</string>
|
||||
<string name="passed">Passed: %1$s</string>
|
||||
<string name="make_active">Make active</string>
|
||||
<string name="today">Today</string>
|
||||
|
|
|
@ -31,6 +31,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
public static final String TAG = "MapMarkersDialogFragment";
|
||||
|
||||
private MapMarkersActiveFragment activeFragment;
|
||||
private MapMarkersGroupsFragment groupsFragment;
|
||||
private MapMarkersHistoryFragment historyFragment;
|
||||
|
||||
@Override
|
||||
|
@ -50,6 +51,8 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
for (Fragment fragment : fragments) {
|
||||
if (fragment instanceof MapMarkersActiveFragment) {
|
||||
activeFragment = (MapMarkersActiveFragment) fragment;
|
||||
} else if (fragment instanceof MapMarkersGroupsFragment) {
|
||||
groupsFragment = (MapMarkersGroupsFragment) fragment;
|
||||
} else if (fragment instanceof MapMarkersHistoryFragment) {
|
||||
historyFragment = (MapMarkersHistoryFragment) fragment;
|
||||
}
|
||||
|
@ -58,6 +61,9 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
if (activeFragment == null) {
|
||||
activeFragment = new MapMarkersActiveFragment();
|
||||
}
|
||||
if (groupsFragment == null) {
|
||||
groupsFragment = new MapMarkersGroupsFragment();
|
||||
}
|
||||
if (historyFragment == null) {
|
||||
historyFragment = new MapMarkersHistoryFragment();
|
||||
}
|
||||
|
@ -111,13 +117,23 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
viewPager.setCurrentItem(0);
|
||||
optionsButton.setVisibility(View.VISIBLE);
|
||||
return true;
|
||||
case R.id.action_history:
|
||||
case R.id.action_groups:
|
||||
activeFragment.stopLocationUpdate();
|
||||
if (viewPager.getCurrentItem() != 1) {
|
||||
groupsFragment.updateAdapter();
|
||||
activeFragment.hideSnackbar();
|
||||
historyFragment.hideSnackbar();
|
||||
}
|
||||
viewPager.setCurrentItem(1);
|
||||
optionsButton.setVisibility(View.GONE);
|
||||
return true;
|
||||
case R.id.action_history:
|
||||
activeFragment.stopLocationUpdate();
|
||||
if (viewPager.getCurrentItem() != 2) {
|
||||
historyFragment.updateAdapter();
|
||||
activeFragment.hideSnackbar();
|
||||
}
|
||||
viewPager.setCurrentItem(1);
|
||||
viewPager.setCurrentItem(2);
|
||||
optionsButton.setVisibility(View.GONE);
|
||||
return true;
|
||||
}
|
||||
|
@ -203,7 +219,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
|
||||
MapMarkersViewPagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
fragments = Arrays.asList(activeFragment, historyFragment);
|
||||
fragments = Arrays.asList(activeFragment, groupsFragment, historyFragment);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package net.osmand.plus.mapmarkers;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapmarkers.adapters.MapMarkersGroupsAdapter;
|
||||
|
||||
public class MapMarkersGroupsFragment extends Fragment {
|
||||
|
||||
public static final String TAG = "MapMarkersGroupsFragment";
|
||||
|
||||
private MapMarkersGroupsAdapter adapter;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
final RecyclerView recyclerView = new RecyclerView(getContext());
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||
|
||||
adapter = new MapMarkersGroupsAdapter(mapActivity);
|
||||
return recyclerView;
|
||||
}
|
||||
|
||||
void updateAdapter() {
|
||||
if (adapter != null) {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package net.osmand.plus.mapmarkers.adapters;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> {
|
||||
|
||||
private MapActivity mapActivity;
|
||||
private List<MapMarkersHelper.MapMarker> markers;
|
||||
private boolean night;
|
||||
|
||||
public MapMarkersGroupsAdapter(MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
markers = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers();
|
||||
night = !mapActivity.getMyApplication().getSettings().isLightContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
|
||||
return new MapMarkerItemViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(MapMarkerItemViewHolder mapMarkerItemViewHolder, int i) {
|
||||
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
|
||||
MapMarkersHelper.MapMarker marker = markers.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return markers.size();
|
||||
}
|
||||
|
||||
public MapMarkersHelper.MapMarker getItem(int position) {
|
||||
return markers.get(position);
|
||||
}
|
||||
|
||||
public List<MapMarkersHelper.MapMarker> getItems() {
|
||||
return markers;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue