From d465c6be9504934fe612dfca4ff50c5561e05755 Mon Sep 17 00:00:00 2001 From: Nayanesh Gupte Date: Tue, 19 Apr 2016 07:29:54 +0530 Subject: [PATCH] code improvement --- app/app.iml | 10 ++++-- .../adapter/IssuesListAdapter.java | 3 +- .../fragment/GitCommentsListFragment.java | 1 - .../fragment/GitIssuesListFragment.java | 34 ++++++++----------- 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/app/app.iml b/app/app.iml index e7d1ad8..5eef367 100644 --- a/app/app.iml +++ b/app/app.iml @@ -85,10 +85,16 @@ + + + + + + @@ -97,11 +103,11 @@ + - - + diff --git a/app/src/main/java/com/twittercrashlytics/adapter/IssuesListAdapter.java b/app/src/main/java/com/twittercrashlytics/adapter/IssuesListAdapter.java index e8e4204..0e3541d 100644 --- a/app/src/main/java/com/twittercrashlytics/adapter/IssuesListAdapter.java +++ b/app/src/main/java/com/twittercrashlytics/adapter/IssuesListAdapter.java @@ -50,8 +50,7 @@ public void add(List data) { @Override public IssuesViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = inflater.inflate(R.layout.row_issues, parent, false); - IssuesViewHolder holder = new IssuesViewHolder(view); - return holder; + return new IssuesViewHolder(view); } @Override diff --git a/app/src/main/java/com/twittercrashlytics/fragment/GitCommentsListFragment.java b/app/src/main/java/com/twittercrashlytics/fragment/GitCommentsListFragment.java index c9c5426..48feb1d 100644 --- a/app/src/main/java/com/twittercrashlytics/fragment/GitCommentsListFragment.java +++ b/app/src/main/java/com/twittercrashlytics/fragment/GitCommentsListFragment.java @@ -125,7 +125,6 @@ public void onDetach() { @Override public void onDataReceived(List listIssues) { - progressBar.setVisibility(View.GONE); commentsListAdapter.add(listIssues); progressBar.setVisibility(View.GONE); diff --git a/app/src/main/java/com/twittercrashlytics/fragment/GitIssuesListFragment.java b/app/src/main/java/com/twittercrashlytics/fragment/GitIssuesListFragment.java index c945034..927a13b 100644 --- a/app/src/main/java/com/twittercrashlytics/fragment/GitIssuesListFragment.java +++ b/app/src/main/java/com/twittercrashlytics/fragment/GitIssuesListFragment.java @@ -30,7 +30,7 @@ /** * Fragment holding list of issues. */ -public class GitIssuesListFragment extends Fragment implements IAppConstants, OnItemClickListener { +public class GitIssuesListFragment extends Fragment implements IAppConstants, OnItemClickListener, Response.Listener { private static final String TAG = GitIssuesListFragment.class.getSimpleName(); @@ -92,7 +92,7 @@ private void getIssuesList() { GsonRequest myReq = new GsonRequest(BASE_URL, Issue[].class, null, - createMyReqSuccessListener(), + this, createMyReqErrorListener()); TwitterCrashlyticsApplication.getInstance().addToRequestQueue(myReq, TAG); @@ -107,24 +107,6 @@ private void getIssuesList() { } - private Response.Listener createMyReqSuccessListener() { - return new Response.Listener() { - @Override - public void onResponse(Issue[] response) { - - List listIssues = Arrays.asList(response); - - Collections.sort(listIssues, new DateComparator()); - - issuesListAdapter.add(listIssues); - - - progressBar.setVisibility(View.GONE); - - } - - }; - } private Response.ErrorListener createMyReqErrorListener() { return new Response.ErrorListener() { @@ -161,4 +143,16 @@ public void onDetach() { } + @Override + public void onResponse(Issue[] response) { + + List listIssues = Arrays.asList(response); + + Collections.sort(listIssues, new DateComparator()); + + issuesListAdapter.add(listIssues); + + + progressBar.setVisibility(View.GONE); + } }