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<PanoramioImageInfo> { + 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<PanoramioImageInfo> photosDescriptions) { @@ -43,11 +45,29 @@ public class PanoramioAdapter extends ArrayAdapter<PanoramioImageInfo> { 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 <TextView android:id="@+id/place_rate" android:layout_width="wrap_content" android:layout_height="wrap_content" diff --git a/app/src/main/res/layout/location_item.xml b/app/src/main/res/layout/location_item.xml index ab61f64..148b77a 100644 --- a/app/src/main/res/layout/location_item.xml +++ b/app/src/main/res/layout/location_item.xml @@ -2,7 +2,8 @@ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" - android:layout_height="wrap_content"> + android:layout_height="wrap_content" + android:padding="10dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" @@ -18,11 +19,46 @@ android:layout_height="80dp" android:layout_marginRight="10dp"/> - <TextView - android:id="@+id/location_description" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/test_string"/> + <LinearLayout android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <TextView + android:id="@+id/location_description" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/test_string"/> + + <Space android:layout_width="0dp" + android:layout_height="0dp" + android:layout_weight="1" /> + + <LinearLayout android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + + <TextView + android:id="@+id/location_author" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/test_string"/> + + <Space android:layout_width="0dp" + android:layout_height="0dp" + android:layout_weight="1" /> + + <TextView + android:id="@+id/location_upload_date" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="right" + android:text="@string/test_string"/> + + </LinearLayout> + + </LinearLayout> + + </LinearLayout> </FrameLayout> \ 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 @@ <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" - android:layout_height="match_parent" + android:layout_height="wrap_content" android:layout_marginLeft="8dp" android:layout_marginTop="8dp" android:layout_marginRight="8dp" @@ -20,7 +20,7 @@ <LinearLayout android:id="@+id/wiki_locs_item_desc_container" android:layout_width="0dp" - android:layout_height="wrap_content" + android:layout_height="match_parent" android:layout_weight="1" android:orientation="vertical"> @@ -29,9 +29,14 @@ android:layout_height="wrap_content" android:text="@string/wiki_location_fill_title"/> + <Space android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1"/> + <TextView android:id="@+id/wiki_locs_item_distance" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_gravity="left" android:text="@string/wiki_location_fill_distance"/>