Android Open Source - ISBN-Reporter Ruboto Broadcast Receiver






From Project

Back to project page ISBN-Reporter.

License

The source code is released under:

MIT License

If you think the Android project ISBN-Reporter 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 org.ruboto;
//  ww  w.  j  av a  2 s  .  c  om
import java.io.IOException;

import org.ruboto.ScriptLoader;

public class RubotoBroadcastReceiver extends android.content.BroadcastReceiver implements org.ruboto.RubotoComponent {
    private final ScriptInfo scriptInfo = new ScriptInfo();

    public ScriptInfo getScriptInfo() {
        return scriptInfo;
    }

    public RubotoBroadcastReceiver() {
        super();
        scriptInfo.setRubyClassName(getClass().getSimpleName());
        if (JRubyAdapter.isInitialized()) {
            ScriptLoader.loadScript(this);
        }
    }

    public void onReceive(android.content.Context context, android.content.Intent intent) {
        try {
            Log.d("onReceive: " + this + " " + ScriptLoader.isCalledFromJRuby());
            if (ScriptLoader.isCalledFromJRuby()) {
                return;
            }
            if (!scriptInfo.isLoaded()) {
                if (JRubyAdapter.setUpJRuby(context)) {
                    ScriptLoader.loadScript(this);
                } else {
                    // FIXME(uwe): What to do if the Ruboto Core platform is missing?
                }
            }

            // FIXME(uwe):  Simplify when we stop support for snake case aliasing interface callback methods.
            if ((Boolean)JRubyAdapter.runScriptlet(scriptInfo.getRubyClassName() + ".instance_methods(false).any?{|m| m.to_sym == :onReceive}")) {
                Log.d("onReceive: call method");
              JRubyAdapter.runRubyMethod(this, "onReceive", new Object[]{context, intent});
            } else if ((Boolean)JRubyAdapter.runScriptlet(scriptInfo.getRubyClassName() + ".instance_methods(false).any?{|m| m.to_sym == :on_receive}")) {
              JRubyAdapter.runRubyMethod(this, "on_receive", new Object[]{context, intent});
            }
            // EMXIF
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

}




Java Source Code List

org.ruboto.EntryPointActivity.java
org.ruboto.JRubyAdapter.java
org.ruboto.Log.java
org.ruboto.RubotoActivity.java
org.ruboto.RubotoBroadcastReceiver.java
org.ruboto.RubotoComponent.java
org.ruboto.RubotoDialog.java
org.ruboto.RubotoService.java
org.ruboto.ScriptInfo.java
org.ruboto.ScriptLoader.java
org.ruboto.Script.java
org.ruboto.SplashActivity.java
org.ruboto.example.isbn_reporter.IsbnReporterActivity.java