-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #611 from h4ckm310n/novel-watchlist
小说追更列表功能
- Loading branch information
Showing
16 changed files
with
343 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
app/src/main/java/ceui/lisa/adapters/WatchlistNovelAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package ceui.lisa.adapters | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.view.View | ||
import ceui.lisa.databinding.RecyWatchlistNovelBinding | ||
import ceui.lisa.models.WatchlistNovelItem | ||
import ceui.lisa.R | ||
import ceui.lisa.activities.Shaft | ||
import ceui.lisa.activities.TemplateActivity | ||
import ceui.lisa.activities.UserActivity | ||
import ceui.lisa.utils.GlideUtil | ||
import ceui.lisa.utils.Params | ||
import ceui.lisa.utils.PixivOperate | ||
import com.bumptech.glide.Glide | ||
|
||
class WatchlistNovelAdapter( | ||
list: MutableList<WatchlistNovelItem>, | ||
context: Context | ||
) : BaseAdapter<WatchlistNovelItem, RecyWatchlistNovelBinding>(list, context) { | ||
override fun initLayout() { | ||
mLayoutID = R.layout.recy_watchlist_novel | ||
} | ||
|
||
override fun bindData( | ||
target: WatchlistNovelItem, | ||
bindView: ViewHolder<RecyWatchlistNovelBinding>, | ||
position: Int | ||
) { | ||
if (isInvalidItem(target)) { | ||
bindView.baseBind.title.text = target.mask_text | ||
bindView.baseBind.author.text = "" | ||
bindView.baseBind.lastDate.text = "" | ||
bindView.baseBind.contentCount.text = "" | ||
bindView.baseBind.readLatest.visibility = View.INVISIBLE | ||
bindView.baseBind.cover.visibility = View.INVISIBLE | ||
bindView.itemView.setOnClickListener {} | ||
bindView.baseBind.author.setOnClickListener {} | ||
bindView.baseBind.userHead.setOnClickListener {} | ||
} else { | ||
bindView.baseBind.title.text = target.title | ||
bindView.baseBind.author.text = target.user!!.name | ||
Glide.with(mContext).load(GlideUtil.getUrl(target.url!!)).into(bindView.baseBind.cover) | ||
bindView.baseBind.lastDate.text = target.last_published_content_datetime!! | ||
bindView.baseBind.contentCount.text = mContext.getString(R.string.episode_number, target.published_content_count) | ||
bindView.itemView.setOnClickListener { | ||
val intent = Intent(mContext, TemplateActivity::class.java) | ||
intent.putExtra(Params.ID, target.id) | ||
intent.putExtra(TemplateActivity.EXTRA_FRAGMENT, "小说系列详情") | ||
mContext.startActivity(intent) | ||
} | ||
bindView.baseBind.readLatest.setOnClickListener { | ||
PixivOperate.getNovelByID(Shaft.sUserModel, target.latest_content_id!!.toLong(), mContext, null) | ||
} | ||
bindView.baseBind.author.setOnClickListener { | ||
val intent = Intent(mContext, UserActivity::class.java) | ||
intent.putExtra(Params.USER_ID, target.user!!.id) | ||
mContext.startActivity(intent) | ||
} | ||
bindView.baseBind.userHead.setOnClickListener { | ||
val intent = Intent(mContext, UserActivity::class.java) | ||
intent.putExtra(Params.USER_ID, target.user!!.id) | ||
mContext.startActivity(intent) | ||
} | ||
} | ||
Glide.with(mContext).load(GlideUtil.getHead(target.user)).into(bindView.baseBind.userHead) | ||
} | ||
|
||
private fun isInvalidItem(target: WatchlistNovelItem): Boolean { | ||
// 表示できない作品です | ||
return (target.title == "" && target.url == null | ||
&& target.mask_text != null && target.user!!.id == 0) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
app/src/main/java/ceui/lisa/fragments/FragmentWatchlistNovel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ceui.lisa.fragments | ||
|
||
import androidx.databinding.ViewDataBinding | ||
import ceui.lisa.adapters.BaseAdapter | ||
import ceui.lisa.adapters.WatchlistNovelAdapter | ||
import ceui.lisa.core.BaseRepo | ||
import ceui.lisa.databinding.FragmentBaseListBinding | ||
import ceui.lisa.model.ListWatchlistNovel | ||
import ceui.lisa.models.WatchlistNovelItem | ||
import ceui.lisa.repo.WatchlistNovelRepo | ||
|
||
class FragmentWatchlistNovel: | ||
NetListFragment<FragmentBaseListBinding, ListWatchlistNovel, WatchlistNovelItem>() { | ||
override fun adapter(): BaseAdapter<*, out ViewDataBinding> { | ||
return WatchlistNovelAdapter(allItems, mContext) | ||
} | ||
|
||
override fun repository(): BaseRepo { | ||
return WatchlistNovelRepo() | ||
} | ||
|
||
override fun showToolbar(): Boolean { | ||
return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package ceui.lisa.model; | ||
|
||
import java.util.List; | ||
|
||
import ceui.lisa.interfaces.ListShow; | ||
import ceui.lisa.models.WatchlistNovelItem; | ||
|
||
public class ListWatchlistNovel implements ListShow<WatchlistNovelItem> { | ||
private String next_url; | ||
private List<WatchlistNovelItem> series; | ||
|
||
@Override | ||
public List<WatchlistNovelItem> getList() { | ||
return series; | ||
} | ||
|
||
@Override | ||
public String getNextUrl() { | ||
return next_url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ceui.lisa.repo | ||
|
||
import ceui.lisa.core.RemoteRepo | ||
import ceui.lisa.http.Retro | ||
import ceui.lisa.model.ListWatchlistNovel | ||
import io.reactivex.Observable | ||
|
||
class WatchlistNovelRepo: RemoteRepo<ListWatchlistNovel>() { | ||
override fun initApi(): Observable<out ListWatchlistNovel> { | ||
return Retro.getAppApi().getWatchlistNovel(token()) | ||
} | ||
|
||
override fun initNextApi(): Observable<out ListWatchlistNovel> { | ||
return Retro.getAppApi().getNextWatchlistNovel(token(), nextUrl) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<data> | ||
|
||
</data> | ||
|
||
<androidx.cardview.widget.CardView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<RelativeLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<com.makeramen.roundedimageview.RoundedImageView | ||
android:id="@+id/cover" | ||
android:layout_width="90dp" | ||
android:layout_height="120dp" | ||
android:layout_alignParentEnd="true" | ||
android:layout_marginTop="@dimen/eight_dp" | ||
android:layout_marginEnd="@dimen/eight_dp" | ||
android:layout_marginBottom="@dimen/eight_dp" | ||
android:scaleType="centerCrop" | ||
app:riv_border_width="0dp" | ||
app:riv_corner_radius="@dimen/eight_dp"> | ||
</com.makeramen.roundedimageview.RoundedImageView> | ||
|
||
<RelativeLayout | ||
android:layout_width="match_parent" | ||
android:id="@+id/top_rela" | ||
android:layout_marginEnd="@dimen/eight_dp" | ||
android:layout_toStartOf="@+id/cover" | ||
android:layout_height="wrap_content"> | ||
|
||
<ImageView | ||
android:layout_width="2dp" | ||
android:background="?attr/colorPrimary" | ||
android:layout_alignTop="@+id/title" | ||
android:layout_alignBottom="@+id/title" | ||
android:layout_height="wrap_content"> | ||
|
||
</ImageView> | ||
|
||
<TextView | ||
android:id="@+id/title" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="@dimen/eight_dp" | ||
android:layout_marginTop="@dimen/eight_dp" | ||
android:layout_marginBottom="@dimen/eight_dp" | ||
android:ellipsize="end" | ||
android:maxLines="2" | ||
android:textColor="@color/rank_text_color" | ||
android:textSize="16sp"> | ||
|
||
</TextView> | ||
</RelativeLayout> | ||
|
||
<TextView | ||
android:id="@+id/last_date" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/top_rela" | ||
android:layout_marginStart="@dimen/eight_dp" | ||
android:layout_marginEnd="@dimen/eight_dp" | ||
android:layout_toStartOf="@+id/cover" | ||
android:ellipsize="end" | ||
android:maxLines="2" | ||
android:textColor="?attr/colorPrimary" | ||
android:textSize="15sp"> | ||
</TextView> | ||
|
||
<TextView | ||
android:id="@+id/content_count" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/last_date" | ||
android:layout_marginStart="@dimen/eight_dp" | ||
android:layout_marginEnd="@dimen/eight_dp" | ||
android:layout_toStartOf="@+id/cover" | ||
android:ellipsize="end" | ||
android:maxLines="2" | ||
android:textColor="?attr/colorPrimary" | ||
android:textSize="15sp"> | ||
</TextView> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@id/content_count" | ||
android:layout_alignParentBottom="true" | ||
android:layout_marginBottom="@dimen/four_dp" | ||
android:layout_toStartOf="@id/cover" | ||
android:orientation="horizontal"> | ||
|
||
<de.hdodenhof.circleimageview.CircleImageView | ||
android:id="@+id/user_head" | ||
android:layout_width="28dp" | ||
android:layout_height="28dp" | ||
android:layout_gravity="center_vertical" | ||
android:layout_marginVertical="0dp" | ||
android:layout_marginStart="@dimen/eight_dp" | ||
android:layout_marginEnd="@dimen/four_dp" | ||
app:civ_border_color="@color/dark_bg" | ||
app:civ_border_width="1dp" /> | ||
|
||
<TextView | ||
android:id="@+id/author" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_vertical" | ||
android:layout_marginVertical="0dp" | ||
android:layout_marginTop="14dp" | ||
android:layout_marginEnd="@dimen/eight_dp" | ||
android:layout_weight="1" | ||
android:ellipsize="end" | ||
android:maxLines="1" | ||
android:shadowColor="@android:color/black" | ||
android:textColor="@color/rank_text_color" | ||
android:textSize="13sp" | ||
android:textStyle="bold" /> | ||
|
||
<Button | ||
android:id="@+id/read_latest" | ||
style="@style/Widget.AppCompat.Button.Borderless" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_vertical" | ||
android:text="@string/read_latest_episode" | ||
android:textColor="?attr/colorPrimary"> | ||
</Button> | ||
</LinearLayout> | ||
</RelativeLayout> | ||
</androidx.cardview.widget.CardView> | ||
</layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.