Skip to content
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.

Commit

Permalink
Fix crash on duplicate keys, #96
Browse files Browse the repository at this point in the history
  • Loading branch information
PranavPurwar authored Aug 19, 2023
1 parent bf6c4a7 commit 65534bf
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import de.Maxr1998.modernpreferences.PreferenceScreen
import org.cosmicide.rewrite.util.MultipleDexClassLoader
import java.io.File
import java.lang.reflect.Modifier
import java.lang.reflect.InvocationTargetException

object PluginLoader {
@JvmStatic
Expand Down Expand Up @@ -62,8 +63,13 @@ object PluginLoader {
)
if (Modifier.isStatic(method.modifiers)) {
Log.d("Plugin", "Registering preferences for plugin ${plugin.name}")
prefsMethods.add {
prefMethod.invoke(null, this)
try {
prefsMethods.add {
prefMethod.invoke(null, this)
}
} catch (e: InvocationTargetException) {
// usually occurs when prefs is already registered. For more info, see #96)
e.printStackTrace()
}
} else {
Log.e("Plugin", "registerPreferences method is not static")
Expand All @@ -77,4 +83,4 @@ object PluginLoader {
Log.e("Plugin", "Failed to load plugin ${plugin.name}", it)
}
}
}
}

0 comments on commit 65534bf

Please sign in to comment.