mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-01 20:43:20 +08:00
Android: Move native code to its own class
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
#include <git2.h>
|
||||
|
||||
extern "C" JNIEXPORT jstring JNICALL
|
||||
Java_io_gitjournal_gitjournal_MainActivity_stringFromJNI(
|
||||
Java_io_gitjournal_gitjournal_Git_stringFromJNI(
|
||||
JNIEnv *env,
|
||||
jobject /* this */) {
|
||||
|
||||
@ -21,7 +21,7 @@ Java_io_gitjournal_gitjournal_MainActivity_stringFromJNI(
|
||||
hello += " SSH Version: ";
|
||||
hello += ssh2_version;
|
||||
|
||||
//git_libgit2_init();
|
||||
git_libgit2_init();
|
||||
int major;
|
||||
int minor;
|
||||
int patch;
|
||||
|
13
android/app/src/main/java/io/gitjournal/gitjournal/Git.java
Normal file
13
android/app/src/main/java/io/gitjournal/gitjournal/Git.java
Normal file
@ -0,0 +1,13 @@
|
||||
package io.gitjournal.gitjournal;
|
||||
|
||||
public class Git {
|
||||
static {
|
||||
System.loadLibrary("native-lib");
|
||||
}
|
||||
|
||||
/**
|
||||
* A native method that is implemented by the 'native-lib' native library,
|
||||
* which is packaged with this application.
|
||||
*/
|
||||
public native String stringFromJNI();
|
||||
}
|
@ -21,23 +21,13 @@ import io.flutter.util.PathUtils;
|
||||
// For MethodChannel
|
||||
|
||||
public class MainActivity extends FlutterActivity implements MethodCallHandler {
|
||||
static {
|
||||
System.loadLibrary("native-lib");
|
||||
}
|
||||
|
||||
/**
|
||||
* A native method that is implemented by the 'native-lib' native library,
|
||||
* which is packaged with this application.
|
||||
*/
|
||||
public native String stringFromJNI();
|
||||
|
||||
|
||||
private static final String CHANNEL_NAME = "gitjournal.io/git";
|
||||
static MethodChannel channel;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Log.d("VISH", stringFromJNI());
|
||||
Git git = new Git();
|
||||
Log.d("VISH", git.stringFromJNI());
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
GeneratedPluginRegistrant.registerWith(this);
|
||||
|
Reference in New Issue
Block a user