Improve marker list view layout

This commit is contained in:
Jimmy Shih
2013-10-30 14:29:40 -07:00
parent 261327ed4a
commit 7354b5a438
5 changed files with 56 additions and 23 deletions
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="90"
android:endColor="@android:color/black"
android:startColor="@android:color/white" />
</shape>
+11 -2
View File
@@ -17,15 +17,24 @@ limitations under the License.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent" >
<!-- Photo -->
<ImageView
android:contentDescription="@string/icon_marker"
android:id="@+id/list_item_background"
android:id="@+id/list_item_photo"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:scaleType="centerCrop" />
<!-- A gradient on top of the photo -->
<ImageView
android:alpha=".6"
android:contentDescription="@string/icon_marker"
android:id="@+id/list_item_photo_gradient"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:src="@drawable/photo_gradient" />
<!-- Table 1 -->
<TableLayout
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingBottom="12dp"
@@ -183,14 +183,13 @@ public class MarkerListActivity extends AbstractMyTracksActivity implements Dele
int iconId = statistics ? R.drawable.ic_marker_yellow_pushpin
: R.drawable.ic_marker_blue_pushpin;
String name = cursor.getString(nameIndex);
String sharedOwner = track.getSharedOwner();
long time = cursor.getLong(timeIndex);
String category = statistics ? null : cursor.getString(categoryIndex);
String description = statistics ? null : cursor.getString(descriptionIndex);
String photoUrl = cursor.getString(photoUrlIndex);
ListItemUtils.setListItem(MarkerListActivity.this, view, false, true, iconId,
R.string.icon_marker, name, sharedOwner, null, null, 0, time, category, description,
R.string.icon_marker, name, null, null, null, 0, time, category, description,
photoUrl);
}
};
@@ -475,13 +475,11 @@ public class SearchListActivity extends AbstractSendToGoogleActivity implements
* the retrieval phase of the search.
*/
String trackName = null;
String sharedOwner = null;
long trackId = waypoint.getTrackId();
if (trackId != -1L) {
Track track = myTracksProviderUtils.getTrack(trackId);
if (track != null) {
trackName = track.getName();
sharedOwner = track.getSharedOwner();
}
}
@@ -493,7 +491,7 @@ public class SearchListActivity extends AbstractSendToGoogleActivity implements
statistics ? R.drawable.ic_marker_yellow_pushpin : R.drawable.ic_marker_blue_pushpin);
resultMap.put(ICON_CONTENT_DESCRIPTION_ID_FIELD, R.string.icon_marker);
resultMap.put(NAME_FIELD, waypoint.getName());
resultMap.put(SHARED_OWNER_FIELD, sharedOwner);
resultMap.put(SHARED_OWNER_FIELD, null);
// Display the marker's track name in the total time field
resultMap.put(TOTAL_TIME_FIELD, trackName == null ? null
: getString(R.string.search_list_marker_track_location, trackName));
@@ -91,7 +91,7 @@ public class ListItemUtils {
ownerTimeDistance = activity.getString(
isPaused ? R.string.generic_paused : R.string.generic_recording);
} else {
// Need to match the style set in list_item.xml
// Match list_item_owner_time_distance in list_item.xml
ownerTimeDistanceTextView.setTextAppearance(activity, R.style.TextSmall);
ownerTimeDistance = getOwnerTimeDistance(sharedOwner, totalTime, totalDistance);
if (markerCount > 0) {
@@ -99,7 +99,7 @@ public class ListItemUtils {
}
}
setTextView(ownerTimeDistanceTextView, ownerTimeDistance);
// Set markerCount
ImageView markerCountIcon = (ImageView) view.findViewById(R.id.list_item_marker_count_icon);
TextView markerCountTextView = (TextView) view.findViewById(R.id.list_item_marker_count);
@@ -126,26 +126,31 @@ public class ListItemUtils {
TextView timeTextView = (TextView) view.findViewById(R.id.list_item_time);
setTextView(timeTextView, dateTime[1]);
/*
* If column0 is GONE, change to INVISIBLE so column1 is placed at the
* correct position.
*/
if (timeTextView.getVisibility() == View.VISIBLE
&& ownerTimeDistanceTextView.getVisibility() == View.GONE) {
ownerTimeDistanceTextView.setVisibility(View.INVISIBLE);
// Set category and description
TextView categoryDescriptionTextView = (TextView) view.findViewById(
R.id.list_item_category_description);
String categoryDescription = isRecording ? null
: StringUtils.getCategoryDescription(category, description);
if (sharedOwner == null && totalTime == null && totalDistance == null && markerCount == 0) {
setTextView(categoryDescriptionTextView, null);
// Match list_item_category_description in list_item.xml
ownerTimeDistanceTextView.setSingleLine(false);
ownerTimeDistanceTextView.setMaxLines(2);
setTextView(ownerTimeDistanceTextView, categoryDescription);
} else {
// Match list_item_owner_time_distance in list_item.xml
ownerTimeDistanceTextView.setSingleLine(true);
setTextView(categoryDescriptionTextView, categoryDescription);
}
// Set category and description
TextView categoryDescription = (TextView) view.findViewById(
R.id.list_item_category_description);
setTextView(categoryDescription,
isRecording ? null : StringUtils.getCategoryDescription(category, description));
ImageView photo = (ImageView) view.findViewById(R.id.list_item_background);
ImageView photo = (ImageView) view.findViewById(R.id.list_item_photo);
ImageView photoGradient = (ImageView) view.findViewById(R.id.list_item_photo_gradient);
if (photoUrl == null || photoUrl.equals("")) {
photo.setVisibility(View.GONE);
photoGradient.setVisibility(View.GONE);
} else {
photo.setVisibility(View.VISIBLE);
photoGradient.setVisibility(View.VISIBLE);
Display defaultDisplay = activity.getWindowManager().getDefaultDisplay();
PhotoUtils.setImageVew(
photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), getPhotoHeight(activity), false);