[codereview]

This commit is contained in:
Dmitry Kunin 2013-08-28 16:47:19 +03:00 committed by Alex Zolotarev
parent 888239c75d
commit c5465383da
2 changed files with 18 additions and 18 deletions

View file

@ -777,21 +777,21 @@ extern "C"
{
vector<guides::GuideInfo> infos;
g_framework->NativeFramework()->GetGuidesInfosWithDownloadedMaps(infos);
const size_t mapsFound = infos.size();
LOG(LDEBUG, ("Got maps:", infos));
if (infos.size() > 0)
if (mapsFound > 0)
{
const jclass giClass = env->FindClass("com/mapswithme/maps/guides/GuideInfo");
const jmethodID methodID = env->GetMethodID(giClass, "<init>",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
const string lang = languages::CurrentLanguage();
jobjectArray jInfos = env->NewObjectArray(infos.size(), giClass, NULL);
jobjectArray jInfos = env->NewObjectArray(mapsFound, giClass, NULL);
for (int i = 0; i < infos.size(); ++i)
for (size_t i = 0; i < mapsFound; ++i)
{
const guides::GuideInfo info = infos[i];
const guides::GuideInfo & info = infos[i];
jobject jGuideInfo = env->NewObject(giClass, methodID,
jni::ToJavaString(env, info.GetAppID()),
jni::ToJavaString(env, info.GetURL()), jni::ToJavaString(env, info.GetAdTitle(lang)),

View file

@ -279,21 +279,21 @@ public class DownloadResourcesActivity extends MapsWithMeBaseActivity
private void tryAdvertiseGuides()
{
final GuideInfo[] gInfos = Framework.getGuideInfosForDownloadedMaps();
if (gInfos != null)
if (gInfos == null)
return;
// iterate all guides until find not installed && not advertised one
for (final GuideInfo info : gInfos)
{
// iterate all guides until find not installed && not advertised one
for (final GuideInfo info : gInfos)
if (GuidesUtils.isGuideInstalled(info.mAppId, this))
Framework.setWasAdvertised(info.mAppId);
else if (!Framework.wasAdvertised(info.mAppId))
{
if (!GuidesUtils.isGuideInstalled(info.mAppId, this) && !Framework.wasAdvertised(info.mAppId))
{
final Notifier noty = new Notifier(this);
noty.placeGuideAvailable(info.mAppId, info.mTitle, info.mMessage);
Framework.setWasAdvertised(info.mAppId);
break;
}
// mark installed guides as advertised
else if (GuidesUtils.isGuideInstalled(info.mAppId, this))
Framework.setWasAdvertised(info.mAppId);
final Notifier noty = new Notifier(this);
noty.placeGuideAvailable(info.mAppId, info.mTitle, info.mMessage);
Framework.setWasAdvertised(info.mAppId);
break;
}
}
}