Commit 836f9540 by 刘鹏

Merge branch 'feat/lp/lp_article' into 'd/v4.4.04'

文章详情改版

See merge request app_android_lib/YDL-Component!260
parents 839d3d70 63526323
...@@ -304,7 +304,9 @@ public class WVClickAbstractListener implements WebViewClientClickListener { ...@@ -304,7 +304,9 @@ public class WVClickAbstractListener implements WebViewClientClickListener {
@Override @Override
public void shareAction(H5JsBean.H5JsCmd.Params params) { public void shareAction(H5JsBean.H5JsCmd.Params params) {
if (mContext instanceof NewH5Activity) {
((NewH5Activity) mContext).showShareMenu(params);
}
} }
@Override @Override
...@@ -392,7 +394,7 @@ public class WVClickAbstractListener implements WebViewClientClickListener { ...@@ -392,7 +394,7 @@ public class WVClickAbstractListener implements WebViewClientClickListener {
@Override @Override
public void back() { public void back() {
mContext.finish();
} }
@Override @Override
...@@ -568,4 +570,13 @@ public class WVClickAbstractListener implements WebViewClientClickListener { ...@@ -568,4 +570,13 @@ public class WVClickAbstractListener implements WebViewClientClickListener {
((NewH5Activity) mContext).setBG(rgb, alpha); ((NewH5Activity) mContext).setBG(rgb, alpha);
} }
} }
@Override
public void showCommentArticleDialog(H5JsBean.H5JsCmd.Params params) {
if (mContext instanceof NewH5Activity){
((NewH5Activity)mContext).showCommentArticleDialog(params.getTitle());
}
}
} }
...@@ -460,6 +460,10 @@ class WebJavascriptHandler(private val webView: WebView?, private val wvEnventPr ...@@ -460,6 +460,10 @@ class WebJavascriptHandler(private val webView: WebView?, private val wvEnventPr
wvEnventPro?.switchPushStatus(jsData.cmd?.params) wvEnventPro?.switchPushStatus(jsData.cmd?.params)
} }
"open_article_comment_dialog" -> {
wvEnventPro?.showCommentArticleDialog(jsData.cmd?.params)
}
"resources_to_preview" -> { "resources_to_preview" -> {
wvEnventPro?.resourceToPreview(jsData.cmd?.params) wvEnventPro?.resourceToPreview(jsData.cmd?.params)
......
...@@ -204,6 +204,10 @@ public interface WebViewClientClickListener { ...@@ -204,6 +204,10 @@ public interface WebViewClientClickListener {
//h5页面是否需要打开推送 //h5页面是否需要打开推送
void switchPushStatus(H5JsBean.H5JsCmd.Params params); void switchPushStatus(H5JsBean.H5JsCmd.Params params);
//显示评论弹窗
void showCommentArticleDialog(H5JsBean.H5JsCmd.Params params);
void resourceToPreview(H5JsBean.H5JsCmd.Params params); void resourceToPreview(H5JsBean.H5JsCmd.Params params);
void showDocBooking(H5JsBean.H5JsCmd.Params params); void showDocBooking(H5JsBean.H5JsCmd.Params params);
......
ext { ext {
dev_mode = false //组件发布的时候需要设置为false dev_mode = false //组件发布的时候需要设置为false
ydl2PublishVersion = "0.2.0.14" ydl2PublishVersion = "0.2.0.20-SNAPSHOT"
ydlPublishVersion = [ ydlPublishVersion = [
// -------------- 业务模块 -------------- // -------------- 业务模块 --------------
//第三步 若干 //第三步 若干
...@@ -11,7 +11,7 @@ ext { ...@@ -11,7 +11,7 @@ ext {
"m-home" : "0.0.24.06", "m-home" : "0.0.24.06",
"m-im" : "0.0.21.69", "m-im" : "0.0.21.69",
"m-dynamic" : "0.0.7.80", "m-dynamic" : "0.0.7.80",
"m-article" : "0.0.0.10", "m-article" : "0.0.0.11",
"m-muse" : "0.0.28.87", "m-muse" : "0.0.28.87",
"m-tests" : "0.0.24.24", "m-tests" : "0.0.24.24",
"m-course" : "0.0.43.39", "m-course" : "0.0.43.39",
...@@ -22,7 +22,7 @@ ext { ...@@ -22,7 +22,7 @@ ext {
"ydl-platform" : "0.0.41.54", "ydl-platform" : "0.0.41.54",
//第二步 若干 //第二步 若干
"ydl-webview" : "0.0.39.03", "ydl-webview" : "0.2.0.7",
"ydl-media" : "0.0.21.52", "ydl-media" : "0.0.21.52",
"ydl-pay" : "0.0.18.21", "ydl-pay" : "0.0.18.21",
"m-audioim" : "0.0.49.30.23", "m-audioim" : "0.0.49.30.23",
......
...@@ -52,6 +52,12 @@ dependencies { ...@@ -52,6 +52,12 @@ dependencies {
kapt 'com.alibaba:arouter-compiler:1.2.2' kapt 'com.alibaba:arouter-compiler:1.2.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
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-classics:2.0.5' //经典刷新头
api rootProject.ext.dependencies["ydl-user-router"] api rootProject.ext.dependencies["ydl-user-router"]
if (rootProject.ext.dev_mode){ if (rootProject.ext.dev_mode){
//开发时使用 //开发时使用
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
<application> <application>
<activity android:name=".flutter.ArticleActivity" <activity android:name=".flutter.ArticleActivity"
android:screenOrientation="portrait"/> android:screenOrientation="portrait"/>
<activity android:name="activity.ArticleHomeActivity"
android:screenOrientation="portrait"/>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
package activity
import adapter.ArticlePagerAdapter
import android.annotation.SuppressLint
import android.graphics.Typeface
import android.text.SpannableString
import android.text.Spanned
import android.text.style.StyleSpan
import android.widget.ImageView
import androidx.viewpager2.widget.ViewPager2
import com.alibaba.android.arouter.facade.annotation.Route
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.yidianling.article.R
import fragment.ArticleHomeFragment
import http.ArticleHttp
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
@Route(path = "/article/list")
class ArticleHomeActivity : BaseActivity() {
private var TAG_IDS = mutableListOf(0)
private var mTabName = mutableListOf("推荐")
private var mTabLayout: TabLayout? = null
private var mViewPager: ViewPager2? = null
private var mFragments = mutableListOf(ArticleHomeFragment.newInstance(0))
override fun layoutResId(): Int {
return R.layout.article_home_activity_layout
}
override fun initDataAndEvent() {
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()
}
loadData()
}
@SuppressLint("CheckResult")
private fun loadData() {
ArticleHttp.getInstance().getArticleCategoryList()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { response ->
if (response.code == "200" && response.data != null && !response.data.articleCategoryResponseList.isNullOrEmpty()) {
var tabNameString = StringBuffer("推荐")
response.data.articleCategoryResponseList!!.forEach {
mTabName.add(it.name)
TAG_IDS.add(it.categoryId)
mFragments.add(ArticleHomeFragment.newInstance(it.categoryId))
tabNameString.append("|${it.name}")
}
ActionCountUtils.record(
"article_list_main_page",
"article_list_sort_visit",
tabNameString.toString()
)
mViewPager?.post {
mViewPager?.adapter = ArticlePagerAdapter(this, mFragments)
mTabLayout?.addOnTabSelectedListener(object :
TabLayout.OnTabSelectedListener {
override fun onTabSelected(tab: TabLayout.Tab?) {
ActionCountUtils.record(
"article_list_main_page",
"article_list_toptitle_click",
tab?.text.toString() ?: ""
)
var text: String? = tab?.text.toString().trim()
val spStr = SpannableString(text)
val styleSpan = StyleSpan(Typeface.BOLD)
spStr.setSpan(
styleSpan,
0,
text?.length ?: 0,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE
)
tab?.text = spStr
}
override fun onTabUnselected(tab: TabLayout.Tab?) {
var text: String? = tab?.text.toString().trim()
val spStr = SpannableString(text)
val styleSpan = StyleSpan(Typeface.NORMAL)
spStr.setSpan(
styleSpan,
0,
text?.length ?: 0,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE
)
tab?.text = spStr
}
override fun onTabReselected(tab: TabLayout.Tab?) {
}
})
TabLayoutMediator(mTabLayout!!, mViewPager!!) { tab, position ->
tab.text = mTabName[position]
}.attach()
}
}
}
}
}
\ No newline at end of file
package adapter
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.AppCompatTextView
import androidx.recyclerview.widget.RecyclerView
import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.yidianling.article.R
import data.ArticleBean
class ArticleHomeItemAdapter(private val mContext:Context):RecyclerView.Adapter<ArticleHomeItemAdapter.ArticleViewHolder>() {
private var mData = mutableListOf<ArticleBean>()
private var mListener:OnItemClickListener?=null
fun setOnItemClickListener(listener: OnItemClickListener){
mListener = listener
}
fun setData(data:MutableList<ArticleBean>){
mData.clear()
mData.addAll(data)
notifyDataSetChanged()
}
fun addData(data:MutableList<ArticleBean>){
mData.addAll(data)
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, position: Int): ArticleViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.article_home_item_layout,parent,false)
return ArticleViewHolder(view)
}
override fun onBindViewHolder(holder: ArticleViewHolder, position: Int) {
holder.tvTitle.text = mData[position].title
holder.tvDesc.text = mData[position].desc
holder.tvAuthorName.text = mData[position].name
holder.tvArticleViewNum.text = "${mData[position].readNum}浏览"
holder.tvArticleLikeNum.text = "${mData[position].zanNum}点赞"
YDLImageCacheManager.showImage(mContext, mData[position]?.imgUrl, holder.ivArticleImage)
YDLImageCacheManager.showImage(mContext, mData[position]?.smallImage, holder.ivAuthorAvatar)
holder.itemView.setOnClickListener {
mListener?.onItemClick(mData[position])
}
}
override fun getItemCount(): Int {
return mData.size
}
inner class ArticleViewHolder(itemView:View):RecyclerView.ViewHolder(itemView){
var tvTitle:AppCompatTextView = itemView.findViewById(R.id.tv_article_title)
var tvDesc:AppCompatTextView = itemView.findViewById(R.id.tv_article_desc)
var ivArticleImage:AppCompatImageView = itemView.findViewById(R.id.iv_article_image)
var ivAuthorAvatar:AppCompatImageView = itemView.findViewById(R.id.iv_author_avatar)
var tvAuthorName:AppCompatTextView = itemView.findViewById(R.id.tv_author_name)
var tvArticleViewNum:AppCompatTextView = itemView.findViewById(R.id.tv_article_view_num)
var tvArticleLikeNum:AppCompatTextView = itemView.findViewById(R.id.tv_article_like_num)
}
interface OnItemClickListener{
fun onItemClick(articleBean: ArticleBean)
}
}
\ No newline at end of file
package adapter
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import fragment.ArticleHomeFragment
class ArticlePagerAdapter constructor(activity: FragmentActivity,list: MutableList<ArticleHomeFragment>):FragmentStateAdapter(activity) {
private var list = mutableListOf<ArticleHomeFragment>()
init {
this.list = list
}
override fun getItemCount(): Int {
return list.size
}
override fun createFragment(position: Int): Fragment {
return list[position]
}
}
\ No newline at end of file
...@@ -9,7 +9,7 @@ import org.json.JSONObject ...@@ -9,7 +9,7 @@ import org.json.JSONObject
* Created by harvie on 2019/9/6. * Created by harvie on 2019/9/6.
*/ */
@Route(path = "/article/list") //@Route(path = "/article/list")
class ArticleActivity : BaseFlutterActivity() { class ArticleActivity : BaseFlutterActivity() {
override fun initialRoute(): String { override fun initialRoute(): String {
......
package data
data class ArticleCategoryListBean(
val articleCategoryResponseList: MutableList<ArticleCategoryBean>?=null
)
data class ArticleCategoryBean(
val categoryId:Int,
val name: String
)
data class ArticleListBean(
val list:MutableList<ArticleBean>?=null,
val totalPage:Int = 0,
val currentPage:Int = 0
)
//"id": 12516,
//"readNum": 215,
//"title": "当你过于敏感焦虑,来试一下系统脱敏训练吧!",
//"desc": "解析阿辰过于敏感失眠的案例,分析过于敏感和外归因的影响,介绍系统脱敏训练方法,鼓励大家用系统脱敏训练来学会放松,缓解敏感焦虑。",
//"imgUrl": "https://img.ydlcdn.com/file/2022/07/05/z5g81dlgbbu6wjq1.jpg!/fw/270",
//"name": "徐姗姗",
//"doctorId": 33094,
//"smallImage": "http://ydl-userprivacy.ydl.com/2022_05_28_63195910000PWTRVQPVQQUQU.772.jpg",
//"pseudonym": "",
//"countOfFavorite": 2,
//"hUrl": "https://h2.yidianling.com/article/12516",
//"mUrl": "https://m.ydl.com/article/12516",
//"createTime": "Jul 5, 2022 9:58:24 AM",
//"createTimeFormat": "2022-07-05",
//"zanNum": 2,
//"url": "https://h2.yidianling.com/article/12516"
data class ArticleBean(
val id:Int,
val readNum:Int,
val title:String,
val desc:String,
val imgUrl:String,
val name:String,
val doctorId:Int,
val smallImage:String,
val pseudonym:String,
val countOfFavorite:Int,
val hUrl:String,
val mUrl:String,
val createTime:String,
val createTimeFormat:String,
val zanNum:Int,
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.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.ClassicsFooter
import com.scwang.smart.refresh.header.ClassicsHeader
import com.scwang.smart.refresh.layout.SmartRefreshLayout
import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydl_router.manager.YDLRouterParams
import com.ydl.ydlcommon.base.BaseFragment
import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.yidianling.article.R
import data.ArticleBean
import http.ArticleHttp
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
class ArticleHomeFragment : BaseFragment() {
private lateinit var mSmartRefreshLayout: SmartRefreshLayout
private lateinit var mRvArticleContent: RecyclerView
private lateinit var mLlEmptyLayout: LinearLayout
private var mCurrentPage = 1
private var mTotalPage = 0
private var mTagId: Int = 0
private lateinit var mAdapter: ArticleHomeItemAdapter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mTagId = arguments?.getInt(KEY_ARTICLE_TAG_ID, 0) ?: 0
}
override fun layoutResId(): Int {
return R.layout.article_fragment_layout
}
override fun initDataAndEventLazy() {
}
override fun initDataAndEvent() {
mSmartRefreshLayout = rootView.findViewById(R.id.smart_refresh_layout)
mRvArticleContent = rootView.findViewById(R.id.rv_article_content)
mLlEmptyLayout = rootView.findViewById(R.id.ll_empty)
mSmartRefreshLayout.setRefreshHeader(ClassicsHeader(activity))
mSmartRefreshLayout.setRefreshFooter(ClassicsFooter(activity))
mAdapter = ArticleHomeItemAdapter(activity as Context)
mAdapter.setOnItemClickListener(object : ArticleHomeItemAdapter.OnItemClickListener {
override fun onItemClick(articleBean: ArticleBean) {
ActionCountUtils.record("article_list_main_page","article_list_detail_click")
YDLRouterManager.router(
IYDLRouterConstant.ROUTER_H5_H5,
YDLRouterParams().putExtra(IYDLRouterConstant.EXTRA_URL, articleBean.listAllUrl!!), ""
)
}
})
mRvArticleContent.layoutManager =
LinearLayoutManager(activity, RecyclerView.VERTICAL, false)
mRvArticleContent.adapter = mAdapter
mSmartRefreshLayout.autoRefresh()
mSmartRefreshLayout.setOnRefreshListener {
if (mTagId == 0) {
getRecommendArticleList(isRefresh = true,isLoadMore = false)
} else {
getArticleList(isRefresh = true,isLoadMore = false)
}
mSmartRefreshLayout.finishRefresh()
}
mSmartRefreshLayout.setOnLoadMoreListener {
if (mTagId == 0) {
getRecommendArticleList(isRefresh = false,isLoadMore = true)
} else {
getArticleList(isRefresh = false,isLoadMore = true)
}
mSmartRefreshLayout.finishLoadMore()
}
}
override fun onResume() {
super.onResume()
mSmartRefreshLayout.autoRefresh()
}
private fun getRecommendArticleList(isRefresh: Boolean = true, isLoadMore: Boolean = false) {
ArticleHttp.getInstance().getRecommendArticleList(
perPageRows = 10, page = if (isRefresh) {
1
} else {
mCurrentPage + 1
}
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
if (it.code == "200" && it.data != null) {
if (it.data.list.isNullOrEmpty()) {
mLlEmptyLayout.visibility = View.VISIBLE
mRvArticleContent.visibility = View.GONE
} else {
mLlEmptyLayout.visibility = View.GONE
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 {
mLlEmptyLayout.visibility = View.VISIBLE
mRvArticleContent.visibility = View.GONE
}
}
}
private fun getArticleList(isRefresh: Boolean = true, isLoadMore: Boolean = false) {
ArticleHttp.getInstance().getArticleList(
perPageRows = 10,
page = if (isRefresh) {
1
} else {
mCurrentPage + 1
},
tagId = mTagId
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
if (it.code == "200" && it.data != null) {
if (it.data.list.isNullOrEmpty()) {
mLlEmptyLayout.visibility = View.VISIBLE
mRvArticleContent.visibility = View.GONE
} else {
mLlEmptyLayout.visibility = View.GONE
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 {
mLlEmptyLayout.visibility = View.VISIBLE
mRvArticleContent.visibility = View.GONE
}
}, {
mLlEmptyLayout.visibility = View.VISIBLE
mRvArticleContent.visibility = View.GONE
})
}
companion object {
const val KEY_ARTICLE_TAG_ID = "key_article_tag_id"
fun newInstance(tagId: Int): ArticleHomeFragment {
val args = Bundle()
args.putInt(KEY_ARTICLE_TAG_ID, tagId)
val fragment = ArticleHomeFragment()
fragment.arguments = args
return fragment
}
}
}
\ No newline at end of file
package http
import com.ydl.ydlcommon.base.config.YDL_DOMAIN
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import data.ArticleCategoryListBean
import data.ArticleListBean
import io.reactivex.Observable
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.Query
interface ArticleApi {
//文章标签
@GET("newArticle/ArticleCate")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getArticleTagList(): Observable<BaseAPIResponse<ArticleCategoryListBean>>
//文章列表
@GET("newArticle/list/all")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getArticleList(
@Query("perPageRows") perPageRows: Int = 10,
@Query("page") page: Int = 1,
@Query("tagId") tagId: Int = 0
): Observable<BaseAPIResponse<ArticleListBean>>
//文章列表 推荐列表
@GET("newArticle/list/recommend")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getRecommendArticleList(
@Query("perPageRows") perPageRows: Int = 10,
@Query("page") page: Int = 1
): Observable<BaseAPIResponse<ArticleListBean>>
}
\ No newline at end of file
package http
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlnet.YDLHttpUtils
import data.ArticleCategoryListBean
import data.ArticleListBean
import io.reactivex.Observable
class ArticleHttp {
companion object{
fun getInstance() = Holder.INSTANCE
}
object Holder{
val INSTANCE = ArticleHttp()
}
private var articleApi:ArticleApi?=null
private fun getArticleApi():ArticleApi{
if (articleApi == null){
articleApi = YDLHttpUtils.obtainApi(ArticleApi::class.java)
}
return articleApi!!
}
fun getArticleCategoryList():Observable<BaseAPIResponse<ArticleCategoryListBean>>{
return getArticleApi().getArticleTagList()
}
fun getRecommendArticleList(perPageRows:Int,page:Int):Observable<BaseAPIResponse<ArticleListBean>>{
return getArticleApi().getRecommendArticleList(perPageRows = perPageRows,page = page)
}
fun getArticleList(perPageRows:Int,page:Int,tagId:Int):Observable<BaseAPIResponse<ArticleListBean>>{
return getArticleApi().getArticleList(perPageRows = perPageRows,page = page,tagId = tagId)
}
}
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M15,3l-8,8l8,8"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#10233A"
android:fillType="evenOdd"
android:strokeLineCap="round"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/smart_refresh_layout"
android:layout_width="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"/>
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
<LinearLayout
android:id="@+id/ll_empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone"
android:gravity="center"
tools:visibility="visible">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/platform_ydlcommon_blank"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:text="暂无相应记录"
android:textColor="#b2b2b2"/>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_back"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginStart="9dp"
android:padding="9dp"
android:src="@drawable/article_home_back_icon"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="文章·阅读"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#F8F8F8" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
style="@style/ArticleTabLayoutStyle"
android:layout_width="match_parent"
android:layout_height="38dp"
android:paddingTop="10dp"
app:tabBackground="@color/transparent"
app:tabIndicatorFullWidth="false"
app:tabMaxWidth="88dp"
app:tabMinWidth="64dp"
app:tabMode="scrollable"
app:tabRippleColor="@color/transparent"
app:tabTextAppearance="@style/TabLayoutTextStyle" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:paddingHorizontal="16dp"
android:paddingTop="4dp">
<androidx.cardview.widget.CardView
android:id="@+id/card_view_article_image"
android:layout_width="88dp"
android:layout_height="70dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:cardCornerRadius="8dp"
app:cardElevation="0dp">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_article_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
tools:src="@drawable/picture_album_bg"/>
</androidx.cardview.widget.CardView>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_article_title"
android:layout_width="0dp"
app:layout_constraintHorizontal_weight="1"
android:layout_height="wrap_content"
android:maxHeight="44dp"
android:maxLines="2"
app:layout_constraintEnd_toStartOf="@id/card_view_article_image"
android:ellipsize="end"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="#1C1F28"
android:layout_marginEnd="18dp"
android:lineSpacingExtra="1dp"
tools:text="最伟大的作品,是魔术啊,最伟大的作品,是魔术啊。"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/card_view_article_image"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_article_desc"
android:layout_width="0dp"
app:layout_constraintHorizontal_weight="1"
android:layout_height="18dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toStartOf="@id/card_view_article_image"
android:maxLines="1"
android:ellipsize="end"
android:textSize="13sp"
android:singleLine="true"
android:textColor="#9D9EA7"
android:layout_marginEnd="18dp"
tools:text="最伟大的作品,是魔术啊,最伟大的作品,是魔术啊。fdasfa"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_article_title"/>
<androidx.cardview.widget.CardView
android:id="@+id/card_view_avatar"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginTop="17dp"
app:layout_constraintStart_toStartOf="@id/tv_article_title"
app:layout_constraintTop_toBottomOf="@id/card_view_article_image"
app:cardElevation="0dp"
app:cardCornerRadius="8dp">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_author_avatar"
android:layout_width="16dp"
android:layout_height="16dp"
tools:src="@drawable/icon_meditation_share_wechat"/>
</androidx.cardview.widget.CardView>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_author_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:textSize="13sp"
android:textColor="#62636F"
tools:text="黄秀章"
app:layout_constraintStart_toEndOf="@id/card_view_avatar"
app:layout_constraintTop_toTopOf="@id/card_view_avatar"
app:layout_constraintBottom_toBottomOf="@id/card_view_avatar"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_article_view_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="2656浏览"
android:textSize="13sp"
android:layout_marginEnd="70dp"
android:textColor="#62636F"
app:layout_constraintBaseline_toBaselineOf="@id/tv_author_name"
app:layout_constraintEnd_toEndOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_article_like_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="3327点赞"
android:textSize="13sp"
android:textColor="#62636F"
app:layout_constraintBaseline_toBaselineOf="@id/tv_author_name"
app:layout_constraintEnd_toEndOf="parent"/>
<View
android:id="@+id/homeModuleArticleItemViewBottomLine"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#EFEFF1"
android:layout_marginTop="20dp"
android:layout_marginBottom="30dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/card_view_avatar"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="color_1DA1F2">#1DA1F2</color>
<color name="color_999999">#999999</color>
<color name="color_000000">#000000</color>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ArticleTabLayoutStyle" parent="TextAppearance.Design.Tab">
<item name="tabIndicatorColor">@color/color_1DA1F2</item>
<item name="tabIndicatorHeight">4dp</item>
<item name="tabIndicatorFullWidth">false</item>
<item name="android:textSize">16sp</item>
<item name="tabSelectedTextColor">@color/color_000000</item>
<item name="android:textColor">@color/color_999999</item>
<item name="android:textStyle">normal</item>
</style>
<style name="TabLayoutTextStyle" parent="TextAppearance.Design.Tab">
<item name="android:textSize">16sp</item>
</style>
</resources>
\ No newline at end of file
...@@ -45,6 +45,7 @@ import com.yidianling.tests.api.service.ITestsApiService ...@@ -45,6 +45,7 @@ import com.yidianling.tests.api.service.ITestsApiService
import com.yidianling.user.api.service.IUserService import com.yidianling.user.api.service.IUserService
import de.greenrobot.event.EventBus import de.greenrobot.event.EventBus
import org.json.JSONObject import org.json.JSONObject
import java.net.URLDecoder
open class HomeBaseImpl : IHomeBaseEvent { open class HomeBaseImpl : IHomeBaseEvent {
...@@ -539,11 +540,14 @@ open class HomeBaseImpl : IHomeBaseEvent { ...@@ -539,11 +540,14 @@ open class HomeBaseImpl : IHomeBaseEvent {
return return
} }
ActionCountUtils.count(HomeBIConstants.YDL_USER_ARTICLE_CLICK, bean.id.toString()) ActionCountUtils.count(
HomeBIConstants.YDL_USER_ARTICLE_CLICK, bean.id.toString(),
bean.title ?: ""
)
YDLRouterManager.router( YDLRouterManager.router(
IYDLRouterConstant.ROUTER_H5_H5, IYDLRouterConstant.ROUTER_H5_H5,
YDLRouterParams().putExtra(IYDLRouterConstant.EXTRA_URL, bean.gethUrl()!!), "" YDLRouterParams().putExtra(IYDLRouterConstant.EXTRA_URL, bean.listAllUrl!!), ""
) )
} }
......
...@@ -78,7 +78,7 @@ class HomeBaseHttp { ...@@ -78,7 +78,7 @@ class HomeBaseHttp {
//首页文章请求 //首页文章请求
fun getArticleData(): Observable<BaseAPIResponse<HomeArticleBean>> { fun getArticleData(): Observable<BaseAPIResponse<HomeArticleBean>> {
articleListSize = if (YdlCommonOut.getApp().packageName == "com.cxzapp.xinlizixun") "6" else "4" articleListSize = if (YdlCommonOut.getApp().packageName == "com.cxzapp.xinlizixun") "6" else "3"
return getHomePagerApi().getArticleData(perPageRows = articleListSize) return getHomePagerApi().getArticleData(perPageRows = articleListSize)
} }
......
...@@ -96,10 +96,10 @@ interface HomeBasePagerApi { ...@@ -96,10 +96,10 @@ interface HomeBasePagerApi {
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA) @Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getFMData(@Query("perPageRows") perPageRows: String = "4"): Observable<BaseAPIResponse<HomeFMBean>> 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) @Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getArticleData(@Query("perPageRows") perPageRows: String = "4"): Observable<BaseAPIResponse<HomeArticleBean>> fun getArticleData(@Query("perPageRows") perPageRows: String = "3"): Observable<BaseAPIResponse<HomeArticleBean>>
//首页问答 - 点赞 //首页问答 - 点赞
@FormUrlEncoded @FormUrlEncoded
......
...@@ -72,5 +72,8 @@ class HomeArticleBean : HomeItemBaseBean { ...@@ -72,5 +72,8 @@ class HomeArticleBean : HomeItemBaseBean {
fun sethUrl(hUrl: String) { fun sethUrl(hUrl: String) {
this.hUrl = hUrl this.hUrl = hUrl
} }
var listAllUrl:String?=null
} }
} }
...@@ -3,6 +3,7 @@ package com.yidianling.home.ui.view ...@@ -3,6 +3,7 @@ package com.yidianling.home.ui.view
import android.content.Context import android.content.Context
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.ydl.ydl_image.manager.YDLImageCacheManager import com.ydl.ydl_image.manager.YDLImageCacheManager
...@@ -38,12 +39,12 @@ class HomeArticleItemView(private val mContext: Context, private var homeEvent: ...@@ -38,12 +39,12 @@ class HomeArticleItemView(private val mContext: Context, private var homeEvent:
homeModuleArticleItemViewTitle.text = bean?.title homeModuleArticleItemViewTitle.text = bean?.title
homeModuleArticleItemViewContent.text = bean?.desc homeModuleArticleItemViewContent.text = bean?.desc
homeModuleArticleItemViewAuthor.text = bean?.name homeModuleArticleItemViewAuthor.text = bean?.name
homeModuleArticleItemViewGreatNum.text = bean?.countOfFavorite.toString() homeModuleArticleItemViewGreatNum.text = "${bean?.countOfFavorite}点赞"
homeModuleArticleItemViewLookNum.text = bean?.readNum.toString() homeModuleArticleItemViewLookNum.text = "${bean?.readNum}浏览"
YDLImageCacheManager.showImage(mContext, bean?.imgUrl, homeModuleArticleItemViewImg) YDLImageCacheManager.showImage(mContext, bean?.imgUrl, homeModuleArticleItemViewImg)
YDLImageCacheManager.showImage(mContext, bean?.smallImage, homeModuleArticleItemViewIcon)
setOnClickListener { setOnClickListener {
homeEvent?.articleItemClick(bean) homeEvent?.articleItemClick(bean)
} }
} }
......
...@@ -5,6 +5,7 @@ import android.view.View ...@@ -5,6 +5,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.yidianling.home.R import com.yidianling.home.R
import com.yidianling.home.constract.HomeViewConfig import com.yidianling.home.constract.HomeViewConfig
import com.yidianling.home.event.IHomeBaseEvent import com.yidianling.home.event.IHomeBaseEvent
...@@ -56,6 +57,8 @@ class HomeArticleView(private val mContext: Context, private var homeEvent: IHom ...@@ -56,6 +57,8 @@ class HomeArticleView(private val mContext: Context, private var homeEvent: IHom
} }
} }
} }
// 文章阅读新增埋点
ActionCountUtils.record("ydl_user_main_page", "ydl_user_article_visit")
} }
} }
......
...@@ -4,124 +4,128 @@ ...@@ -4,124 +4,128 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:paddingLeft="@dimen/platform_dp_15" android:paddingLeft="16dp"
android:paddingRight="@dimen/platform_dp_15" android:paddingRight="16dp"
android:paddingTop="@dimen/platform_dp_15"> android:paddingTop="4dp">
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:id="@+id/homeModuleArticleItemViewCardImg" android:id="@+id/homeModuleArticleItemViewCardImg"
android:layout_width="@dimen/platform_dp_127" android:layout_width="88dp"
android:layout_height="@dimen/platform_dp_88" android:layout_height="70dp"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
app:cardCornerRadius="@dimen/platform_dp_6" app:cardCornerRadius="8dp"
app:cardElevation="0dp"> app:cardElevation="0dp">
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:id="@+id/homeModuleArticleItemViewImg" android:id="@+id/homeModuleArticleItemViewImg"
android:background="@drawable/home_image_default_back"/> tools:src="@drawable/home_image_default_back"/>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>
<TextView <TextView
android:id="@+id/homeModuleArticleItemViewTitle" android:id="@+id/homeModuleArticleItemViewTitle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:maxHeight="44dp"
android:maxLines="2" android:maxLines="2"
android:ellipsize="end" android:ellipsize="end"
android:textSize="@dimen/platform_dp_18" android:textSize="16sp"
android:textStyle="bold" android:textStyle="bold"
android:layout_marginTop="-2dp" android:textColor="#1C1F28"
android:textColor="@color/platform_color_222222"
android:layout_alignParentTop="true"
android:lineSpacingExtra="@dimen/platform_dp_1" android:lineSpacingExtra="@dimen/platform_dp_1"
tools:text="喧嚣的世界中,你的重要何以而来?喧嚣的世界中,你的重要何以而来?" tools:text="喧嚣的世界中,你的重要何以而来?"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignTop="@id/homeModuleArticleItemViewCardImg"
android:layout_toLeftOf="@+id/homeModuleArticleItemViewCardImg" android:layout_toLeftOf="@+id/homeModuleArticleItemViewCardImg"
android:layout_marginRight="@dimen/platform_dp_20"/> android:layout_marginRight="18dp"/>
<TextView <TextView
android:id="@+id/homeModuleArticleItemViewContent" android:id="@+id/homeModuleArticleItemViewContent"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="18dp"
android:maxLines="2" android:layout_marginTop="8dp"
android:maxLines="1"
android:gravity="center_vertical"
android:ellipsize="end" android:ellipsize="end"
android:textSize="@dimen/platform_dp_13" android:textSize="@dimen/platform_dp_13"
android:layout_marginTop="@dimen/platform_dp_4" android:textColor="#9D9EA7"
android:textColor="@color/platform_color_666666"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_below="@+id/homeModuleArticleItemViewTitle"
android:lineSpacingExtra="@dimen/platform_dp_3"
tools:text="喧嚣的世界中,你的重要何以而来?当我伫立在我所伫立之处..." tools:text="喧嚣的世界中,你的重要何以而来?当我伫立在我所伫立之处..."
android:layout_toLeftOf="@+id/homeModuleArticleItemViewCardImg" android:layout_toLeftOf="@+id/homeModuleArticleItemViewCardImg"
android:layout_marginRight="@dimen/platform_dp_20"/> android:layout_below="@id/homeModuleArticleItemViewTitle"
android:layout_marginRight="18dp"/>
<LinearLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/homeModuleArticleItemViewBottomLayout" android:id="@+id/homeModuleArticleItemViewBottomLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_below="@+id/homeModuleArticleItemViewCardImg" android:layout_below="@+id/homeModuleArticleItemViewCardImg"
android:layout_marginTop="@dimen/platform_dp_16"> android:layout_marginTop="17dp">
<androidx.cardview.widget.CardView
android:id="@+id/card_view_avatar"
android:layout_width="16dp"
android:layout_height="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:cardElevation="0dp"
app:cardCornerRadius="8dp">
<ImageView <ImageView
android:id="@+id/homeModuleArticleItemViewIcon" android:id="@+id/homeModuleArticleItemViewIcon"
android:layout_width="@dimen/platform_dp_12" android:layout_width="16dp"
android:layout_height="@dimen/platform_dp_12" android:layout_height="16dp"
android:src="@drawable/home_article_item_icon" android:src="@drawable/home_article_item_icon"/>
android:layout_alignParentLeft="true"/>
<TextView
android:id="@+id/homeModuleArticleItemViewAuthor"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textSize="@dimen/platform_dp_12"
android:textColor="@color/platform_color_242424"
android:layout_marginLeft="@dimen/platform_dp_3"
android:textStyle="bold"
tools:text="赵秀英"/>
<TextView </androidx.cardview.widget.CardView>
android:id="@+id/homeModuleArticleItemViewGreatNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="3327"
android:textSize="@dimen/platform_dp_12"
android:textColor="@color/platform_color_242424"/>
<TextView <TextView
android:id="@+id/homeModuleArticleItemViewAuthor"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="点赞" android:textSize="13sp"
android:textSize="@dimen/platform_dp_11" android:textColor="#62636F"
android:layout_marginRight="@dimen/platform_dp_12" android:layout_marginLeft="5dp"
android:textColor="@color/platform_color_666666"/> app:layout_constraintStart_toEndOf="@id/card_view_avatar"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
tools:text="赵秀英"/>
<TextView <TextView
android:id="@+id/homeModuleArticleItemViewLookNum" android:id="@+id/homeModuleArticleItemViewLookNum"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:text="2656" android:layout_marginEnd="70dp"
android:textSize="@dimen/platform_dp_12" tools:text="2656浏览"
android:textColor="@color/platform_color_242424"/> android:textSize="13sp"
android:textColor="#62636F"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<TextView <TextView
android:id="@+id/homeModuleArticleItemViewGreatNum"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="浏览" tools:text="3327点赞"
android:textSize="@dimen/platform_dp_11" android:textSize="13sp"
android:textColor="@color/platform_color_666666"/> android:textColor="#62636F"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<View <View
android:id="@+id/homeModuleArticleItemViewBottomLine" android:id="@+id/homeModuleArticleItemViewBottomLine"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0.5dp" android:layout_height="0.5dp"
android:background="@color/platform_color_EBEBEB" android:background="#EFEFF1"
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:layout_below="@+id/homeModuleArticleItemViewBottomLayout" android:layout_below="@+id/homeModuleArticleItemViewBottomLayout"
android:layout_marginTop="@dimen/platform_dp_16"/> android:layout_marginTop="20dp"
android:layout_marginBottom="30dp"/>
</RelativeLayout> </RelativeLayout>
...@@ -258,18 +258,6 @@ class HttpConfig { ...@@ -258,18 +258,6 @@ class HttpConfig {
}else{ }else{
AliYunRichLogsHelper.getInstance().sendRichLog(AliYunLogConfig.API, "writeMaiDianDataError:$api---params:$params ---- message:$message") AliYunRichLogsHelper.getInstance().sendRichLog(AliYunLogConfig.API, "writeMaiDianDataError:$api---params:$params ---- message:$message")
} }
}else{
var params = ""
if (request.method() == "GET") {
params = request.url().query().toString()
} else if (request.method() == "POST") {
params = RequestLogInterceptor.parseParams(request)
}
val message = originalResponse.message()
val api = request.url().encodedPath()
if (api.contains("maidian/writeMaiDianData")){
AliYunRichLogsHelper.getInstance().sendRichLog(AliYunLogConfig.API, "writeMaiDianDatacode$code:$api---params:$params ---- message:$message")
}
} }
} }
originalResponse originalResponse
......
package com.ydl.view
import android.os.Bundle
import android.util.DisplayMetrics
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.ImageView
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.fragment.app.DialogFragment
import com.blankj.utilcode.util.KeyboardUtils
import com.ydl.webview.R
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.remind.ToastHelper
class ArticleDialogFragment: DialogFragment() {
private lateinit var ivClose: ImageView
private lateinit var etComment: EditText
private lateinit var tvPublish: TextView
private lateinit var cslLayout:ConstraintLayout
private lateinit var mListener: OnPublishArticleCommentListener
private var mTitle:String = ""
fun setOnPublishListener(listener: OnPublishArticleCommentListener){
mListener = listener
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NO_TITLE, R.style.BottomDialogAnimation)
}
override fun onStart() {
super.onStart()
val displayMetrics = DisplayMetrics()
activity?.windowManager?.defaultDisplay?.getMetrics(displayMetrics)
val window = dialog?.window
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.layout_comment_article,container)
initView(view)
return view
}
private fun initView(view: View){
mTitle = arguments?.getString(KEY_ARTICLE_TITLE)?:""
ivClose = view.findViewById(R.id.iv_close_dialog)
etComment = view.findViewById(R.id.et_article_comment)
tvPublish = view.findViewById(R.id.tv_publish_comment)
cslLayout = view.findViewById(R.id.csl_root_layout)
cslLayout.setOnClickListener {
ActionCountUtils.record("article_detail_page","article_detail_cancelcomment_click",mTitle)
dismiss()
}
KeyboardUtils.showSoftInput(etComment)
ivClose.setOnClickListener {
ActionCountUtils.record("article_detail_page","article_detail_cancelcomment_click",mTitle)
dismiss()
}
tvPublish.setOnClickListener {
if (etComment.text.toString().isNullOrBlank()){
ToastHelper.show("评论内容不能为空~")
return@setOnClickListener
}
mListener.onPublishClick(etComment.text.toString())
ActionCountUtils.record("article_detail_page","article_detail_issuecomment_click",mTitle)
etComment.setText("")
dismiss()
}
}
override fun dismiss() {
KeyboardUtils.hideSoftInput(etComment)
super.dismiss()
}
companion object {
private const val KEY_ARTICLE_TITLE = "key_share_title"
@JvmStatic
fun newInstance(title: String): ArticleDialogFragment {
val args = Bundle()
args.putString(KEY_ARTICLE_TITLE, title)
val fragment = ArticleDialogFragment()
fragment.arguments = args
return fragment
}
}
interface OnPublishArticleCommentListener{
fun onPublishClick(comment:String)
}
}
\ No newline at end of file
...@@ -37,6 +37,7 @@ import com.umeng.socialize.bean.SHARE_MEDIA; ...@@ -37,6 +37,7 @@ import com.umeng.socialize.bean.SHARE_MEDIA;
import com.ydl.utils.PopUtils; import com.ydl.utils.PopUtils;
import com.ydl.utils.ProxyCheckUtils; import com.ydl.utils.ProxyCheckUtils;
import com.ydl.utils.WebUrlParamsUtils; import com.ydl.utils.WebUrlParamsUtils;
import com.ydl.view.ArticleDialogFragment;
import com.ydl.view.ShareMeditationDialog; import com.ydl.view.ShareMeditationDialog;
import com.ydl.ydl_router.manager.YDLRouterManager; import com.ydl.ydl_router.manager.YDLRouterManager;
import com.ydl.ydlcommon.base.BaseActivity; import com.ydl.ydlcommon.base.BaseActivity;
...@@ -128,6 +129,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -128,6 +129,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
private boolean isDarkMode = false; private boolean isDarkMode = false;
private ShareMeditationDialog shareMeditationDialog; private ShareMeditationDialog shareMeditationDialog;
private ArticleDialogFragment commentArticleDialog;
protected PopupWindow popupWindow; protected PopupWindow popupWindow;
...@@ -1543,4 +1545,19 @@ public class NewH5Activity extends BaseActivity implements PtrHandler { ...@@ -1543,4 +1545,19 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
} }
public void showCommentArticleDialog(String title){
if (commentArticleDialog == null) {
String titleStr = title==null?wv_content.getTitle():title;
commentArticleDialog = ArticleDialogFragment.newInstance(titleStr);
commentArticleDialog.setOnPublishListener(comment -> {
callJSFunc("sendComment('"+comment+"')");
});
}
if (commentArticleDialog != null && !commentArticleDialog.isAdded()) {
commentArticleDialog.show(getSupportFragmentManager(), "article_comment");
}
}
} }
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:ignore="MissingDefaultResource">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toYDelta="100%p" />
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="100%p"
android:interpolator="@android:anim/accelerate_interpolator"
android:toYDelta="0" />
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dp"/>
<solid android:color="#1DA1F2"/>
</shape>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M-13,-228h375v813h-375z"
android:strokeWidth="1"
android:fillColor="#FAFAFB"
android:fillType="evenOdd"
android:strokeColor="#00000000"/>
<path
android:pathData="M-13,-76h375v333h-375z"
android:strokeWidth="1"
android:fillColor="#FFFFFF"
android:fillType="evenOdd"
android:strokeColor="#00000000"/>
<path
android:pathData="M-14,-246h376v854h-376z"
android:strokeAlpha="0.452821"
android:strokeWidth="1"
android:fillColor="#000000"
android:fillType="evenOdd"
android:strokeColor="#00000000"
android:fillAlpha="0.452821"/>
<path
android:pathData="M-5,-15L355,-15C359.4183,-15 363,-11.4183 363,-7L363,262L363,262L-13,262L-13,-7C-13,-11.4183 -9.4183,-15 -5,-15Z"
android:strokeWidth="1"
android:fillColor="#000000"
android:fillType="evenOdd"
android:strokeColor="#00000000"/>
<path
android:pathData="M-5,-15L355,-15C359.4183,-15 363,-11.4183 363,-7L363,262L363,262L-13,262L-13,-7C-13,-11.4183 -9.4183,-15 -5,-15Z"
android:strokeWidth="1"
android:fillColor="#FFFFFF"
android:fillType="evenOdd"
android:strokeColor="#00000000"/>
<path
android:pathData="M6.6504,17.4636L17.6504,6.4636M17.6504,17.4636L6.6504,6.4636"
android:strokeWidth="1.8"
android:fillColor="#00000000"
android:strokeColor="#242424"
android:fillType="evenOdd"
android:strokeLineCap="round"/>
<path
android:pathData="M-13,-228h375v813h-375z"
android:strokeWidth="1"
android:fillColor="#FAFAFB"
android:fillType="evenOdd"
android:strokeColor="#00000000"/>
<path
android:pathData="M-13,-76h375v333h-375z"
android:strokeWidth="1"
android:fillColor="#FFFFFF"
android:fillType="evenOdd"
android:strokeColor="#00000000"/>
<path
android:pathData="M-14,-246h376v854h-376z"
android:strokeAlpha="0.452821"
android:strokeWidth="1"
android:fillColor="#000000"
android:fillType="evenOdd"
android:strokeColor="#00000000"
android:fillAlpha="0.452821"/>
<path
android:pathData="M-5,-15L355,-15C359.4183,-15 363,-11.4183 363,-7L363,262L363,262L-13,262L-13,-7C-13,-11.4183 -9.4183,-15 -5,-15Z"
android:strokeWidth="1"
android:fillColor="#000000"
android:fillType="evenOdd"
android:strokeColor="#00000000"/>
<path
android:pathData="M-5,-15L355,-15C359.4183,-15 363,-11.4183 363,-7L363,262L363,262L-13,262L-13,-7C-13,-11.4183 -9.4183,-15 -5,-15Z"
android:strokeWidth="1"
android:fillColor="#FFFFFF"
android:fillType="evenOdd"
android:strokeColor="#00000000"/>
<path
android:pathData="M6.6504,17.4636L17.6504,6.4636M17.6504,17.4636L6.6504,6.4636"
android:strokeWidth="1.8"
android:fillColor="#00000000"
android:strokeColor="#242424"
android:fillType="evenOdd"
android:strokeLineCap="round"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFFFF"/>
<corners
android:topLeftRadius="4dp"
android:topRightRadius="4dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/csl_root_layout">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/csl_comment_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_comment_article"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<ImageView
android:id="@+id/iv_close_dialog"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="2dp"
android:padding="13dp"
android:src="@drawable/article_close_dialog"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="发布评论"
android:textColor="#1C1F28"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@id/iv_close_dialog"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/iv_close_dialog" />
<TextView
android:id="@+id/tv_publish_comment"
android:layout_width="55dp"
android:layout_height="28dp"
android:layout_marginEnd="15dp"
android:background="@drawable/article_bg_publish"
android:gravity="center"
android:text="发布"
android:textColor="@color/white"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@id/iv_close_dialog"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/iv_close_dialog" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/et_article_comment"
android:layout_width="match_parent"
android:layout_height="240dp"
android:background="@null"
android:focusedByDefault="true"
android:gravity="start|top"
android:hint="说点什么吧..."
android:paddingHorizontal="20dp"
android:textColor="#1C1F28"
android:textColorHint="#C3C4CA"
android:textSize="16sp"
app:layout_constraintTop_toBottomOf="@id/iv_close_dialog"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -9,4 +9,18 @@ ...@@ -9,4 +9,18 @@
</style> </style>
<style name="BottomDialogAnimation" parent="Theme.Design.BottomSheetDialog">
<item name="android:windowIsFloating">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:background">@color/transparent</item>
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowFrame">@null</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowSoftInputMode">stateAlwaysVisible</item>
<item name="android:windowEnterAnimation">@anim/dialog_bottom_up</item>
<item name="android:windowExitAnimation">@anim/dialog_bottom_down</item>
</style>
</resources> </resources>
\ No newline at end of file
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