From e4025420af28bbc52e3272b3a4f6419f16ba7828 Mon Sep 17 00:00:00 2001 From: TwistedUmbrella Date: Fri, 21 Nov 2014 15:03:22 -0500 Subject: [PATCH] Fix indentation issues when transferring code --- .../com/reicast/emulator/AboutFragment.java | 289 +++++++++--------- 1 file changed, 144 insertions(+), 145 deletions(-) diff --git a/shell/android/src/com/reicast/emulator/AboutFragment.java b/shell/android/src/com/reicast/emulator/AboutFragment.java index 475a0605a..ab8a80af0 100644 --- a/shell/android/src/com/reicast/emulator/AboutFragment.java +++ b/shell/android/src/com/reicast/emulator/AboutFragment.java @@ -23,7 +23,6 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; -import android.os.Debug; import android.os.Handler; import android.support.v4.app.Fragment; import android.text.util.Linkify; @@ -42,7 +41,7 @@ import com.reicast.emulator.debug.GitAdapter; public class AboutFragment extends Fragment { String buildId = ""; - String git_api = "https://api.github.com/repos/reicast/reicast-emulator/commits"; + String git_api = "https://api.github.com/repos/reicast/reicast-emulator/commits"; SlidingDrawer slidingGithub; private ListView list; private GitAdapter adapter; @@ -87,11 +86,11 @@ public class AboutFragment extends Fragment { } catch (NameNotFoundException e) { e.printStackTrace(); } - + TextView website = (TextView) getView().findViewById( R.id.site_text); Linkify.addLinks(website, Linkify.ALL); - + handler = new Handler(); slidingGithub = (SlidingDrawer) getView().findViewById( @@ -110,159 +109,159 @@ public class AboutFragment extends Fragment { }); } - + public class retrieveGitTask extends AsyncTask>> { -@Override -protected void onPreExecute() { + @Override + protected void onPreExecute() { -} + } -@Override -protected ArrayList> doInBackground( - String... paths) { - ArrayList> commitList = new ArrayList>(); - try { - JSONArray gitObject = getContent(paths[0]); - for (int i = 0; i < gitObject.length(); i++) { - JSONObject jsonObject = gitObject.getJSONObject(i); + @Override + protected ArrayList> doInBackground( + String... paths) { + ArrayList> commitList = new ArrayList>(); + try { + JSONArray gitObject = getContent(paths[0]); + for (int i = 0; i < gitObject.length(); i++) { + JSONObject jsonObject = gitObject.getJSONObject(i); - JSONObject commitArray = jsonObject.getJSONObject("commit"); + JSONObject commitArray = jsonObject.getJSONObject("commit"); - String date = commitArray.getJSONObject("committer") - .getString("date").replace("T", " ") - .replace("Z", ""); - String author = commitArray.getJSONObject("author") - .getString("name"); - String committer = commitArray.getJSONObject("committer") - .getString("name"); + String date = commitArray.getJSONObject("committer") + .getString("date").replace("T", " ") + .replace("Z", ""); + String author = commitArray.getJSONObject("author") + .getString("name"); + String committer = commitArray.getJSONObject("committer") + .getString("name"); - String avatar = null; - if (!jsonObject.getString("committer").equals("null")) { - avatar = jsonObject.getJSONObject("committer") - .getString("avatar_url"); - committer = committer - + " (" - + jsonObject.getJSONObject("committer") + String avatar = null; + if (!jsonObject.getString("committer").equals("null")) { + avatar = jsonObject.getJSONObject("committer") + .getString("avatar_url"); + committer = committer + + " (" + + jsonObject.getJSONObject("committer") .getString("login") + ")"; - if (avatar.equals("null")) { - avatar = "https://github.com/apple-touch-icon-144.png"; + if (avatar.equals("null")) { + avatar = "https://github.com/apple-touch-icon-144.png"; + } + } else { + avatar = "https://github.com/apple-touch-icon-144.png"; + } + if (!jsonObject.getString("author").equals("null")) { + author = author + + " (" + + jsonObject.getJSONObject("author").getString( + "login") + ")"; + } + String sha = jsonObject.getString("sha"); + String curl = jsonObject + .getString("url") + .replace("https://api.github.com/repos", + "https://github.com") + .replace("commits", "commit"); + + String title = "No commit heading attached"; + String message = "No commit message attached"; + + if (commitArray.getString("message").contains("\n\n")) { + String fullOutput = commitArray.getString("message"); + title = fullOutput.substring(0, + fullOutput.indexOf("\n\n")); + message = fullOutput.substring( + fullOutput.indexOf("\n\n") + 1, + fullOutput.length()); + } else { + title = commitArray.getString("message"); + } + + HashMap map = new HashMap(); + map.put("Date", date); + map.put("Committer", committer); + map.put("Title", title); + map.put("Message", message); + map.put("Sha", sha); + map.put("Url", curl); + map.put("Author", author); + map.put("Avatar", avatar); + map.put("Build", buildId); + commitList.add(map); + } + + } catch (JSONException e) { + handler.post(new Runnable() { + public void run() { + MainActivity.showToastMessage(getActivity(), + getActivity().getString(R.string.git_broken), + R.drawable.ic_github); + slidingGithub.close(); + } + }); + e.printStackTrace(); + } catch (Exception e) { + handler.post(new Runnable() { + public void run() { + MainActivity.showToastMessage(getActivity(), + getActivity().getString(R.string.git_broken), + R.drawable.ic_github); + slidingGithub.close(); + } + }); + e.printStackTrace(); + } + + return commitList; + } + + @Override + protected void onPostExecute( + ArrayList> commitList) { + if (commitList != null && commitList.size() > 0) { + list = (ListView) getView().findViewById(R.id.list); + list.setSelector(R.drawable.list_selector); + list.setChoiceMode(ListView.CHOICE_MODE_SINGLE); + adapter = new GitAdapter(getActivity(), commitList); + // Set adapter as specified collection + list.setAdapter(adapter); + + list.setOnItemClickListener(new OnItemClickListener() { + public void onItemClick(AdapterView parent, View view, + int position, long id) { + } + }); + } + + } + } + + private JSONArray getContent(String urlString) throws IOException, + JSONException { + StringBuilder builder = new StringBuilder(); + HttpClient client = new DefaultHttpClient(); + HttpGet httpGet = new HttpGet(urlString); + try { + HttpResponse response = client.execute(httpGet); + StatusLine statusLine = response.getStatusLine(); + int statusCode = statusLine.getStatusCode(); + if (statusCode == 200) { + HttpEntity entity = response.getEntity(); + InputStream content = entity.getContent(); + BufferedReader reader = new BufferedReader( + new InputStreamReader(content)); + String line; + while ((line = reader.readLine()) != null) { + builder.append(line); } } else { - avatar = "https://github.com/apple-touch-icon-144.png"; } - if (!jsonObject.getString("author").equals("null")) { - author = author - + " (" - + jsonObject.getJSONObject("author").getString( - "login") + ")"; - } - String sha = jsonObject.getString("sha"); - String curl = jsonObject - .getString("url") - .replace("https://api.github.com/repos", - "https://github.com") - .replace("commits", "commit"); - - String title = "No commit heading attached"; - String message = "No commit message attached"; - - if (commitArray.getString("message").contains("\n\n")) { - String fullOutput = commitArray.getString("message"); - title = fullOutput.substring(0, - fullOutput.indexOf("\n\n")); - message = fullOutput.substring( - fullOutput.indexOf("\n\n") + 1, - fullOutput.length()); - } else { - title = commitArray.getString("message"); - } - - HashMap map = new HashMap(); - map.put("Date", date); - map.put("Committer", committer); - map.put("Title", title); - map.put("Message", message); - map.put("Sha", sha); - map.put("Url", curl); - map.put("Author", author); - map.put("Avatar", avatar); - map.put("Build", buildId); - commitList.add(map); + } catch (ClientProtocolException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); } - - } catch (JSONException e) { - handler.post(new Runnable() { - public void run() { - MainActivity.showToastMessage(getActivity(), - getActivity().getString(R.string.git_broken), - R.drawable.ic_github); - slidingGithub.close(); - } - }); - e.printStackTrace(); - } catch (Exception e) { - handler.post(new Runnable() { - public void run() { - MainActivity.showToastMessage(getActivity(), - getActivity().getString(R.string.git_broken), - R.drawable.ic_github); - slidingGithub.close(); - } - }); - e.printStackTrace(); + return new JSONArray(builder.toString()); } - - return commitList; -} - -@Override -protected void onPostExecute( - ArrayList> commitList) { - if (commitList != null && commitList.size() > 0) { - list = (ListView) getView().findViewById(R.id.list); - list.setSelector(R.drawable.list_selector); - list.setChoiceMode(ListView.CHOICE_MODE_SINGLE); - adapter = new GitAdapter(getActivity(), commitList); - // Set adapter as specified collection - list.setAdapter(adapter); - - list.setOnItemClickListener(new OnItemClickListener() { - public void onItemClick(AdapterView parent, View view, - int position, long id) { - } - }); - } - -} -} - -private JSONArray getContent(String urlString) throws IOException, - JSONException { -StringBuilder builder = new StringBuilder(); -HttpClient client = new DefaultHttpClient(); -HttpGet httpGet = new HttpGet(urlString); -try { - HttpResponse response = client.execute(httpGet); - StatusLine statusLine = response.getStatusLine(); - int statusCode = statusLine.getStatusCode(); - if (statusCode == 200) { - HttpEntity entity = response.getEntity(); - InputStream content = entity.getContent(); - BufferedReader reader = new BufferedReader( - new InputStreamReader(content)); - String line; - while ((line = reader.readLine()) != null) { - builder.append(line); - } - } else { - } -} catch (ClientProtocolException e) { - e.printStackTrace(); -} catch (IOException e) { - e.printStackTrace(); -} -return new JSONArray(builder.toString()); -} }