-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate shell to v2 and make termonal onexit optional
- Loading branch information
1 parent
6af65d0
commit 6cd5e69
Showing
12 changed files
with
245 additions
and
111 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
Android/app/src/main/java/com/dergoogler/core/NativeShell.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.dergoogler.util; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class Json { | ||
public static Map<String, String> toMap(JSONObject jsonobj) throws JSONException { | ||
Map<String, String> map = new HashMap<String, String>(); | ||
Iterator<String> keys = jsonobj.keys(); | ||
while (keys.hasNext()) { | ||
String key = keys.next(); | ||
String value = jsonobj.getString(key); | ||
map.put(key, value); | ||
} | ||
return map; | ||
} | ||
|
||
public static List<Object> toList(JSONArray array) throws JSONException { | ||
List<Object> list = new ArrayList<Object>(); | ||
for (int i = 0; i < array.length(); i++) { | ||
Object value = array.get(i); | ||
if (value instanceof JSONArray) { | ||
value = toList((JSONArray) value); | ||
} else if (value instanceof JSONObject) { | ||
value = toMap((JSONObject) value); | ||
} | ||
list.add(value); | ||
} | ||
return list; | ||
} | ||
|
||
public static String[] getStringArray(JSONArray jsonArray) { | ||
String[] stringArray = null; | ||
if (jsonArray != null) { | ||
int length = jsonArray.length(); | ||
stringArray = new String[length]; | ||
for (int i = 0; i < length; i++) { | ||
stringArray[i] = jsonArray.optString(i); | ||
} | ||
} | ||
return stringArray; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.