17 */ |
17 */ |
18 |
18 |
19 package org.hedgewars.hedgeroid; |
19 package org.hedgewars.hedgeroid; |
20 |
20 |
21 import org.hedgewars.hedgeroid.Downloader.DownloadAssets; |
21 import org.hedgewars.hedgeroid.Downloader.DownloadAssets; |
22 import org.hedgewars.hedgeroid.Downloader.DownloadFragment; |
|
23 import org.hedgewars.hedgeroid.Downloader.DownloadListActivity; |
22 import org.hedgewars.hedgeroid.Downloader.DownloadListActivity; |
24 import org.hedgewars.hedgeroid.Downloader.DownloadService; |
|
25 |
23 |
|
24 import android.app.AlertDialog; |
|
25 import android.app.Dialog; |
26 import android.app.ProgressDialog; |
26 import android.app.ProgressDialog; |
|
27 import android.content.DialogInterface; |
27 import android.content.Intent; |
28 import android.content.Intent; |
28 import android.os.Bundle; |
29 import android.os.Bundle; |
29 import android.preference.PreferenceManager; |
30 import android.preference.PreferenceManager; |
30 import android.support.v4.app.FragmentActivity; |
31 import android.support.v4.app.FragmentActivity; |
31 import android.view.View; |
32 import android.view.View; |
46 startGame = (Button)findViewById(R.id.startGame); |
47 startGame = (Button)findViewById(R.id.startGame); |
47 |
48 |
48 downloader.setOnClickListener(downloadClicker); |
49 downloader.setOnClickListener(downloadClicker); |
49 startGame.setOnClickListener(startGameClicker); |
50 startGame.setOnClickListener(startGameClicker); |
50 |
51 |
51 boolean assetsCopied = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("assetscopied", false); |
|
52 |
52 |
53 if(!assetsCopied){ |
53 String cacheDir = Utils.getCachePath(this); |
54 DownloadAssets assetsAsyncTask = new DownloadAssets(this); |
54 if(cacheDir == null){ |
55 assetsDialog = ProgressDialog.show(this, "Please wait a moment", "Moving assets..."); |
55 showDialog(0); |
56 assetsAsyncTask.execute((Object[])null); |
56 }else{ |
|
57 boolean assetsCopied = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("assetscopied", false); |
|
58 |
|
59 if(!assetsCopied){ |
|
60 DownloadAssets assetsAsyncTask = new DownloadAssets(this); |
|
61 assetsDialog = ProgressDialog.show(this, "Please wait a moment", "Moving assets..."); |
|
62 assetsAsyncTask.execute((Object[])null); |
|
63 } |
57 } |
64 } |
|
65 } |
|
66 |
|
67 public Dialog onCreateDialog(int id, Bundle args){ |
|
68 AlertDialog.Builder builder = new AlertDialog.Builder(this); |
|
69 builder.setTitle(R.string.sdcard_not_mounted_title); |
|
70 builder.setMessage(R.string.sdcard_not_mounted); |
|
71 builder.setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener(){ |
|
72 public void onClick(DialogInterface dialog, int which) { |
|
73 finish(); |
|
74 } |
|
75 }); |
|
76 |
|
77 return builder.create(); |
58 } |
78 } |
59 |
79 |
60 public void onAssetsDownloaded(boolean result){ |
80 public void onAssetsDownloaded(boolean result){ |
61 if(result){ |
81 if(result){ |
62 PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("assetscopied", true).commit(); |
82 PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("assetscopied", true).commit(); |