From a13174ac4d022db68c7522a9cc35c99b97c96a63 Mon Sep 17 00:00:00 2001 From: jendib Date: Wed, 11 May 2016 00:55:27 +0200 Subject: [PATCH] Android: use GET /tag/list instead of /tag/stats --- .../java/com/sismics/docs/activity/MainActivity.java | 6 +++--- .../com/sismics/docs/adapter/TagListAdapter.java | 8 ++------ .../java/com/sismics/docs/resource/TagResource.java | 6 +++--- .../app/src/main/res/layout/tag_list_item.xml | 12 ------------ 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/docs-android/app/src/main/java/com/sismics/docs/activity/MainActivity.java b/docs-android/app/src/main/java/com/sismics/docs/activity/MainActivity.java index e0db2430..0da860a8 100644 --- a/docs-android/app/src/main/java/com/sismics/docs/activity/MainActivity.java +++ b/docs-android/app/src/main/java/com/sismics/docs/activity/MainActivity.java @@ -87,13 +87,13 @@ public class MainActivity extends AppCompatActivity { tagListView.setEmptyView(tagProgressView); JSONObject cacheTags = PreferenceUtil.getCachedJson(this, PreferenceUtil.PREF_CACHED_TAGS_JSON); if (cacheTags != null) { - tagListView.setAdapter(new TagListAdapter(cacheTags.optJSONArray("stats"))); + tagListView.setAdapter(new TagListAdapter(cacheTags.optJSONArray("tags"))); } - TagResource.stats(this, new HttpCallback() { + TagResource.list(this, new HttpCallback() { @Override public void onSuccess(JSONObject response) { PreferenceUtil.setCachedJson(MainActivity.this, PreferenceUtil.PREF_CACHED_TAGS_JSON, response); - tagListView.setAdapter(new TagListAdapter(response.optJSONArray("stats"))); + tagListView.setAdapter(new TagListAdapter(response.optJSONArray("tags"))); tagProgressView.setVisibility(View.GONE); tagListView.setEmptyView(tagEmptyView); } diff --git a/docs-android/app/src/main/java/com/sismics/docs/adapter/TagListAdapter.java b/docs-android/app/src/main/java/com/sismics/docs/adapter/TagListAdapter.java index f921a804..213bd59d 100644 --- a/docs-android/app/src/main/java/com/sismics/docs/adapter/TagListAdapter.java +++ b/docs-android/app/src/main/java/com/sismics/docs/adapter/TagListAdapter.java @@ -46,7 +46,7 @@ public class TagListAdapter extends BaseAdapter { // Reorder tags by parent/child relation and compute depth int depth = 0; - initTags(tags, JSONObject.NULL.toString(), depth); + initTags(tags, "", depth); } /** @@ -60,11 +60,10 @@ public class TagListAdapter extends BaseAdapter { // Get all tags with this parent for (JSONObject tag : tags) { String tagParentId = tag.optString("parent"); - if (tagParentId.equals(parentId)) { + if (parentId.equals(tagParentId)) { TagItem tagItem = new TagItem(); tagItem.id = tag.optString("id"); tagItem.name = tag.optString("name"); - tagItem.count = tag.optInt("count"); tagItem.color = tag.optString("color"); tagItem.depth = depth; tagItemList.add(tagItem); @@ -99,8 +98,6 @@ public class TagListAdapter extends BaseAdapter { TagItem tagItem = getItem(position); TextView tagTextView = (TextView) view.findViewById(R.id.tagTextView); tagTextView.setText(tagItem.name); - TextView tagCountTextView = (TextView) view.findViewById(R.id.tagCountTextView); - tagCountTextView.setText(String.format(Locale.ENGLISH, "%d", tagItem.count)); // Label color filtering ImageView labelImageView = (ImageView) view.findViewById(R.id.labelImageView); @@ -125,7 +122,6 @@ public class TagListAdapter extends BaseAdapter { public static class TagItem { private String id; private String name; - private int count; private String color; private int depth; diff --git a/docs-android/app/src/main/java/com/sismics/docs/resource/TagResource.java b/docs-android/app/src/main/java/com/sismics/docs/resource/TagResource.java index 34539d14..f7c17ec4 100644 --- a/docs-android/app/src/main/java/com/sismics/docs/resource/TagResource.java +++ b/docs-android/app/src/main/java/com/sismics/docs/resource/TagResource.java @@ -16,14 +16,14 @@ import okhttp3.Request; */ public class TagResource extends BaseResource { /** - * GET /tag/stats. + * GET /tag/list. * * @param context Context * @param callback Callback */ - public static void stats(Context context, HttpCallback callback) { + public static void list(Context context, HttpCallback callback) { Request request = new Request.Builder() - .url(HttpUrl.parse(getApiUrl(context) + "/tag/stats")) + .url(HttpUrl.parse(getApiUrl(context) + "/tag/list")) .get() .build(); OkHttpUtil.buildClient(context) diff --git a/docs-android/app/src/main/res/layout/tag_list_item.xml b/docs-android/app/src/main/res/layout/tag_list_item.xml index 2724a7b7..f238f1fb 100644 --- a/docs-android/app/src/main/res/layout/tag_list_item.xml +++ b/docs-android/app/src/main/res/layout/tag_list_item.xml @@ -28,17 +28,5 @@ android:textColor="#212121" android:text="Appartement" android:textSize="14sp"/> - - \ No newline at end of file