Revision f53016ac
Added by Leszek Koltunski almost 2 years ago
distorted-sokoban/src/main/java/org/distorted/sokoban/SokobanActivity.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.sokoban; |
21 | 21 |
|
22 |
import android.app.ListActivity;
|
|
22 |
import android.app.Activity; |
|
23 | 23 |
import android.os.Build; |
24 | 24 |
import android.os.Bundle; |
25 | 25 |
import android.util.DisplayMetrics; |
... | ... | |
29 | 29 |
import android.view.ViewGroup; |
30 | 30 |
import android.view.WindowManager; |
31 | 31 |
import android.widget.AdapterView; |
32 |
import android.widget.GridView; |
|
32 | 33 |
import android.widget.LinearLayout; |
33 |
import android.widget.SimpleAdapter; |
|
34 | 34 |
import android.widget.TextView; |
35 | 35 |
|
36 |
import java.util.ArrayList; |
|
37 |
import java.util.HashMap; |
|
38 |
import java.util.List; |
|
39 |
import java.util.Map; |
|
40 |
|
|
41 | 36 |
import helpers.TransparentImageButton; |
42 | 37 |
|
43 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
44 | 39 |
|
45 |
public class SokobanActivity extends ListActivity
|
|
40 |
public class SokobanActivity extends Activity |
|
46 | 41 |
{ |
47 |
private static final String L_NUMBER = "lNumber"; |
|
48 |
private static final String L_RECORD = "lRecord"; |
|
49 |
private static final String L_IMAGE = "lImage"; |
|
50 |
private static final String R_NUMBER = "rNumber"; |
|
51 |
private static final String R_RECORD = "rRecord"; |
|
52 |
private static final String R_IMAGE = "rImage"; |
|
53 |
|
|
54 | 42 |
private static final float RATIO_BAR = 0.10f; |
55 | 43 |
private static final float RATIO_INSET = 0.09f; |
56 | 44 |
private static final float MENU_SIZE = 0.05f; |
... | ... | |
128 | 116 |
public void onResume() |
129 | 117 |
{ |
130 | 118 |
super.onResume(); |
131 |
createListOfLevels(); |
|
119 |
|
|
120 |
GridView gridview = findViewById(R.id.gridview); |
|
121 |
gridview.setAdapter(new SokobanGridAdapter(this)); |
|
122 |
|
|
123 |
gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() |
|
124 |
{ |
|
125 |
@Override |
|
126 |
public void onItemClick(AdapterView<?> parent, View v, int position, long id) |
|
127 |
{ |
|
128 |
android.util.Log.e("D", "position="+position); |
|
129 |
} |
|
130 |
}); |
|
132 | 131 |
} |
133 | 132 |
|
134 | 133 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
292 | 291 |
default: return huge; |
293 | 292 |
} |
294 | 293 |
} |
295 |
|
|
296 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
297 |
|
|
298 |
private void createListOfLevels() |
|
299 |
{ |
|
300 |
/* |
|
301 |
final List<Map<String, Object>> data = new ArrayList<>(); |
|
302 |
|
|
303 |
int index=0; |
|
304 |
|
|
305 |
for( Application app : Application.values() ) |
|
306 |
{ |
|
307 |
final Map<String, Object> item = new HashMap<>(); |
|
308 |
item.put(ITEM_IMAGE, app.icon); |
|
309 |
item.put(ITEM_TITLE, (index+1)+". "+getText(app.title)); |
|
310 |
item.put(ITEM_SUBTITLE, getText(app.subtitle)); |
|
311 |
data.add(item); |
|
312 |
} |
|
313 |
|
|
314 |
final SimpleAdapter dataAdapter = new SimpleAdapter( this, |
|
315 |
data, |
|
316 |
R.layout.toc_item, |
|
317 |
new String[] {L_NUMBER, L_RECORD, L_IMAGE, R_NUMBER, R_RECORD, R_IMAGE}, |
|
318 |
new int[] {R.id.leftNumber , R.id.leftRecord , R.id.leftImage , |
|
319 |
R.id.rightNumber, R.id.rightRecord, R.id.rightImage,} ); |
|
320 |
setListAdapter(dataAdapter); |
|
321 |
|
|
322 |
getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() |
|
323 |
{ |
|
324 |
@Override |
|
325 |
public void onItemClick(AdapterView<?> parent, View view, int position, long id) |
|
326 |
{ |
|
327 |
android.util.Log.e("D","id="+id+" position="+position+" clicked!!"); |
|
328 |
} |
|
329 |
}); |
|
330 |
|
|
331 |
*/ |
|
332 |
} |
|
333 | 294 |
} |
Also available in: Unified diff
Lots of progress with the main screen