From 071f2e2f5030660715432d29b9461774f205f836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20P=C3=B3=C5=82grabia?= Date: Fri, 21 Oct 2016 22:07:04 +0200 Subject: [PATCH] Panoramio styles improved --- .../fragments/PanoramioAdapter.java | 22 ++++++++- app/src/main/res/layout/google_place_item.xml | 2 +- app/src/main/res/layout/location_item.xml | 48 ++++++++++++++++--- .../main/res/layout/wiki_locations_item.xml | 9 +++- 4 files changed, 71 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/PanoramioAdapter.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/PanoramioAdapter.java index 1ebec5f..c6517d9 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/PanoramioAdapter.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/PanoramioAdapter.java @@ -22,6 +22,8 @@ import java.util.List; * Created by tpolgrabia on 27.08.16. */ public class PanoramioAdapter extends ArrayAdapter { + public static final int MAX_OWNERNAME_LENGTH = 10; + public static final int MAX_PANORAMIO_DESCRIPTION_LENGTH = 96; private final AQuery aq; public PanoramioAdapter(FragmentActivity activity, int location_item, List photosDescriptions) { @@ -43,11 +45,29 @@ public class PanoramioAdapter extends ArrayAdapter { TextView locDesc = (TextView) itemView.findViewById(R.id.location_description); itemView.setTag(item.getPhotoId()); - locDesc.setText(item.getPhotoTitle()); + final String description = item.getPhotoTitle(); + final String trimmedDescription = + description != null && description.length() > MAX_PANORAMIO_DESCRIPTION_LENGTH + ? description.substring(0, MAX_PANORAMIO_DESCRIPTION_LENGTH) + "..." + : description; + locDesc.setText(trimmedDescription); final String photoUrl = item.getPhotoFileUrl(); ImageView photoImg = (ImageView) itemView.findViewById(R.id.photo_img); photoImg.setImageBitmap(BitmapFactory.decodeResource(getContext().getResources(), R.drawable.noimage)); ImageLoader.getInstance().displayImage(photoUrl, photoImg, MainActivity.options); + + + TextView authorWidget = (TextView) itemView.findViewById(R.id.location_author); + final String ownerName = item.getOwnerName(); + final String trimmedOwnerName = + ownerName != null && ownerName.length() > MAX_OWNERNAME_LENGTH + ? ownerName.substring(0, MAX_OWNERNAME_LENGTH) + "..." + : ownerName; + authorWidget.setText(trimmedOwnerName); + + TextView uploadDateWidget = (TextView) itemView.findViewById(R.id.location_upload_date); + uploadDateWidget.setText(item.getUploadDate()); + return itemView; } } \ No newline at end of file diff --git a/app/src/main/res/layout/google_place_item.xml b/app/src/main/res/layout/google_place_item.xml index 702960e..11d6437 100644 --- a/app/src/main/res/layout/google_place_item.xml +++ b/app/src/main/res/layout/google_place_item.xml @@ -22,7 +22,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/test_string"/> - +w + android:layout_height="wrap_content" + android:padding="10dp"> - + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/wiki_locations_item.xml b/app/src/main/res/layout/wiki_locations_item.xml index c8fd848..e8b741b 100644 --- a/app/src/main/res/layout/wiki_locations_item.xml +++ b/app/src/main/res/layout/wiki_locations_item.xml @@ -7,7 +7,7 @@ @@ -29,9 +29,14 @@ android:layout_height="wrap_content" android:text="@string/wiki_location_fill_title"/> + +