a
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
package com.bbgo.module_wechat
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.bbgo.wechat_module", appContext.packageName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.bbgo.module_wechat">
|
||||
|
||||
|
||||
|
||||
</manifest>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.bbgo.module_wechat
|
||||
|
||||
import com.bbgo.common_base.BaseApplication
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: wangyuebin
|
||||
* @Date: 2021/9/10 5:12 下午
|
||||
*/
|
||||
//@HiltAndroidApp
|
||||
class WeChatApp : BaseApplication() {
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.bbgo.module_wechat.activity
|
||||
|
||||
import com.bbgo.common_base.base.BaseActivity
|
||||
import com.bbgo.module_wechat.R
|
||||
import com.bbgo.module_wechat.databinding.FragmentWechatBinding
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
class WeChatMainActivity : BaseActivity<FragmentWechatBinding>() {
|
||||
override fun inflateViewBinding() = FragmentWechatBinding.inflate(layoutInflater)
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package com.bbgo.module_wechat.bean
|
||||
|
||||
import androidx.annotation.Keep
|
||||
|
||||
@Keep
|
||||
data class ArticleData(
|
||||
val curPage: Int,
|
||||
val datas: MutableList<ArticleDetail>,
|
||||
val offset: Int,
|
||||
val over: Boolean,
|
||||
val pageCount: Int,
|
||||
val size: Int,
|
||||
val total: Int
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class ArticleDetail(
|
||||
val apkLink: String,
|
||||
val audit: Int,
|
||||
val author: String,
|
||||
val canEdit: Boolean,
|
||||
val chapterId: Int,
|
||||
val chapterName: String,
|
||||
var collect: Boolean,
|
||||
val courseId: Int,
|
||||
val desc: String,
|
||||
val descMd: String,
|
||||
val envelopePic: String,
|
||||
val fresh: Boolean,
|
||||
val host: String,
|
||||
val id: Int,
|
||||
val link: String,
|
||||
val niceDate: String,
|
||||
val niceShareDate: String,
|
||||
val origin: String,
|
||||
val prefix: String,
|
||||
val projectLink: String,
|
||||
val publishTime: Long,
|
||||
val realSuperChapterId: Int,
|
||||
val selfVisible: Int,
|
||||
val shareDate: Long,
|
||||
val shareUser: String,
|
||||
val superChapterId: Int,
|
||||
val superChapterName: String,
|
||||
val tags: List<Tag>,
|
||||
val title: String,
|
||||
val type: Int,
|
||||
val userId: Int,
|
||||
val visible: Int,
|
||||
val zan: Int,
|
||||
var top: String,
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class Tag(
|
||||
val name: String,
|
||||
val url: String
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class WXArticle (
|
||||
val courseId: Int,
|
||||
val id: Int,
|
||||
val name: String,
|
||||
val order: Int,
|
||||
val parentChapterId: Int,
|
||||
val userControlSetTop: Boolean,
|
||||
val visible: Int
|
||||
)
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.bbgo.module_wechat.net.api
|
||||
|
||||
import com.bbgo.common_base.bean.HttpResult
|
||||
import com.bbgo.module_wechat.bean.ArticleData
|
||||
import com.bbgo.module_wechat.bean.WXArticle
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Path
|
||||
import retrofit2.http.Query
|
||||
|
||||
/**
|
||||
* author: wangyb
|
||||
* date: 4/7/21 9:24 PM
|
||||
* description: http api
|
||||
*/
|
||||
interface HttpWeChatApiService {
|
||||
|
||||
/**
|
||||
* 获取公众号列表
|
||||
* http://wanandroid.com/wxarticle/chapters/json
|
||||
*/
|
||||
@GET("wxarticle/chapters/json")
|
||||
fun getWXChapters(): Flow<HttpResult<List<WXArticle>>>
|
||||
|
||||
/**
|
||||
* 查看某个公众号历史数据
|
||||
* http://wanandroid.com/wxarticle/list/405/1/json
|
||||
* @param id 公众号 ID
|
||||
* @param page 公众号页码
|
||||
*/
|
||||
@GET("/wxarticle/list/{id}/{page}/json")
|
||||
fun getWXArticles(@Path("id") id: Int,
|
||||
@Path("page") page: Int): Flow<HttpResult<ArticleData>>
|
||||
|
||||
/**
|
||||
* 在某个公众号中搜索历史文章
|
||||
* http://wanandroid.com/wxarticle/list/405/1/json?k=Java
|
||||
* @param id 公众号 ID
|
||||
* @param key 搜索关键字
|
||||
* @param page 公众号页码
|
||||
*/
|
||||
@GET("/wxarticle/list/{id}/{page}/json")
|
||||
fun queryWXArticles(@Path("id") id: Int,
|
||||
@Query("k") key: String,
|
||||
@Path("page") page: Int): Flow<HttpResult<ArticleData>>
|
||||
|
||||
/**
|
||||
* 知识体系下的文章
|
||||
* http://www.wanandroid.com/article/list/0/json?cid=168
|
||||
* @param page
|
||||
* @param cid
|
||||
*/
|
||||
@GET("article/list/{page}/json")
|
||||
fun getKnowledgeList(@Path("page") page: Int, @Query("cid") cid: Int): Flow<HttpResult<ArticleData>>
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.bbgo.module_wechat.repository
|
||||
|
||||
import dagger.hilt.android.scopes.ActivityRetainedScoped
|
||||
import dagger.hilt.android.scopes.ActivityScoped
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
/**
|
||||
* author: wangyb
|
||||
* date: 3/30/21 2:36 PM
|
||||
* description: todo
|
||||
*/
|
||||
@ActivityRetainedScoped
|
||||
class WxLocalRepository @Inject constructor(){
|
||||
|
||||
|
||||
/*companion object {
|
||||
@Volatile
|
||||
private var repository: WxLocalRepository? = null
|
||||
|
||||
fun getInstance(): WxLocalRepository {
|
||||
if (repository == null) {
|
||||
synchronized(WxRepository::class.java) {
|
||||
if (repository == null) {
|
||||
repository = WxLocalRepository()
|
||||
}
|
||||
}
|
||||
}
|
||||
return repository!!
|
||||
}
|
||||
}*/
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.bbgo.module_wechat.repository
|
||||
|
||||
import com.bbgo.common_base.bean.HttpResult
|
||||
import com.bbgo.common_base.net.ServiceCreators
|
||||
import com.bbgo.module_wechat.bean.ArticleData
|
||||
import com.bbgo.module_wechat.bean.WXArticle
|
||||
import com.bbgo.module_wechat.net.api.HttpWeChatApiService
|
||||
import dagger.hilt.android.scopes.ActivityRetainedScoped
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* author: wangyb
|
||||
* date: 3/30/21 2:35 PM
|
||||
* description: todo
|
||||
*/
|
||||
@ActivityRetainedScoped
|
||||
class WxRemoteRepository @Inject constructor() {
|
||||
|
||||
private val service = ServiceCreators.create(HttpWeChatApiService::class.java)
|
||||
|
||||
fun getWXChapters() : Flow<HttpResult<List<WXArticle>>> {
|
||||
return service.getWXChapters()
|
||||
}
|
||||
|
||||
fun getWXArticles(id: Int, page: Int) : Flow<HttpResult<ArticleData>> {
|
||||
return service.getWXArticles(id, page)
|
||||
}
|
||||
|
||||
fun getKnowledgeList(id: Int, page: Int) : Flow<HttpResult<ArticleData>> {
|
||||
return service.getKnowledgeList(id, page)
|
||||
}
|
||||
|
||||
/********************静态内部类单例***************************/
|
||||
/*companion object {
|
||||
val instance = SingleTonHolder.holder
|
||||
}
|
||||
|
||||
private object SingleTonHolder {
|
||||
val holder = WxRemoteRepository()
|
||||
}*/
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.bbgo.module_wechat.repository
|
||||
|
||||
import com.bbgo.common_base.bean.HttpResult
|
||||
import com.bbgo.module_wechat.bean.ArticleData
|
||||
import com.bbgo.module_wechat.bean.WXArticle
|
||||
import dagger.hilt.android.scopes.ActivityRetainedScoped
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* author: wangyb
|
||||
* date: 3/29/21 9:32 PM
|
||||
* description: todo
|
||||
*/
|
||||
@ActivityRetainedScoped
|
||||
class WxRepository @Inject constructor(private val remoteRepository: WxRemoteRepository, private val localRepository: WxLocalRepository) {
|
||||
|
||||
fun getWXChapters() : Flow<HttpResult<List<WXArticle>>> {
|
||||
return remoteRepository.getWXChapters()
|
||||
}
|
||||
|
||||
fun getWXArticles(id: Int, page: Int) : Flow<HttpResult<ArticleData>> {
|
||||
return remoteRepository.getWXArticles(id, page)
|
||||
}
|
||||
|
||||
fun getKnowledgeList(id: Int, page: Int) : Flow<HttpResult<ArticleData>> {
|
||||
return remoteRepository.getKnowledgeList(id, page)
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.bbgo.module_wechat.ui
|
||||
|
||||
import android.text.Html
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import com.bbgo.common_base.util.ImageLoader
|
||||
import com.bbgo.module_wechat.R
|
||||
import com.bbgo.module_wechat.bean.ArticleDetail
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.viewholder.BaseViewHolder
|
||||
|
||||
|
||||
class ArticleListAdapter(datas: MutableList<ArticleDetail>)
|
||||
: BaseQuickAdapter<ArticleDetail, BaseViewHolder>(R.layout.item_article_list, datas) {
|
||||
|
||||
override fun convert(holder: BaseViewHolder, item: ArticleDetail) {
|
||||
val authorStr = if (item.author.isNotEmpty()) item.author else item.shareUser
|
||||
holder.setText(R.id.tv_article_title, Html.fromHtml(item.title))
|
||||
.setText(R.id.tv_article_author, authorStr)
|
||||
.setText(R.id.tv_article_date, item.niceDate)
|
||||
.setImageResource(R.id.iv_like,
|
||||
if (item.collect) R.drawable.ic_like else R.drawable.ic_like_not
|
||||
)
|
||||
val chapterName = when {
|
||||
item.superChapterName.isNotEmpty() and item.chapterName.isNotEmpty() ->
|
||||
"${item.superChapterName} / ${item.chapterName}"
|
||||
item.superChapterName.isNotEmpty() -> item.superChapterName
|
||||
item.chapterName.isNotEmpty() -> item.chapterName
|
||||
else -> ""
|
||||
}
|
||||
holder.setText(R.id.tv_article_chapterName, chapterName)
|
||||
|
||||
if (!TextUtils.isEmpty(item.envelopePic)) {
|
||||
holder.getView<ImageView>(R.id.iv_article_thumbnail)
|
||||
.visibility = View.VISIBLE
|
||||
ImageLoader.load(context, item.envelopePic, holder.getView(R.id.iv_article_thumbnail))
|
||||
} else {
|
||||
holder.getView<ImageView>(R.id.iv_article_thumbnail)
|
||||
.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+247
@@ -0,0 +1,247 @@
|
||||
package com.bbgo.module_wechat.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.lifecycle.*
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.alibaba.android.arouter.facade.annotation.Autowired
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.bbgo.common_base.base.BaseFragment
|
||||
import com.bbgo.common_base.bus.BusKey
|
||||
import com.bbgo.common_base.bus.LiveDataBus
|
||||
import com.bbgo.common_base.constants.Constants
|
||||
import com.bbgo.common_base.constants.RouterPath
|
||||
import com.bbgo.common_base.event.MessageEvent
|
||||
import com.bbgo.common_base.event.ScrollEvent
|
||||
import com.bbgo.common_base.ext.Resource
|
||||
import com.bbgo.common_base.ext.showToast
|
||||
import com.bbgo.common_base.util.log.Logs
|
||||
import com.bbgo.common_base.widget.SpaceItemDecoration
|
||||
import com.bbgo.common_service.collect.CollectService
|
||||
import com.bbgo.module_wechat.R
|
||||
import com.bbgo.module_wechat.bean.ArticleDetail
|
||||
import com.bbgo.module_wechat.databinding.FragmentArticleListBinding
|
||||
import com.bbgo.module_wechat.viewmodel.WeChatViewModel
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* Created by wangyb
|
||||
*/
|
||||
@AndroidEntryPoint
|
||||
class ArticleListFragment : BaseFragment<FragmentArticleListBinding>() {
|
||||
|
||||
companion object {
|
||||
fun getInstance(cid: Int): ArticleListFragment {
|
||||
val fragment = ArticleListFragment()
|
||||
val args = Bundle()
|
||||
args.putInt(Constants.CONTENT_CID_KEY, cid)
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
lateinit var collectService: CollectService
|
||||
|
||||
/**
|
||||
* 在这里不使用委托方式by 来创建viewmodel,是因为该方式只会创建一个viewmodel实例
|
||||
* 多个fragment需要多个viewmodel实例
|
||||
*/
|
||||
private lateinit var weChatViewModel: WeChatViewModel
|
||||
|
||||
/**
|
||||
* cid
|
||||
*/
|
||||
private var cid: Int = 0
|
||||
|
||||
/**
|
||||
* 是否是下拉刷新
|
||||
*/
|
||||
private var isRefresh = true
|
||||
|
||||
/**
|
||||
* datas
|
||||
*/
|
||||
private val articleList = mutableListOf<ArticleDetail>()
|
||||
|
||||
/**
|
||||
* RecyclerView Divider
|
||||
*/
|
||||
private val recyclerViewItemDecoration by lazy {
|
||||
activity?.let {
|
||||
SpaceItemDecoration(it)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* LinearLayoutManager
|
||||
*/
|
||||
private val linearLayoutManager: LinearLayoutManager by lazy {
|
||||
LinearLayoutManager(activity)
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapter
|
||||
*/
|
||||
private val mAdapter: ArticleListAdapter by lazy {
|
||||
ArticleListAdapter(articleList)
|
||||
}
|
||||
|
||||
/**
|
||||
* RefreshListener
|
||||
*/
|
||||
private val onRefreshListener = SwipeRefreshLayout.OnRefreshListener {
|
||||
binding.swipeRefreshLayout.isRefreshing = false
|
||||
isRefresh = true
|
||||
}
|
||||
|
||||
|
||||
override fun initView() {
|
||||
binding.recyclerView.post {
|
||||
Logs.d("width = ${binding.recyclerView.width}")
|
||||
Logs.d("height = ${binding.recyclerView.height}")
|
||||
}
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
Logs.d("width handler = ${binding.recyclerView.width}")
|
||||
Logs.d("height handler = ${binding.recyclerView.height}")
|
||||
}
|
||||
ARouter.getInstance().inject(this)
|
||||
|
||||
cid = arguments?.getInt(Constants.CONTENT_CID_KEY) ?: 0
|
||||
binding.swipeRefreshLayout.setOnRefreshListener(onRefreshListener)
|
||||
binding.recyclerView.run {
|
||||
layoutManager = linearLayoutManager
|
||||
adapter = mAdapter
|
||||
itemAnimator = DefaultItemAnimator()
|
||||
recyclerViewItemDecoration?.let { addItemDecoration(it) }
|
||||
}
|
||||
|
||||
mAdapter.run {
|
||||
setOnItemClickListener { adapter, view, position ->
|
||||
val article = articleList[position]
|
||||
ARouter.getInstance().build(RouterPath.Content.PAGE_CONTENT)
|
||||
.withString(Constants.POSITION, position.toString())
|
||||
.withString(Constants.CONTENT_ID_KEY, article.id.toString())
|
||||
.withString(Constants.CONTENT_TITLE_KEY, article.title)
|
||||
.withString(Constants.CONTENT_URL_KEY, article.link)
|
||||
.withString(Constants.COLLECT, article.collect.toString())
|
||||
.navigation()
|
||||
}
|
||||
addChildClickViewIds(R.id.iv_like)
|
||||
setOnItemChildClickListener { adapter, view, position ->
|
||||
if (view.id == R.id.iv_like) {
|
||||
val article = articleList[position]
|
||||
if (article.collect) {
|
||||
collectService.unCollect(
|
||||
Constants.FragmentIndex.WECHAT_INDEX,
|
||||
position,
|
||||
articleList[position].id
|
||||
)
|
||||
return@setOnItemChildClickListener
|
||||
}
|
||||
collectService.collect(
|
||||
Constants.FragmentIndex.WECHAT_INDEX,
|
||||
position,
|
||||
articleList[position].id
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
weChatViewModel = ViewModelProvider(this).get(WeChatViewModel::class.java)
|
||||
|
||||
initBus()
|
||||
}
|
||||
|
||||
override fun lazyLoad() {
|
||||
weChatViewModel.getWXArticles(cid, 0)
|
||||
}
|
||||
|
||||
override fun observe() {
|
||||
lifecycleScope.launch {
|
||||
/**
|
||||
* 如果只收集一个stateFlow的数据,则可以使用flowWithLifecycle
|
||||
* 操作符决定生命周期
|
||||
*
|
||||
*/
|
||||
weChatViewModel.wxArticlesUiState
|
||||
.flowWithLifecycle(lifecycle, Lifecycle.State.STARTED)
|
||||
.collectLatest {
|
||||
handleInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化事件总线,和eventbus效果相同
|
||||
*/
|
||||
private fun initBus() {
|
||||
LiveDataBus.get().with(BusKey.COLLECT, MessageEvent::class.java).observe(this) {
|
||||
if (it.indexPage == Constants.FragmentIndex.WECHAT_INDEX) {
|
||||
handleCollect(it)
|
||||
}
|
||||
}
|
||||
LiveDataBus.get().with(BusKey.SCROLL_TOP, ScrollEvent::class.java).observe(this) {
|
||||
if (it.index == 1) {
|
||||
scrollToTop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleCollect(event: MessageEvent) {
|
||||
when (event.type) {
|
||||
Constants.CollectType.UNKNOWN -> {
|
||||
ARouter.getInstance().build(RouterPath.LoginRegister.PAGE_LOGIN).navigation()
|
||||
}
|
||||
else -> {
|
||||
if (articleList.isEmpty()) {
|
||||
return
|
||||
}
|
||||
if (event.type == Constants.CollectType.COLLECT) {
|
||||
showToast(getString(R.string.collect_success))
|
||||
articleList[event.position].collect = true
|
||||
mAdapter.setList(articleList)
|
||||
return
|
||||
}
|
||||
articleList[event.position].collect = false
|
||||
mAdapter.setList(articleList)
|
||||
showToast(getString(R.string.cancel_collect_success))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleInfo(status: Resource<MutableList<ArticleDetail>>) {
|
||||
if (status !is Resource.Success) return
|
||||
articleList.clear()
|
||||
articleList.addAll(status.data)
|
||||
mAdapter.run {
|
||||
if (isRefresh) {
|
||||
setList(articleList)
|
||||
} else {
|
||||
addData(articleList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun scrollToTop() {
|
||||
binding.recyclerView.run {
|
||||
if (linearLayoutManager.findFirstVisibleItemPosition() > 20) {
|
||||
scrollToPosition(0)
|
||||
} else {
|
||||
smoothScrollToPosition(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun inflateViewBinding(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?
|
||||
) = FragmentArticleListBinding.inflate(inflater, container, false)
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
package com.bbgo.module_wechat.ui
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.flowWithLifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.bbgo.common_base.base.BaseFragment
|
||||
import com.bbgo.common_base.constants.RouterPath
|
||||
import com.bbgo.common_base.databinding.LayoutLoadingBinding
|
||||
import com.bbgo.common_base.ext.Resource
|
||||
import com.bbgo.common_base.ext.showToast
|
||||
import com.bbgo.common_base.util.log.Logs
|
||||
import com.bbgo.module_wechat.bean.WXArticle
|
||||
import com.bbgo.module_wechat.databinding.FragmentWechatBinding
|
||||
import com.bbgo.module_wechat.viewmodel.WeChatViewModel
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* author: wangyb
|
||||
* date: 2021/5/20 3:04 下午
|
||||
* description: todo
|
||||
*/
|
||||
@Route(path = RouterPath.WeChat.PAGE_WECHAT)
|
||||
@AndroidEntryPoint
|
||||
class WeChatFragment : BaseFragment<FragmentWechatBinding>() {
|
||||
|
||||
private lateinit var loadingBinding: LayoutLoadingBinding
|
||||
|
||||
private val weChatViewModel: WeChatViewModel by activityViewModels()
|
||||
|
||||
/**
|
||||
* datas
|
||||
*/
|
||||
private val weChatDatas = mutableListOf<WXArticle>()
|
||||
|
||||
/**
|
||||
* ViewPagerAdapter
|
||||
*/
|
||||
private val viewPagerAdapter: WeChatPagerAdapter by lazy {
|
||||
WeChatPagerAdapter(this)
|
||||
}
|
||||
|
||||
override fun lazyLoad() {
|
||||
weChatViewModel.getWXChapters()
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
loadingBinding = LayoutLoadingBinding.bind(binding.root)
|
||||
binding.viewPager.adapter = viewPagerAdapter
|
||||
TabLayoutMediator(binding.tabLayout, binding.viewPager, true, true) { tab, position ->
|
||||
tab.text = weChatDatas[position].name
|
||||
}.attach()
|
||||
}
|
||||
|
||||
override fun observe() {
|
||||
/**
|
||||
* 如果只收集一个stateFlow的数据,则可以使用flowWithLifecycle
|
||||
* 操作符决定生命周期
|
||||
*
|
||||
*/
|
||||
lifecycleScope.launch {
|
||||
weChatViewModel.wxChapterUiState.flowWithLifecycle(lifecycle, Lifecycle.State.STARTED)
|
||||
.collectLatest {
|
||||
handleWxChapter(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleWxChapter(status: Resource<List<WXArticle>>) {
|
||||
when(status) {
|
||||
is Resource.Loading -> {
|
||||
Logs.d("Resource.Loading")
|
||||
loadingBinding.progressBar.visibility = View.VISIBLE
|
||||
}
|
||||
is Resource.Error -> {
|
||||
loadingBinding.progressBar.visibility = View.GONE
|
||||
showToast(status.exception.toString())
|
||||
}
|
||||
is Resource.Success -> {
|
||||
loadingBinding.progressBar.visibility = View.GONE
|
||||
weChatDatas.addAll(status.data)
|
||||
viewPagerAdapter.setList(weChatDatas)
|
||||
binding.viewPager.offscreenPageLimit = weChatDatas.size
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "WeChatFragment"
|
||||
}
|
||||
|
||||
override fun inflateViewBinding(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?
|
||||
) = FragmentWechatBinding.inflate(inflater, container, false)
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.bbgo.module_wechat.ui
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import com.bbgo.module_wechat.bean.WXArticle
|
||||
|
||||
/**
|
||||
* @author chenxz
|
||||
* @date 2018/10/28
|
||||
* @desc
|
||||
*/
|
||||
class WeChatPagerAdapter(fm: Fragment)
|
||||
: FragmentStateAdapter(fm) {
|
||||
|
||||
private val fragments = mutableListOf<Fragment>()
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return fragments.size
|
||||
}
|
||||
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
return fragments[position]
|
||||
}
|
||||
|
||||
fun setList(list: List<WXArticle>) {
|
||||
fragments.clear()
|
||||
list.forEach {
|
||||
fragments.add(ArticleListFragment.getInstance(it.id))
|
||||
}
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package com.bbgo.module_wechat.viewmodel
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.bbgo.common_base.ext.HTTP_REQUEST_ERROR
|
||||
import com.bbgo.common_base.ext.Resource
|
||||
import com.bbgo.common_base.util.log.Logs
|
||||
import com.bbgo.module_wechat.bean.ArticleDetail
|
||||
import com.bbgo.module_wechat.bean.WXArticle
|
||||
import com.bbgo.module_wechat.repository.WxRepository
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* author: wangyb
|
||||
* date: 3/29/21 9:31 PM
|
||||
* description: todo
|
||||
*/
|
||||
@HiltViewModel
|
||||
class WeChatViewModel @Inject constructor(private val repository: WxRepository) : ViewModel() {
|
||||
|
||||
val wxChapterUiState = MutableStateFlow<Resource<List<WXArticle>>>(Resource.Loading())
|
||||
|
||||
val wxArticlesUiState = MutableStateFlow<Resource<MutableList<ArticleDetail>>>(Resource.Loading())
|
||||
|
||||
fun getWXChapters() = viewModelScope.launch {
|
||||
/**
|
||||
* 1.必须要有异常处理
|
||||
* 2.必须要有collect,否则map里面的代码不执行
|
||||
*/
|
||||
repository.getWXChapters()
|
||||
.map {
|
||||
if (it.errorCode == HTTP_REQUEST_ERROR) {
|
||||
Resource.Error(Exception(it.errorMsg))
|
||||
} else {
|
||||
Resource.Success(it.data)
|
||||
}
|
||||
}
|
||||
.catch {
|
||||
}
|
||||
.collectLatest {
|
||||
wxChapterUiState.value = it
|
||||
}
|
||||
}
|
||||
|
||||
fun getWXArticles(id: Int, page: Int) = viewModelScope.launch {
|
||||
/**
|
||||
* 1.必须要有异常处理
|
||||
* 2.必须要有collect,否则map里面的代码不执行
|
||||
*/
|
||||
repository.getWXArticles(id, page)
|
||||
.map {
|
||||
if (it.errorCode == HTTP_REQUEST_ERROR) {
|
||||
Resource.Error(Exception(it.errorMsg))
|
||||
} else {
|
||||
Resource.Success(it.data.datas)
|
||||
}
|
||||
}
|
||||
.catch {
|
||||
Logs.e(it, it.message)
|
||||
}
|
||||
.collectLatest {
|
||||
wxArticlesUiState.value = it
|
||||
}
|
||||
}
|
||||
|
||||
private val TAG = "WeChatViewModel"
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.bbgo.module_wechat">
|
||||
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- 配置权限,用来记录应用配置信息 -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 重力加速度传感器权限 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- Android8.0安装apk需要请求安装权限 -->
|
||||
<uses-permission android:name="android.permission.VIBRATE" /> <!-- 小米push -->
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.REORDER_TASKS" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.hardware.sensor.accelerometer" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.FLASHLIGHT" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
||||
|
||||
<application
|
||||
android:name=".WeChatApp"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<activity
|
||||
android:name=".activity.WeChatMainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<stroke android:color="@color/Red"
|
||||
android:width="@dimen/dp_05"/>
|
||||
|
||||
<corners android:radius="@dimen/dp_2" />
|
||||
|
||||
</shape>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<stroke
|
||||
android:width="@dimen/dp_05"
|
||||
android:color="@color/colorAccent" />
|
||||
|
||||
<corners android:radius="@dimen/dp_2" />
|
||||
|
||||
</shape>
|
||||
@@ -0,0 +1,11 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="#00BCD4"
|
||||
android:alpha="0.8">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,11 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="#9E9E9E"
|
||||
android:alpha="0.8">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M22,9.24l-7.19,-0.62L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21 12,17.27 18.18,21l-1.63,-7.03L22,9.24zM12,15.4l-3.76,2.27 1,-4.28 -3.32,-2.88 4.38,-0.38L12,6.1l1.71,4.04 4.38,0.38 -3.32,2.88 1,4.28L12,15.4z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="com.bbgo.module_wechat.ui.WeChatFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</fragment>
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?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">
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeRefreshLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/viewBackground">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
style="@style/RecyclerViewStyle"
|
||||
tools:listitem="@layout/item_article_list" />
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="64dp"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"
|
||||
android:indeterminateTint="@color/colorPrimary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/viewBackground"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tabLayout"
|
||||
style="@style/MyTabLayoutStyle"
|
||||
android:theme="@style/AppTheme.AppBarOverlay"
|
||||
android:layout_height="0dp"
|
||||
app:tabGravity="center"
|
||||
app:tabMode="scrollable"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintHeight_percent="0.06" />
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
app:layout_constraintTop_toBottomOf="@id/tabLayout"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintHeight_percent="0.94"/>
|
||||
|
||||
<include layout="@layout/layout_loading" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView 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:id="@+id/cardView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
app:cardBackgroundColor="@color/viewBackground"
|
||||
app:cardCornerRadius="@dimen/dp_1"
|
||||
app:cardElevation="@dimen/dp_1">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/item_content_padding"
|
||||
android:paddingRight="@dimen/item_content_padding"
|
||||
android:paddingBottom="@dimen/item_content_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_article_author"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_10"
|
||||
android:textColor="@color/item_author"
|
||||
android:textSize="@dimen/item_tv_author"
|
||||
tools:text="@string/app_name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_article_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:textColor="@color/item_date"
|
||||
android:textSize="@dimen/item_tv_date"
|
||||
tools:text="@string/app_name" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_article_thumbnail"
|
||||
android:layout_width="@dimen/item_img_width"
|
||||
android:layout_height="@dimen/item_img_height"
|
||||
android:layout_below="@+id/tv_article_author"
|
||||
android:layout_marginLeft="@dimen/dp_10"
|
||||
android:layout_marginTop="@dimen/dp_8"
|
||||
android:scaleType="centerCrop"
|
||||
app:srcCompat="@drawable/bg_placeholder" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_article_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/tv_article_author"
|
||||
android:layout_marginLeft="@dimen/dp_10"
|
||||
android:layout_marginTop="@dimen/dp_8"
|
||||
android:layout_toRightOf="@+id/iv_article_thumbnail"
|
||||
android:ellipsize="end"
|
||||
android:gravity="top|start"
|
||||
android:lineSpacingExtra="2dp"
|
||||
android:maxLines="2"
|
||||
android:paddingBottom="@dimen/dp_6"
|
||||
android:textColor="@color/item_title"
|
||||
android:textSize="@dimen/item_tv_title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_article_chapterName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/tv_article_title"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginStart="@dimen/dp_10"
|
||||
android:layout_marginLeft="@dimen/dp_10"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:layout_marginEnd="@dimen/dp_10"
|
||||
android:layout_marginRight="@dimen/dp_10"
|
||||
android:layout_toRightOf="@+id/iv_article_thumbnail"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/item_chapter"
|
||||
android:textSize="@dimen/item_tv_tag"
|
||||
tools:text="@string/app_name" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_like"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_like_not" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/colorPrimary"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1,16 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.WanAndroid" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_200</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/black</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_200</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,7 @@
|
||||
<resources>
|
||||
<string name="app_name">微信公众号模块</string>
|
||||
<string name="collect_success">收藏成功</string>
|
||||
<string name="cancel_collect_success">已取消收藏</string>
|
||||
<string name="new_fresh">新</string>
|
||||
<string name="top_tip">置顶</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,16 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.WanAndroid" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_500</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.bbgo.module_wechat
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user