2014-05-28 00:07:50 +01:00
|
|
|
package org.swig.simple;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.ScrollView;
|
|
|
|
import android.text.method.ScrollingMovementMethod;
|
2014-06-04 22:07:37 +01:00
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
import android.content.pm.PackageInfo;
|
|
|
|
import android.content.pm.PackageManager.NameNotFoundException;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.content.res.AssetManager;
|
2014-05-28 00:07:50 +01:00
|
|
|
|
|
|
|
public class SwigSimple extends Activity
|
|
|
|
{
|
|
|
|
TextView outputText = null;
|
|
|
|
ScrollView scroller = null;
|
2014-06-04 22:07:37 +01:00
|
|
|
YAPEngine eng = null;
|
2014-05-28 00:07:50 +01:00
|
|
|
|
|
|
|
/** Called when the activity is first created. */
|
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState)
|
|
|
|
{
|
2014-06-04 22:07:37 +01:00
|
|
|
|
2014-05-28 00:07:50 +01:00
|
|
|
super.onCreate(savedInstanceState);
|
2014-06-04 22:07:37 +01:00
|
|
|
String s = "ugh";
|
|
|
|
setContentView(R.layout.main);
|
2014-05-28 00:07:50 +01:00
|
|
|
|
2014-06-04 22:07:37 +01:00
|
|
|
try {
|
|
|
|
PackageManager m = getPackageManager();
|
|
|
|
s = getPackageName();
|
|
|
|
PackageInfo p = m.getPackageInfo(s, 0);
|
|
|
|
s = p.applicationInfo.dataDir;
|
|
|
|
mgr = getResources().getAssets();
|
|
|
|
load(mgr);
|
|
|
|
} catch(NameNotFoundException e) {
|
|
|
|
Log.e(TAG, "Couldn't find package information in PackageManager", e);
|
|
|
|
}
|
|
|
|
|
2014-05-28 00:07:50 +01:00
|
|
|
outputText = (TextView)findViewById(R.id.OutputText);
|
2014-06-04 22:07:37 +01:00
|
|
|
outputText.setText("Application " + s + "\nPress 'Run' to start...\n");
|
2014-05-28 00:07:50 +01:00
|
|
|
outputText.setMovementMethod(new ScrollingMovementMethod());
|
2014-06-04 22:07:37 +01:00
|
|
|
YAPParams p = new YAPParams();
|
|
|
|
eng = new YAPEngine( p );
|
|
|
|
|
2014-05-28 00:07:50 +01:00
|
|
|
scroller = (ScrollView)findViewById(R.id.Scroller);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onRunButtonClick(View view)
|
|
|
|
{
|
|
|
|
outputText.append("Started...\n");
|
2014-06-04 22:07:37 +01:00
|
|
|
if (BuildConfig.DEBUG) {
|
|
|
|
Log.i(TAG, "onRunButtonClick called");
|
|
|
|
}
|
2014-05-28 00:07:50 +01:00
|
|
|
outputText.append("Finished!\n");
|
|
|
|
|
|
|
|
// Ensure scroll to end of text
|
|
|
|
scroller.post(new Runnable() {
|
|
|
|
public void run() {
|
|
|
|
scroller.fullScroll(ScrollView.FOCUS_DOWN);
|
2014-06-04 22:07:37 +01:00
|
|
|
String s = "['/assets/share/Yap/lists'].\n";
|
|
|
|
outputText.append(s);
|
|
|
|
YAPQuery q = eng.query(s);
|
|
|
|
q.next();
|
|
|
|
String s = "member(X, [1,2,3]).\n";
|
|
|
|
outputText.append(s);
|
|
|
|
YAPQuery q = eng.query(s);
|
|
|
|
q.next();
|
|
|
|
String sn =
|
2014-05-28 00:07:50 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** static constructor */
|
|
|
|
static {
|
2014-06-04 22:07:37 +01:00
|
|
|
System.loadLibrary("android");
|
|
|
|
System.loadLibrary("log");
|
2014-05-28 00:07:50 +01:00
|
|
|
System.loadLibrary("example");
|
|
|
|
}
|
2014-06-04 22:07:37 +01:00
|
|
|
|
|
|
|
private static native void load(AssetManager mgr);
|
|
|
|
|
|
|
|
private AssetManager mgr;
|
|
|
|
|
|
|
|
private static final String TAG = "SwigSimple";
|
2014-05-28 00:07:50 +01:00
|
|
|
|
|
|
|
}
|