Navigation Menu

Skip to content

Commit

Permalink
Android: apply code simplications found with lint / Android Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
1bsyl committed Oct 27, 2020
1 parent ddc0727 commit 97cf314
Show file tree
Hide file tree
Showing 4 changed files with 220 additions and 220 deletions.
15 changes: 8 additions & 7 deletions android-project/app/src/main/java/org/libsdl/app/SDL.java
Expand Up @@ -2,7 +2,8 @@

import android.content.Context;

import java.lang.reflect.*;
import java.lang.Class;
import java.lang.reflect.Method;

/**
SDL library initialization
Expand Down Expand Up @@ -51,16 +52,16 @@ public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError,
// To use ReLinker, just add it as a dependency. For more information, see
// https://github.com/KeepSafe/ReLinker for ReLinker's repository.
//
Class relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
Class relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
Class contextClass = mContext.getClassLoader().loadClass("android.content.Context");
Class stringClass = mContext.getClassLoader().loadClass("java.lang.String");
Class<?> relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
Class<?> relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
Class<?> contextClass = mContext.getClassLoader().loadClass("android.content.Context");
Class<?> stringClass = mContext.getClassLoader().loadClass("java.lang.String");

// Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if
// they've changed during updates.
Method forceMethod = relinkClass.getDeclaredMethod("force");
Object relinkInstance = forceMethod.invoke(null);
Class relinkInstanceClass = relinkInstance.getClass();
Class<?> relinkInstanceClass = relinkInstance.getClass();

// Actually load the library!
Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass);
Expand All @@ -77,7 +78,7 @@ public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError,
catch (final SecurityException se) {
throw se;
}
}
}
}

protected static Context mContext;
Expand Down

0 comments on commit 97cf314

Please sign in to comment.