Download map automatically when user opens downloader after routing error.

This commit is contained in:
Dmitry Yunitsky 2014-12-10 15:39:01 +03:00 committed by Alex Zolotarev
parent 8b0b8c1453
commit 96b6879877
3 changed files with 21 additions and 2 deletions

View file

@ -93,6 +93,7 @@ extern "C"
{
GetMapLayout().DownloadMap(ToGroup(group), position, ToOptions(options));
}
JNIEXPORT void JNICALL
Java_com_mapswithme_country_ActiveCountryTree_deleteMap(JNIEnv * env, jclass clazz, jint group, jint position, jint options)
{
@ -146,4 +147,10 @@ extern "C"
return storage::ToJava(GetMapLayout().GetCoreIndex(static_cast<storage::ActiveMapsLayout::TGroup>(group),
static_cast<int>(position)));
}
JNIEXPORT void JNICALL
Java_com_mapswithme_country_ActiveCountryTree_downloadMapForIndex(JNIEnv * env, jclass clazz, jobject index, jint options)
{
GetMapLayout().DownloadMap(storage::ToNative(index), ToOptions(options));
}
}

View file

@ -55,4 +55,6 @@ public class ActiveCountryTree
public static native int addListener(ActiveCountryListener listener);
public static native void removeListener(int slotId);
public static native void downloadMapForIndex(Index index, int options);
}

View file

@ -46,6 +46,7 @@ import android.widget.Toast;
import com.mapswithme.country.ActiveCountryTree;
import com.mapswithme.country.DownloadActivity;
import com.mapswithme.country.DownloadFragment;
import com.mapswithme.country.StorageOptions;
import com.mapswithme.maps.Ads.AdsManager;
import com.mapswithme.maps.Ads.Banner;
import com.mapswithme.maps.Ads.BannerDialogFragment;
@ -804,11 +805,14 @@ public class MWMActivity extends NvEventQueueActivity
return;
setVerticalToolbarVisible(false);
popFragment();
hideInfoView();
SearchController.getInstance().cancel();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
Fragment fragment = new DownloadFragment();
fragment.setArguments(getIntent().getExtras());
final Bundle extras = new Bundle();
extras.putBoolean(DownloadActivity.EXTRA_OPEN_DOWNLOADED_LIST, openDownloadedList);
fragment.setArguments(extras);
transaction.setCustomAnimations(R.anim.abc_slide_in_bottom, R.anim.abc_slide_out_bottom,
R.anim.abc_slide_in_bottom, R.anim.abc_slide_out_bottom);
transaction.add(R.id.fragment_container, fragment, fragment.getClass().getName());
@ -1849,7 +1853,13 @@ public class MWMActivity extends NvEventQueueActivity
@Override
public void onClick(DialogInterface dialog, int which)
{
// TODO start country download automatically?
final Location location = LocationService.INSTANCE.getLastLocation();
if (location != null)
{
final Index currentIndex = Framework.nativeGetCountryIndex(location.getLatitude(), location.getLongitude());
if (currentIndex != null)
ActiveCountryTree.downloadMapForIndex(currentIndex, StorageOptions.MAP_OPTION_MAP_AND_CAR_ROUTING);
}
showDownloader(true);
closeRouting();
dialog.dismiss();