Going back to old approach of using JSR-234 directly, then compiling with different...
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Sun, 26 Oct 2008 13:29:46 +0000 (13:29 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Sun, 26 Oct 2008 13:29:46 +0000 (13:29 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@641 59b500cc-1b3d-0410-9834-0bbf25fbcc57

javame/src/com/google/zxing/client/j2me/AdvancedMultimediaManager.java
javame/src/com/google/zxing/client/j2me/DefaultMultimediaManager.java
javame/src/com/google/zxing/client/j2me/ZXingMIDlet.java

index 3b5a0f3..888f76c 100644 (file)
@@ -19,14 +19,12 @@ package com.google.zxing.client.j2me;
 import javax.microedition.amms.control.camera.ExposureControl;
 import javax.microedition.amms.control.camera.FocusControl;
 import javax.microedition.amms.control.camera.ZoomControl;
-import javax.microedition.media.Control;
 import javax.microedition.media.Controllable;
 import javax.microedition.media.MediaException;
 
 /**
- * <p>See {@link DefaultMultimediaManager} documentation for details.</p>
- *
- * <p>This class should never be directly imported or reference in the code.</p>
+ * <p>Implementation suitable for JSR-234 phones which takes advantage of advanced camera
+ * capability.</p>
  *
  * @author Sean Owen (srowen@google.com)
  */
@@ -38,18 +36,6 @@ final class AdvancedMultimediaManager implements MultimediaManager {
   private static final String DESIRED_METERING = "center-weighted";
 
   AdvancedMultimediaManager() {
-    // Another try at fixing Issue 70. Seems like FocusControl et al. are sometimes not
-    // loaded until first use in the setFocus() method. This is too late for our
-    // mechanism to handle, since it is trying to detect this API is not available
-    // at the time this class is instantiated. We can't move the player.getControl() calls
-    // into here since we don't have a Controllable to call on, since we can't pass an
-    // arg into the constructor, since we can't do that in J2ME when instantiating via
-    // newInstance(). So we just try writing some dead code here to induce the VM to
-    // definitely load the classes now:
-    Control dummy = null;
-    ExposureControl dummy1 = (ExposureControl) dummy;
-    FocusControl dummy2 = (FocusControl) dummy;
-    ZoomControl dummy3 = (ZoomControl) dummy;
   }
 
   public void setFocus(Controllable player) {
index 951bed2..1f784e8 100644 (file)
@@ -19,58 +19,22 @@ package com.google.zxing.client.j2me;
 import javax.microedition.media.Controllable;
 
 /**
- * <p>This class encapsulates optional multimedia-related operations that the device
- * may support, like setting focus and zoom. This implementation itself will do nothing.
- * It will attempt to dynamically instantiate {@link com.google.zxing.client.j2me.AdvancedMultimediaManager}
- * which has methods that call JSR-234 APIs to actually set focus, zoom, etc. If successful,
- * this class will delegate to that implementation. But if the phone does not support these
- * APIs, instantiation will simply fail and this implementation will do nothing.</p>
- *
- * <p>Credit to Paul Hackenberger for the nice workaround</p>
+ * <p>Dummy implemenation which does nothing. This is suitable for non-JSR-234 phones.</p>
  *
  * @author Sean Owen (srowen@google.com)
- * @author Paul Hackenberger
  */
-class DefaultMultimediaManager implements MultimediaManager {
-
-  private MultimediaManager advancedMultimediaManager;
+final class DefaultMultimediaManager implements MultimediaManager {
 
   DefaultMultimediaManager() {
-    // Having issues with non-JSR-234 phones not accepting the build? then try commenting out from here:
-    try {
-      advancedMultimediaManager = (MultimediaManager)
-          Class.forName("com.google.zxing.client.j2me.AdvancedMultimediaManager").newInstance();
-    } catch (ClassNotFoundException cnfe) {
-      // continue
-    } catch (IllegalAccessException iae) {
-      // continue
-    } catch (InstantiationException ie) {
-      // continue
-    } catch (NoClassDefFoundError ncdfe) {
-      // continue
-    }
-    // to here. Then add this line:
-    // advancedMultimediaManager = null;
-    // You may also need to delete the class AdvancedMultimediaManager in this package to be completely free
-    // of JSR-234 references.
   }
 
   public void setFocus(Controllable player) {
-    if (advancedMultimediaManager != null) {
-      advancedMultimediaManager.setFocus(player);
-    }
   }
 
   public void setZoom(Controllable player) {
-    if (advancedMultimediaManager != null) {
-      advancedMultimediaManager.setZoom(player);
-    }
   }
 
   public void setExposure(Controllable player) {
-    if (advancedMultimediaManager != null) {
-      advancedMultimediaManager.setExposure(player);
-    }
   }
 
 }
\ No newline at end of file
index 00c4073..4da438c 100644 (file)
@@ -69,7 +69,9 @@ public final class ZXingMIDlet extends MIDlet {
     try {
       player = createPlayer();
       player.realize();
-      MultimediaManager multimediaManager = new DefaultMultimediaManager();
+      MultimediaManager multimediaManager = new AdvancedMultimediaManager();
+      // Comment line above / uncomment below to make the basic version
+      //MultimediaManager multimediaManager = new DefaultMultimediaManager();
       multimediaManager.setZoom(player);
       multimediaManager.setExposure(player);
       videoControl = (VideoControl) player.getControl("VideoControl");