Feat [ExtraCore]: ExtraCore can now consume values

The commit also prepares a few new constants and change an anotation
This commit is contained in:
Boulay Mathias 2022-11-05 16:58:39 +01:00
parent d1c88a19e0
commit f74a77826d
3 changed files with 24 additions and 2 deletions

View File

@ -4,9 +4,24 @@ public class ExtraConstants {
/* ExtraCore constant: a HashMap for converting values such as latest-snapshot or latest-release to actual game version names */
public static final String RELEASE_TABLE = "release_table";
/* ExtraCore constant: an ArrayList of Strings, where each String is a Minecraft version name */
public static final String VERSION_LIST= "lac_version_list";
public static final String VERSION_LIST = "lac_version_list";
/* ExtraCore constant: Serpent's back button tracking thing */
public static final String BACK_PREFERENCE = "back_preference";
/* ExtraCore constant: The OPENGL version that should be exposed */
public static final String OPEN_GL_VERSION = "open_gl_version";
/* ExtraCore constant: When the microsoft authentication via webview is done */
public static final String MICROSOFT_LOGIN_TODO = "webview_login_done";
/* ExtraCore constant: Mojang or "local" authentication to perform */
public static final String MOJANG_LOGIN_TODO = "mojang_login_todo";
/* ExtraCore constant: Add minecraft account procedure, the user has to select between mojang or microsoft */
public static final String SELECT_AUTH_METHOD = "start_login_procedure";
/* ExtraCore constant: Selected file or folder, as a String */
public static final String FILE_SELECTOR = "file_selector";
/* ExtraCore constant: Need to refresh the version spinner, selecting the uuid at the same time. Can be DELETED_PROFILE */
public static final String REFRESH_VERSION_SPINNER = "refresh_version";
/* ExtraCore Constant: When we want to launch the game */
public static final String LAUNCH_GAME = "launch_game";
}

View File

@ -71,6 +71,12 @@ public final class ExtraCore {
getInstance().mValueMap.remove(key);
}
public static Object consumeValue(String key){
Object value = getInstance().mValueMap.get(key);
getInstance().mValueMap.remove(key);
return value;
}
/** Remove all values */
public static void removeAllValues(){
getInstance().mValueMap.clear();

View File

@ -1,5 +1,6 @@
package net.kdt.pojavlaunch.extra;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/**
@ -14,6 +15,6 @@ public interface ExtraListener<T> {
* @param value The new value as a string
* @return Whether you consume the Listener (stop listening)
*/
boolean onValueSet(String key, @Nullable T value);
boolean onValueSet(String key, @NonNull T value);
}