Initial commit
This commit is contained in:
118
sources/com/ubt/jimu/base/util/PathHelper.java
Normal file
118
sources/com/ubt/jimu/base/util/PathHelper.java
Normal file
@@ -0,0 +1,118 @@
|
||||
package com.ubt.jimu.base.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.base.entities.RobotLite;
|
||||
import com.ubt.jimu.controller.data.action.ActionSequence;
|
||||
import com.ubt.jimu.unity.ModelType;
|
||||
import com.ubt.jimu.utils.ExternalOverFroyoUtils;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class PathHelper {
|
||||
private static final String CONTROLLER_DIR = "ControllerData";
|
||||
public static final String CONTROLLER_PREFIX = "controller_";
|
||||
private static final String GAME_CONTROLLER_CONFIG_DIR = "gameControllerConfig";
|
||||
private static final String GAME_CONTROLLER_KEY_MAP_FILE_NAME = "keymap.xml";
|
||||
private static final String MOVE_CONFIG_NAME = "moveConfig.xml";
|
||||
public static final String OLD_CONTROLLER_PREFIX = "robot_";
|
||||
private static final String SOUNDS_DIR = "sounds";
|
||||
private static final String SOUND_SUFFIX = ".aac";
|
||||
private static final String WIDGET_CONFIG_DIR = "widgetConfig";
|
||||
|
||||
static /* synthetic */ boolean a(File file, String str) {
|
||||
return str.startsWith(CONTROLLER_PREFIX) || str.startsWith(OLD_CONTROLLER_PREFIX);
|
||||
}
|
||||
|
||||
public static String getActionDir(Context context, RobotLite robotLite, boolean z) {
|
||||
if (robotLite == null) {
|
||||
return null;
|
||||
}
|
||||
return getDataRootDir(context, robotLite, z) + "actions" + File.separator;
|
||||
}
|
||||
|
||||
public static String getControllerDir(Context context, RobotLite robotLite, boolean z) {
|
||||
if (robotLite == null) {
|
||||
return null;
|
||||
}
|
||||
return getDataRootDir(context, robotLite, z) + "ControllerData" + File.separator;
|
||||
}
|
||||
|
||||
public static String getControllerPath(String str) {
|
||||
File[] listFiles;
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
return null;
|
||||
}
|
||||
File file = new File(str);
|
||||
if (!file.exists() || !file.isDirectory() || (listFiles = file.listFiles(new FilenameFilter() { // from class: com.ubt.jimu.base.util.a
|
||||
@Override // java.io.FilenameFilter
|
||||
public final boolean accept(File file2, String str2) {
|
||||
return PathHelper.a(file2, str2);
|
||||
}
|
||||
})) == null || listFiles.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
return listFiles[0].getAbsolutePath();
|
||||
}
|
||||
|
||||
public static String getCustomUserDir(Context context) {
|
||||
return ExternalOverFroyoUtils.b() + File.separator + ModelType.PLAYER_DATA.getName() + File.separator;
|
||||
}
|
||||
|
||||
public static String getDataRootDir(Context context, RobotLite robotLite, boolean z) {
|
||||
if (robotLite == null) {
|
||||
return null;
|
||||
}
|
||||
return (robotLite.isOfficial() ? !z ? getOfficialDir(context) : getOfficialUserDir(context) : getCustomUserDir(context)) + robotLite.getModelId() + File.separator;
|
||||
}
|
||||
|
||||
public static String getGameControllerKeyMapDir(Context context, RobotLite robotLite) {
|
||||
if (robotLite == null) {
|
||||
return null;
|
||||
}
|
||||
return getDataRootDir(context, robotLite, true) + GAME_CONTROLLER_CONFIG_DIR + File.separator;
|
||||
}
|
||||
|
||||
public static String getGameControllerKeyMapFilePath(Context context, RobotLite robotLite) {
|
||||
String gameControllerKeyMapDir = getGameControllerKeyMapDir(context, robotLite);
|
||||
if (gameControllerKeyMapDir == null) {
|
||||
return null;
|
||||
}
|
||||
return gameControllerKeyMapDir + GAME_CONTROLLER_KEY_MAP_FILE_NAME;
|
||||
}
|
||||
|
||||
public static String getMoveConfigPath(Context context, RobotLite robotLite, boolean z) {
|
||||
if (robotLite == null) {
|
||||
return null;
|
||||
}
|
||||
return getDataRootDir(context, robotLite, z) + "widgetConfig" + File.separator + MOVE_CONFIG_NAME;
|
||||
}
|
||||
|
||||
public static String getOfficialDir(Context context) {
|
||||
return ExternalOverFroyoUtils.a(context, ModelType.DEFAULT);
|
||||
}
|
||||
|
||||
public static String getOfficialUserDir(Context context) {
|
||||
return ExternalOverFroyoUtils.b() + File.separator + ModelType.DEFAULT.getName() + File.separator;
|
||||
}
|
||||
|
||||
public static String getSoundPath(Context context, RobotLite robotLite, ActionSequence actionSequence) {
|
||||
if (robotLite == null) {
|
||||
return null;
|
||||
}
|
||||
String str = getDataRootDir(context, robotLite, !actionSequence.j()) + "sounds" + File.separator + actionSequence.e() + ".aac";
|
||||
if (new File(str).exists()) {
|
||||
return str;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getUserDiyActionPath() {
|
||||
return ExternalOverFroyoUtils.b() + File.separator;
|
||||
}
|
||||
|
||||
public static String newControllerFileName(String str) {
|
||||
return CONTROLLER_PREFIX + str;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user