mirror of
https://github.com/etlegacy/etlegacy-android.git
synced 2025-04-12 04:00:48 +00:00
java: download required file to run an app
This option will be disabled for now.
This commit is contained in:
parent
962830b805
commit
ee6cf3b3eb
1 changed files with 30 additions and 0 deletions
|
@ -17,12 +17,18 @@ import android.widget.ImageButton;
|
|||
import android.widget.RelativeLayout;
|
||||
import com.erz.joysticklibrary.JoyStick;
|
||||
import com.erz.joysticklibrary.JoyStick.JoyStickListener;
|
||||
import com.google.common.io.Files;
|
||||
import com.loopj.android.http.AsyncHttpClient;
|
||||
import com.loopj.android.http.FileAsyncHttpResponseHandler;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import cz.msebera.android.httpclient.Header;
|
||||
|
||||
public class ETLActivity extends SDLActivity implements JoyStickListener {
|
||||
|
||||
static volatile boolean UiMenu = false;
|
||||
|
@ -256,6 +262,7 @@ public class ETLActivity extends SDLActivity implements JoyStickListener {
|
|||
|
||||
|
||||
|
||||
|
||||
public static int pxToDp(int px) {
|
||||
return (int) (px / Resources.getSystem().getDisplayMetrics().density);
|
||||
}
|
||||
|
@ -276,6 +283,29 @@ public class ETLActivity extends SDLActivity implements JoyStickListener {
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
/*
|
||||
TODO: Keep it for now. Find a way to download pak0 before ETL lib is launched.
|
||||
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 response) {
|
||||
// Do something with the file `response`
|
||||
if (response.exists()) {
|
||||
try {
|
||||
Files.move(response.getAbsoluteFile(), new File(getExternalFilesDir(null), "pak2.pk3"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onFailure(int statusCode, Header[] headers, Throwable throwable, File file) {
|
||||
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue