This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/swig/android/SwigSimple.java

90 lines
2.5 KiB
Java
Raw Normal View History

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;
public class SwigSimple extends Activity
{
TextView outputText = null;
ScrollView scroller = null;
2014-06-04 22:07:37 +01:00
YAPEngine eng = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
2014-06-04 22:07:37 +01:00
super.onCreate(savedInstanceState);
2014-06-04 22:07:37 +01:00
String s = "ugh";
setContentView(R.layout.main);
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);
}
outputText = (TextView)findViewById(R.id.OutputText);
2014-06-04 22:07:37 +01:00
outputText.setText("Application " + s + "\nPress 'Run' to start...\n");
outputText.setMovementMethod(new ScrollingMovementMethod());
2014-06-04 22:07:37 +01:00
YAPParams p = new YAPParams();
eng = new YAPEngine( p );
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");
}
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 =
}
});
}
/** static constructor */
static {
2014-06-04 22:07:37 +01:00
System.loadLibrary("android");
System.loadLibrary("log");
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";
}