Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralexzatsepin <az@mapswithme.com>2016-11-22 16:09:36 +0300
committerДобрый Ээх <bukharaev@gmail.com>2016-12-09 20:11:34 +0300
commit6c09259a9de1e504f2dc0e19b4c387df29b879d8 (patch)
tree846ab0c90ba4e459f88da99740a30999d3c0d0de /android
parent340e5ccd01191f023e65e568bfd8f39ca87eae01 (diff)
[android] Added the additional crashlytics logs to diagnose the 'IndexOutOfBounds' error in downloaderAdapter
Diffstat (limited to 'android')
-rw-r--r--android/src/com/mapswithme/maps/downloader/DownloaderAdapter.java59
-rw-r--r--android/src/com/mapswithme/maps/downloader/DownloaderFragment.java2
-rw-r--r--android/src/com/mapswithme/util/statistics/MytargetHelper.java1
3 files changed, 50 insertions, 12 deletions
diff --git a/android/src/com/mapswithme/maps/downloader/DownloaderAdapter.java b/android/src/com/mapswithme/maps/downloader/DownloaderAdapter.java
index 5098356a6d..5b6433d2c0 100644
--- a/android/src/com/mapswithme/maps/downloader/DownloaderAdapter.java
+++ b/android/src/com/mapswithme/maps/downloader/DownloaderAdapter.java
@@ -16,6 +16,7 @@ import android.support.v7.widget.RecyclerView;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.StyleSpan;
+import android.util.Log;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
@@ -23,6 +24,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
+import com.crashlytics.android.Crashlytics;
import com.mapswithme.maps.MwmActivity;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
@@ -621,9 +623,40 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
void bind(int position)
{
if (position >= mNearMeCount && position < mNearMeCount + getAdsCount())
+ {
mTitle.setText(HEADER_ADVERTISMENT_TITLE);
+ }
else
- mTitle.setText(mHeaders.get(mItems.get(position).headerId));
+ {
+ // TODO: remove this debug 'if' if the crash is gone in next (6.5.3) release
+ // - https://www.fabric.io/mapsme/android/apps/com.mapswithme.maps.pro/issues/58249a350aeb16625bb4d0a7,
+ // otherwise the logged information should help to pinpoint the 'IndexOutOfBounds' bug.
+ if (position >= mItems.size())
+ logIndexOutOfBoundsErrorInfoToCrashlytics(position);
+
+ CountryItem ci = mItems.get(position);
+ mTitle.setText(mHeaders.get(ci.headerId));
+ }
+ }
+ }
+
+ private void logIndexOutOfBoundsErrorInfoToCrashlytics(int position)
+ {
+ String tag = DownloaderAdapter.class.getSimpleName();
+ int itemSize = mItems.size();
+ Crashlytics.log(Log.ERROR, tag, "Index " + position + " is out of bounds, mItem.size = "
+ + itemSize + ", current thread = " + Thread.currentThread() +
+ " mNearMeCount = " + mNearMeCount + ", ads count = " + mAds.size()
+ + ", showAds = " + mShowAds + ", mAdsLoaded = " + mAdsLoaded
+ + ", mAdsLoading = " + mAdsLoading +
+ " mSearchResultsMode = " + mSearchResultsMode
+ + ", mSearchQuery = " + mSearchQuery +
+ " mHeaders.size = " + mHeaders.size()
+ + " mHeaders = " + mHeaders);
+ if (itemSize > 0)
+ {
+ CountryItem lastCi = mItems.get(--itemSize);
+ Crashlytics.log(Log.INFO, tag, "last county item in position = " + itemSize + " = " + lastCi);
}
}
@@ -750,7 +783,7 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
processData();
}
- void clearAds()
+ void clearAdsAndCancelMyTarget()
{
if (mAds.isEmpty())
return;
@@ -758,9 +791,8 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
if (mMytargetHelper != null)
mMytargetHelper.cancel();
- mAds.clear();
+ clearAdsInternal();
mAdsLoaded = false;
- notifyDataSetChanged();
}
void resetSearchResultsMode()
@@ -996,13 +1028,7 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
mAdsLoading = false;
mAdsLoaded = true;
- int oldSize = mAds.size();
- mAds.clear();
- if (oldSize > 0)
- {
- mHeadersDecoration.invalidateHeaders();
- notifyItemRangeRemoved(mNearMeCount, oldSize);
- }
+ clearAdsInternal();
}
@Override
@@ -1044,6 +1070,17 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
});
}
+ private void clearAdsInternal()
+ {
+ int oldSize = mAds.size();
+ mAds.clear();
+ if (oldSize > 0)
+ {
+ mHeadersDecoration.invalidateHeaders();
+ notifyItemRangeRemoved(mNearMeCount, oldSize);
+ }
+ }
+
void attach()
{
mListenerSlot = MapManager.nativeSubscribe(mStorageCallback);
diff --git a/android/src/com/mapswithme/maps/downloader/DownloaderFragment.java b/android/src/com/mapswithme/maps/downloader/DownloaderFragment.java
index f087b50e61..bed0dcb445 100644
--- a/android/src/com/mapswithme/maps/downloader/DownloaderFragment.java
+++ b/android/src/com/mapswithme/maps/downloader/DownloaderFragment.java
@@ -76,7 +76,7 @@ public class DownloaderFragment extends BaseMwmRecyclerFragment
mCurrentSearch = System.nanoTime();
SearchEngine.searchMaps(mToolbarController.getQuery(), mCurrentSearch);
mToolbarController.showProgress(true);
- mAdapter.clearAds();
+ mAdapter.clearAdsAndCancelMyTarget();
}
void clearSearchQuery()
diff --git a/android/src/com/mapswithme/util/statistics/MytargetHelper.java b/android/src/com/mapswithme/util/statistics/MytargetHelper.java
index 97775f4160..97b924d977 100644
--- a/android/src/com/mapswithme/util/statistics/MytargetHelper.java
+++ b/android/src/com/mapswithme/util/statistics/MytargetHelper.java
@@ -137,6 +137,7 @@ public final class MytargetHelper
private NativeAppwallAd loadAds(final @NonNull Listener<List<NativeAppwallBanner>> listener, Activity activity)
{
NativeAppwallAd res = new NativeAppwallAd(PrivateVariables.myTargetSlot(), activity);
+ res.setCachePeriod(0);
res.setListener(new NativeAppwallAd.AppwallAdListener()
{
@Override