Skip to content

Commit

Permalink
NDK
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexMahao committed Oct 11, 2016
1 parent 1e91308 commit f62aebc
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

Expand All @@ -27,5 +28,9 @@ public void to(View view){
imgPath.add("1");
Intent intent = new Intent(this,Main2Activity.class);
startActivity(intent);


Handler handler = new Handler();
handler.sendEmptyMessage()
}
}
2 changes: 1 addition & 1 deletion customviewdemo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:design:24.1.0'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.0-beta1'
}
7 changes: 7 additions & 0 deletions ndkdemo/src/main/java/com/alex/ndkdemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

NdkJniUtils jni = new NdkJniUtils();

String str = jni.getJniString();

Toast.makeText(MainActivity.this, str, Toast.LENGTH_SHORT).show();
}
}
10 changes: 10 additions & 0 deletions ndkdemo/src/main/java/com/alex/ndkdemo/NdkJniUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.alex.ndkdemo;

/**
* Created by alex_mahao on 2016/9/27.
*/
public class NdkJniUtils {

public static native String getJniString();

}
12 changes: 7 additions & 5 deletions utils/src/main/java/com/mahao/alex/utils/json/OrgJSONTest.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.mahao.alex.utils.json;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
* Created by mdw on 2016/6/6.
*/
Expand All @@ -15,7 +12,12 @@ public class OrgJSONTest {


public static void main(String[] args) {
JSONObject obj = new JSONObject(json);//最外层的JSONObject对象
JSONObject obj = null;//最外层的JSONObject对象
try {
obj = new JSONObject(json);
} catch (JSONException e) {
e.printStackTrace();
}


JSONObject user = obj.optJSONObject("user");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
Expand Down Expand Up @@ -58,7 +60,7 @@ public static void writeBeanJson(){
System.out.println(json);
}

public static void parserArray(){
public static void parserArray() throws JSONException {
String json = "{\"user\":[{\"name\":\"alex\",\"age\":18,\"isMan\":true},{\"name\":\"mahao\",\"age\":16,\"isMan\":true}]}";

//1, 获取对应实体类对象的字符串,当前为user的值。
Expand All @@ -77,7 +79,7 @@ public static void parserArray(){
}


public static void parserObject(){
public static void parserObject() throws JSONException {

String json = "{\"user\":{\"name\":\"alex\",\"age\":18,\"isMan\":true}}";

Expand Down

0 comments on commit f62aebc

Please sign in to comment.