[new downloader][android] add: "Near me" group in downloader.

This commit is contained in:
Alexander Marchuk 2016-03-10 17:50:17 +03:00 committed by Sergey Yershov
parent 7595deba8d
commit 9f13111ff2
3 changed files with 30 additions and 5 deletions

View file

@ -269,9 +269,9 @@ static void PutItemsToList(JNIEnv * env, jobject const list, TCountriesVec const
}
}
// static void nativeListItems(@Nullable String parent, List<CountryItem> result);
// static void nativeListItems(@Nullable String root, double lat, double lon, boolean hasLocation, List<CountryItem> result);
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_downloader_MapManager_nativeListItems(JNIEnv * env, jclass clazz, jstring parent, jobject result)
Java_com_mapswithme_maps_downloader_MapManager_nativeListItems(JNIEnv * env, jclass clazz, jstring parent, jdouble lat, jdouble lon, jboolean hasLocation, jobject result)
{
PrepareClassRefs(env);
@ -287,7 +287,12 @@ Java_com_mapswithme_maps_downloader_MapManager_nativeListItems(JNIEnv * env, jcl
}
else
{
// TODO (trashkalmar): Countries near me
if (hasLocation)
{
TCountriesVec near;
g_framework->NativeFramework()->CountryInfoGetter().GetRegionsCountryId(MercatorBounds::FromLatLon(lat, lon), near);
PutItemsToList(env, result, near, ItemCategory::NEAR_ME);
}
TCountriesVec downloaded, available;
storage.GetChildrenInGroups(parentId, downloaded, available);

View file

@ -3,12 +3,14 @@ package com.mapswithme.maps.downloader;
import android.app.Activity;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
@ -28,6 +30,7 @@ import com.mapswithme.maps.MwmActivity;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import com.mapswithme.maps.background.Notifier;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.maps.widget.WheelProgressView;
import com.mapswithme.util.BottomSheetHelper;
import com.mapswithme.util.Graphics;
@ -524,7 +527,24 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
mSearchResultsMode = false;
mItems.clear();
MapManager.nativeListItems(getCurrentParent(), mItems);
String parent = getCurrentParent();
boolean hasLocation = false;
double lat = 0.0;
double lon = 0.0;
if (TextUtils.isEmpty(parent))
{
Location loc = LocationHelper.INSTANCE.getLastLocation();
hasLocation = (loc != null);
if (hasLocation)
{
lat = loc.getLatitude();
lon = loc.getLongitude();
}
}
MapManager.nativeListItems(parent, lat, lon, hasLocation, mItems);
processData();
}

View file

@ -160,7 +160,7 @@ public final class MapManager
/**
* Retrieves list of country items with its status info. Uses root as parent if {@code root} is null.
*/
public static native void nativeListItems(@Nullable String root, List<CountryItem> result);
public static native void nativeListItems(@Nullable String root, double lat, double lon, boolean hasLocation, List<CountryItem> result);
/**
* Sets following attributes of the given {@code item}: