Skip to content

armgit / haven

Public Imported from GitHub
0

Haven is for people who need a way to protect their personal spaces and possessions without compromising their own privacy, through an Android app and on-device sensors

Fix potential crash from fresco thank to ShawnDongAi on stackoverflow

fattire46e1c9e99be5
diff --git a/src/main/java/org/havenapp/main/HavenApp.java b/src/main/java/org/havenapp/main/HavenApp.java
index ab61507..b6a967e 100644
--- a/src/main/java/org/havenapp/main/HavenApp.java
+++ b/src/main/java/org/havenapp/main/HavenApp.java
@@ -19,10 +19,15 @@ package org.havenapp.main;
import android.util.Log;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatDelegate;
+import androidx.multidex.MultiDexApplication;
+
import com.evernote.android.job.JobManager;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.imagepipeline.core.ImagePipelineConfig;
import com.facebook.imagepipeline.decoder.SimpleProgressiveJpegConfig;
+import com.facebook.imagepipeline.nativecode.ImagePipelineNativeLoader;
import org.havenapp.main.database.HavenEventDB;
import org.havenapp.main.service.HavenJobCreator;
@@ -30,10 +35,6 @@ import org.havenapp.main.service.WebServer;
import java.io.IOException;
-import androidx.annotation.NonNull;
-import androidx.appcompat.app.AppCompatDelegate;
-import androidx.multidex.MultiDexApplication;
-
public class HavenApp extends MultiDexApplication {
@@ -54,14 +55,25 @@ public class HavenApp extends MultiDexApplication {
mPrefs = new PreferenceManager(this);
- ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
+ ImagePipelineConfig.Builder b = ImagePipelineConfig.newBuilder(this);
+ ImagePipelineConfig config = b
.setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())
.setResizeAndRotateEnabledForNetwork(true)
.setDownsampleEnabled(true)
.build();
Fresco.initialize(this,config);
-
+
+ try {
+ ImagePipelineNativeLoader.load();
+ } catch (UnsatisfiedLinkError e) {
+ Fresco.shutDown();
+ b.experiment().setNativeCodeDisabled(true);
+ config = b.build();
+ Fresco.initialize(this, config);
+ e.printStackTrace();
+ }
+
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
if (mPrefs.getRemoteAccessActive())