aboutsummaryrefslogtreecommitdiffstats
path: root/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java')
-rw-r--r--src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java69
1 files changed, 35 insertions, 34 deletions
diff --git a/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java b/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java
index c184bd0..eb581ca 100644
--- a/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java
+++ b/src/cgeo/geocaching/apps/cache/GeneralAppsFactory.java
@@ -1,5 +1,9 @@
package cgeo.geocaching.apps.cache;
+import cgeo.geocaching.cgCache;
+import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.apps.AbstractAppFactory;
+
import org.apache.commons.lang3.ArrayUtils;
import android.app.Activity;
@@ -7,41 +11,38 @@ import android.content.res.Resources;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
-import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgSettings;
-import cgeo.geocaching.apps.AbstractAppFactory;
public final class GeneralAppsFactory extends AbstractAppFactory {
- private static GeneralApp[] apps = new GeneralApp[] {};
-
- private static GeneralApp[] getGeneralApps(Resources res) {
- if (ArrayUtils.isEmpty(apps)) {
- apps = new GeneralApp[] { new GccApp(res),
- new WhereYouGoApp(res) };
- }
- return apps;
- }
-
- public static void addMenuItems(Menu menu, Activity activity,
- Resources res, cgCache cache) {
- for (GeneralApp app : getGeneralApps(res)) {
- if (app.isInstalled(activity) && app.isEnabled(cache)) {
- menu.add(0, app.getId(), 0, app.getName());
- }
- }
- }
-
- public static boolean onMenuItemSelected(final MenuItem item,
- Activity activity, cgCache cache) {
- GeneralApp app = (GeneralApp) getAppFromMenuItem(item, apps);
- if (app != null) {
- try {
- return app.invoke(activity, cache);
- } catch (Exception e) {
- Log.e(cgSettings.tag, "GeneralAppsFactory.onMenuItemSelected: " + e.toString());
- }
- }
- return false;
- }
+ private static GeneralApp[] apps = new GeneralApp[] {};
+
+ private static GeneralApp[] getGeneralApps(Resources res) {
+ if (ArrayUtils.isEmpty(apps)) {
+ apps = new GeneralApp[] { new GccApp(res),
+ new WhereYouGoApp(res) };
+ }
+ return apps;
+ }
+
+ public static void addMenuItems(Menu menu, Activity activity,
+ Resources res, cgCache cache) {
+ for (GeneralApp app : getGeneralApps(res)) {
+ if (app.isInstalled(activity) && app.isEnabled(cache)) {
+ menu.add(0, app.getId(), 0, app.getName());
+ }
+ }
+ }
+
+ public static boolean onMenuItemSelected(final MenuItem item,
+ Activity activity, cgCache cache) {
+ GeneralApp app = (GeneralApp) getAppFromMenuItem(item, apps);
+ if (app != null) {
+ try {
+ return app.invoke(activity, cache);
+ } catch (Exception e) {
+ Log.e(cgSettings.tag, "GeneralAppsFactory.onMenuItemSelected: " + e.toString());
+ }
+ }
+ return false;
+ }
}