blob: 22ce677b6a81a6974a60c7a9eeac7c7d483877bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
package cgeo.geocaching.apps.cache;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.apps.AbstractAppFactory;
import cgeo.geocaching.utils.Log;
import org.apache.commons.lang3.ArrayUtils;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
public final class GeneralAppsFactory extends AbstractAppFactory {
private static GeneralApp[] apps = new GeneralApp[] {};
private static GeneralApp[] getGeneralApps() {
if (ArrayUtils.isEmpty(apps)) {
apps = new GeneralApp[] { new GccApp(),
new WhereYouGoApp() };
}
return apps;
}
public static void addMenuItems(Menu menu, cgCache cache) {
for (GeneralApp app : getGeneralApps()) {
if (app.isInstalled() && app.isEnabled(cache)) {
menu.add(0, app.getId(), 0, app.getName());
}
}
}
public static boolean onMenuItemSelected(final MenuItem item, Activity activity, cgCache cache) {
final GeneralApp app = (GeneralApp) getAppFromMenuItem(item, apps);
if (app != null) {
try {
return app.invoke(activity, cache);
} catch (Exception e) {
Log.e("GeneralAppsFactory.onMenuItemSelected: " + e.toString());
}
}
return false;
}
}
|