Android Open Source - Abstack-books-management Toast Plugin






From Project

Back to project page Abstack-books-management.

License

The source code is released under:

MIT License

If you think the Android project Abstack-books-management listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.abstack.book.plugin;
//  w  w  w .  j  a v  a 2 s. com
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;

import android.widget.Toast;

public class ToastPlugin extends CordovaPlugin {
  private static final String TOAST = "toast";

  @Override
  public boolean execute(String action, JSONArray args,
      CallbackContext callbackContext) throws JSONException {
    if (TOAST.equals(action)) {
      toast(args, callbackContext);
    } else {
      callbackContext.error("Methods that are not allowed!");
      return false;
    }
    return true;
  }

  private void toast(JSONArray args, CallbackContext callbackContext) {
    int len = args.length();
    Toast toast;
    int time = 2000;
    try {
      switch (len) {
      case 2:
        time = args.getInt(1);
      case 1:
        if("".equals(args.getString(0))) {
          callbackContext.error("Message info not null!");
          return;
        }
        toast = Toast.makeText(this.cordova.getActivity(), args.getString(0), time);
        break;
      default:
        callbackContext.error("Number of parameters is not enough!");
        return;
      }
      toast.show();
    } catch (JSONException e) {
      callbackContext.error("Illegal json data!");
    }
  }
}




Java Source Code List

com.abstack.book.AbstackBook.java
com.abstack.book.CaptureActivity.java
com.abstack.book.plugin.CameraPlugin.java
com.abstack.book.plugin.ToastPlugin.java
com.abstack.book.plugin.camera.AutoFocusCallback.java
com.abstack.book.plugin.camera.CameraConfigurationManager.java
com.abstack.book.plugin.camera.CameraManager.java
com.abstack.book.plugin.camera.FlashlightManager.java
com.abstack.book.plugin.camera.PlanarYUVLuminanceSource.java
com.abstack.book.plugin.camera.PreviewCallback.java
com.abstack.book.plugin.camera.decoding.CaptureActivityHandler.java
com.abstack.book.plugin.camera.decoding.DecodeFormatManager.java
com.abstack.book.plugin.camera.decoding.DecodeHandler.java
com.abstack.book.plugin.camera.decoding.DecodeThread.java
com.abstack.book.plugin.camera.decoding.FinishListener.java
com.abstack.book.plugin.camera.decoding.InactivityTimer.java
com.abstack.book.plugin.camera.decoding.Intents.java
com.abstack.book.plugin.camera.encoding.EncodingHandler.java
com.abstack.book.plugin.camera.util.HttpConnection.java
com.abstack.book.plugin.camera.view.ViewfinderResultPointCallback.java
com.abstack.book.plugin.camera.view.ViewfinderView.java