修正热更无法正常运行的bug
This commit is contained in:
parent
b1726e94ce
commit
098cc65123
@ -128,7 +128,7 @@ public class LaunchActivity extends Activity {
|
||||
*/
|
||||
private void getLocalVersionInfo() {
|
||||
String fileName = gameUrl.replace("index.html", "version.json");
|
||||
String realPath = getFileDirByUrl(fileName);
|
||||
String realPath = preloadPath + "/" + getFileDirByUrl(fileName) + "version.json" ;
|
||||
File versionFile = new File(realPath);
|
||||
if (versionFile.exists()) {
|
||||
JSONObject data = AssetsUtil.readJsonFromFile(this, realPath);
|
||||
@ -198,7 +198,7 @@ public class LaunchActivity extends Activity {
|
||||
});
|
||||
}
|
||||
private void preloadGame() {
|
||||
String dir = preloadPath + getFileDirByUrl(gameUrl);
|
||||
String dir = preloadPath + "/" + getFileDirByUrl(gameUrl);
|
||||
File dirFile = new File(dir);
|
||||
if (!dirFile.exists()) {
|
||||
dirFile.mkdirs();
|
||||
|
@ -12,6 +12,7 @@ import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -187,12 +188,15 @@ public class AssetsUtil {
|
||||
*/
|
||||
public static String readFromFile(Context context, String path) {
|
||||
try {
|
||||
InputStreamReader inputReader = new InputStreamReader(context.openFileInput(path));
|
||||
FileInputStream fileInputStream = new FileInputStream(new File(path));
|
||||
InputStreamReader inputReader = new InputStreamReader(fileInputStream);
|
||||
BufferedReader bufReader = new BufferedReader(inputReader);
|
||||
|
||||
String line="";
|
||||
StringBuilder result= new StringBuilder();
|
||||
while((line = bufReader.readLine()) != null)
|
||||
result.append(line);
|
||||
fileInputStream.close();
|
||||
inputReader.close();
|
||||
bufReader.close();
|
||||
return result.toString();
|
||||
|
Loading…
x
Reference in New Issue
Block a user