Skip to content

Instantly share code, notes, and snippets.

@rscottm
Created November 7, 2010 22:53
Show Gist options
  • Save rscottm/667092 to your computer and use it in GitHub Desktop.
Save rscottm/667092 to your computer and use it in GitHub Desktop.
Java classes created by the experimental subclass and interfce gen code
package org.scottmoyer.test;
import org.jruby.Ruby;
import org.jruby.javasupport.util.RuntimeHelpers;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.javasupport.JavaUtil;
import org.jruby.exceptions.RaiseException;
import org.ruboto.Script;
public class MyDateSetListener implements android.app.DatePickerDialog.OnDateSetListener {
private IRubyObject __this__;
private Ruby __ruby__;
public static final int CB_DATE_SET = 0;
public static final int CB_LAST = 1;
private boolean[] callbackOptions = new boolean [CB_LAST];
public MyDateSetListener() {
super();
setupRuboto();
}
private void setupRuboto() {
__ruby__ = Script.getRuby();
__this__ = JavaUtil.convertJavaToRuby(__ruby__, this);
}
public void requestCallback(int id) {
callbackOptions[id] = true;
}
public void removeCallback(int id) {
callbackOptions[id] = false;
}
public void onDateSet(android.widget.DatePicker view, int year, int monthOfYear, int dayOfMonth) {
if (callbackOptions[CB_DATE_SET]) {
try {
IRubyObject[] args = {JavaUtil.convertJavaToRuby(__ruby__, view), JavaUtil.convertJavaToRuby(__ruby__, year), JavaUtil.convertJavaToRuby(__ruby__, monthOfYear), JavaUtil.convertJavaToRuby(__ruby__, dayOfMonth)};
RuntimeHelpers.invoke(__ruby__.getCurrentContext(), __this__, "on_date_set" , args);
} catch (RaiseException re) {
re.printStackTrace();
}
}
}
}
package org.scottmoyer.test;
import org.jruby.Ruby;
import org.jruby.javasupport.util.RuntimeHelpers;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.javasupport.JavaUtil;
import org.jruby.exceptions.RaiseException;
import org.ruboto.Script;
public class MyPhoneStateListener extends android.telephony.PhoneStateListener {
private IRubyObject __this__;
private Ruby __ruby__;
public static final int CB_CALL_FORWARDING_INDICATOR_CHANGED = 0;
public static final int CB_CALL_STATE_CHANGED = 1;
public static final int CB_CELL_LOCATION_CHANGED = 2;
public static final int CB_DATA_ACTIVITY = 3;
public static final int CB_DATA_CONNECTION_STATE_CHANGED = 4;
public static final int CB_MESSAGE_WAITING_INDICATOR_CHANGED = 5;
public static final int CB_SERVICE_STATE_CHANGED = 6;
public static final int CB_SIGNAL_STRENGTH_CHANGED = 7;
public static final int CB_LAST = 8;
private boolean[] callbackOptions = new boolean [CB_LAST];
public MyPhoneStateListener() {
super();
setupRuboto();
}
private void setupRuboto() {
__ruby__ = Script.getRuby();
__this__ = JavaUtil.convertJavaToRuby(__ruby__, this);
}
public void requestCallback(int id) {
callbackOptions[id] = true;
}
public void removeCallback(int id) {
callbackOptions[id] = false;
}
public void onCallForwardingIndicatorChanged(boolean cfi) {
if (callbackOptions[CB_CALL_FORWARDING_INDICATOR_CHANGED]) {
super.onCallForwardingIndicatorChanged(cfi);
try {
RuntimeHelpers.invoke(__ruby__.getCurrentContext(), __this__, "on_call_forwarding_indicator_changed" , JavaUtil.convertJavaToRuby(__ruby__, cfi));
} catch (RaiseException re) {
re.printStackTrace();
}
} else {
super.onCallForwardingIndicatorChanged(cfi);
}
}
public void onCallStateChanged(int state, java.lang.String incomingNumber) {
if (callbackOptions[CB_CALL_STATE_CHANGED]) {
super.onCallStateChanged(state, incomingNumber);
try {
RuntimeHelpers.invoke(__ruby__.getCurrentContext(), __this__, "on_call_state_changed" , JavaUtil.convertJavaToRuby(__ruby__, state), JavaUtil.convertJavaToRuby(__ruby__, incomingNumber));
} catch (RaiseException re) {
re.printStackTrace();
}
} else {
super.onCallStateChanged(state, incomingNumber);
}
}
public void onCellLocationChanged(android.telephony.CellLocation location) {
if (callbackOptions[CB_CELL_LOCATION_CHANGED]) {
super.onCellLocationChanged(location);
try {
RuntimeHelpers.invoke(__ruby__.getCurrentContext(), __this__, "on_cell_location_changed" , JavaUtil.convertJavaToRuby(__ruby__, location));
} catch (RaiseException re) {
re.printStackTrace();
}
} else {
super.onCellLocationChanged(location);
}
}
public void onDataActivity(int direction) {
if (callbackOptions[CB_DATA_ACTIVITY]) {
super.onDataActivity(direction);
try {
RuntimeHelpers.invoke(__ruby__.getCurrentContext(), __this__, "on_data_activity" , JavaUtil.convertJavaToRuby(__ruby__, direction));
} catch (RaiseException re) {
re.printStackTrace();
}
} else {
super.onDataActivity(direction);
}
}
public void onDataConnectionStateChanged(int state) {
if (callbackOptions[CB_DATA_CONNECTION_STATE_CHANGED]) {
super.onDataConnectionStateChanged(state);
try {
RuntimeHelpers.invoke(__ruby__.getCurrentContext(), __this__, "on_data_connection_state_changed" , JavaUtil.convertJavaToRuby(__ruby__, state));
} catch (RaiseException re) {
re.printStackTrace();
}
} else {
super.onDataConnectionStateChanged(state);
}
}
public void onMessageWaitingIndicatorChanged(boolean mwi) {
if (callbackOptions[CB_MESSAGE_WAITING_INDICATOR_CHANGED]) {
super.onMessageWaitingIndicatorChanged(mwi);
try {
RuntimeHelpers.invoke(__ruby__.getCurrentContext(), __this__, "on_message_waiting_indicator_changed" , JavaUtil.convertJavaToRuby(__ruby__, mwi));
} catch (RaiseException re) {
re.printStackTrace();
}
} else {
super.onMessageWaitingIndicatorChanged(mwi);
}
}
public void onServiceStateChanged(android.telephony.ServiceState serviceState) {
if (callbackOptions[CB_SERVICE_STATE_CHANGED]) {
super.onServiceStateChanged(serviceState);
try {
RuntimeHelpers.invoke(__ruby__.getCurrentContext(), __this__, "on_service_state_changed" , JavaUtil.convertJavaToRuby(__ruby__, serviceState));
} catch (RaiseException re) {
re.printStackTrace();
}
} else {
super.onServiceStateChanged(serviceState);
}
}
public void onSignalStrengthChanged(int asu, android.telephony.SignalStrength signalStrength) {
if (callbackOptions[CB_SIGNAL_STRENGTH_CHANGED]) {
super.onSignalStrengthChanged(asu, signalStrength);
try {
RuntimeHelpers.invoke(__ruby__.getCurrentContext(), __this__, "on_signal_strength_changed" , JavaUtil.convertJavaToRuby(__ruby__, asu), JavaUtil.convertJavaToRuby(__ruby__, signalStrength));
} catch (RaiseException re) {
re.printStackTrace();
}
} else {
super.onSignalStrengthChanged(asu, signalStrength);
}
}
}
package org.scottmoyer.test;
import org.jruby.Ruby;
import org.jruby.javasupport.util.RuntimeHelpers;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.javasupport.JavaUtil;
import org.jruby.exceptions.RaiseException;
import org.ruboto.Script;
public class MySQLOpenHelper extends android.database.sqlite.SQLiteOpenHelper {
private IRubyObject __this__;
private Ruby __ruby__;
public static final int CB_CREATE = 0;
public static final int CB_OPEN = 1;
public static final int CB_UPGRADE = 2;
public static final int CB_LAST = 3;
private boolean[] callbackOptions = new boolean [CB_LAST];
public MySQLOpenHelper(android.content.Context context, java.lang.String name, android.database.sqlite.SQLiteDatabase.CursorFactory factory, int version) {
super(context, name, factory, version);
setupRuboto();
}
private void setupRuboto() {
__ruby__ = Script.getRuby();
__this__ = JavaUtil.convertJavaToRuby(__ruby__, this);
}
public void requestCallback(int id) {
callbackOptions[id] = true;
}
public void removeCallback(int id) {
callbackOptions[id] = false;
}
public void onCreate(android.database.sqlite.SQLiteDatabase db) {
if (callbackOptions[CB_CREATE]) {
try {
RuntimeHelpers.invoke(__ruby__.getCurrentContext(), __this__, "on_create" , JavaUtil.convertJavaToRuby(__ruby__, db));
} catch (RaiseException re) {
re.printStackTrace();
}
}
}
public void onOpen(android.database.sqlite.SQLiteDatabase db) {
if (callbackOptions[CB_OPEN]) {
super.onOpen(db);
try {
RuntimeHelpers.invoke(__ruby__.getCurrentContext(), __this__, "on_open" , JavaUtil.convertJavaToRuby(__ruby__, db));
} catch (RaiseException re) {
re.printStackTrace();
}
} else {
super.onOpen(db);
}
}
public void onUpgrade(android.database.sqlite.SQLiteDatabase db, int oldVersion, int newVersion) {
if (callbackOptions[CB_UPGRADE]) {
try {
RuntimeHelpers.invoke(__ruby__.getCurrentContext(), __this__, "on_upgrade" , JavaUtil.convertJavaToRuby(__ruby__, db), JavaUtil.convertJavaToRuby(__ruby__, oldVersion), JavaUtil.convertJavaToRuby(__ruby__, newVersion));
} catch (RaiseException re) {
re.printStackTrace();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment