mirror of
https://github.com/etlegacy/etlegacy-android.git
synced 2024-11-10 06:52:06 +00:00
java: Check for pak0.pk3 and download it if not found
This commit is contained in:
parent
10dce0a220
commit
648a5e2fd4
1 changed files with 9 additions and 5 deletions
|
@ -4,6 +4,7 @@ import android.app.Activity;
|
|||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.loopj.android.http.AsyncHttpClient;
|
||||
|
@ -20,7 +21,9 @@ public class ETLMain extends Activity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
File etl_pak = new File(getExternalFilesDir(null), "pak2.pk3");
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
File etl_pak = new File(getExternalFilesDir(null), "/etlegacy/etmain/pak0.pk3");
|
||||
final Intent intent = new Intent(ETLMain.this, ETLActivity.class);
|
||||
|
||||
if (etl_pak.exists()) {
|
||||
|
@ -28,8 +31,8 @@ public class ETLMain extends Activity {
|
|||
finish();
|
||||
}
|
||||
else {
|
||||
AsyncHttpClient client = new AsyncHttpClient();
|
||||
client.get("http://mirror.etlegacy.com/etmain/pak2.pk3", new FileAsyncHttpResponseHandler(this) {
|
||||
final AsyncHttpClient client = new AsyncHttpClient();
|
||||
client.get("http://mirror.etlegacy.com/etmain/pak0.pk3", new FileAsyncHttpResponseHandler(this) {
|
||||
|
||||
@Override
|
||||
public void onSuccess(int statusCode, Header[] headers, File file) {
|
||||
|
@ -40,9 +43,10 @@ public class ETLMain extends Activity {
|
|||
super.onFinish();
|
||||
if (file.getAbsoluteFile().exists()) {
|
||||
try {
|
||||
Files.move(file.getAbsoluteFile(), new File(getExternalFilesDir(null), "pak2.pk3"));
|
||||
finish();
|
||||
Files.move(file.getAbsoluteFile(), new File(getExternalFilesDir(null), "/etlegacy/etmain/pak0.pk3"));
|
||||
client.cancelAllRequests(true);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue