Fix for title when image is not available

This commit is contained in:
Raghul 2015-07-07 12:00:10 +08:00
parent d0022e053e
commit 9e09ad247b
3 changed files with 40 additions and 11 deletions

View File

@ -8,6 +8,7 @@ import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;
import de.danoeh.antennapod.R;
@ -20,8 +21,9 @@ import de.danoeh.antennapod.utils.TimeUtils;
public class SubscriptionViewItem extends RelativeLayout {
private ImageView mImageView;
private TextView mTitle;
private TextView mTextTime;
private TextView mUnreadCountText;
private TextView mFeedTitle;
private Context mContext;
public SubscriptionViewItem(Context context) {
@ -49,15 +51,28 @@ public class SubscriptionViewItem extends RelativeLayout {
LayoutInflater mLayoutInflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = mLayoutInflater.inflate(R.layout.subscription_view, this);
mTitle = (TextView) view.findViewById(R.id.txtvTitle);
mTextTime = (TextView) view.findViewById(R.id.txtvTime);
mFeedTitle = (TextView) view.findViewById(R.id.txtvTitle);
mImageView = (ImageView) view.findViewById(R.id.imgvCover);
mUnreadCountText = (TextView) view.findViewById(R.id.unread_count_text);
}
public void setFeed(Feed feed, int unreadCount) {
Picasso.with(mContext).load(feed.getImageUri()).centerCrop().fit().into(mImageView);
public void setFeed(final Feed feed, int unreadCount) {
mFeedTitle.setVisibility(VISIBLE);
mFeedTitle.setText(feed.getTitle());
Picasso.with(mContext).load(feed.getImageUri()).centerCrop().fit().into(mImageView, new Callback() {
@Override
public void onSuccess() {
mFeedTitle.setVisibility(GONE);
}
@Override
public void onError() {
}
});
mUnreadCountText.setText(unreadCount + "");
mTitle.setText(TimeUtils.getTimeAgo(feed.getLastUpdate().getTime(), mContext));
mTextTime.setText(TimeUtils.getTimeAgo(feed.getLastUpdate().getTime(), mContext));
}
}

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@ -10,28 +11,40 @@
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher" />
tools:src="@drawable/ic_launcher" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/cover_image_bg">
<TextView
android:id="@+id/txtvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="@dimen/minimum_text_margin"
android:ellipsize="end"
android:textColor="@color/overlay_dark"
android:textSize="15sp"
android:textStyle="bold"
tools:text="@string/app_name" />
</RelativeLayout>
<TextView
android:id="@+id/txtvTitle"
android:id="@+id/txtvTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="5dp"
android:layout_margin="@dimen/minimum_text_margin"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/app_name"
android:textColor="@color/white"
android:textSize="12sp" />
android:textSize="12sp"
tools:text="@string/app_name" />
<RelativeLayout
android:layout_width="18dp"
@ -48,7 +61,7 @@
android:layout_centerInParent="true"
android:ellipsize="end"
android:maxLines="1"
android:text="3"
android:text="0"
android:textColor="@color/white"
android:textSize="11sp" />

View File

@ -30,6 +30,7 @@
<dimen name="listitem_threeline_horizontalpadding">16dp</dimen>
<dimen name="list_vertical_padding">8dp</dimen>
<dimen name="minimum_text_margin">8dp</dimen>
<dimen name="listitem_icon_leftpadding">16dp</dimen>
<dimen name="listitem_icon_rightpadding">16dp</dimen>