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
import android.app.IntentService; | |
import android.content.Intent; | |
import android.content.pm.PackageManager; | |
import android.content.pm.ResolveInfo; | |
import android.util.Log; | |
import java.util.List; | |
public class MyDispatchService extends IntentService { |
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
private static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException { | |
WritableMap map = new WritableNativeMap(); | |
Iterator<String> iterator = jsonObject.keys(); | |
while (iterator.hasNext()) { | |
String key = iterator.next(); | |
Object value = jsonObject.get(key); | |
if (value instanceof JSONObject) { | |
map.putMap(key, convertJsonToMap((JSONObject) value)); | |
} else if (value instanceof JSONArray) { |
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
private long getJsonHashcode(@NonNull Object json) throws JSONException { | |
long result = 15l; | |
int multiplier = 27; | |
if (json instanceof JSONObject) { | |
JSONObject obj = (JSONObject) json; | |
for (Iterator<String> iterator = obj.keys(); iterator.hasNext(); ) { | |
String key = iterator.next(); | |
Object value = obj.get(key); | |
result = multiplier * result + key.hashCode(); |
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
#!/bin/bash | |
# Originally written by Ralf Kistner <ralf@embarkmobile.com>, but placed in the public domain | |
# Edited for log brevity by Affian <https://github.com/viperwarp> | |
set +e | |
bootanim="" | |
failcounter=0 | |
echo "Waiting for Emulator" |
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
public JSONObject getJsonFromUri(String url) throws JSONException, IOException { | |
URLConnection conn = null; | |
DataInputStream data = null; | |
String line; | |
StringBuffer buf = new StringBuffer(); | |
conn = new URL(url).openConnection(); | |
conn.connect(); | |
data = new DataInputStream(new BufferedInputStream(conn.getInputStream())); |
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
//Download menu icons | |
if (menu != null && !menuImageURL.equals("")) { | |
File cacheDir = new File (ClassificationActivity.this.getCacheDir(), "/ic_menu/"); | |
if (!cacheDir.exists()) cacheDir.mkdirs(); | |
List<String> existingFiles = Arrays.asList(cacheDir.list()); | |
for (int i = 0; i < menu.length(); i++) { | |
try { | |
String filename = menu.getJSONObject(i).getString("image"); | |
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
// And to convert the image URI (content:// format) to the direct file system path of the image file | |
// From "http://www.androidsnippets.com/get-file-path-of-gallery-image" | |
public String getRealPathFromURI(Uri contentUri) { | |
// can post image | |
String [] proj={MediaStore.Images.Media.DATA}; | |
Cursor cursor = managedQuery( contentUri, | |
proj, // Which columns to return | |
null, // WHERE clause; which rows to return (all rows) | |
null, // WHERE clause selection arguments (none) |
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
GitHub username: viperwarp | |
Day job: Mobile Developer | |
Favorite open source project: Bukkit | |
Open Source contributions (if any): None yet | |
Stranded on an island, what 3 items do you take: Pickaxe, Torch, Workbench | |
Tie-breaker, pick a number between 1 and 20,000: 16384 |