Showing
5 changed files
with
127 additions
and
5 deletions
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <project version="4"> | 2 | <project version="4"> |
3 | <component name="VcsDirectoryMappings"> | 3 | <component name="VcsDirectoryMappings"> |
4 | + <mapping directory="$PROJECT_DIR$/../.." vcs="Git" /> | ||
4 | <mapping directory="$PROJECT_DIR$/.." vcs="Git" /> | 5 | <mapping directory="$PROJECT_DIR$/.." vcs="Git" /> |
5 | </component> | 6 | </component> |
6 | </project> | 7 | </project> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -26,4 +26,5 @@ dependencies { | ... | @@ -26,4 +26,5 @@ dependencies { |
26 | testImplementation 'junit:junit:4.12' | 26 | testImplementation 'junit:junit:4.12' |
27 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' | 27 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' |
28 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | 28 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' |
29 | + implementation 'com.google.code.gson:gson:2.8.5' | ||
29 | } | 30 | } | ... | ... |
1 | +{"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 | ... | \ No newline at end of file |
... | @@ -5,6 +5,7 @@ import androidx.appcompat.app.AppCompatActivity; | ... | @@ -5,6 +5,7 @@ import androidx.appcompat.app.AppCompatActivity; |
5 | import android.app.Activity; | 5 | import android.app.Activity; |
6 | import android.app.ProgressDialog; | 6 | import android.app.ProgressDialog; |
7 | import android.content.Intent; | 7 | import android.content.Intent; |
8 | +import android.content.res.AssetManager; | ||
8 | import android.graphics.Bitmap; | 9 | import android.graphics.Bitmap; |
9 | import android.graphics.BitmapFactory; | 10 | import android.graphics.BitmapFactory; |
10 | import android.graphics.Color; | 11 | import android.graphics.Color; |
... | @@ -30,6 +31,9 @@ import android.view.animation.Animation; | ... | @@ -30,6 +31,9 @@ import android.view.animation.Animation; |
30 | import android.view.animation.AnimationUtils; | 31 | import android.view.animation.AnimationUtils; |
31 | 32 | ||
32 | 33 | ||
34 | +import android.content.res.AssetManager; | ||
35 | +import android.content.res.AssetManager.AssetInputStream; | ||
36 | + | ||
33 | import android.os.AsyncTask; | 37 | import android.os.AsyncTask; |
34 | /* | 38 | /* |
35 | import com.google.gson.Gson; | 39 | import com.google.gson.Gson; |
... | @@ -37,6 +41,12 @@ import com.google.gson.GsonBuilder; | ... | @@ -37,6 +41,12 @@ import com.google.gson.GsonBuilder; |
37 | import com.google.gson.JsonElement; | 41 | import com.google.gson.JsonElement; |
38 | import com.google.gson.JsonParser; | 42 | import com.google.gson.JsonParser; |
39 | */ | 43 | */ |
44 | +import org.json.JSONArray; | ||
45 | +import org.json.JSONException; | ||
46 | +import org.json.JSONObject; | ||
47 | + | ||
48 | +import java.io.IOException; | ||
49 | +import java.io.InputStream; | ||
40 | import java.net.HttpURLConnection; | 50 | import java.net.HttpURLConnection; |
41 | 51 | ||
42 | public class MainActivity extends AppCompatActivity { | 52 | public class MainActivity extends AppCompatActivity { |
... | @@ -233,6 +243,24 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -233,6 +243,24 @@ public class MainActivity extends AppCompatActivity { |
233 | //시작 시 mode 0로 보여주기 | 243 | //시작 시 mode 0로 보여주기 |
234 | mode0(); | 244 | mode0(); |
235 | 245 | ||
246 | + String jj; | ||
247 | + Player_info pp = new Player_info(); | ||
248 | + | ||
249 | + jj = json_reg("Hide on bush.json"); | ||
250 | + json1(pp, jj); | ||
251 | + /* | ||
252 | + try { | ||
253 | + JSONObject jsonObject = new JSONObject(jj); | ||
254 | + | ||
255 | + //JSONArray imp = jsonObject.getJSONArray("name"); | ||
256 | + | ||
257 | + pp.setName(jsonObject.getString("name")); | ||
258 | + | ||
259 | + } catch (JSONException e) { | ||
260 | + e.printStackTrace(); | ||
261 | + } | ||
262 | + */ | ||
263 | + Toast.makeText(MainActivity.this, pp.getName(), Toast.LENGTH_SHORT).show(); | ||
236 | 264 | ||
237 | } | 265 | } |
238 | 266 | ||
... | @@ -543,7 +571,55 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -543,7 +571,55 @@ public class MainActivity extends AppCompatActivity { |
543 | //public class MyAsyncTask extends AsyncTask<String, Void,PlayAnalysis> { | 571 | //public class MyAsyncTask extends AsyncTask<String, Void,PlayAnalysis> { |
544 | 572 | ||
545 | 573 | ||
574 | + //json에 쓰는 함수 반환 값은 json string 이다... | ||
575 | + public String json_reg(String files) { | ||
576 | + String jj = " "; | ||
577 | + try { | ||
578 | + InputStream is = getAssets().open(files); | ||
579 | + int fileSize = is.available(); | ||
580 | + | ||
581 | + byte[] buffer = new byte[fileSize]; | ||
582 | + is.read(buffer); | ||
583 | + is.close(); | ||
546 | 584 | ||
585 | + jj = new String(buffer, "UTF-8"); | ||
586 | + } catch (IOException ex) { | ||
587 | + ex.printStackTrace(); | ||
588 | + } | ||
589 | + | ||
590 | + return jj; | ||
591 | + } | ||
592 | + | ||
593 | + //1단계 전용 함수(이름으로 아이디 2종 받아오기) | ||
594 | + public void json1(Player_info pp, String jj){ | ||
595 | + try { | ||
596 | + JSONObject jsonObject = new JSONObject(jj); | ||
597 | + | ||
598 | + //JSONArray imp = jsonObject.getJSONArray("name"); | ||
599 | + pp.setEncryptId(jsonObject.getString("id")); | ||
600 | + pp.setAccountId(jsonObject.getString("id")); | ||
601 | + pp.setName(jsonObject.getString("name")); | ||
602 | + | ||
603 | + | ||
604 | + } catch (JSONException e) { | ||
605 | + e.printStackTrace(); | ||
606 | + } | ||
607 | + } | ||
608 | + | ||
609 | + public void json2(Player_info pp, String jj){ | ||
610 | + try { | ||
611 | + JSONObject jsonObject = new JSONObject(jj); | ||
612 | + | ||
613 | + //JSONArray imp = jsonObject.getJSONArray("name"); | ||
614 | + pp.setEncryptId(jsonObject.getString("tier")); | ||
615 | + pp.setAccountId(jsonObject.getString("rank")); | ||
616 | + pp.setName(jsonObject.getString("name")); | ||
617 | + | ||
618 | + | ||
619 | + } catch (JSONException e) { | ||
620 | + e.printStackTrace(); | ||
621 | + } | ||
622 | + } | ||
547 | 623 | ||
548 | 624 | ||
549 | } | 625 | } | ... | ... |
... | @@ -3,15 +3,59 @@ package com.example.pro_lol_log; | ... | @@ -3,15 +3,59 @@ package com.example.pro_lol_log; |
3 | public class Player_info { | 3 | public class Player_info { |
4 | 4 | ||
5 | 5 | ||
6 | - //이 3가지를 중점으로 테스트하자 정보는 | 6 | + //이 3가지를 중점으로 테스트하자 이름을 통해서 |
7 | + //아래 3개의 정보들을 가져온다. | ||
7 | String name; | 8 | String name; |
8 | - long summonerLevel; | ||
9 | String accountId; | 9 | String accountId; |
10 | + String encryptId; | ||
11 | + | ||
12 | + String tier; | ||
13 | + String rank; | ||
14 | + int leaguePoints; | ||
15 | + | ||
16 | + //두 번째로는 | ||
17 | + public String getName(){ | ||
18 | + return name; | ||
19 | + } | ||
20 | + public void setName(String nn){ | ||
21 | + name = nn; | ||
22 | + } | ||
23 | + public String getAccountId(){ | ||
24 | + return accountId; | ||
25 | + } | ||
26 | + public void setAccountId(String nn){ | ||
27 | + accountId = nn; | ||
28 | + } | ||
29 | + public String getEncryptId(){ | ||
30 | + return encryptId; | ||
31 | + } | ||
32 | + public void setEncryptId(String nn){ | ||
33 | + encryptId = nn; | ||
34 | + } | ||
35 | + public String getTier(){ | ||
36 | + return tier; | ||
37 | + } | ||
38 | + public void setTier(String nn){ | ||
39 | + encryptId = nn; | ||
40 | + } | ||
41 | + public String getRank(){ | ||
42 | + return rank; | ||
43 | + } | ||
44 | + public void setRank(String ss){ | ||
45 | + rank = ss; | ||
46 | + } | ||
47 | + public int getLeaguePoints(){ | ||
48 | + return leaguePoints; | ||
49 | + } | ||
50 | + public void setLeaguePoints(int ii){ | ||
51 | + leaguePoints = ii; | ||
52 | + } | ||
53 | + | ||
10 | 54 | ||
11 | 55 | ||
12 | 56 | ||
13 | - String get_all(){ | 57 | + //String get_all(){ |
14 | - return name+" / "+summonerLevel+" / "+accountId; | 58 | + //return name+" / "+summonerLevel+" / "+accountId; |
15 | } | 59 | } |
16 | 60 | ||
17 | /* | 61 | /* |
... | @@ -33,6 +77,5 @@ public class Player_info { | ... | @@ -33,6 +77,5 @@ public class Player_info { |
33 | matches[count]=match; | 77 | matches[count]=match; |
34 | } | 78 | } |
35 | */ | 79 | */ |
36 | -} | ||
37 | 80 | ||
38 | 81 | ... | ... |
-
Please register or login to post a comment