mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
more flexible MenuActivity: actions could be added in init() method
This commit is contained in:
parent
64b3684ec3
commit
63593bc0d8
1 changed files with 17 additions and 10 deletions
|
@ -45,12 +45,10 @@ abstract class MenuActivity extends ListActivity implements AdapterView.OnItemCl
|
||||||
try {
|
try {
|
||||||
startActivityForResult(new Intent(getAction(), getIntent().getData()), 0);
|
startActivityForResult(new Intent(getAction(), getIntent().getData()), 0);
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException e) {
|
||||||
if (myInfos.size() == 1) {
|
if (finishInitialization()) {
|
||||||
runItem(myInfos.get(0));
|
|
||||||
}
|
|
||||||
finish();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setListAdapter(new ActionListAdapter());
|
setListAdapter(new ActionListAdapter());
|
||||||
getListView().setOnItemClickListener(this);
|
getListView().setOnItemClickListener(this);
|
||||||
|
@ -61,6 +59,20 @@ abstract class MenuActivity extends ListActivity implements AdapterView.OnItemCl
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean finishInitialization() {
|
||||||
|
switch (myInfos.size()) {
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
case 0:
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
case 1:
|
||||||
|
runItem(myInfos.get(0));
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
|
@ -71,12 +83,7 @@ abstract class MenuActivity extends ListActivity implements AdapterView.OnItemCl
|
||||||
if (actions != null) {
|
if (actions != null) {
|
||||||
myInfos.addAll(actions);
|
myInfos.addAll(actions);
|
||||||
}
|
}
|
||||||
if (myInfos.size() == 0) {
|
if (finishInitialization()) {
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
} else if (myInfos.size() == 1) {
|
|
||||||
runItem(myInfos.get(0));
|
|
||||||
finish();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Collections.sort(myInfos);
|
Collections.sort(myInfos);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue