정훈용

parsing made

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
......
......@@ -26,4 +26,5 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.code.gson:gson:2.8.5'
}
......
{"id":"1K6Gl993M9yX5HXBgA7aZP-nwrR2qNYoJGBMvkSVZ7pRNQ","accountId":"nhxryxTxT8XD2gkwh3Kw3GLvgdSaunipacRmqsAJ66ge","puuid":"Z_4gQvSU5TfHtBHhFWefsuGvXbAHnVMaKQMLSl4AjXIWrv7ZI5_zeEYCxPifni759DYdAqH0pO27OQ","name":"Hide on bush","profileIconId":6,"revisionDate":1574056130000,"summonerLevel":270}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import androidx.appcompat.app.AppCompatActivity;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
......@@ -30,6 +31,9 @@ import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.content.res.AssetManager;
import android.content.res.AssetManager.AssetInputStream;
import android.os.AsyncTask;
/*
import com.google.gson.Gson;
......@@ -37,6 +41,12 @@ import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
*/
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
public class MainActivity extends AppCompatActivity {
......@@ -233,6 +243,24 @@ public class MainActivity extends AppCompatActivity {
//시작 시 mode 0로 보여주기
mode0();
String jj;
Player_info pp = new Player_info();
jj = json_reg("Hide on bush.json");
json1(pp, jj);
/*
try {
JSONObject jsonObject = new JSONObject(jj);
//JSONArray imp = jsonObject.getJSONArray("name");
pp.setName(jsonObject.getString("name"));
} catch (JSONException e) {
e.printStackTrace();
}
*/
Toast.makeText(MainActivity.this, pp.getName(), Toast.LENGTH_SHORT).show();
}
......@@ -543,7 +571,55 @@ public class MainActivity extends AppCompatActivity {
//public class MyAsyncTask extends AsyncTask<String, Void,PlayAnalysis> {
//json에 쓰는 함수 반환 값은 json string 이다...
public String json_reg(String files) {
String jj = " ";
try {
InputStream is = getAssets().open(files);
int fileSize = is.available();
byte[] buffer = new byte[fileSize];
is.read(buffer);
is.close();
jj = new String(buffer, "UTF-8");
} catch (IOException ex) {
ex.printStackTrace();
}
return jj;
}
//1단계 전용 함수(이름으로 아이디 2종 받아오기)
public void json1(Player_info pp, String jj){
try {
JSONObject jsonObject = new JSONObject(jj);
//JSONArray imp = jsonObject.getJSONArray("name");
pp.setEncryptId(jsonObject.getString("id"));
pp.setAccountId(jsonObject.getString("id"));
pp.setName(jsonObject.getString("name"));
} catch (JSONException e) {
e.printStackTrace();
}
}
public void json2(Player_info pp, String jj){
try {
JSONObject jsonObject = new JSONObject(jj);
//JSONArray imp = jsonObject.getJSONArray("name");
pp.setEncryptId(jsonObject.getString("tier"));
pp.setAccountId(jsonObject.getString("rank"));
pp.setName(jsonObject.getString("name"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
......
......@@ -3,15 +3,59 @@ package com.example.pro_lol_log;
public class Player_info {
//이 3가지를 중점으로 테스트하자 정보는
//이 3가지를 중점으로 테스트하자 이름을 통해서
//아래 3개의 정보들을 가져온다.
String name;
long summonerLevel;
String accountId;
String encryptId;
String tier;
String rank;
int leaguePoints;
//두 번째로는
public String getName(){
return name;
}
public void setName(String nn){
name = nn;
}
public String getAccountId(){
return accountId;
}
public void setAccountId(String nn){
accountId = nn;
}
public String getEncryptId(){
return encryptId;
}
public void setEncryptId(String nn){
encryptId = nn;
}
public String getTier(){
return tier;
}
public void setTier(String nn){
encryptId = nn;
}
public String getRank(){
return rank;
}
public void setRank(String ss){
rank = ss;
}
public int getLeaguePoints(){
return leaguePoints;
}
public void setLeaguePoints(int ii){
leaguePoints = ii;
}
String get_all(){
return name+" / "+summonerLevel+" / "+accountId;
//String get_all(){
//return name+" / "+summonerLevel+" / "+accountId;
}
/*
......@@ -33,6 +77,5 @@ public class Player_info {
matches[count]=match;
}
*/
}
......