summaryrefslogtreecommitdiffstats
path: root/src/org/codeaurora/gallery3d/ext/IActivityHooker.java
diff options
context:
space:
mode:
authorLikai Ding <likaid@codeaurora.org>2013-08-19 15:04:18 +0800
committerXiaojing Zhang <zhangx@codeaurora.org>2014-11-04 20:37:50 -0800
commit85963d969c149b9ba5e5681524e520b8b8afba08 (patch)
tree42fa492e598b3a6e39e7a6cd3b55b735bf201070 /src/org/codeaurora/gallery3d/ext/IActivityHooker.java
parentcecd51ead6cace89db4506df96b7419502f64b61 (diff)
downloadandroid_packages_apps_Gallery2-85963d969c149b9ba5e5681524e520b8b8afba08.tar.gz
android_packages_apps_Gallery2-85963d969c149b9ba5e5681524e520b8b8afba08.tar.bz2
android_packages_apps_Gallery2-85963d969c149b9ba5e5681524e520b8b8afba08.zip
Gallery2: support loop/single video play mode
This change allows a video to be played repeatedly. It also introduces an extension framework. Change-Id: I5566192f138c1f0fd889b85496dd27fbf2aed10d CRs-Fixed: 507973
Diffstat (limited to 'src/org/codeaurora/gallery3d/ext/IActivityHooker.java')
-rw-r--r--src/org/codeaurora/gallery3d/ext/IActivityHooker.java99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/org/codeaurora/gallery3d/ext/IActivityHooker.java b/src/org/codeaurora/gallery3d/ext/IActivityHooker.java
new file mode 100644
index 000000000..fa1b5c0a0
--- /dev/null
+++ b/src/org/codeaurora/gallery3d/ext/IActivityHooker.java
@@ -0,0 +1,99 @@
+package org.codeaurora.gallery3d.ext;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+
+/**
+ * Activity action hooker class. Host app's activity will call this hooker's
+ * functions in its lifecycle. For example:
+ * HostActivity.onCreate()-->hooker.onCreate(). But void init(Activity context,
+ * Intent intent) will be called before other functions. <br/>
+ * IActivityHooker objects may show menus, but we should give a unique menu id
+ * to every menus. Hooker can call getMenuActivityId(int) to get a global unique
+ * menu id to be used in menu.add(), and can call getMenuOriginalId(int) to get
+ * the original menu id. the example: class Hooker implements IActivityHooker {
+ * private static final int MENU_EXAMPLE = 1;
+ *
+ * @Override public boolean onCreateOptionsMenu(Menu menu) {
+ * super.onCreateOptionsMenu(menu); menu.add(0,
+ * getMenuActivityId(MENU_EXAMPLE), 0, android.R.string.ok); return
+ * true; }
+ * @Override public boolean onOptionsItemSelected(MenuItem item) {
+ * switch(getMenuOriginalId(item.getItemId())) { case MENU_EXAMPLE:
+ * //do something return true; default: return false; } } }
+ */
+public interface IActivityHooker {
+
+ /**
+ * Will be called in Host Activity.onCreateOptionsMenu(Menu menu)
+ *
+ * @param menu
+ * @return
+ */
+ boolean onCreateOptionsMenu(Menu menu);
+
+ /**
+ * Will be called in Host Activity.onPrepareOptionsMenu(Menu menu)
+ *
+ * @param menu
+ * @return
+ */
+ boolean onPrepareOptionsMenu(Menu menu);
+
+ /**
+ * Will be called in Host Activity.onOptionsItemSelected(MenuItem item)
+ *
+ * @param item
+ * @return
+ */
+ boolean onOptionsItemSelected(MenuItem item);
+
+ /**
+ * Should be called before any other functions.
+ *
+ * @param context
+ * @param intent
+ */
+ void init(Activity context, Intent intent);
+
+ /**
+ * @return return activity set by init(Activity context, Intent intent)
+ */
+ Activity getContext();
+
+ /**
+ * @return return intent set by init(Activity context, Intent intent)
+ */
+ Intent getIntent();
+
+ /**
+ * IActivityHooker objects may show menus, but we should give a unique menu
+ * id to every menus. Hooker can call this function to get a global unique
+ * menu id to be used in menu.add()
+ *
+ * @param id
+ * @return
+ */
+ int getMenuActivityId(int id);
+
+ /**
+ * When onOptionsItemSelected is called, we can get menu's id from
+ * parameter. You can get the original menu id by calling this function.
+ *
+ * @param id
+ * @return
+ */
+ int getMenuOriginalId(int id);
+
+ /**
+ * Host activity will call this function to set parameter to hooker
+ * activity.
+ *
+ * @param key
+ * @param value
+ */
+ void setParameter(String key, Object value);
+}