diff options
| author | campbeb <bpcampbell@gmail.com> | 2013-05-08 23:59:41 -1000 |
|---|---|---|
| committer | campbeb <bpcampbell@gmail.com> | 2013-05-09 00:14:20 -1000 |
| commit | ac558f3d7e5cc96a1c97d35430a676debbe1ff90 (patch) | |
| tree | 6162c2d58c6737c00576205cd56d02bea79ac80e /main | |
| parent | 4b95081918b795575808a5be62655b82e7ca9750 (diff) | |
| download | cgeo-ac558f3d7e5cc96a1c97d35430a676debbe1ff90.zip cgeo-ac558f3d7e5cc96a1c97d35430a676debbe1ff90.tar.gz cgeo-ac558f3d7e5cc96a1c97d35430a676debbe1ff90.tar.bz2 | |
Fix #2685 - Don't add images each time log entry is drawn on screen
TextView with images was being added to the view each time the log
entry was drawn. Instead of inflating and adding the TextView, we
now use on that is arleady there and hide it if there are no images.
Diffstat (limited to 'main')
| -rw-r--r-- | main/res/layout/trackable_logs_img.xml | 16 | ||||
| -rw-r--r-- | main/res/layout/trackable_logs_item.xml | 16 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/TrackableActivity.java | 35 |
3 files changed, 28 insertions, 39 deletions
diff --git a/main/res/layout/trackable_logs_img.xml b/main/res/layout/trackable_logs_img.xml deleted file mode 100644 index aaed32b..0000000 --- a/main/res/layout/trackable_logs_img.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <TextView - android:id="@+id/title" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="left|top" - android:drawableLeft="?log_img_icon" - android:drawablePadding="3dip" - android:textColor="?text_color" - android:textSize="14dip" /> - -</LinearLayout>
\ No newline at end of file diff --git a/main/res/layout/trackable_logs_item.xml b/main/res/layout/trackable_logs_item.xml index 52a38a9..65f3e16 100644 --- a/main/res/layout/trackable_logs_item.xml +++ b/main/res/layout/trackable_logs_item.xml @@ -20,6 +20,7 @@ android:textSize="18dip" /> <LinearLayout + android:id="@+id/detail_box" android:layout_width="102dip" android:layout_height="wrap_content" android:layout_alignParentLeft="true" @@ -92,7 +93,7 @@ android:layout_marginLeft="102dip" android:orientation="vertical" android:padding="3dip" - android:textSize="14dip" > + android:textSize="14sp" > <TextView android:id="@+id/log" @@ -104,7 +105,18 @@ android:gravity="left" android:padding="3dip" android:textColor="?text_color" - android:textSize="14dip" /> + android:textSize="14sp" /> + + <TextView + android:id="@+id/log_images" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="left|top" + android:layout_marginTop="3dip" + android:drawableLeft="?log_img_icon" + android:drawablePadding="3dip" + android:textColor="?text_color" + android:textSize="14sp" /> </LinearLayout> </RelativeLayout>
\ No newline at end of file diff --git a/main/src/cgeo/geocaching/TrackableActivity.java b/main/src/cgeo/geocaching/TrackableActivity.java index e5468f3..9b3dbfc 100644 --- a/main/src/cgeo/geocaching/TrackableActivity.java +++ b/main/src/cgeo/geocaching/TrackableActivity.java @@ -390,18 +390,18 @@ public class TrackableActivity extends AbstractViewPagerActivity<TrackableActivi private final TextView type; private final TextView author; private final TextView location; - private final TextView log; + private final TextView text; + private final TextView images; private final ImageView marker; - private final LinearLayout logImages; public LogViewHolder(View rowView) { added = ((TextView) rowView.findViewById(R.id.added)); type = ((TextView) rowView.findViewById(R.id.type)); author = ((TextView) rowView.findViewById(R.id.author)); location = ((TextView) rowView.findViewById(R.id.location)); - log = (TextView) rowView.findViewById(R.id.log); + text = (TextView) rowView.findViewById(R.id.log); + images = (TextView) rowView.findViewById(R.id.log_images); marker = (ImageView) rowView.findViewById(R.id.log_mark); - logImages = (LinearLayout) rowView.findViewById(R.id.log_layout); } } @@ -432,7 +432,7 @@ public class TrackableActivity extends AbstractViewPagerActivity<TrackableActivi return view; } - protected void fillViewHolder(LogViewHolder holder, LogEntry log) { + protected void fillViewHolder(LogViewHolder holder, final LogEntry log) { if (log.date > 0) { holder.added.setText(Formatter.formatShortDate(log.date)); } @@ -454,7 +454,7 @@ public class TrackableActivity extends AbstractViewPagerActivity<TrackableActivi }); } - TextView logView = holder.log; + TextView logView = holder.text; logView.setMovementMethod(LinkMovementMethod.getInstance()); String logText = log.log; @@ -477,25 +477,18 @@ public class TrackableActivity extends AbstractViewPagerActivity<TrackableActivi statusMarker.setVisibility(View.GONE); } - // add LogImages - LinearLayout logLayout = holder.logImages; - + // images if (log.hasLogImages()) { - - final ArrayList<Image> logImages = new ArrayList<Image>(log.getLogImages()); - - final View.OnClickListener listener = new View.OnClickListener() { + holder.images.setText(log.getImageTitles()); + holder.images.setVisibility(View.VISIBLE); + holder.images.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - ImagesActivity.startActivityLogImages(TrackableActivity.this, trackable.getGeocode(), logImages); + ImagesActivity.startActivityLogImages(TrackableActivity.this, trackable.getGeocode(), new ArrayList<Image>(log.getLogImages())); } - }; - - LinearLayout log_imgView = (LinearLayout) getLayoutInflater().inflate(R.layout.trackable_logs_img, null); - TextView log_img_title = (TextView) log_imgView.findViewById(R.id.title); - log_img_title.setText(log.getImageTitles()); - log_img_title.setOnClickListener(listener); - logLayout.addView(log_imgView); + }); + } else { + holder.images.setVisibility(View.GONE); } holder.author.setOnClickListener(new UserActionsListener()); |
