Handle actual list filtering based on category dropdown selection.
This commit is contained in:
parent
8a5dbaf001
commit
0ee34076af
@ -427,6 +427,7 @@ public class DB {
|
|||||||
|
|
||||||
public Vector<String> getCategories() {
|
public Vector<String> getCategories() {
|
||||||
Vector<String> result = new Vector<String>();
|
Vector<String> result = new Vector<String>();
|
||||||
|
result.add("All");
|
||||||
Cursor c = null;
|
Cursor c = null;
|
||||||
try {
|
try {
|
||||||
c = db.rawQuery("select distinct category from " + TABLE_APP + " order by category", null);
|
c = db.rawQuery("select distinct category from " + TABLE_APP + " order by category", null);
|
||||||
|
@ -51,9 +51,10 @@ import android.widget.TabHost;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
import android.widget.TabHost.TabSpec;
|
import android.widget.TabHost.TabSpec;
|
||||||
|
|
||||||
public class FDroid extends TabActivity implements OnItemClickListener {
|
public class FDroid extends TabActivity implements OnItemClickListener, OnItemSelectedListener {
|
||||||
|
|
||||||
private String LOCAL_PATH = "/sdcard/.fdroid";
|
private String LOCAL_PATH = "/sdcard/.fdroid";
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ public class FDroid extends TabActivity implements OnItemClickListener {
|
|||||||
|
|
||||||
// Category list
|
// Category list
|
||||||
private ArrayAdapter<String> categories;
|
private ArrayAdapter<String> categories;
|
||||||
|
private String currentCategory = "All";
|
||||||
|
|
||||||
private ProgressDialog pd;
|
private ProgressDialog pd;
|
||||||
|
|
||||||
@ -114,6 +116,7 @@ public class FDroid extends TabActivity implements OnItemClickListener {
|
|||||||
new Vector<String>());
|
new Vector<String>());
|
||||||
categories.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
categories.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
spinner.setAdapter(categories);
|
spinner.setAdapter(categories);
|
||||||
|
spinner.setOnItemSelectedListener(FDroid.this);
|
||||||
|
|
||||||
tabHost = getTabHost();
|
tabHost = getTabHost();
|
||||||
createTabs();
|
createTabs();
|
||||||
@ -349,6 +352,9 @@ public class FDroid extends TabActivity implements OnItemClickListener {
|
|||||||
+ " ms)");
|
+ " ms)");
|
||||||
|
|
||||||
for (DB.App app : apps) {
|
for (DB.App app : apps) {
|
||||||
|
if (!"All".equals(currentCategory) && !currentCategory.equals(app.category)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (app.installedVersion == null) {
|
if (app.installedVersion == null) {
|
||||||
apps_av.addItem(app);
|
apps_av.addItem(app);
|
||||||
} else {
|
} else {
|
||||||
@ -405,6 +411,15 @@ public class FDroid extends TabActivity implements OnItemClickListener {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||||
|
currentCategory = parent.getItemAtPosition(pos).toString();
|
||||||
|
populateLists(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
|
// We always have at least "All"
|
||||||
|
}
|
||||||
|
|
||||||
// Handler for a click on one of the items in an application list. Pops
|
// Handler for a click on one of the items in an application list. Pops
|
||||||
// up a dialog that shows the details of the application and all its
|
// up a dialog that shows the details of the application and all its
|
||||||
// available versions, with buttons to allow installation etc.
|
// available versions, with buttons to allow installation etc.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user