author | koda |
Tue, 04 Oct 2011 17:18:25 +0200 | |
branch | hedgeroid |
changeset 6031 | 95d565991edd |
parent 5671 | ba4c3a4c8b09 |
permissions | -rw-r--r-- |
5621 | 1 |
/* |
2 |
* Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game |
|
3 |
* Copyright (c) 2011 Richard Deurwaarder <xeli@xelification.com> |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
5397 | 19 |
package org.hedgewars.mobile; |
20 |
||
5416
26a36326d199
Added a small example of the frontend still being worked but commited so the downloader now works
Xeli
parents:
5397
diff
changeset
|
21 |
import org.hedgewars.mobile.Downloader.DownloadActivity; |
5671
ba4c3a4c8b09
Check if we need to download and prevent user from reaching the startgame menu because it needs images from the download
Xeli
parents:
5621
diff
changeset
|
22 |
import org.hedgewars.mobile.Downloader.DownloadService; |
5416
26a36326d199
Added a small example of the frontend still being worked but commited so the downloader now works
Xeli
parents:
5397
diff
changeset
|
23 |
|
5397 | 24 |
import android.app.Activity; |
25 |
import android.content.Intent; |
|
26 |
import android.os.Bundle; |
|
5671
ba4c3a4c8b09
Check if we need to download and prevent user from reaching the startgame menu because it needs images from the download
Xeli
parents:
5621
diff
changeset
|
27 |
import android.preference.PreferenceManager; |
5397 | 28 |
import android.view.View; |
29 |
import android.view.View.OnClickListener; |
|
30 |
import android.widget.Button; |
|
5671
ba4c3a4c8b09
Check if we need to download and prevent user from reaching the startgame menu because it needs images from the download
Xeli
parents:
5621
diff
changeset
|
31 |
import android.widget.Toast; |
5397 | 32 |
|
33 |
public class MainActivity extends Activity { |
|
34 |
||
35 |
Button downloader, startGame; |
|
36 |
||
37 |
public void onCreate(Bundle sis){ |
|
38 |
super.onCreate(sis); |
|
39 |
setContentView(R.layout.main); |
|
40 |
||
41 |
downloader = (Button)findViewById(R.id.downloader); |
|
42 |
startGame = (Button)findViewById(R.id.startGame); |
|
43 |
||
44 |
downloader.setOnClickListener(downloadClicker); |
|
45 |
startGame.setOnClickListener(startGameClicker); |
|
46 |
} |
|
47 |
||
48 |
||
49 |
||
50 |
private OnClickListener downloadClicker = new OnClickListener(){ |
|
51 |
public void onClick(View v){ |
|
52 |
startActivityForResult(new Intent(getApplicationContext(), DownloadActivity.class), 0); |
|
53 |
} |
|
54 |
}; |
|
55 |
||
56 |
private OnClickListener startGameClicker = new OnClickListener(){ |
|
57 |
public void onClick(View v){ |
|
5671
ba4c3a4c8b09
Check if we need to download and prevent user from reaching the startgame menu because it needs images from the download
Xeli
parents:
5621
diff
changeset
|
58 |
if(PreferenceManager.getDefaultSharedPreferences(MainActivity.this).getBoolean(DownloadService.PREF_DOWNLOADED, false)) |
ba4c3a4c8b09
Check if we need to download and prevent user from reaching the startgame menu because it needs images from the download
Xeli
parents:
5621
diff
changeset
|
59 |
startActivity(new Intent(getApplicationContext(), StartGameActivity.class)); |
ba4c3a4c8b09
Check if we need to download and prevent user from reaching the startgame menu because it needs images from the download
Xeli
parents:
5621
diff
changeset
|
60 |
else { |
ba4c3a4c8b09
Check if we need to download and prevent user from reaching the startgame menu because it needs images from the download
Xeli
parents:
5621
diff
changeset
|
61 |
Toast.makeText(MainActivity.this, R.string.download_userexplain, Toast.LENGTH_LONG).show(); |
ba4c3a4c8b09
Check if we need to download and prevent user from reaching the startgame menu because it needs images from the download
Xeli
parents:
5621
diff
changeset
|
62 |
startActivityForResult(new Intent(getApplicationContext(), DownloadActivity.class), 0); |
ba4c3a4c8b09
Check if we need to download and prevent user from reaching the startgame menu because it needs images from the download
Xeli
parents:
5621
diff
changeset
|
63 |
} |
5397 | 64 |
} |
65 |
}; |
|
66 |
||
67 |
} |