mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 10:19:33 +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,11 +45,9 @@ abstract class MenuActivity extends ListActivity implements AdapterView.OnItemCl
|
|||
try {
|
||||
startActivityForResult(new Intent(getAction(), getIntent().getData()), 0);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
if (myInfos.size() == 1) {
|
||||
runItem(myInfos.get(0));
|
||||
if (finishInitialization()) {
|
||||
return;
|
||||
}
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
setListAdapter(new ActionListAdapter());
|
||||
|
@ -61,6 +59,20 @@ abstract class MenuActivity extends ListActivity implements AdapterView.OnItemCl
|
|||
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
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
if (intent != null) {
|
||||
|
@ -71,12 +83,7 @@ abstract class MenuActivity extends ListActivity implements AdapterView.OnItemCl
|
|||
if (actions != null) {
|
||||
myInfos.addAll(actions);
|
||||
}
|
||||
if (myInfos.size() == 0) {
|
||||
finish();
|
||||
return;
|
||||
} else if (myInfos.size() == 1) {
|
||||
runItem(myInfos.get(0));
|
||||
finish();
|
||||
if (finishInitialization()) {
|
||||
return;
|
||||
}
|
||||
Collections.sort(myInfos);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue