4 |
import android.app.Activity; |
import android.app.Activity; |
5 |
import android.content.Intent; |
import android.content.Intent; |
6 |
import android.os.Bundle; |
import android.os.Bundle; |
7 |
|
import android.view.Menu; |
8 |
|
import android.view.MenuItem; |
9 |
import android.view.View; |
import android.view.View; |
10 |
import android.widget.AdapterView; |
import android.widget.AdapterView; |
11 |
import android.widget.GridView; |
import android.widget.GridView; |
12 |
import android.widget.AdapterView.OnItemClickListener; |
import android.widget.AdapterView.OnItemClickListener; |
13 |
|
|
14 |
public class PictureOverview extends Activity { |
public class PictureOverview extends Activity { |
15 |
|
final static int MENU_DATE = 0; |
16 |
|
final static int MENU_CAPTION = 1; |
17 |
|
|
18 |
|
int current_order = MENU_DATE; |
19 |
|
|
20 |
ImageAdapter mImages; |
ImageAdapter mImages; |
21 |
|
|
33 |
public void onItemClick(AdapterView<?> parent, View v, int position, long id) { |
public void onItemClick(AdapterView<?> parent, View v, int position, long id) { |
34 |
|
|
35 |
Intent i = new Intent(PictureOverview.this, dk.thoerup.side9.PictureView.class); |
Intent i = new Intent(PictureOverview.this, dk.thoerup.side9.PictureView.class); |
36 |
i.putExtra("files", mImages.getImagePaths()); |
i.putExtra("images", mImages.getImages()); |
37 |
i.putExtra("index", position); |
i.putExtra("index", position); |
38 |
|
|
39 |
startActivity(i); |
startActivity(i); |
40 |
} |
} |
41 |
}); |
}); |
42 |
|
|
43 |
|
|
44 |
CheckUpdates update = new CheckUpdates(); |
CheckUpdates update = new CheckUpdates(); |
45 |
update.checkForUpdates(this, "http://t-hoerup.dk/android/side9/version.txt", "Side 9 Pigen", "http://t-hoerup.dk/android/side9/Side9.apk"); |
update.checkForUpdates(this, "http://t-hoerup.dk/android/side9/version.txt", "Side 9 Pigen", "http://t-hoerup.dk/android/side9/Side9.apk"); |
46 |
|
} |
47 |
|
|
48 |
|
@Override |
49 |
|
public boolean onCreateOptionsMenu(Menu menu) { |
50 |
|
menu.add(0,MENU_DATE,0, "Order by date"); |
51 |
|
menu.add(0,MENU_CAPTION,0, "Order by caption"); |
52 |
|
|
53 |
|
return true; |
54 |
} |
} |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
@Override |
59 |
|
public boolean onPrepareOptionsMenu(Menu menu) { |
60 |
|
MenuItem item = menu.findItem(MENU_DATE); |
61 |
|
if (current_order == MENU_DATE) |
62 |
|
item.setEnabled(false); |
63 |
|
else |
64 |
|
item.setEnabled(true); |
65 |
|
|
66 |
|
item = menu.findItem(MENU_CAPTION); |
67 |
|
if (current_order == MENU_CAPTION) |
68 |
|
item.setEnabled(false); |
69 |
|
else |
70 |
|
item.setEnabled(true); |
71 |
|
|
72 |
|
return true; |
73 |
|
} |
74 |
|
|
75 |
|
@Override |
76 |
|
public boolean onOptionsItemSelected(MenuItem item) { |
77 |
|
switch( item.getItemId() ) { |
78 |
|
case MENU_DATE: |
79 |
|
mImages.orderByPath(); |
80 |
|
current_order = MENU_DATE; |
81 |
|
return true; |
82 |
|
case MENU_CAPTION: |
83 |
|
mImages.orderByCaption(); |
84 |
|
current_order = MENU_CAPTION; |
85 |
|
return true; |
86 |
|
default: |
87 |
|
return super.onOptionsItemSelected(item); |
88 |
|
} |
89 |
|
} |
90 |
|
|
91 |
|
|
92 |
} |
} |