-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
236 additions
and
44 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
app/src/main/java/io/github/haoyiwen/jinritoutiao/presenter/NewsDetailPresenter.java
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,17 @@ | ||
package io.github.haoyiwen.jinritoutiao.presenter; | ||
|
||
import io.github.haoyiwen.jinritoutiao.base.BasePresenter; | ||
import io.github.haoyiwen.jinritoutiao.presenter.view.INewsListView; | ||
|
||
public class NewsDetailPresenter extends BasePresenter<INewsListView> { | ||
public NewsDetailPresenter(INewsListView view) { | ||
super(view); | ||
} | ||
|
||
public void getNewsDetail(String mDetailUrl) { | ||
} | ||
|
||
public void getComment(String mGroupId, String mItemId, int i) { | ||
|
||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
app/src/main/java/io/github/haoyiwen/jinritoutiao/ui/activities/NewsDetailBaseActivity.java
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,108 @@ | ||
package io.github.haoyiwen.jinritoutiao.ui.activities; | ||
|
||
import android.content.Intent; | ||
import android.widget.FrameLayout; | ||
import android.widget.TextView; | ||
|
||
import androidx.viewbinding.ViewBinding; | ||
|
||
import com.chad.library.adapter.base.BaseQuickAdapter; | ||
import com.github.nukc.stateview.StateView; | ||
|
||
import java.net.ProtocolException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Stack; | ||
|
||
import io.github.haoyiwen.jinritoutiao.R; | ||
import io.github.haoyiwen.jinritoutiao.base.BaseActivity; | ||
import io.github.haoyiwen.jinritoutiao.base.BasePresenter; | ||
import io.github.haoyiwen.jinritoutiao.model.entity.CommentData; | ||
import io.github.haoyiwen.jinritoutiao.model.response.CommentResponse; | ||
import io.github.haoyiwen.jinritoutiao.presenter.NewsDetailPresenter; | ||
import io.github.haoyiwen.jinritoutiao.presenter.view.INewsListView; | ||
import io.github.haoyiwen.jinritoutiao.ui.adapter.CommentAdapter; | ||
import io.github.haoyiwen.jinritoutiao.ui.widget.NewsDetailHeaderView; | ||
import io.github.haoyiwen.uikit.powerfulrecyclerview.PowerfulRecyclerView; | ||
|
||
public abstract class NewsDetailBaseActivity extends BaseActivity<NewsDetailPresenter, ViewBinding> implements INewsListView, BaseQuickAdapter.RequestLoadMoreListener { | ||
public static final String CHANNEL_CODE = "channelCode"; | ||
|
||
public static final String VIDEO_URL = "videoUrl"; | ||
|
||
public static final String PROGRESS = "progress"; | ||
|
||
public static final String POSITION = "position"; | ||
|
||
public static final String DETAIL_URL = "detailUrl"; | ||
|
||
public static final String GROUP_ID = "groupId"; | ||
|
||
public static final String ITEM_ID = "itemId"; | ||
|
||
FrameLayout mFlContent; | ||
|
||
PowerfulRecyclerView mRvComment; | ||
|
||
TextView mTvCommentCount; | ||
|
||
private List<CommentData> commentList = new ArrayList<>(); | ||
|
||
protected StateView mStateView; | ||
|
||
private CommentAdapter mCommentAdapter; | ||
|
||
protected NewsDetailHeaderView mHeaderView; | ||
|
||
private String mDetailUrl; | ||
|
||
private String mGroupId; | ||
|
||
private String mItemId; | ||
|
||
protected CommentResponse mCommentResponse; | ||
|
||
protected String mChannelCode; | ||
|
||
protected int mPosition; | ||
|
||
|
||
protected abstract ViewBinding initViewBinding(); | ||
|
||
@Override | ||
protected NewsDetailPresenter createPresenter() { | ||
return new NewsDetailPresenter(this); | ||
} | ||
|
||
@Override | ||
public void initView() { | ||
mStateView = StateView.inject(mFlContent); | ||
mStateView.setLoadingResource(io.github.haoyiwen.uikit.R.layout.page_loading); | ||
mStateView.setRetryResource(io.github.haoyiwen.uikit.R.layout.page_net_error); | ||
} | ||
|
||
@Override | ||
public void initData() { | ||
Intent intent = getIntent(); | ||
|
||
mChannelCode = intent.getStringExtra(CHANNEL_CODE); | ||
mPosition = intent.getIntExtra(POSITION, 0); | ||
mDetailUrl = intent.getStringExtra(DETAIL_URL); | ||
mGroupId = intent.getStringExtra(GROUP_ID); | ||
mItemId = intent.getStringExtra(ITEM_ID); | ||
mItemId = mItemId.replace("i", ""); | ||
|
||
mPresenter.getNewsDetail(mDetailUrl); | ||
loadCommentData(); | ||
} | ||
|
||
private void loadCommentData() { | ||
mStateView.showLoading(); | ||
mPresenter.getComment(mGroupId, mItemId, 1); | ||
} | ||
|
||
@Override | ||
public void initListener() { | ||
|
||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/io/github/haoyiwen/jinritoutiao/ui/adapter/CommentAdapter.java
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 io.github.haoyiwen.jinritoutiao.ui.adapter; | ||
|
||
import androidx.annotation.Nullable; | ||
|
||
import com.chad.library.adapter.base.BaseQuickAdapter; | ||
import com.chad.library.adapter.base.BaseViewHolder; | ||
|
||
import java.util.List; | ||
|
||
import io.github.haoyiwen.jinritoutiao.model.entity.CommentData; | ||
|
||
public class CommentAdapter extends BaseQuickAdapter<CommentData, BaseViewHolder> { | ||
public CommentAdapter(int layoutResId, @Nullable List<CommentData> data) { | ||
super(layoutResId, data); | ||
} | ||
|
||
@Override | ||
protected void convert(BaseViewHolder baseViewHolder, CommentData commentDatam) { | ||
|
||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
app/src/main/java/io/github/haoyiwen/jinritoutiao/ui/widget/NewsDetailHeaderView.java
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,22 @@ | ||
package io.github.haoyiwen.jinritoutiao.ui.widget; | ||
|
||
import android.content.Context; | ||
import android.util.AttributeSet; | ||
import android.widget.FrameLayout; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
public class NewsDetailHeaderView extends FrameLayout { | ||
public NewsDetailHeaderView(@NonNull Context context) { | ||
super(context); | ||
} | ||
|
||
public NewsDetailHeaderView(@NonNull Context context, @Nullable AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public NewsDetailHeaderView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
} | ||
} |
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