Improve recent chapters layout

This commit is contained in:
inorichi 2016-01-21 16:38:25 +01:00
parent fa71e906c9
commit dd0a2d842a
7 changed files with 44 additions and 30 deletions

View File

@ -114,7 +114,7 @@ dependencies {
compile "frankiesardo:icepick:$ICEPICK_VERSION" compile "frankiesardo:icepick:$ICEPICK_VERSION"
provided "frankiesardo:icepick-processor:$ICEPICK_VERSION" provided "frankiesardo:icepick-processor:$ICEPICK_VERSION"
compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.4' compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.4'
compile 'eu.davidea:flexible-adapter:4.2.0@aar' compile 'eu.davidea:flexible-adapter:4.2.0'
compile 'com.nononsenseapps:filepicker:2.5.1' compile 'com.nononsenseapps:filepicker:2.5.1'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.github.pwittchen:reactivenetwork:0.1.5' compile 'com.github.pwittchen:reactivenetwork:0.1.5'

View File

@ -1,7 +1,7 @@
package eu.kanade.tachiyomi.ui.recent; package eu.kanade.tachiyomi.ui.recent;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.text.format.DateFormat; import android.text.format.DateUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -10,6 +10,8 @@ import android.widget.TextView;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import eu.davidea.flexibleadapter.FlexibleAdapter; import eu.davidea.flexibleadapter.FlexibleAdapter;
import eu.kanade.tachiyomi.R; import eu.kanade.tachiyomi.R;
import eu.kanade.tachiyomi.data.database.models.MangaChapter; import eu.kanade.tachiyomi.data.database.models.MangaChapter;
@ -18,8 +20,8 @@ public class RecentChaptersAdapter extends FlexibleAdapter<RecyclerView.ViewHold
private RecentChaptersFragment fragment; private RecentChaptersFragment fragment;
private static final int CHAPTER = 0; private static final int VIEW_TYPE_CHAPTER = 0;
private static final int SECTION = 1; private static final int VIEW_TYPE_SECTION = 1;
public RecentChaptersAdapter(RecentChaptersFragment fragment) { public RecentChaptersAdapter(RecentChaptersFragment fragment) {
this.fragment = fragment; this.fragment = fragment;
@ -47,7 +49,7 @@ public class RecentChaptersAdapter extends FlexibleAdapter<RecyclerView.ViewHold
@Override @Override
public int getItemViewType(int position) { public int getItemViewType(int position) {
return getItem(position) instanceof MangaChapter ? CHAPTER : SECTION; return getItem(position) instanceof MangaChapter ? VIEW_TYPE_CHAPTER : VIEW_TYPE_SECTION;
} }
@Override @Override
@ -55,10 +57,10 @@ public class RecentChaptersAdapter extends FlexibleAdapter<RecyclerView.ViewHold
LayoutInflater inflater = LayoutInflater.from(parent.getContext()); LayoutInflater inflater = LayoutInflater.from(parent.getContext());
View v; View v;
switch (viewType) { switch (viewType) {
case CHAPTER: case VIEW_TYPE_CHAPTER:
v = inflater.inflate(R.layout.item_recent_chapter, parent, false); v = inflater.inflate(R.layout.item_recent_chapter, parent, false);
return new RecentChaptersHolder(v, this, fragment); return new RecentChaptersHolder(v, this, fragment);
case SECTION: case VIEW_TYPE_SECTION:
v = inflater.inflate(R.layout.item_recent_chapter_section, parent, false); v = inflater.inflate(R.layout.item_recent_chapter_section, parent, false);
return new SectionViewHolder(v); return new SectionViewHolder(v);
} }
@ -68,11 +70,11 @@ public class RecentChaptersAdapter extends FlexibleAdapter<RecyclerView.ViewHold
@Override @Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
switch (holder.getItemViewType()) { switch (holder.getItemViewType()) {
case CHAPTER: case VIEW_TYPE_CHAPTER:
final MangaChapter chapter = (MangaChapter) getItem(position); final MangaChapter chapter = (MangaChapter) getItem(position);
((RecentChaptersHolder) holder).onSetValues(chapter); ((RecentChaptersHolder) holder).onSetValues(chapter);
break; break;
case SECTION: case VIEW_TYPE_SECTION:
final Date date = (Date) getItem(position); final Date date = (Date) getItem(position);
((SectionViewHolder) holder).onSetValues(date); ((SectionViewHolder) holder).onSetValues(date);
break; break;
@ -86,18 +88,21 @@ public class RecentChaptersAdapter extends FlexibleAdapter<RecyclerView.ViewHold
return fragment; return fragment;
} }
private static class SectionViewHolder extends RecyclerView.ViewHolder { public static class SectionViewHolder extends RecyclerView.ViewHolder {
private TextView view; @Bind(R.id.section_text) TextView section;
private final long now = new Date().getTime();
public SectionViewHolder(View view) { public SectionViewHolder(View view) {
super(view); super(view);
this.view = (TextView) view; ButterKnife.bind(this, view);
} }
public void onSetValues(Date date) { public void onSetValues(Date date) {
String s = DateFormat.getDateFormat(view.getContext()).format(date); CharSequence s = DateUtils.getRelativeTimeSpanString(
view.setText(s); date.getTime(), now, DateUtils.DAY_IN_MILLIS);
section.setText(s);
} }
} }
} }

View File

@ -1,14 +1,27 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout
android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="48dp" android:layout_width="match_parent"
android:gravity="center_vertical" android:layout_height="32dp"
android:paddingLeft="24dp" android:gravity="center_vertical"
android:singleLine="true" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:textAllCaps="true" android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
android:textColor="@color/colorAccent" android:paddingRight="?android:attr/listPreferredItemPaddingRight"
android:background="@android:color/transparent" android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:textSize="16sp" android:background="@color/colorPrimary">
android:id="@+id/section_text"
android:textStyle="bold" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/white"
android:textSize="16sp"
android:id="@+id/section_text"
android:text="asd"
android:layout_gravity="center_vertical"
android:textStyle="bold" />
</FrameLayout>

View File

@ -8,7 +8,6 @@
android:theme="@style/AppTheme.Overlay.Dark" android:theme="@style/AppTheme.Overlay.Dark"
android:background="@color/colorPrimary" android:background="@color/colorPrimary"
android:visibility="gone" android:visibility="gone"
app:elevation="4dp"
app:tabGravity="center" app:tabGravity="center"
app:tabMode="scrollable" app:tabMode="scrollable"
app:tabMinWidth="75dp" app:tabMinWidth="75dp"

View File

@ -8,5 +8,4 @@
android:theme="@style/AppTheme.Overlay.Dark" android:theme="@style/AppTheme.Overlay.Dark"
app:tabGravity="fill" app:tabGravity="fill"
android:background="@color/colorPrimary" android:background="@color/colorPrimary"
app:elevation="4dp"
app:tabIndicatorColor="@color/white"/> app:tabIndicatorColor="@color/white"/>

View File

@ -5,6 +5,5 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary" android:background="@color/colorPrimary"
app:elevation="4dp"
android:theme="@style/AppTheme.ActionBar" android:theme="@style/AppTheme.ActionBar"
app:layout_scrollFlags="scroll|enterAlways|snap"/> app:layout_scrollFlags="scroll|enterAlways|snap"/>

View File

@ -20,7 +20,6 @@ allprojects {
repositories { repositories {
jcenter() jcenter()
maven { url "https://clojars.org/repo/" } maven { url "https://clojars.org/repo/" }
maven { url "http://dl.bintray.com/davideas/maven" }
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }
maven { url 'http://dl.bintray.com/amulyakhare/maven' } maven { url 'http://dl.bintray.com/amulyakhare/maven' }
maven { url 'https://github.com/suckgamony/RapidDecoder/raw/master/repository' } maven { url 'https://github.com/suckgamony/RapidDecoder/raw/master/repository' }