UI refactoring of "simple" (default) list view
This commit is contained in:
parent
0e5eba6d86
commit
29ea6659ec
11 changed files with 169 additions and 76 deletions
|
@ -111,7 +111,7 @@ dependencies {
|
|||
implementation "com.android.support:customtabs:${SUPPORT_VERSION}"
|
||||
implementation "com.android.support:cardview-v7:${SUPPORT_VERSION}"
|
||||
implementation 'de.mrmaffen:holocircularprogressbar:1.0.1'
|
||||
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
|
||||
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
implementation 'com.jakewharton:butterknife:8.8.1'
|
||||
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
|
||||
|
|
|
@ -16,8 +16,7 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration {
|
|||
private int size = 0;
|
||||
|
||||
public DividerItemDecoration(Context context) {
|
||||
final TypedArray a = context
|
||||
.obtainStyledAttributes(new int[]{android.R.attr.listDivider});
|
||||
final TypedArray a = context.obtainStyledAttributes(new int[]{android.R.attr.listDivider});
|
||||
mDivider = a.getDrawable(0);
|
||||
a.recycle();
|
||||
if(mDivider != null)
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
package de.luhmer.owncloudnewsreader.adapter;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
|
||||
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
import android.text.Spannable;
|
||||
|
@ -18,14 +23,25 @@ import android.util.SparseArray;
|
|||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.assist.LoadedFrom;
|
||||
import com.nostra13.universalimageloader.core.display.BitmapDisplayer;
|
||||
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
|
||||
import com.nostra13.universalimageloader.core.imageaware.ImageAware;
|
||||
import com.nostra13.universalimageloader.core.process.BitmapProcessor;
|
||||
import com.pascalwelsch.holocircularprogressbar.HoloCircularProgressBar;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
|
@ -34,8 +50,11 @@ import de.luhmer.owncloudnewsreader.async_tasks.RssItemToHtmlTask;
|
|||
import de.luhmer.owncloudnewsreader.database.model.RssItem;
|
||||
import de.luhmer.owncloudnewsreader.helper.ColorHelper;
|
||||
import de.luhmer.owncloudnewsreader.helper.FavIconHandler;
|
||||
import de.luhmer.owncloudnewsreader.helper.ImageHandler;
|
||||
import de.luhmer.owncloudnewsreader.services.PodcastDownloadService;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||
private final static String TAG = "RecyclerView.ViewHolder";
|
||||
|
||||
|
@ -54,9 +73,16 @@ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL
|
|||
@BindView(R.id.tv_subscription)
|
||||
protected TextView textViewTitle;
|
||||
|
||||
@Nullable
|
||||
@BindView(R.id.imgViewFavIcon)
|
||||
protected ImageView imgViewFavIcon;
|
||||
|
||||
@Nullable
|
||||
@BindView(R.id.imgViewThumbnail)
|
||||
protected ImageView imgViewThumbnail;
|
||||
|
||||
|
||||
@Nullable
|
||||
@BindView(R.id.color_line_feed)
|
||||
protected View colorLineFeed;
|
||||
|
||||
|
@ -64,7 +90,8 @@ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL
|
|||
protected ImageView btnPlayPausePodcast;
|
||||
|
||||
@BindView(R.id.podcastDownloadProgress)
|
||||
protected HoloCircularProgressBar pbPodcastDownloadProgress;
|
||||
//protected HoloCircularProgressBar pbPodcastDownloadProgress; // TODO reminder: remove this dependency (and fix podcast progressbar issues)
|
||||
protected ProgressBar pbPodcastDownloadProgress;
|
||||
|
||||
@BindView(R.id.podcast_wrapper)
|
||||
View flPlayPausePodcastWrapper;
|
||||
|
@ -87,6 +114,7 @@ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL
|
|||
private int selectedListLayout;
|
||||
private int starColor;
|
||||
private int inactiveStarColor;
|
||||
private DisplayImageOptions displayImageOptionsThumbnail;
|
||||
|
||||
public ViewHolder(View itemView, int titleLineCount) {
|
||||
super(itemView);
|
||||
|
@ -110,13 +138,23 @@ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL
|
|||
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
|
||||
|
||||
displayImageOptionsThumbnail = new DisplayImageOptions.Builder()
|
||||
.displayer(new RoundedBitmapDisplayer(30))
|
||||
//.showImageOnLoading(placeHolder)
|
||||
//.showImageForEmptyUri(placeHolder)
|
||||
//.showImageOnFail(placeHolder)
|
||||
.cacheOnDisk(true)
|
||||
.cacheInMemory(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onEvent(PodcastDownloadService.DownloadProgressUpdate downloadProgress) {
|
||||
downloadProgressList.put((int) downloadProgress.podcast.itemId, downloadProgress.podcast.downloadProgress);
|
||||
if (rssItem.getId().equals(downloadProgress.podcast.itemId)) {
|
||||
pbPodcastDownloadProgress.setProgress(downloadProgress.podcast.downloadProgress / 100f);
|
||||
pbPodcastDownloadProgress.setProgress((int) (downloadProgress.podcast.downloadProgress / 100f));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,7 +169,7 @@ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL
|
|||
progress = 0;
|
||||
}
|
||||
}
|
||||
pbPodcastDownloadProgress.setProgress(progress);
|
||||
pbPodcastDownloadProgress.setProgress((int) progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -148,8 +186,10 @@ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL
|
|||
return clickListener.onLongClick(this, getLayoutPosition());
|
||||
}
|
||||
|
||||
public void setFeedColor(int color) {
|
||||
colorLineFeed.setBackgroundColor(color);
|
||||
private void setFeedColor(int color) {
|
||||
if(colorLineFeed != null) {
|
||||
colorLineFeed.setBackgroundColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
public void setReadState(boolean isRead) {
|
||||
|
@ -238,11 +278,24 @@ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL
|
|||
textViewBody.setText(Html.fromHtml(body));
|
||||
}
|
||||
|
||||
if(textViewItemDate != null)
|
||||
if(textViewItemDate != null) {
|
||||
textViewItemDate.setText(DateUtils.getRelativeTimeSpanString(rssItem.getPubDate().getTime()));
|
||||
}
|
||||
|
||||
if (imgViewFavIcon != null)
|
||||
if (imgViewFavIcon != null) {
|
||||
favIconHandler.loadFavIconForFeed(favIconUrl, imgViewFavIcon);
|
||||
}
|
||||
|
||||
if(imgViewThumbnail != null) {
|
||||
String body = rssItem.getBody();
|
||||
List<String> images = ImageHandler.getImageLinksFromText(body);
|
||||
|
||||
if(images.size() > 0) {
|
||||
ImageLoader.getInstance().displayImage(images.get(0), imgViewThumbnail, displayImageOptionsThumbnail);
|
||||
} else {
|
||||
imgViewThumbnail.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if(webView_body != null) {
|
||||
String htmlPage = RssItemToHtmlTask.getHtmlPage(itemView.getContext(), rssItem, false);
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/>
|
||||
</vector>
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M22,9.24l-7.19,-0.62L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21 12,17.27 18.18,21l-1.63,-7.03L22,9.24zM12,15.4l-3.76,2.27 1,-4.28 -3.32,-2.88 4.38,-0.38L12,6.1l1.71,4.04 4.38,0.38 -3.32,2.88 1,4.28L12,15.4z"/>
|
||||
</vector>
|
|
@ -2,7 +2,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:showIn="@layout/activity_news_detail">
|
||||
tools:showIn="@layout/activity_newsreader">
|
||||
|
||||
<android.support.v4.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeRefresh"
|
||||
|
@ -11,6 +11,8 @@
|
|||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
android:paddingStart="@dimen/listview_row_margin_left"
|
||||
android:paddingEnd="@dimen/listview_row_margin_right"
|
||||
style="?android:attr/textAppearanceLarge"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -18,6 +18,15 @@
|
|||
android:contentDescription="@string/content_desc_pause"
|
||||
android:src="@drawable/ic_action_pause" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/podcastDownloadProgress"
|
||||
android:indeterminateTintMode="src_atop"
|
||||
android:indeterminateTint="@color/colorPrimaryDarkDarkTheme"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<!--
|
||||
<com.pascalwelsch.holocircularprogressbar.HoloCircularProgressBar
|
||||
android:id="@+id/podcastDownloadProgress"
|
||||
android:layout_width="30dp"
|
||||
|
@ -29,5 +38,6 @@
|
|||
app:marker_visible="false"
|
||||
app:thumb_visible="false"
|
||||
android:layout_gravity="center" />
|
||||
-->
|
||||
|
||||
</FrameLayout>
|
|
@ -1,59 +1,41 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<!--
|
||||
<View
|
||||
android:id="@+id/color_line_feed"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="4dp"
|
||||
android:background="?attr/dividerLineColor"
|
||||
android:layout_marginEnd="@dimen/listview_row_margin_left"
|
||||
android:layout_marginRight="@dimen/listview_row_margin_left"/>
|
||||
android:layout_marginEnd="@dimen/listview_row_margin_left" />
|
||||
-->
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:layout_marginTop="@dimen/listview_row_margin_top"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="@dimen/listview_row_margin_bottom"
|
||||
android:id="@+id/list_item_header">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="start"
|
||||
android:textAlignment="viewStart"
|
||||
android:ellipsize="end"
|
||||
android:lines="2"
|
||||
android:textSize="17sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="Summary Text\nSecond Line"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:minLines="2"
|
||||
android:maxLines="2"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toLeftOf="@+id/podcast_wrapper"
|
||||
android:layout_toStartOf="@+id/podcast_wrapper"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgViewFavIcon"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_below="@+id/summary"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginEnd="8dp"
|
||||
tools:src="@drawable/default_feed_icon_light"
|
||||
android:layout_marginTop="2dp"
|
||||
android:contentDescription="@string/content_desc_none"/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_subscription"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -63,12 +45,48 @@
|
|||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textSize="13sp"
|
||||
tools:text="PortableApps.com"
|
||||
android:layout_below="@+id/summary"
|
||||
android:layout_toStartOf="@+id/tv_item_date"
|
||||
android:layout_toEndOf="@+id/imgViewFavIcon"
|
||||
android:layout_toLeftOf="@+id/tv_item_date"
|
||||
android:layout_toRightOf="@+id/imgViewFavIcon"/>
|
||||
android:layout_toStartOf="@id/imgViewThumbnail"
|
||||
tools:text="PortableApps.com and some other long name behind here!"/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="start"
|
||||
android:textAlignment="viewStart"
|
||||
android:ellipsize="end"
|
||||
android:textSize="17sp"
|
||||
android:textStyle="bold"
|
||||
android:lines="3"
|
||||
android:minLines="3"
|
||||
android:maxLines="3"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_below="@id/tv_subscription"
|
||||
android:layout_toStartOf="@+id/imgViewThumbnail"
|
||||
tools:text="Summary Text\nSecond\nthird\nfourth"/>
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgViewThumbnail"
|
||||
android:layout_width="88dp"
|
||||
android:layout_height="88dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:contentDescription="@string/img_view_thumbnail"
|
||||
android:scaleType="centerCrop"
|
||||
tools:src="@drawable/default_feed_icon_dark"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_item_date"
|
||||
|
@ -78,41 +96,32 @@
|
|||
android:singleLine="true"
|
||||
android:textSize="13sp"
|
||||
tools:text="vor 13 Stunden"
|
||||
android:layout_marginEnd="@dimen/listview_row_margin_right"
|
||||
android:layout_marginRight="@dimen/listview_row_margin_right"
|
||||
android:layout_toStartOf="@+id/podcast_wrapper"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_toLeftOf="@+id/podcast_wrapper"
|
||||
android:layout_alignBaseline="@id/tv_subscription"/>
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@id/imgViewThumbnail" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/star_imageview"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="15dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="@dimen/listview_row_margin_right"
|
||||
android:paddingRight="@dimen/listview_row_margin_right"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@drawable/ic_action_star_dark"
|
||||
android:tint="?attr/starredColor"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:contentDescription="@string/content_desc_add_to_favorites"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/podcast_wrapper"
|
||||
layout="@layout/subscription_detail_list_item_podcast_wrapper"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginTop="-4dp"
|
||||
android:id="@+id/podcast_wrapper"
|
||||
android:layout_toLeftOf="@id/star_imageview"
|
||||
android:layout_toStartOf="@id/star_imageview"/>
|
||||
android:layout_toStartOf="@id/star_imageview"
|
||||
android:layout_below="@id/imgViewThumbnail"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/star_imageview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="15dp"
|
||||
android:paddingStart="8dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
app:srcCompat="@drawable/ic_star_black_24dp"
|
||||
android:tint="?attr/starredColor"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_below="@id/imgViewThumbnail"
|
||||
android:contentDescription="@string/content_desc_add_to_favorites"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -4,10 +4,10 @@
|
|||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
|
||||
<dimen name="listview_row_margin_left">10dp</dimen>
|
||||
<dimen name="listview_row_margin_right">10dp</dimen>
|
||||
<dimen name="listview_row_margin_top">5dp</dimen>
|
||||
<dimen name="listview_row_margin_bottom">5dp</dimen>
|
||||
<dimen name="listview_row_margin_left">16dp</dimen>
|
||||
<dimen name="listview_row_margin_right">16dp</dimen>
|
||||
<dimen name="listview_row_margin_top">8dp</dimen>
|
||||
<dimen name="listview_row_margin_bottom">8dp</dimen>
|
||||
|
||||
<dimen name="exp_listview_row_height">48dp</dimen>
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
<string name="menu_StartImageCaching">Download images</string>
|
||||
<string name="menu_downloadMoreItems">Download more items</string>
|
||||
|
||||
<string name="img_view_thumbnail" translatable="false">Thumbnail</string>
|
||||
|
||||
<!-- Action Bar Items -->
|
||||
<string name="action_starred">Starred</string>
|
||||
|
|
|
@ -55,7 +55,8 @@
|
|||
<item name="windowActionBar">false</item>
|
||||
|
||||
<item name="dividerLineColor">#1e000000</item>
|
||||
<item name="rssItemListBackground">#ffdedede</item>
|
||||
<!-- <item name="rssItemListBackground">#ffdedede</item> -->
|
||||
<item name="rssItemListBackground">#f2f2f2</item>
|
||||
|
||||
<item name="extended_listview_item_body_text_color">@color/extended_listview_item_body_text_color_light_theme</item>
|
||||
|
||||
|
|
Loading…
Reference in a new issue