forked from organicmaps/organicmaps
[android] Added bookmark webview error description logging
This commit is contained in:
parent
559021ffef
commit
e98624d6e2
2 changed files with 30 additions and 3 deletions
|
@ -1,7 +1,9 @@
|
|||
package com.mapswithme.maps.bookmarks;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.net.http.SslError;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
@ -22,6 +24,7 @@ import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
|||
import com.mapswithme.util.ConnectionState;
|
||||
import com.mapswithme.util.DialogUtils;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.Utils;
|
||||
import com.mapswithme.util.log.Logger;
|
||||
import com.mapswithme.util.log.LoggerFactory;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
@ -183,7 +186,15 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
|
|||
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error)
|
||||
{
|
||||
super.onReceivedError(view, request, error);
|
||||
handleError(error);
|
||||
String description = Utils.isMarshmallowOrLater() ? makeDescription(error) : null;
|
||||
handleError(error, description);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
@NonNull
|
||||
private static String makeDescription(@NonNull WebResourceError error)
|
||||
{
|
||||
return error.getErrorCode() + " " + error.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -194,6 +205,11 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
|
|||
}
|
||||
|
||||
private void handleError(@NonNull Object error)
|
||||
{
|
||||
handleError(error, null);
|
||||
}
|
||||
|
||||
private void handleError(@NonNull Object error, @Nullable String description)
|
||||
{
|
||||
mError = error;
|
||||
BookmarksCatalogFragment frag;
|
||||
|
@ -204,7 +220,7 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
|
|||
UiUtils.hide(frag.mWebView, frag.mProgressView);
|
||||
if (ConnectionState.isConnected())
|
||||
{
|
||||
LOGGER.e(TAG, "Failed to load catalog: " + mError.toString());
|
||||
LOGGER.e(TAG, "Failed to load catalog: " + mError + ", description: " + description);
|
||||
Statistics.INSTANCE.trackDownloadCatalogError(Statistics.ParamValue.UNKNOWN);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -62,8 +62,19 @@ public class Utils
|
|||
|
||||
public static boolean isLollipopOrLater()
|
||||
{
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
|
||||
return isTargetOrLater(Build.VERSION_CODES.LOLLIPOP);
|
||||
}
|
||||
|
||||
public static boolean isMarshmallowOrLater()
|
||||
{
|
||||
return isTargetOrLater(Build.VERSION_CODES.M);
|
||||
}
|
||||
|
||||
private static boolean isTargetOrLater(int target)
|
||||
{
|
||||
return Build.VERSION.SDK_INT >= target;
|
||||
}
|
||||
|
||||
public static boolean isAmazonDevice()
|
||||
{
|
||||
return "Amazon".equalsIgnoreCase(Build.MANUFACTURER);
|
||||
|
|
Loading…
Add table
Reference in a new issue