Commit 9f151440 by 范玉宾

H5 debug to be continue

parent 5cbcfc05
......@@ -525,4 +525,13 @@ public class WVClickAbstractListener implements WebViewClientClickListener {
((NewH5Activity)mContext).setBG(rgb, alpha);
}
}
@Override
public void showCommentArticleDialog(H5JsBean.H5JsCmd.Params params) {
if (mContext instanceof NewH5Activity){
((NewH5Activity)mContext).showCommentArticleDialog();
}
}
}
......@@ -464,6 +464,10 @@ class WebJavascriptHandler : IJavascriptHandler{
wvEnventPro?.switchPushStatus(jsData.cmd?.params)
}
"open_article_comment_dialog" -> {
wvEnventPro?.showCommentArticleDialog(jsData.cmd?.params)
}
}
}
}
......@@ -203,4 +203,8 @@ public interface WebViewClientClickListener {
//h5页面是否需要打开推送
void switchPushStatus(H5JsBean.H5JsCmd.Params params);
//显示评论弹窗
void showCommentArticleDialog(H5JsBean.H5JsCmd.Params params);
}
......@@ -23,7 +23,7 @@ ext {
"ydl-platform" : "0.0.41.51",
//第二步 若干
"ydl-webview" : "0.0.39.03",
"ydl-webview" : "0.0.39.04-beta01",
"ydl-media" : "0.0.21.52",
"ydl-pay" : "0.0.18.21",
"m-audioim" : "0.0.49.30.23",
......@@ -108,7 +108,7 @@ ext {
//第二步 若干
"ydl-webview" : "0.0.39.03",
"ydl-webview" : "0.0.39.04-beta01",
"ydl-media" : "0.0.21.52",
"ydl-pay" : "0.0.18.21",
"m-audioim" : "0.0.49.30.23",
......
......@@ -83,8 +83,7 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"
implementation "androidx.lifecycle:lifecycle-runtime:2.0.0"
implementation 'io.github.scwang90:refresh-layout-kernel:2.0.5' //核心必须依赖
implementation 'io.github.scwang90:refresh-header-radar:2.0.5' //雷达刷新头
implementation 'io.github.scwang90:refresh-footer-ball:2.0.5' //球脉冲加载
implementation 'io.github.scwang90:refresh-header-classics:2.0.5' //经典刷新头
api rootProject.ext.dependencies["ydl-user-router"]
......
......@@ -33,7 +33,10 @@ class ArticleHomeActivity : BaseActivity() {
mTabLayout = findViewById(R.id.tab_layout)
mViewPager = findViewById(R.id.view_pager)
mViewPager?.offscreenPageLimit = 3
findViewById<ImageView>(R.id.iv_back).setOnClickListener {
ActionCountUtils.record("article_list_main_page","article_list_return_click")
finish()
}
......@@ -53,9 +56,8 @@ class ArticleHomeActivity : BaseActivity() {
mTabLayout?.addOnTabSelectedListener(object :
TabLayout.OnTabSelectedListener {
override fun onTabSelected(tab: TabLayout.Tab?) {
//冥想|声音|睡眠点击事件
// ActionCountUtils.count(HomeBIConstants.YDL_HOME_MEDITATION_SUBJECT_CLICK,
// tab?.let { bean?.mditationListResponse?.get(it.position)?.buried } ?:"")
ActionCountUtils.record("article_list_main_page","article_list_toptitle_click",tab?.toString()?:"")
ActionCountUtils.record("article_list_main_page","article_list_sort_visit",tab?.toString()?:"")
var text: String? = tab?.text.toString().trim()
val spStr = SpannableString(text)
......
package adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.yidianling.article.R
class ArticleHomeAdapter:RecyclerView.Adapter<ArticleHomeAdapter.ArticleViewHolder>() {
val list = listOf("One","Two","Three","Four","Five","Six")
override fun onCreateViewHolder(parent: ViewGroup, position: Int): ArticleViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.article_fragment_layout,parent,false)
return ArticleViewHolder(view)
}
override fun onBindViewHolder(holder: ArticleViewHolder, position: Int) {
}
override fun getItemCount(): Int {
return list.size
}
inner class ArticleViewHolder(val view: View):RecyclerView.ViewHolder(view)
}
\ No newline at end of file
......@@ -49,5 +49,12 @@ data class ArticleBean(
val createTime:String,
val createTimeFormat:String,
val zanNum:Int,
val url:String
val categoryId:Int,
val commentTotal:Int,
val label:String,
val content:String,
val status:Int,
val userType:Int,
val userDoctorId:Int,
val listAllUrl:String
)
package fragment
import adapter.ArticleHomeItemAdapter
import android.annotation.SuppressLint
import android.content.Context
import android.os.Bundle
import android.view.View
import android.widget.LinearLayout
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.scwang.smart.refresh.footer.BallPulseFooter
import com.scwang.smart.refresh.header.BezierRadarHeader
import com.scwang.smart.refresh.footer.ClassicsFooter
import com.scwang.smart.refresh.header.ClassicsHeader
import com.scwang.smart.refresh.layout.SmartRefreshLayout
import com.scwang.smart.refresh.layout.wrapper.RefreshFooterWrapper
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydlcommon.base.BaseFragment
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.yidianling.article.R
import data.ArticleBean
import http.ArticleHttp
......@@ -25,13 +22,11 @@ import io.reactivex.schedulers.Schedulers
class ArticleHomeFragment : BaseFragment() {
private lateinit var mSmartRefreshLayout: SmartRefreshLayout
private lateinit var mLvArticleContent: RecyclerView
private lateinit var mLlEmptyLayout: LinearLayout
private var isRefreshing: Boolean = false
private var isLoadingMore: Boolean = false
private lateinit var mRvArticleContent: RecyclerView
private lateinit var mLlEmptyLayout: LinearLayout
private var mCurrentPage = 0
private var mCurrentPage = 1
private var mTotalPage = 0
private var mTagId: Int = 0
......@@ -45,46 +40,50 @@ class ArticleHomeFragment : BaseFragment() {
override fun initDataAndEvent() {
mSmartRefreshLayout = rootView.findViewById(R.id.smart_refresh_layout)
mLvArticleContent = rootView.findViewById(R.id.rv_article_content)
mLlEmptyLayout = rootView.findViewById(R.id.ll_empty)
mSmartRefreshLayout.setRefreshHeader(BezierRadarHeader(activity))
mSmartRefreshLayout.setRefreshFooter(BallPulseFooter(activity))
mRvArticleContent = rootView.findViewById(R.id.rv_article_content)
mLlEmptyLayout = rootView.findViewById(R.id.ll_empty)
mSmartRefreshLayout.autoRefresh()
mSmartRefreshLayout.setRefreshHeader(ClassicsHeader(activity))
mSmartRefreshLayout.setRefreshFooter(ClassicsFooter(activity))
mAdapter = ArticleHomeItemAdapter(activity as Context)
mAdapter.setOnItemClickListener(object : ArticleHomeItemAdapter.OnItemClickListener {
override fun onItemClick(articleBean: ArticleBean) {
YDLRouterManager.router("ydl-user://h5/h5?params={'url':'${articleBean.hUrl}'}")
ActionCountUtils.record("article_list_main_page","article_list_detail_click")
YDLRouterManager.router("ydl-user://h5/h5?params={'url':'${articleBean.listAllUrl}'}")
}
})
mLvArticleContent.layoutManager =
mRvArticleContent.layoutManager =
LinearLayoutManager(activity, RecyclerView.VERTICAL, false)
mLvArticleContent.adapter = mAdapter
mRvArticleContent.adapter = mAdapter
isRefreshing = true
mSmartRefreshLayout.autoRefresh()
mSmartRefreshLayout.setOnRefreshListener {
isRefreshing = true
if (mTagId == 0){
getRecommendArticleList()
}else{
getArticleList(isRefreshing = true, isLoadMore = false)
if (mTagId == 0) {
getRecommendArticleList(isRefresh = true,isLoadMore = false)
} else {
getArticleList(isRefresh = true,isLoadMore = false)
}
it.finishRefresh()
mSmartRefreshLayout.finishRefresh()
}
mSmartRefreshLayout.setOnLoadMoreListener {
isLoadingMore = true
if (mTagId == 0){
getRecommendArticleList()
}else{
getArticleList(isRefreshing = false, isLoadMore = true)
if (mTagId == 0) {
getRecommendArticleList(isRefresh = false,isLoadMore = true)
} else {
getArticleList(isRefresh = false,isLoadMore = true)
}
mSmartRefreshLayout.finishLoadMore()
}
it.finishLoadMore()
}
override fun onResume() {
super.onResume()
mSmartRefreshLayout.autoRefresh()
}
override fun initDataAndEventLazy() {
......@@ -95,10 +94,14 @@ class ArticleHomeFragment : BaseFragment() {
return R.layout.article_fragment_layout
}
@SuppressLint("CheckResult")
private fun getRecommendArticleList(loadMore: Boolean = false) {
private fun getRecommendArticleList(isRefresh: Boolean = true, isLoadMore: Boolean = false) {
ArticleHttp.getInstance().getRecommendArticleList(
perPageRows = 10, page = mCurrentPage
perPageRows = 10, page = if (isRefresh) {
1
} else {
mCurrentPage + 1
}
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
......@@ -106,74 +109,73 @@ class ArticleHomeFragment : BaseFragment() {
if (it.code == "200" && it.data != null) {
if (it.data.list.isNullOrEmpty()) {
mLlEmptyLayout.visibility = View.VISIBLE
mLvArticleContent.visibility = View.GONE
mRvArticleContent.visibility = View.GONE
} else {
mLlEmptyLayout.visibility = View.GONE
mLvArticleContent.visibility = View.VISIBLE
mRvArticleContent.visibility = View.VISIBLE
mCurrentPage = it.data.currentPage
mTotalPage = it.data.totalPage
mSmartRefreshLayout.setEnableLoadMore(mCurrentPage<mTotalPage)
val articles = it.data.list
if (articles != null) {
if (isRefresh) {
mAdapter.setData(articles)
}
if (isLoadMore) {
mAdapter.addData(articles)
}
}
}else{
}
} else {
mLlEmptyLayout.visibility = View.VISIBLE
mLvArticleContent.visibility = View.GONE
mRvArticleContent.visibility = View.GONE
}
}
}
@SuppressLint("CheckResult")
private fun getArticleList(isRefreshing:Boolean = true,isLoadMore: Boolean = false) {
private fun getArticleList(isRefresh: Boolean = true, isLoadMore: Boolean = false) {
ArticleHttp.getInstance().getArticleList(
perPageRows = 10,
page = if (isRefreshing) {
page = if (isRefresh) {
1
}else{
mCurrentPage+1
}, tagId = mTagId
} else {
mCurrentPage + 1
},
tagId = mTagId
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
.subscribe({
if (it.code == "200" && it.data != null) {
if (it.data.list.isNullOrEmpty()) {
mLlEmptyLayout.visibility = View.VISIBLE
mLvArticleContent.visibility = View.GONE
mRvArticleContent.visibility = View.GONE
} else {
mLlEmptyLayout.visibility = View.GONE
mLvArticleContent.visibility = View.VISIBLE
mRvArticleContent.visibility = View.VISIBLE
mCurrentPage = it.data.currentPage
mTotalPage = it.data.totalPage
mSmartRefreshLayout.setEnableLoadMore(mCurrentPage<mTotalPage)
val articles = it.data.list
if (articles != null) {
if (isRefreshing){
if (isRefresh) {
mAdapter.setData(articles)
}else{
}
if (isLoadMore) {
mAdapter.addData(articles)
}
}
}
}else{
} else {
mLlEmptyLayout.visibility = View.VISIBLE
mLvArticleContent.visibility = View.GONE
}
}
}
private fun refreshOrLoadingComplete() {
if (isLoadingMore) {
isLoadingMore = false
}
if (isRefreshing) {
isRefreshing = false
mRvArticleContent.visibility = View.GONE
}
}, {
mLlEmptyLayout.visibility = View.VISIBLE
mRvArticleContent.visibility = View.GONE
})
}
companion object {
......
......@@ -27,7 +27,7 @@ interface ArticleApi {
): Observable<BaseAPIResponse<ArticleListBean>>
//文章列表 推荐列表
@GET("article/list/recommend")
@GET("newArticle/list/recommend")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getRecommendArticleList(
@Query("perPageRows") perPageRows: Int = 10,
......
......@@ -7,19 +7,17 @@
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/smart_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:paddingTop="20dp"
android:clipToPadding="false">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_article_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="20dp"
android:clipToPadding="false"/>
android:layout_height="match_parent"/>
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
<LinearLayout
android:id="@+id/ll_empty"
android:layout_width="match_parent"
......
......@@ -45,6 +45,7 @@ import com.yidianling.tests.api.service.ITestsApiService
import com.yidianling.user.api.service.IUserService
import de.greenrobot.event.EventBus
import org.json.JSONObject
import java.net.URLDecoder
open class HomeBaseImpl : IHomeBaseEvent {
......@@ -546,7 +547,7 @@ open class HomeBaseImpl : IHomeBaseEvent {
YDLRouterManager.router(
IYDLRouterConstant.ROUTER_H5_H5,
YDLRouterParams().putExtra(IYDLRouterConstant.EXTRA_URL, bean.gethUrl()!!), ""
YDLRouterParams().putExtra(IYDLRouterConstant.EXTRA_URL, bean.listAllUrl!!), ""
)
}
......
......@@ -97,7 +97,7 @@ interface HomeBasePagerApi {
fun getFMData(@Query("perPageRows") perPageRows: String = "4"): Observable<BaseAPIResponse<HomeFMBean>>
//首页文章请求 文章改版需求改为3条
@GET("article/list/all")
@GET("newArticle/list/all")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getArticleData(@Query("perPageRows") perPageRows: String = "3"): Observable<BaseAPIResponse<HomeArticleBean>>
......
......@@ -72,5 +72,8 @@ class HomeArticleBean : HomeItemBaseBean {
fun sethUrl(hUrl: String) {
this.hUrl = hUrl
}
var listAllUrl:String?=null
}
}
......@@ -45,7 +45,6 @@ class HomeArticleItemView(private val mContext: Context, private var homeEvent:
YDLImageCacheManager.showImage(mContext, bean?.smallImage, homeModuleArticleItemViewIcon)
setOnClickListener {
homeEvent?.articleItemClick(bean)
}
}
......
......@@ -129,6 +129,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
private boolean isDarkMode = false;
private ShareMeditationDialog shareMeditationDialog;
private ArticleDialogFragment commentArticleDialog;
protected PopupWindow popupWindow;
......@@ -1217,13 +1218,10 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
WebModularServiceUtils.Companion.startMain(NewH5Activity.this);
finish();
} else {
// if (ActivityManager.Companion.getInstance().getActivitys().size() == 1) {
// WebModularServiceUtils.Companion.startMain(NewH5Activity.this);
// }
// finish();
new ArticleDialogFragment().show(getSupportFragmentManager(),"Article");
if (ActivityManager.Companion.getInstance().getActivitys().size() == 1) {
WebModularServiceUtils.Companion.startMain(NewH5Activity.this);
}
finish();
}
});
} else {
......@@ -1546,4 +1544,15 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
}
public void showCommentArticleDialog(){
if (commentArticleDialog == null) {
commentArticleDialog = new ArticleDialogFragment();
}
if (commentArticleDialog != null && !commentArticleDialog.isAdded()) {
commentArticleDialog.show(getSupportFragmentManager(), "article_comment");
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment