mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-24 18:08:24 +01:00
Improve recent chapters layout
This commit is contained in:
parent
fa71e906c9
commit
dd0a2d842a
@ -114,7 +114,7 @@ dependencies {
|
||||
compile "frankiesardo:icepick:$ICEPICK_VERSION"
|
||||
provided "frankiesardo:icepick-processor:$ICEPICK_VERSION"
|
||||
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.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
||||
compile 'com.github.pwittchen:reactivenetwork:0.1.5'
|
||||
|
@ -1,7 +1,7 @@
|
||||
package eu.kanade.tachiyomi.ui.recent;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.format.DateFormat;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -10,6 +10,8 @@ import android.widget.TextView;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
||||
import eu.kanade.tachiyomi.R;
|
||||
import eu.kanade.tachiyomi.data.database.models.MangaChapter;
|
||||
@ -18,8 +20,8 @@ public class RecentChaptersAdapter extends FlexibleAdapter<RecyclerView.ViewHold
|
||||
|
||||
private RecentChaptersFragment fragment;
|
||||
|
||||
private static final int CHAPTER = 0;
|
||||
private static final int SECTION = 1;
|
||||
private static final int VIEW_TYPE_CHAPTER = 0;
|
||||
private static final int VIEW_TYPE_SECTION = 1;
|
||||
|
||||
public RecentChaptersAdapter(RecentChaptersFragment fragment) {
|
||||
this.fragment = fragment;
|
||||
@ -47,7 +49,7 @@ public class RecentChaptersAdapter extends FlexibleAdapter<RecyclerView.ViewHold
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return getItem(position) instanceof MangaChapter ? CHAPTER : SECTION;
|
||||
return getItem(position) instanceof MangaChapter ? VIEW_TYPE_CHAPTER : VIEW_TYPE_SECTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -55,10 +57,10 @@ public class RecentChaptersAdapter extends FlexibleAdapter<RecyclerView.ViewHold
|
||||
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||
View v;
|
||||
switch (viewType) {
|
||||
case CHAPTER:
|
||||
case VIEW_TYPE_CHAPTER:
|
||||
v = inflater.inflate(R.layout.item_recent_chapter, parent, false);
|
||||
return new RecentChaptersHolder(v, this, fragment);
|
||||
case SECTION:
|
||||
case VIEW_TYPE_SECTION:
|
||||
v = inflater.inflate(R.layout.item_recent_chapter_section, parent, false);
|
||||
return new SectionViewHolder(v);
|
||||
}
|
||||
@ -68,11 +70,11 @@ public class RecentChaptersAdapter extends FlexibleAdapter<RecyclerView.ViewHold
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
switch (holder.getItemViewType()) {
|
||||
case CHAPTER:
|
||||
case VIEW_TYPE_CHAPTER:
|
||||
final MangaChapter chapter = (MangaChapter) getItem(position);
|
||||
((RecentChaptersHolder) holder).onSetValues(chapter);
|
||||
break;
|
||||
case SECTION:
|
||||
case VIEW_TYPE_SECTION:
|
||||
final Date date = (Date) getItem(position);
|
||||
((SectionViewHolder) holder).onSetValues(date);
|
||||
break;
|
||||
@ -86,18 +88,21 @@ public class RecentChaptersAdapter extends FlexibleAdapter<RecyclerView.ViewHold
|
||||
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) {
|
||||
super(view);
|
||||
this.view = (TextView) view;
|
||||
ButterKnife.bind(this, view);
|
||||
}
|
||||
|
||||
public void onSetValues(Date date) {
|
||||
String s = DateFormat.getDateFormat(view.getContext()).format(date);
|
||||
view.setText(s);
|
||||
CharSequence s = DateUtils.getRelativeTimeSpanString(
|
||||
date.getTime(), now, DateUtils.DAY_IN_MILLIS);
|
||||
section.setText(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="24dp"
|
||||
android:singleLine="true"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@color/colorAccent"
|
||||
android:background="@android:color/transparent"
|
||||
android:textSize="16sp"
|
||||
android:id="@+id/section_text"
|
||||
android:textStyle="bold" />
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="32dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
|
||||
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:background="@color/colorPrimary">
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
android:theme="@style/AppTheme.Overlay.Dark"
|
||||
android:background="@color/colorPrimary"
|
||||
android:visibility="gone"
|
||||
app:elevation="4dp"
|
||||
app:tabGravity="center"
|
||||
app:tabMode="scrollable"
|
||||
app:tabMinWidth="75dp"
|
||||
|
@ -8,5 +8,4 @@
|
||||
android:theme="@style/AppTheme.Overlay.Dark"
|
||||
app:tabGravity="fill"
|
||||
android:background="@color/colorPrimary"
|
||||
app:elevation="4dp"
|
||||
app:tabIndicatorColor="@color/white"/>
|
@ -5,6 +5,5 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/colorPrimary"
|
||||
app:elevation="4dp"
|
||||
android:theme="@style/AppTheme.ActionBar"
|
||||
app:layout_scrollFlags="scroll|enterAlways|snap"/>
|
@ -20,7 +20,6 @@ allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven { url "https://clojars.org/repo/" }
|
||||
maven { url "http://dl.bintray.com/davideas/maven" }
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url 'http://dl.bintray.com/amulyakhare/maven' }
|
||||
maven { url 'https://github.com/suckgamony/RapidDecoder/raw/master/repository' }
|
||||
|
Loading…
Reference in New Issue
Block a user