forked from organicmaps/organicmaps
[core] notifications refactoring
This commit is contained in:
parent
5772a273c2
commit
3d1f43fffd
11 changed files with 196 additions and 172 deletions
|
@ -1,6 +1,7 @@
|
|||
#include <jni.h>
|
||||
|
||||
#include "../maps/Framework.hpp"
|
||||
#include "../maps/MapStorage.hpp"
|
||||
#include "../core/jni_helper.hpp"
|
||||
#include "country_helper.hpp"
|
||||
|
||||
|
@ -108,13 +109,19 @@ extern "C"
|
|||
JNIEXPORT int JNICALL
|
||||
Java_com_mapswithme_country_ActiveCountryTree_addListener(JNIEnv * env, jclass clazz, jobject listener)
|
||||
{
|
||||
return GetMapLayout().AddListener(g_framework->setActiveMapsListener(jni::make_global_ref(listener)));
|
||||
return g_framework->AddActiveMapsListener(jni::make_global_ref(listener));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_country_ActiveCountryTree_removeListener(JNIEnv * env, jclass clazz, jint slotID)
|
||||
{
|
||||
g_framework->resetActiveMapsListener();
|
||||
GetMapLayout().RemoveListener(slotID);
|
||||
g_framework->RemoveActiveMapsListener(slotID);
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_com_mapswithme_country_ActiveCountryTree_getCoreIndex(JNIEnv * env, jclass clazz, jint group, jint position)
|
||||
{
|
||||
return storage::ToJava(GetMapLayout().GetCoreIndex(static_cast<storage::ActiveMapsLayout::TGroup>(group),
|
||||
static_cast<int>(position)));
|
||||
}
|
||||
}
|
|
@ -131,13 +131,12 @@ extern "C"
|
|||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_country_CountryTree_setListener(JNIEnv * env, jclass clazz, jobject listener)
|
||||
{
|
||||
GetTree().SetListener(g_framework->setCountryTreeListener(jni::make_global_ref(listener)));
|
||||
g_framework->SetCountryTreeListener(jni::make_global_ref(listener));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_country_CountryTree_resetListener(JNIEnv * env, jclass clazz, jobject listener)
|
||||
{
|
||||
g_framework->resetCountryTreeListener();
|
||||
GetTree().ResetListener();
|
||||
g_framework->ResetCountryTreeListener();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,98 +45,6 @@ android::Framework * g_framework = 0;
|
|||
|
||||
using namespace storage;
|
||||
|
||||
namespace storage
|
||||
{
|
||||
class CountryTreeListenerImpl : public CountryTree::CountryTreeListener
|
||||
{
|
||||
public:
|
||||
void ItemStatusChanged(int position)
|
||||
{
|
||||
JNIEnv * jniEnv = jni::GetEnv();
|
||||
shared_ptr<jobject> m_javaListenerPtr = g_framework->getJavaCountryListener();
|
||||
const jmethodID methodID = jni::GetJavaMethodID(jniEnv,
|
||||
*m_javaListenerPtr.get(),
|
||||
"onItemStatusChanged",
|
||||
"(I)V");
|
||||
ASSERT ( methodID, () );
|
||||
|
||||
jniEnv->CallVoidMethod(*m_javaListenerPtr.get(), methodID, position);
|
||||
}
|
||||
|
||||
void ItemProgressChanged(int position, LocalAndRemoteSizeT const & sizes)
|
||||
{
|
||||
JNIEnv * jniEnv = jni::GetEnv();
|
||||
shared_ptr<jobject> m_javaListenerPtr = g_framework->getJavaCountryListener();
|
||||
|
||||
const jmethodID methodID = jni::GetJavaMethodID(jniEnv,
|
||||
*m_javaListenerPtr.get(),
|
||||
"onItemProgressChanged",
|
||||
"(I[J)V");
|
||||
ASSERT ( methodID, () );
|
||||
|
||||
jniEnv->CallVoidMethod(*m_javaListenerPtr.get(), methodID, position, storage_utils::ToArray(jniEnv, sizes));
|
||||
}
|
||||
};
|
||||
|
||||
class ActiveMapsListenerImpl : public ActiveMapsLayout::ActiveMapsListener
|
||||
{
|
||||
public:
|
||||
void CountryStatusChanged(ActiveMapsLayout::TGroup const & group, int position)
|
||||
{
|
||||
JNIEnv * jniEnv = jni::GetEnv();
|
||||
shared_ptr<jobject> m_javaListenerPtr = g_framework->getJavaActiveCountryListener();
|
||||
const jmethodID methodID = jni::GetJavaMethodID(jniEnv,
|
||||
*m_javaListenerPtr.get(),
|
||||
"onCountryStatusChanged",
|
||||
"(II)V");
|
||||
ASSERT ( methodID, () );
|
||||
|
||||
jniEnv->CallVoidMethod(*m_javaListenerPtr.get(), methodID, group, position);
|
||||
}
|
||||
|
||||
void CountryGroupChanged(ActiveMapsLayout::TGroup const & oldGroup, int oldPosition,
|
||||
ActiveMapsLayout::TGroup const & newGroup, int newPosition)
|
||||
{
|
||||
JNIEnv * jniEnv = jni::GetEnv();
|
||||
shared_ptr<jobject> m_javaListenerPtr = g_framework->getJavaActiveCountryListener();
|
||||
const jmethodID methodID = jni::GetJavaMethodID(jniEnv,
|
||||
*m_javaListenerPtr.get(),
|
||||
"onCountryGroupChanged",
|
||||
"(IIII)V");
|
||||
ASSERT ( methodID, () );
|
||||
|
||||
jniEnv->CallVoidMethod(*m_javaListenerPtr.get(), methodID, oldGroup, oldPosition, newGroup, newPosition);
|
||||
}
|
||||
|
||||
void CountryOptionsChanged(ActiveMapsLayout::TGroup const & group, int position)
|
||||
{
|
||||
JNIEnv * jniEnv = jni::GetEnv();
|
||||
shared_ptr<jobject> m_javaListenerPtr = g_framework->getJavaActiveCountryListener();
|
||||
const jmethodID methodID = jni::GetJavaMethodID(jniEnv,
|
||||
*m_javaListenerPtr.get(),
|
||||
"onCountryOptionsChanged",
|
||||
"(II)V");
|
||||
ASSERT ( methodID, () );
|
||||
|
||||
jniEnv->CallVoidMethod(*m_javaListenerPtr.get(), methodID, group, position);
|
||||
}
|
||||
|
||||
void DownloadingProgressUpdate(ActiveMapsLayout::TGroup const & group, int position, LocalAndRemoteSizeT const & sizes)
|
||||
{
|
||||
JNIEnv * jniEnv = jni::GetEnv();
|
||||
shared_ptr<jobject> m_javaListenerPtr = g_framework->getJavaActiveCountryListener();
|
||||
|
||||
const jmethodID methodID = jni::GetJavaMethodID(jniEnv,
|
||||
*m_javaListenerPtr.get(),
|
||||
"onCountryProgressChanged",
|
||||
"(II[J)V");
|
||||
ASSERT ( methodID, () );
|
||||
|
||||
jniEnv->CallVoidMethod(*m_javaListenerPtr.get(), methodID, group, position, storage_utils::ToArray(jniEnv, sizes));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace android
|
||||
{
|
||||
void Framework::CallRepaint() {}
|
||||
|
@ -152,13 +60,12 @@ namespace android
|
|||
g_framework = this;
|
||||
|
||||
m_videoTimer = new VideoTimer(bind(&Framework::CallRepaint, this));
|
||||
|
||||
m_treeListener = new CountryTreeListenerImpl();
|
||||
m_activeMapsListener = new ActiveMapsListenerImpl();
|
||||
m_activeMapsConnectionID = m_work.GetCountryTree().GetActiveMapLayout().AddListener(this);
|
||||
}
|
||||
|
||||
Framework::~Framework()
|
||||
{
|
||||
m_work.GetCountryTree().GetActiveMapLayout().RemoveListener(m_activeMapsConnectionID);
|
||||
delete m_videoTimer;
|
||||
}
|
||||
|
||||
|
@ -741,36 +648,110 @@ namespace android
|
|||
NativeFramework()->ShowTrack(*nTrack);
|
||||
}
|
||||
|
||||
CountryTree::CountryTreeListener * Framework::setCountryTreeListener(shared_ptr<jobject> objPtr)
|
||||
void Framework::SetCountryTreeListener(shared_ptr<jobject> objPtr)
|
||||
{
|
||||
m_javaCountryListenerPtr = objPtr;
|
||||
return m_treeListener;
|
||||
m_javaCountryListener = objPtr;
|
||||
m_work.GetCountryTree().SetListener(this);
|
||||
}
|
||||
|
||||
void Framework::resetCountryTreeListener()
|
||||
void Framework::ResetCountryTreeListener()
|
||||
{
|
||||
m_javaCountryListenerPtr.reset();
|
||||
m_work.GetCountryTree().ResetListener();
|
||||
m_javaCountryListener.reset();
|
||||
}
|
||||
|
||||
shared_ptr<jobject> Framework::getJavaCountryListener()
|
||||
int Framework::AddActiveMapsListener(shared_ptr<jobject> obj)
|
||||
{
|
||||
return m_javaCountryListenerPtr;
|
||||
m_javaActiveMapListeners[m_currentSlotID] = obj;
|
||||
return m_currentSlotID++;
|
||||
}
|
||||
|
||||
ActiveMapsLayout::ActiveMapsListener * Framework::setActiveMapsListener(shared_ptr<jobject> objPtr)
|
||||
void Framework::RemoveActiveMapsListener(int slotID)
|
||||
{
|
||||
m_javaActiveCountryListenerPtr = objPtr;
|
||||
return m_activeMapsListener;
|
||||
m_javaActiveMapListeners.erase(slotID);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
void Framework::ItemStatusChanged(int childPosition)
|
||||
{
|
||||
if (m_javaCountryListener == NULL)
|
||||
return;
|
||||
|
||||
JNIEnv * jniEnv = jni::GetEnv();
|
||||
jmethodID const methodID = jni::GetJavaMethodID(jniEnv,
|
||||
*m_javaCountryListener,
|
||||
"onItemStatusChanged",
|
||||
"(I)V");
|
||||
ASSERT ( methodID, () );
|
||||
|
||||
jniEnv->CallVoidMethod(*m_javaCountryListener, methodID, childPosition);
|
||||
}
|
||||
|
||||
void Framework::resetActiveMapsListener()
|
||||
void Framework::ItemProgressChanged(int childPosition, LocalAndRemoteSizeT const & sizes)
|
||||
{
|
||||
m_javaActiveCountryListenerPtr.reset();
|
||||
if (m_javaCountryListener == NULL)
|
||||
return;
|
||||
|
||||
JNIEnv * jniEnv = jni::GetEnv();
|
||||
jmethodID const methodID = jni::GetJavaMethodID(jniEnv,
|
||||
*m_javaCountryListener,
|
||||
"onItemProgressChanged",
|
||||
"(I[J)V");
|
||||
ASSERT ( methodID, () );
|
||||
|
||||
jniEnv->CallVoidMethod(*m_javaCountryListener, methodID, childPosition, storage_utils::ToArray(jniEnv, sizes));
|
||||
}
|
||||
|
||||
shared_ptr<jobject> Framework::getJavaActiveCountryListener()
|
||||
void Framework::CountryGroupChanged(ActiveMapsLayout::TGroup const & oldGroup, int oldPosition,
|
||||
ActiveMapsLayout::TGroup const & newGroup, int newPosition)
|
||||
{
|
||||
return m_javaActiveCountryListenerPtr;
|
||||
JNIEnv * jniEnv = jni::GetEnv();
|
||||
for (TListenerMap::const_iterator it = m_javaActiveMapListeners.begin(); it != m_javaActiveMapListeners.end(); ++it)
|
||||
{
|
||||
jmethodID const methodID = jni::GetJavaMethodID(jniEnv, *(it->second), "onCountryGroupChanged", "(IIII)V");
|
||||
ASSERT ( methodID, () );
|
||||
|
||||
jniEnv->CallVoidMethod(*(it->second), methodID, oldGroup, oldPosition, newGroup, newPosition);
|
||||
}
|
||||
}
|
||||
void Framework::CountryStatusChanged(ActiveMapsLayout::TGroup const & group, int position,
|
||||
TStatus const & oldStatus, TStatus const & newStatus)
|
||||
{
|
||||
JNIEnv * jniEnv = jni::GetEnv();
|
||||
for (TListenerMap::const_iterator it = m_javaActiveMapListeners.begin(); it != m_javaActiveMapListeners.end(); ++it)
|
||||
{
|
||||
jmethodID const methodID = jni::GetJavaMethodID(jniEnv, *(it->second), "onCountryStatusChanged", "(IIII)V");
|
||||
ASSERT ( methodID, () );
|
||||
|
||||
jniEnv->CallVoidMethod(*(it->second), methodID, group, position,
|
||||
static_cast<jint>(oldStatus), static_cast<jint>(newStatus));
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::CountryOptionsChanged(ActiveMapsLayout::TGroup const & group, int position,
|
||||
TMapOptions const & oldOpt, TMapOptions const & newOpt)
|
||||
{
|
||||
JNIEnv * jniEnv = jni::GetEnv();
|
||||
for (TListenerMap::const_iterator it = m_javaActiveMapListeners.begin(); it != m_javaActiveMapListeners.end(); ++it)
|
||||
{
|
||||
jmethodID const methodID = jni::GetJavaMethodID(jniEnv, *(it->second), "onCountryOptionsChanged", "(IIII)V");
|
||||
ASSERT ( methodID, () );
|
||||
|
||||
jniEnv->CallVoidMethod(*(it->second), methodID, group, position,
|
||||
static_cast<jint>(oldOpt), static_cast<jint>(newOpt));
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::DownloadingProgressUpdate(ActiveMapsLayout::TGroup const & group, int position,
|
||||
LocalAndRemoteSizeT const & progress)
|
||||
{
|
||||
JNIEnv * jniEnv = jni::GetEnv();
|
||||
for (TListenerMap::const_iterator it = m_javaActiveMapListeners.begin(); it != m_javaActiveMapListeners.end(); ++it)
|
||||
{
|
||||
jmethodID const methodID = jni::GetJavaMethodID(jniEnv, *(it->second), "onCountryProgressChanged", "(II[J)V");
|
||||
ASSERT ( methodID, () );
|
||||
|
||||
jniEnv->CallVoidMethod(*(it->second), methodID, group, position, storage_utils::ToArray(jniEnv, progress));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "../../../../../base/strings_bundle.hpp"
|
||||
|
||||
#include "../../../../../std/shared_ptr.hpp"
|
||||
#include "../../../../../std/map.hpp"
|
||||
|
||||
#include "../../../nv_event/nv_event.hpp"
|
||||
|
||||
|
@ -21,16 +22,21 @@ class CountryStatusDisplay;
|
|||
|
||||
namespace android
|
||||
{
|
||||
class Framework
|
||||
class Framework : public storage::CountryTree::CountryTreeListener,
|
||||
public storage::ActiveMapsLayout::ActiveMapsListener
|
||||
{
|
||||
private:
|
||||
::Framework m_work;
|
||||
VideoTimer * m_videoTimer;
|
||||
|
||||
shared_ptr<jobject> m_javaCountryListenerPtr;
|
||||
shared_ptr<jobject> m_javaActiveCountryListenerPtr;
|
||||
storage::CountryTree::CountryTreeListener * m_treeListener;
|
||||
storage::ActiveMapsLayout::ActiveMapsListener * m_activeMapsListener;
|
||||
typedef shared_ptr<jobject> TJobject;
|
||||
|
||||
TJobject m_javaCountryListener;
|
||||
typedef map<int, TJobject> TListenerMap;
|
||||
TListenerMap m_javaActiveMapListeners;
|
||||
int m_currentSlotID;
|
||||
|
||||
int m_activeMapsConnectionID;
|
||||
|
||||
void CallRepaint();
|
||||
|
||||
|
@ -141,17 +147,24 @@ namespace android
|
|||
|
||||
void ShowTrack(int category, int track);
|
||||
|
||||
storage::CountryTree::CountryTreeListener * setCountryTreeListener(shared_ptr<jobject> objPtr);
|
||||
void SetCountryTreeListener(shared_ptr<jobject> objPtr);
|
||||
void ResetCountryTreeListener();
|
||||
|
||||
void resetCountryTreeListener();
|
||||
int AddActiveMapsListener(shared_ptr<jobject> obj);
|
||||
void RemoveActiveMapsListener(int slotID);
|
||||
|
||||
storage::ActiveMapsLayout::ActiveMapsListener * setActiveMapsListener(shared_ptr<jobject> objPtr);
|
||||
public:
|
||||
virtual void ItemStatusChanged(int childPosition);
|
||||
virtual void ItemProgressChanged(int childPosition, storage::LocalAndRemoteSizeT const & sizes);
|
||||
|
||||
void resetActiveMapsListener();
|
||||
|
||||
shared_ptr<jobject> getJavaCountryListener();
|
||||
|
||||
shared_ptr<jobject> getJavaActiveCountryListener();
|
||||
virtual void CountryGroupChanged(storage::ActiveMapsLayout::TGroup const & oldGroup, int oldPosition,
|
||||
storage::ActiveMapsLayout::TGroup const & newGroup, int newPosition);
|
||||
virtual void CountryStatusChanged(storage::ActiveMapsLayout::TGroup const & group, int position,
|
||||
storage::TStatus const & oldStatus, storage::TStatus const & newStatus);
|
||||
virtual void CountryOptionsChanged(storage::ActiveMapsLayout::TGroup const & group, int position,
|
||||
storage::TMapOptions const & oldOpt, storage::TMapOptions const & newOpt);
|
||||
virtual void DownloadingProgressUpdate(storage::ActiveMapsLayout::TGroup const & group, int position,
|
||||
storage::LocalAndRemoteSizeT const & progress);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
package com.mapswithme.country;
|
||||
|
||||
import com.mapswithme.maps.guides.GuideInfo;
|
||||
import com.mapswithme.maps.MapStorage.Index;
|
||||
|
||||
public class ActiveCountryTree
|
||||
{
|
||||
private ActiveCountryTree() {}
|
||||
|
||||
interface ActiveCountryListener extends CountryTree.BaseListener
|
||||
public interface ActiveCountryListener extends CountryTree.BaseListener
|
||||
{
|
||||
void onCountryProgressChanged(int group, int position, long[] sizes);
|
||||
|
||||
void onCountryStatusChanged(int group, int position);
|
||||
void onCountryStatusChanged(int group, int position, int oldStatus, int newStatus);
|
||||
|
||||
void onCountryGroupChanged(int oldGroup, int oldPosition, int newGroup, int newPosition);
|
||||
|
||||
void onCountryOptionsChanged(int group, int position);
|
||||
void onCountryOptionsChanged(int group, int position, int newOptions, int requestOptions);
|
||||
}
|
||||
|
||||
// Should be equal to values from ActiveMapsLayout::TGroup enum
|
||||
|
@ -47,6 +48,7 @@ public class ActiveCountryTree
|
|||
public static native void downloadMap(int group, int position, int options);
|
||||
|
||||
public static native void deleteMap(int group, int position, int options);
|
||||
public static native Index getCoreIndex(int group, int position);
|
||||
|
||||
public static native void showOnMap(int group, int position);
|
||||
|
||||
|
|
|
@ -271,7 +271,7 @@ public class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCoun
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCountryStatusChanged(int group, int position)
|
||||
public void onCountryStatusChanged(int group, int position, int oldStatus, int newStatus)
|
||||
{
|
||||
onCountryStatusChanged(getAbsolutePosition(group, position));
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ public class DownloadedAdapter extends BaseDownloadAdapter implements ActiveCoun
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCountryOptionsChanged(int group, int position)
|
||||
public void onCountryOptionsChanged(int group, int position, int newOpt, int requestOpt)
|
||||
{
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
|||
import com.mapswithme.maps.guides.GuideInfo;
|
||||
import com.mapswithme.maps.guides.GuidesUtils;
|
||||
import com.mapswithme.maps.location.LocationService;
|
||||
import com.mapswithme.country.ActiveCountryTree;
|
||||
import com.mapswithme.country.StorageOptions;
|
||||
import com.mapswithme.util.Constants;
|
||||
import com.mapswithme.util.FbUtil;
|
||||
import com.mapswithme.util.Utils;
|
||||
|
@ -25,10 +27,12 @@ import com.mapswithme.util.log.Logger;
|
|||
import com.mapswithme.util.log.StubLogger;
|
||||
import com.mobileapptracker.MobileAppTracker;
|
||||
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class MWMApplication extends android.app.Application implements MapStorage.Listener
|
||||
public class MWMApplication extends android.app.Application implements ActiveCountryTree.ActiveCountryListener
|
||||
{
|
||||
private final static String TAG = "MWMApplication";
|
||||
private static final CharSequence PRO_PACKAGE_POSTFIX = ".pro";
|
||||
|
@ -58,26 +62,36 @@ public class MWMApplication extends android.app.Application implements MapStorag
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCountryStatusChanged(Index idx)
|
||||
{
|
||||
switch (MapStorage.INSTANCE.countryStatus(idx))
|
||||
{
|
||||
case MapStorage.ON_DISK:
|
||||
Notifier.placeDownloadCompleted(idx, MapStorage.INSTANCE.countryName(idx));
|
||||
tryNotifyGuideAvailable(idx);
|
||||
break;
|
||||
public void onCountryProgressChanged(int group, int position, long[] sizes) {}
|
||||
|
||||
case MapStorage.DOWNLOAD_FAILED:
|
||||
Notifier.placeDownloadFailed(idx, MapStorage.INSTANCE.countryName(idx));
|
||||
break;
|
||||
@Override
|
||||
public void onCountryStatusChanged(int group, int position, int oldStatus, int newStatus)
|
||||
{
|
||||
if (newStatus == MapStorage.DOWNLOAD_FAILED)
|
||||
Notifier.placeDownloadFailed(ActiveCountryTree.getCoreIndex(group, position), ActiveCountryTree.getCountryName(group, position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCountryGroupChanged(int oldGroup, int oldPosition, int newGroup, int newPosition) {}
|
||||
|
||||
@Override
|
||||
public void onCountryOptionsChanged(int group, int position, int newOptions, int requestOptions)
|
||||
{
|
||||
if (ActiveCountryTree.getCountryStatus(group, position) != MapStorage.ON_DISK)
|
||||
return;
|
||||
|
||||
if (newOptions == requestOptions)
|
||||
{
|
||||
Notifier.placeDownloadCompleted(ActiveCountryTree.getCoreIndex(group, position), ActiveCountryTree.getCountryName(group, position));
|
||||
tryNotifyGuideAvailable(group, position);
|
||||
}
|
||||
}
|
||||
|
||||
private void tryNotifyGuideAvailable(Index idx)
|
||||
private void tryNotifyGuideAvailable(int group, int position)
|
||||
{
|
||||
if (Utils.hasAnyGoogleStoreInstalled())
|
||||
{
|
||||
final GuideInfo info = Framework.getGuideInfoForIndexWithApiCheck(idx);
|
||||
final GuideInfo info = ActiveCountryTree.getGuideInfo(group, position);
|
||||
if (info != null && !GuidesUtils.isGuideInstalled(info.mAppId, this)
|
||||
&& !Framework.wasAdvertised(info.mAppId))
|
||||
{
|
||||
|
@ -87,11 +101,6 @@ public class MWMApplication extends android.app.Application implements MapStorag
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCountryProgress(Index idx, long current, long total)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate()
|
||||
{
|
||||
|
@ -114,7 +123,7 @@ public class MWMApplication extends android.app.Application implements MapStorag
|
|||
nativeInit(getApkPath(), extStoragePath, extTmpPath,
|
||||
getOBBGooglePath(), BuildConfig.IS_PRO, mIsYota);
|
||||
|
||||
MapStorage.INSTANCE.subscribe(this);
|
||||
ActiveCountryTree.addListener(this);
|
||||
|
||||
// init cross-platform strings bundle
|
||||
nativeAddLocalization("country_status_added_to_queue", getString(R.string.country_status_added_to_queue));
|
||||
|
|
|
@ -361,6 +361,8 @@ void ActiveMapsLayout::StatusChangedCallback(TIndex const & index)
|
|||
int position = 0;
|
||||
VERIFY(GetGroupAndPositionByIndex(index, group, position), ());
|
||||
Item & item = GetItemInGroup(group, position);
|
||||
|
||||
TStatus oldStatus = item.m_status;
|
||||
item.m_status = newStatus;
|
||||
|
||||
if (newStatus == TStatus::EOnDisk)
|
||||
|
@ -377,11 +379,12 @@ void ActiveMapsLayout::StatusChangedCallback(TIndex const & index)
|
|||
// but we must notify that options changed because for "NewMaps" m_options is virtual state
|
||||
if (item.m_options != options || group == TGroup::ENewMap)
|
||||
{
|
||||
TMapOptions requestOptions = options;
|
||||
item.m_downloadRequest = item.m_options = options;
|
||||
NotifyOptionsChanged(group, position);
|
||||
NotifyOptionsChanged(group, position, item.m_options, requestOptions);
|
||||
}
|
||||
|
||||
NotifyStatusChanged(group, position);
|
||||
NotifyStatusChanged(group, position, oldStatus, item.m_status);
|
||||
|
||||
int newPosition = MoveItemToGroup(group, position, TGroup::EUpToDate);
|
||||
NotifyMove(group, position, TGroup::EUpToDate, newPosition);
|
||||
|
@ -392,8 +395,9 @@ void ActiveMapsLayout::StatusChangedCallback(TIndex const & index)
|
|||
// "Actual map without routing" -> "Actual map with routing"
|
||||
// "Actual map with routing" -> "Actual map without routing"
|
||||
ASSERT(item.m_options != options, ());
|
||||
TMapOptions requestOpt = item.m_downloadRequest;
|
||||
item.m_options = item.m_downloadRequest = options;
|
||||
NotifyOptionsChanged(group, position);
|
||||
NotifyOptionsChanged(group, position, item.m_options, requestOpt);
|
||||
}
|
||||
}
|
||||
else if (newStatus == TStatus::ENotDownloaded)
|
||||
|
@ -404,7 +408,7 @@ void ActiveMapsLayout::StatusChangedCallback(TIndex const & index)
|
|||
// We handle here only status change for "New maps"
|
||||
// because if new status ENotDownloaded than item.m_options is invalid.
|
||||
// Map have no options and gui not show routing icon
|
||||
NotifyStatusChanged(group, position);
|
||||
NotifyStatusChanged(group, position, oldStatus, item.m_status);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -417,7 +421,7 @@ void ActiveMapsLayout::StatusChangedCallback(TIndex const & index)
|
|||
else if (newStatus == TStatus::EOnDiskOutOfDate)
|
||||
{
|
||||
// We can drop here only if user start update some map and cancel it
|
||||
NotifyStatusChanged(group, position);
|
||||
NotifyStatusChanged(group, position, oldStatus, item.m_status);
|
||||
|
||||
ASSERT(item.m_options == options, ());
|
||||
item.m_downloadRequest = item.m_options = options;
|
||||
|
@ -427,7 +431,7 @@ void ActiveMapsLayout::StatusChangedCallback(TIndex const & index)
|
|||
// EDownloading
|
||||
// EInQueue
|
||||
// downloadig faild for some reason
|
||||
NotifyStatusChanged(group, position);
|
||||
NotifyStatusChanged(group, position, oldStatus, item.m_status);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -607,7 +611,7 @@ void ActiveMapsLayout::NotifyInsertion(TGroup const & group, int position)
|
|||
void ActiveMapsLayout::NotifyDeletion(TGroup const & group, int position)
|
||||
{
|
||||
for (TListenerNode listener : m_listeners)
|
||||
listener.second->CountryGroupChanged(group, position, group, position);
|
||||
listener.second->CountryGroupChanged(group, position, group, -1);
|
||||
}
|
||||
|
||||
void ActiveMapsLayout::NotifyMove(TGroup const & oldGroup, int oldPosition,
|
||||
|
@ -617,16 +621,18 @@ void ActiveMapsLayout::NotifyMove(TGroup const & oldGroup, int oldPosition,
|
|||
listener.second->CountryGroupChanged(oldGroup, oldPosition, newGroup, newPosition);
|
||||
}
|
||||
|
||||
void ActiveMapsLayout::NotifyStatusChanged(TGroup const & group, int position)
|
||||
void ActiveMapsLayout::NotifyStatusChanged(TGroup const & group, int position,
|
||||
TStatus const & oldStatus, TStatus const & newStatus)
|
||||
{
|
||||
for (TListenerNode listener : m_listeners)
|
||||
listener.second->CountryStatusChanged(group, position);
|
||||
listener.second->CountryStatusChanged(group, position, oldStatus, newStatus);
|
||||
}
|
||||
|
||||
void ActiveMapsLayout::NotifyOptionsChanged(TGroup const & group, int position)
|
||||
void ActiveMapsLayout::NotifyOptionsChanged(TGroup const & group, int position,
|
||||
TMapOptions const & oldOpt, TMapOptions const & newOpt)
|
||||
{
|
||||
for (TListenerNode listener : m_listeners)
|
||||
listener.second->CountryOptionsChanged(group, position);
|
||||
listener.second->CountryOptionsChanged(group, position, oldOpt, newOpt);
|
||||
}
|
||||
|
||||
TMapOptions ActiveMapsLayout::ValidOptionsForDownload(TMapOptions const & options)
|
||||
|
|
|
@ -32,8 +32,10 @@ public:
|
|||
/// if group of country been changed. than oldGroup != newGroup, oldPosition >= 0 and newPosition >= 0
|
||||
virtual void CountryGroupChanged(TGroup const & oldGroup, int oldPosition,
|
||||
TGroup const & newGroup, int newPosition) = 0;
|
||||
virtual void CountryStatusChanged(TGroup const & group, int position) = 0;
|
||||
virtual void CountryOptionsChanged(TGroup const & group, int position) = 0;
|
||||
virtual void CountryStatusChanged(TGroup const & group, int position,
|
||||
TStatus const & oldStatus, TStatus const & newStatus) = 0;
|
||||
virtual void CountryOptionsChanged(TGroup const & group, int position,
|
||||
TMapOptions const & oldOpt, TMapOptions const & newOpt) = 0;
|
||||
virtual void DownloadingProgressUpdate(TGroup const & group, int position,
|
||||
LocalAndRemoteSizeT const & progress) = 0;
|
||||
};
|
||||
|
@ -123,8 +125,10 @@ private:
|
|||
void NotifyMove(TGroup const & oldGroup, int oldPosition,
|
||||
TGroup const & newGroup, int newPosition);
|
||||
|
||||
void NotifyStatusChanged(TGroup const & group, int position);
|
||||
void NotifyOptionsChanged(TGroup const & group, int position);
|
||||
void NotifyStatusChanged(TGroup const & group, int position,
|
||||
TStatus const & oldStatus, TStatus const & newStatus);
|
||||
void NotifyOptionsChanged(TGroup const & group, int position,
|
||||
TMapOptions const & oldOpt, TMapOptions const & newOpt);
|
||||
|
||||
TMapOptions ValidOptionsForDownload(TMapOptions const & options);
|
||||
TMapOptions ValidOptionsForDelete(TMapOptions const & options);
|
||||
|
|
|
@ -210,13 +210,14 @@ bool CountryStatusDisplay::onTapCancelled(m2::PointD const & pt)
|
|||
return OnTapAction(bind(&gui::Button::onTapCancelled, _1, _2), pt);
|
||||
}
|
||||
|
||||
void CountryStatusDisplay::CountryStatusChanged(ActiveMapsLayout::TGroup const & group, int position)
|
||||
void CountryStatusDisplay::CountryStatusChanged(ActiveMapsLayout::TGroup const & group, int position,
|
||||
TStatus const & /*oldStatus*/, TStatus const & newStatus)
|
||||
{
|
||||
TIndex index = m_activeMaps.GetCoreIndex(group, position);
|
||||
if (m_countryIdx == index)
|
||||
{
|
||||
Lock();
|
||||
m_countryStatus = m_activeMaps.GetCountryStatus(index);
|
||||
m_countryStatus = newStatus;
|
||||
Repaint();
|
||||
Unlock();
|
||||
}
|
||||
|
|
|
@ -68,8 +68,10 @@ public:
|
|||
private:
|
||||
virtual void CountryGroupChanged(storage::ActiveMapsLayout::TGroup const & oldGroup, int oldPosition,
|
||||
storage::ActiveMapsLayout::TGroup const & newGroup, int newPosition) {}
|
||||
virtual void CountryStatusChanged(storage::ActiveMapsLayout::TGroup const & group, int position);
|
||||
virtual void CountryOptionsChanged(storage::ActiveMapsLayout::TGroup const & group, int position){}
|
||||
virtual void CountryStatusChanged(storage::ActiveMapsLayout::TGroup const & group, int position,
|
||||
storage::TStatus const & oldStatus, storage::TStatus const & newStatus);
|
||||
virtual void CountryOptionsChanged(storage::ActiveMapsLayout::TGroup const & group, int position,
|
||||
storage::TMapOptions const & oldOpt, storage::TMapOptions const & newOpt){}
|
||||
virtual void DownloadingProgressUpdate(storage::ActiveMapsLayout::TGroup const & group, int position,
|
||||
storage::LocalAndRemoteSizeT const & progress);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue