(R.layout.item_home_article) {
19 | override fun convert(
20 | helper: BaseViewHolder,
21 | item: Datas
22 | ) {
23 | helper.setText(R.id.tv_title, item.title)
24 | helper.setText(R.id.tv_create_time, item.niceDate + " " + item.author)
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/ui/adapter/BannerAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.ui.adapter
2 |
3 | import android.view.View
4 | import com.wsg.up.R
5 | import com.wsg.up.entity.BannerChildData
6 | import com.zhpan.bannerview.BaseBannerAdapter
7 | import com.zhpan.bannerview.BaseViewHolder
8 |
9 | /**
10 | *
11 | * Created by zhpan on 2020/4/6.
12 | * Description:
13 |
*
14 | */
15 | class BannerAdapter() : BaseBannerAdapter>() {
16 |
17 | override fun onBind(
18 | holder: BaseViewHolder?,
19 | data: BannerChildData?,
20 | position: Int,
21 | pageSize: Int
22 | ) {
23 | holder!!.bindData(data, position, pageSize)
24 | }
25 |
26 | override fun createViewHolder(
27 | itemView: View?,
28 | viewType: Int
29 | ): BannerViewHolder? {
30 | return BannerViewHolder(itemView!!)
31 | }
32 |
33 | override fun getLayoutId(viewType: Int): Int {
34 | return R.layout.item_banner
35 | }
36 |
37 |
38 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/ui/adapter/BannerViewHolder.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.ui.adapter
2 |
3 | import android.view.View
4 | import android.widget.ImageView
5 | import coil.api.load
6 | import coil.transform.RoundedCornersTransformation
7 | import com.wsg.up.R
8 | import com.wsg.up.entity.BannerChildData
9 | import com.zhpan.bannerview.BaseViewHolder
10 |
11 | /**
12 | * ================================================
13 | * 作 者:wushaoge
14 | * 版 本:1.0
15 | * 创建日期:2020年07月30日11:08:53
16 | * 描 述:
17 | * 修订历史:
18 | * ================================================
19 | */
20 | class BannerViewHolder(itemView: View) :
21 | BaseViewHolder(itemView) {
22 |
23 | override fun bindData(data: BannerChildData?, position: Int, pageSize: Int) {
24 | val imageView = findView(R.id.banner_image)
25 | imageView.load(data?.imagePath) {
26 | crossfade(true)
27 | transformations(RoundedCornersTransformation(5f))
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/ui/adapter/HomePagerAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.ui.adapter
2 |
3 | import android.content.Context
4 | import androidx.annotation.Nullable
5 | import androidx.fragment.app.Fragment
6 | import androidx.fragment.app.FragmentManager
7 | import androidx.fragment.app.FragmentPagerAdapter
8 | import com.wsg.up.ui.fragment.base.MyBaseFragment
9 |
10 | /**
11 | * ================================================
12 | * 作 者:wushaoge
13 | * 版 本:1.0
14 | * 创建日期:2020-07-27 16:48
15 | * 描 述:
16 | * 修订历史:
17 | * ================================================
18 | */
19 | class HomePagerAdapter: FragmentPagerAdapter {
20 |
21 | private var mFragmentList: ArrayList? = null
22 | private var mContext: Context? = null
23 |
24 | constructor(
25 | fm: FragmentManager?,
26 | list: ArrayList
27 | ): super(fm!!, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT){
28 | mFragmentList = list
29 | }
30 |
31 | constructor(
32 | context: Context?,
33 | fm: FragmentManager?,
34 | list: ArrayList?
35 | ) : super(fm!!, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT){
36 | mFragmentList = list
37 | mContext = context
38 | }
39 |
40 | override fun getItem(position: Int): Fragment {
41 | return mFragmentList!![position]
42 | }
43 |
44 | override fun getCount(): Int {
45 | return mFragmentList!!.size
46 | }
47 |
48 | @Nullable
49 | override fun getPageTitle(position: Int): CharSequence? {
50 | return mFragmentList!![position].getTitle()
51 | }
52 |
53 |
54 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/ui/fragment/ChannelFragment.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.ui.fragment
2 | import android.os.Bundle
3 | import android.view.View
4 | import com.wsg.base.ext.setViewsOnClickListener
5 | import com.wsg.base.ext.showToast
6 | import com.wsg.up.R
7 | import com.wsg.up.ext.showConfirmDialog
8 | import com.wsg.up.ext.showProgressDialog
9 | import com.wsg.up.ui.fragment.base.MyBaseFragment
10 | import kotlinx.android.synthetic.main.fragment_channel.*
11 |
12 |
13 | /**
14 | * ================================================
15 | * 作 者:wushaoge
16 | * 版 本:1.0
17 | * 创建日期:2020-07-27 16:33
18 | * 描 述:测试用可以无视
19 | * 修订历史:
20 | * ================================================
21 | */
22 | class ChannelFragment: MyBaseFragment(){
23 |
24 | companion object{
25 | fun newInstance(title: String?): ChannelFragment {
26 | val fragment = ChannelFragment()
27 | val args = Bundle()
28 | fragment.setTitle(title)
29 | args.putString("", title)
30 | fragment.arguments = args
31 | return fragment
32 | }
33 | }
34 |
35 | override fun getLayoutID(): Int {
36 | return R.layout.fragment_channel
37 | }
38 |
39 | override fun initViewModel() {
40 |
41 | }
42 |
43 | override fun initView() {
44 | setViewsOnClickListener(this, ll_zhengyi, ll_fanju, ll_donghua, ll_yinyue, ll_wudao, ll_youxi, ll_yule, ll_keji, ll_yingshi, ll_tiyu, ll_yutang, ll_shenghuo, ll_guichu, ll_xuniouxiang)
45 | }
46 |
47 | override fun initData() {
48 | }
49 |
50 | override fun initMainNetData() {
51 | }
52 |
53 | override fun initLazyData() {
54 |
55 | }
56 |
57 | override fun onClick(v: View?) {
58 | when (v) {
59 | ll_zhengyi -> {
60 | // MyProgressDialog(mContext, "加载中").show()
61 | mContext.showProgressDialog {
62 | setLoadingMsg("啦啦啦")
63 | }
64 | }
65 | ll_fanju -> {
66 | // MyConfirmDialog(mContext, "拨打电话", "斯蒂芬斯蒂芬", { mContext.showToast("点击了确定") }, ::test ).show()
67 | mContext.showConfirmDialog {
68 | title {
69 | "标题题题"
70 | }
71 | content = "多线程必须从"
72 | onOkClick {
73 | showToast("点击了确认")
74 | }
75 | onCancelClick {
76 | test()
77 | }
78 | }
79 | }
80 | ll_donghua -> {
81 |
82 | }
83 | }
84 | }
85 |
86 |
87 |
88 | fun test(){
89 | showToast("点击了取消")
90 | }
91 |
92 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/ui/fragment/FindFragment.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.ui.fragment
2 | import android.os.Bundle
3 | import android.view.View
4 | import androidx.recyclerview.widget.StaggeredGridLayoutManager
5 | import com.scwang.smartrefresh.layout.api.RefreshLayout
6 | import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener
7 | import com.scwang.smartrefresh.layout.listener.OnRefreshListener
8 | import com.wsg.base.ext.getViewModel
9 | import com.wsg.base.ext.showToast
10 | import com.wsg.base.ext.vmObserverDefault
11 | import com.wsg.base.ext.vmObserverMain
12 | import com.wsg.up.R
13 | import com.wsg.up.ui.adapter.CommunityAdapter
14 | import com.wsg.up.ui.fragment.base.MyBaseFragment
15 | import com.wsg.up.utils.Tools
16 | import com.wsg.up.viewmodel.EyeViewModel
17 | import kotlinx.android.synthetic.main.fragment_find.*
18 |
19 |
20 | /**
21 | * ================================================
22 | * 作 者:wushaoge
23 | * 版 本:1.0
24 | * 创建日期:2020-07-27 16:33
25 | * 描 述:
26 | * 修订历史:
27 | * ================================================
28 | */
29 | class FindFragment: MyBaseFragment(), OnRefreshListener, OnLoadMoreListener {
30 |
31 | lateinit var mViewModel: EyeViewModel
32 |
33 | lateinit var adapter: CommunityAdapter
34 |
35 | var nextPage = ""
36 |
37 | companion object{
38 | fun newInstance(title: String?): FindFragment {
39 | val fragment = FindFragment()
40 | val args = Bundle()
41 | fragment.setTitle(title)
42 | args.putString("", title)
43 | fragment.arguments = args
44 | return fragment
45 | }
46 | }
47 |
48 | override fun isShowLoading(): Boolean {
49 | return true
50 | }
51 |
52 | override fun getLayoutID(): Int {
53 | return R.layout.fragment_find
54 | }
55 |
56 | override fun initViewModel() {
57 | mViewModel = getViewModel()
58 | }
59 |
60 | override fun initView() {
61 | srl_content.setOnRefreshListener(this)
62 | srl_content.setOnLoadMoreListener(this)
63 |
64 | adapter = CommunityAdapter(mContext)
65 | val mainLayoutManager = StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)
66 | mainLayoutManager.gapStrategy = StaggeredGridLayoutManager.GAP_HANDLING_NONE
67 | rv_content.layoutManager = mainLayoutManager
68 | rv_content.adapter = adapter
69 | rv_content.setHasFixedSize(true)
70 | rv_content.itemAnimator = null
71 | }
72 |
73 | override fun initData() {
74 | mViewModel.refreshData.vmObserverMain(this,
75 | onSuccess = {
76 | nextPage = it.nextPageUrl!!
77 | val data = it.itemList!!.filter { it.type == "communityColumnsCard"}
78 | if (data.isNotEmpty()) {
79 | adapter.setList(data!!)
80 | } else {
81 | adapter.setNewInstance(null)
82 | adapter.setEmptyView(Tools.getEmptyView(mContext))
83 | }
84 | },
85 | onComplete = {
86 | stopLoad(srl_content)
87 | }
88 | )
89 |
90 | mViewModel.loadMoreData.vmObserverDefault(this,
91 | onSuccess = {
92 | nextPage = it.nextPageUrl!!
93 | adapter.removeEmptyView()
94 | val data = it.itemList!!.filter { it.type == "communityColumnsCard"}
95 | if (data.isNotEmpty()) {
96 | adapter.addData(data)
97 | } else {
98 | mContext.showToast("暂无更多数据")
99 | }
100 | },
101 | onComplete = {
102 | stopLoad(srl_content)
103 | }
104 | )
105 | }
106 |
107 | override fun initMainNetData() {
108 | mViewModel.onRefresh()
109 | }
110 |
111 | override fun initLazyData() {
112 |
113 | }
114 |
115 | override fun onClick(v: View?) {
116 |
117 | }
118 |
119 | override fun onRefresh(refreshLayout: RefreshLayout) {
120 | mViewModel.onRefresh()
121 | }
122 |
123 | override fun onLoadMore(refreshLayout: RefreshLayout) {
124 | if(nextPage.isNotEmpty()){
125 | mViewModel.onLoadMore(nextPage)
126 | }
127 | }
128 |
129 |
130 | }
131 |
132 |
133 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/ui/fragment/HomeFragment.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.ui.fragment
2 | import android.os.Bundle
3 | import android.view.View
4 | import com.blankj.utilcode.util.ColorUtils.getColor
5 | import com.blankj.utilcode.util.LogUtils
6 | import com.scwang.smartrefresh.layout.api.RefreshLayout
7 | import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener
8 | import com.scwang.smartrefresh.layout.listener.OnRefreshListener
9 | import com.wsg.base.ext.*
10 | import com.wsg.up.R
11 | import com.wsg.up.entity.ArticleData
12 | import com.wsg.up.entity.BannerChildData
13 | import com.wsg.up.entity.Datas
14 | import com.wsg.up.ui.activity.common.WebActivity
15 | import com.wsg.up.ui.adapter.ArticleAdapter
16 | import com.wsg.up.ui.adapter.BannerAdapter
17 | import com.wsg.up.ui.fragment.base.MyBaseFragment
18 | import com.wsg.up.utils.Tools
19 | import com.wsg.up.viewmodel.WanAndroidViewModel
20 | import com.zhpan.bannerview.BannerViewPager
21 | import com.zhpan.bannerview.BaseViewHolder
22 | import com.zhpan.indicator.enums.IndicatorSlideMode
23 | import com.zhpan.indicator.enums.IndicatorStyle
24 | import kotlinx.android.synthetic.main.fragment_home.*
25 |
26 |
27 | /**
28 | * ================================================
29 | * 作 者:wushaoge
30 | * 版 本:1.0
31 | * 创建日期:2020-07-27 16:33
32 | * 描 述:
33 | * 修订历史:
34 | * ================================================
35 | */
36 | class HomeFragment: MyBaseFragment(), OnRefreshListener, OnLoadMoreListener {
37 |
38 | lateinit var mViewModel: WanAndroidViewModel
39 |
40 | lateinit var mViewPager: BannerViewPager>
41 |
42 | lateinit var articleAdapter: ArticleAdapter
43 |
44 | companion object{
45 |
46 | fun newInstance(title: String?): HomeFragment {
47 | val fragment = HomeFragment()
48 | val args = Bundle()
49 | fragment.setTitle(title)
50 | args.putString("", title)
51 | fragment.arguments = args
52 | return fragment
53 | }
54 | }
55 |
56 | override fun isShowLoading(): Boolean {
57 | return true
58 | }
59 |
60 | override fun getLayoutID(): Int {
61 | return R.layout.fragment_home
62 | }
63 |
64 | override fun initViewModel() {
65 | mViewModel = getViewModel()
66 |
67 | mViewModel.bannerData.vmObserverMain(this){
68 | mViewPager.refreshData(it.data)
69 | }
70 | mViewModel.articleData.vmObserverDefault(this,
71 | onSuccess = {
72 | setArticleData(it)
73 | },
74 | onComplete = {
75 | stopLoad(srl_content)
76 | }
77 | )
78 | }
79 |
80 | override fun initView() {
81 | srl_content.setOnRefreshListener(this)
82 | srl_content.setOnLoadMoreListener(this)
83 |
84 | mViewPager = baseView!!.findViewById(R.id.banner)
85 |
86 | mViewPager.apply {
87 | adapter = BannerAdapter()
88 | setAutoPlay(true)
89 | setLifecycleRegistry(lifecycle)
90 | setIndicatorStyle(IndicatorStyle.ROUND_RECT)
91 | setIndicatorSliderGap(20)
92 | setIndicatorSlideMode(IndicatorSlideMode.WORM)
93 | setIndicatorSliderRadius(15, 15)
94 | setIndicatorSliderColor(getColor(R.color.red_normal_color), getColor(R.color.red_checked_color))
95 | setOnPageClickListener {
96 | LogUtils.e("第{$it}个,${(banner.getData()[it] as BannerChildData).url}")
97 | startActivity("url" to (banner.getData()[it] as BannerChildData).url)
98 | }
99 | }.create()
100 |
101 | articleAdapter = ArticleAdapter(mContext)
102 | articleAdapter.setOnItemClickListener { adapter, view, position ->
103 | LogUtils.e((adapter.data[position] as Datas).link)
104 | startActivity("url" to (adapter.data[position] as Datas).link)
105 | }
106 | rv_content.adapter = articleAdapter
107 |
108 | }
109 |
110 | override fun initData() {
111 | }
112 |
113 | override fun initMainNetData() {
114 | mViewModel.getBannerData()
115 | getArticleData()
116 | }
117 |
118 | override fun initLazyData() {
119 |
120 | }
121 |
122 | fun getArticleData(){
123 | mViewModel.getArticleData(pageNo)
124 | }
125 |
126 | fun setArticleData(articleData: ArticleData){
127 | val data= articleData?.data?.datas
128 | if (pageNo === 1) {
129 | if (data.isNotEmpty()) {
130 | articleAdapter.setList(data!!)
131 | } else {
132 | articleAdapter.setNewInstance(null)
133 | articleAdapter.setEmptyView(Tools.getEmptyView(mContext))
134 | }
135 | } else {
136 | articleAdapter.removeEmptyView()
137 | if (data.isNotEmpty()) {
138 | articleAdapter.addData(data)
139 | } else {
140 | mContext.showToast("暂无更多数据")
141 | }
142 | }
143 | }
144 |
145 | override fun onClick(v: View?) {
146 |
147 | }
148 |
149 | override fun onRefresh(refreshLayout: RefreshLayout) {
150 | pageNo = 1
151 | getArticleData()
152 | }
153 |
154 | override fun onLoadMore(refreshLayout: RefreshLayout) {
155 | ++pageNo
156 | getArticleData()
157 | }
158 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/ui/fragment/TestFragment.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.ui.fragment
2 | import android.os.Bundle
3 | import android.view.View
4 | import com.wsg.up.R
5 | import com.wsg.up.ui.fragment.base.MyBaseFragment
6 |
7 |
8 | /**
9 | * ================================================
10 | * 作 者:wushaoge
11 | * 版 本:1.0
12 | * 创建日期:2020-07-27 16:33
13 | * 描 述:
14 | * 修订历史:
15 | * ================================================
16 | */
17 | class TestFragment: MyBaseFragment(){
18 |
19 | companion object{
20 | fun newInstance(title: String?): TestFragment {
21 | val fragment = TestFragment()
22 | val args = Bundle()
23 | fragment.setTitle(title)
24 | args.putString("", title)
25 | fragment.arguments = args
26 | return fragment
27 | }
28 | }
29 |
30 | override fun isShowLoading(): Boolean {
31 | return true
32 | }
33 |
34 | override fun getLayoutID(): Int {
35 | return R.layout.fragment_home
36 | }
37 |
38 | override fun initViewModel() {
39 |
40 | }
41 |
42 | override fun initView() {
43 |
44 |
45 | }
46 |
47 | override fun initData() {
48 | }
49 |
50 | override fun initMainNetData() {
51 | }
52 |
53 | override fun initLazyData() {
54 |
55 | }
56 |
57 |
58 | override fun onClick(v: View?) {
59 |
60 | }
61 |
62 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/ui/fragment/base/MyBaseFragment.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.ui.fragment.base
2 |
3 | import com.scwang.smartrefresh.layout.SmartRefreshLayout
4 | import com.scwang.smartrefresh.layout.constant.RefreshState
5 | import com.wsg.base.fragment.BaseFragment
6 | import com.wsg.base.ui.dialog.MyProgressDialog
7 |
8 | /**
9 | * ================================================
10 | * 作 者:wushaoge
11 | * 版 本:1.0
12 | * 创建日期:2020-07-22 15:29
13 | * 描 述:
14 | * 修订历史:
15 | * ================================================
16 | */
17 | abstract class MyBaseFragment: BaseFragment() {
18 |
19 | var baseTitle: String? = ""
20 |
21 | var dialog: MyProgressDialog? = null
22 |
23 | //分页使用
24 | var pageNo = 1
25 | var pageSize = 10
26 | var pageCount = 0
27 |
28 | override fun showLoadingDialog(content: String) {
29 | dialog?:let {
30 | dialog = MyProgressDialog(mContext, content)
31 | }
32 | dialog?.show()
33 | }
34 |
35 | override fun dismissLoadingDialog() {
36 | dialog?.dismiss()
37 | }
38 |
39 | open fun getTitle(): String? {
40 | return baseTitle
41 | }
42 |
43 | open fun setTitle(title: String?) {
44 | this.baseTitle = title
45 | }
46 |
47 | /**
48 | * 结束刷新/加载
49 | *
50 | * @param srl
51 | */
52 | open fun stopLoad(srl: SmartRefreshLayout?) {
53 | if (srl != null) {
54 | if (srl.state == RefreshState.Refreshing) {
55 | srl.finishRefresh()
56 | } else {
57 | srl.finishLoadMore()
58 | }
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/ui/view/MyViewPager.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.ui.view
2 |
3 | import android.content.Context
4 | import android.util.AttributeSet
5 | import android.view.MotionEvent
6 | import androidx.viewpager.widget.ViewPager
7 |
8 | /**
9 | * ================================================
10 | * 作 者:wushaoge
11 | * 版 本:1.0
12 | * 创建日期:2020-07-27 15:01
13 | * 描 述:
14 | * 修订历史:
15 | * ================================================
16 | */
17 | class MyViewPager: ViewPager {
18 | private var scrollble = false
19 |
20 | constructor(context: Context): super(context)
21 |
22 | constructor(
23 | context: Context,
24 | attrs: AttributeSet?
25 | ): super(context, attrs)
26 |
27 |
28 | override fun onTouchEvent(ev: MotionEvent?): Boolean {
29 | return if (scrollble) {
30 | super.onTouchEvent(ev)
31 | } else scrollble
32 | }
33 |
34 | override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
35 | return if (scrollble) {
36 | super.onInterceptTouchEvent(ev)
37 | } else scrollble
38 | }
39 |
40 | fun isScrollble(): Boolean {
41 | return scrollble
42 | }
43 |
44 | fun setScrollble(scrollble: Boolean) {
45 | this.scrollble = scrollble
46 | }
47 |
48 |
49 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/ui/view/dialog/MyConfirmDialog.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.ui.view.dialog
2 |
3 | import android.app.Dialog
4 | import android.content.Context
5 | import android.view.View
6 | import android.view.Window
7 | import com.wsg.up.R
8 | import kotlinx.android.synthetic.main.common_confirm_dialog.*
9 |
10 |
11 | /**
12 | * ================================================
13 | * 作 者:wushaoge
14 | * 版 本:1.0
15 | * 创建日期:2020-08-06 15:45
16 | * 描 述:
17 | * 修订历史:
18 | * ================================================
19 | */
20 | class MyConfirmDialog : Dialog {
21 |
22 |
23 | constructor(context: Context, title: String = "", content: String = "您确定这么做吗", okClick: () -> Unit = {}, cancleClick: () -> Unit = {} ): super(context, R.style.dialog){
24 | requestWindowFeature(Window.FEATURE_NO_TITLE)
25 | setContentView(R.layout.common_confirm_dialog)
26 | this.setCanceledOnTouchOutside(true)
27 |
28 | tv_title.visibility = View.GONE
29 | btn_single.visibility = View.GONE
30 |
31 | title.isNotEmpty().let {
32 | setTitle(title)
33 | }
34 | setContent(content)
35 |
36 | btn_confirm.setOnClickListener { okClick();dismiss() }
37 | btn_cancel.setOnClickListener { cancleClick();dismiss() }
38 | btn_single.setOnClickListener { okClick();dismiss() }
39 | }
40 |
41 |
42 | /**
43 | * 设置标题
44 | * @param str
45 | * @return
46 | */
47 | fun setTitle(str: String?): MyConfirmDialog? {
48 | tv_title.visibility = View.VISIBLE
49 | tv_title.text = str
50 | return this
51 | }
52 |
53 | /**
54 | * 设置内容
55 | * @param str
56 | * @return
57 | */
58 | fun setContent(str: String?): MyConfirmDialog? {
59 | tv_content.text = str
60 | return this
61 | }
62 |
63 |
64 | /**
65 | * 设置取消按钮文字
66 | * @param str
67 | * @return
68 | */
69 | fun setCancleBtnText(str: String?): MyConfirmDialog? {
70 | btn_cancel.setText(str)
71 | return this
72 | }
73 |
74 | /**
75 | * 设置确定按钮文字
76 | * @param str
77 | * @return
78 | */
79 | fun setConfirmBtnText(str: String?): MyConfirmDialog? {
80 | btn_confirm.setText(str)
81 | return this
82 | }
83 |
84 | /**
85 | * 设置单按钮文字
86 | */
87 | fun setSingleBtnText(str: String?): MyConfirmDialog? {
88 | btn_single.setText(str)
89 | return this
90 | }
91 |
92 | /**
93 | * 设置为单个按钮
94 | */
95 | fun setSingleBtnVisible(visible: Boolean): MyConfirmDialog? {
96 | btn_single.visibility = if (visible) View.VISIBLE else View.GONE
97 | btn_cancel.visibility = if (!visible) View.VISIBLE else View.GONE
98 | btn_confirm.visibility = if (!visible) View.VISIBLE else View.GONE
99 | v_single_line.visibility = if (!visible) View.VISIBLE else View.GONE
100 | return this
101 | }
102 |
103 | fun setOkClick(click: () -> Unit){
104 | btn_confirm.setOnClickListener { click();dismiss() }
105 | }
106 |
107 | fun setCancel(click: () -> Unit){
108 | btn_cancel.setOnClickListener { click();dismiss() }
109 | }
110 |
111 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/ui/view/listener/HomeTabSelectedListener.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.ui.view.listener
2 |
3 | import android.content.Context
4 | import android.content.res.ColorStateList
5 | import android.view.View
6 | import android.widget.ImageView
7 | import android.widget.TextView
8 | import androidx.core.content.ContextCompat
9 | import androidx.core.graphics.drawable.DrawableCompat
10 | import com.google.android.material.tabs.TabLayout
11 | import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
12 | import com.wsg.up.R
13 |
14 | /**
15 | * ================================================
16 | * 作 者:wushaoge
17 | * 版 本:1.0
18 | * 创建日期:2018-09-04 19:36
19 | * 描 述:
20 | * 修订历史:
21 | * ================================================
22 | */
23 | class HomeTabSelectedListener(private val mContext: Context) :
24 | OnTabSelectedListener {
25 | override fun onTabSelected(tab: TabLayout.Tab) {
26 | val customView = tab.customView
27 | val tvTitle =
28 | customView!!.findViewById(R.id.tv_tab_title) as TextView
29 | val ivImg =
30 | customView.findViewById(R.id.iv_img) as ImageView
31 | tvTitle.setTextColor(mContext.resources.getColor(R.color.colorPrimary))
32 |
33 | // DrawableCompat.setTint(
34 | // ivImg.drawable,
35 | // ContextCompat.getColor(mContext, R.color.colorPrimary)
36 | // )
37 | ivImg.setImageDrawable(ivImg.drawable)
38 | }
39 |
40 | override fun onTabUnselected(tab: TabLayout.Tab) {
41 | val customView = tab.customView
42 | val tvTitle = customView!!.findViewById(R.id.tv_tab_title) as TextView
43 | val ivImg = customView.findViewById(R.id.iv_img) as ImageView
44 | tvTitle.setTextColor(mContext.resources.getColor(R.color.font_gray_deep))
45 | // DrawableCompat.setTint(
46 | // ivImg.drawable,
47 | // ContextCompat.getColor(mContext, R.color.font_black)
48 | // )
49 | // ivImg.setImageDrawable(ivImg.drawable)
50 |
51 | //通过mutate()复制加载出来的对象
52 | val drawable = ivImg.drawable.mutate()
53 | val wrappedDrawable =
54 | DrawableCompat.wrap(drawable)
55 | DrawableCompat.setTintList(
56 | wrappedDrawable,
57 | ColorStateList.valueOf(ContextCompat.getColor(mContext, R.color.font_black))
58 | )
59 | ivImg.setImageDrawable(wrappedDrawable)
60 | }
61 |
62 | override fun onTabReselected(tab: TabLayout.Tab) {}
63 |
64 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/ui/view/ugc/UgcDetailVideoPlayer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020. vipyinzhiwei
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.wsg.up.ui.view.ugc
17 |
18 | import android.content.Context
19 | import android.util.AttributeSet
20 | import android.widget.ImageView
21 | import com.blankj.utilcode.util.LogUtils
22 | import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
23 | import com.shuyu.gsyvideoplayer.video.base.GSYVideoView
24 | import com.wsg.up.R
25 | import com.wsg.up.ext.gone
26 | import com.wsg.up.ext.visible
27 |
28 | /**
29 | * 社区-推荐详情页面对应的视频播放器。
30 | *
31 | * @author vipyinzhiwei
32 | * @since 2020/5/26
33 | */
34 | class UgcDetailVideoPlayer : StandardGSYVideoPlayer {
35 |
36 | /**
37 | * 是否第一次加载视频。用于隐藏进度条、播放按钮等UI。播放完成后,重新加载视频,会重置为true。
38 | */
39 | private var initFirstLoad = true
40 |
41 | constructor(context: Context) : super(context)
42 |
43 | constructor(context: Context, fullFlag: Boolean?) : super(context, fullFlag)
44 |
45 | constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
46 |
47 | override fun getLayoutId() = R.layout.layout_ugc_detail_video_player
48 |
49 | override fun updateStartImage() {
50 | if (mStartButton is ImageView) {
51 | val imageView = mStartButton as ImageView
52 | when (mCurrentState) {
53 | GSYVideoView.CURRENT_STATE_PLAYING -> imageView.setImageResource(R.drawable.ic_pause_white_24dp)
54 | GSYVideoView.CURRENT_STATE_ERROR -> imageView.setImageResource(R.drawable.ic_play_white_24dp)
55 | GSYVideoView.CURRENT_STATE_AUTO_COMPLETE -> imageView.setImageResource(R.drawable.ic_refresh_white_24dp)
56 | else -> imageView.setImageResource(R.drawable.ic_play_white_24dp)
57 | }
58 |
59 | } else {
60 | super.updateStartImage()
61 | }
62 | }
63 |
64 | //正常
65 | override fun changeUiToNormal() {
66 | super.changeUiToNormal()
67 | LogUtils.e("changeUiToNormal")
68 | initFirstLoad = true
69 | }
70 |
71 | //准备中
72 | override fun changeUiToPreparingShow() {
73 | super.changeUiToPreparingShow()
74 | LogUtils.e("changeUiToPreparingShow")
75 | mBottomContainer.gone()
76 | }
77 |
78 | //播放中
79 | override fun changeUiToPlayingShow() {
80 | super.changeUiToPlayingShow()
81 | LogUtils.e("changeUiToPlayingShow")
82 | if (initFirstLoad) mBottomContainer.gone()
83 | initFirstLoad = false
84 | }
85 |
86 | //开始缓冲
87 | override fun changeUiToPlayingBufferingShow() {
88 | super.changeUiToPlayingBufferingShow()
89 | LogUtils.e("changeUiToPlayingBufferingShow")
90 | if (initFirstLoad) {
91 | mStartButton.gone()
92 | initFirstLoad = false
93 | } else {
94 | mStartButton.visible()
95 | }
96 | }
97 |
98 | //暂停
99 | override fun changeUiToPauseShow() {
100 | super.changeUiToPauseShow()
101 | LogUtils.e("changeUiToPauseShow")
102 | }
103 |
104 | //自动播放结束
105 | override fun changeUiToCompleteShow() {
106 | super.changeUiToCompleteShow()
107 | LogUtils.e("changeUiToCompleteShow")
108 | mBottomContainer.gone()
109 | }
110 |
111 | //错误状态
112 | override fun changeUiToError() {
113 | super.changeUiToError()
114 | LogUtils.e("changeUiToError")
115 | }
116 |
117 | fun getBottomContainer() = mBottomContainer
118 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/utils/Constants.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.utils
2 |
3 | import rxhttp.wrapper.annotation.DefaultDomain
4 |
5 | /**
6 | * ================================================
7 | * 作 者:wushaoge
8 | * 版 本:1.0
9 | * 创建日期:2020-07-23 09:41
10 | * 描 述:
11 | * 修订历史:
12 | * ================================================
13 | */
14 | class Constants {
15 |
16 | companion object{
17 |
18 | @DefaultDomain //设置为默认域名
19 | const val WAN_ANDROID_BASEURL = "http://www.wanandroid.com/"
20 |
21 |
22 | /**
23 | * 玩安卓首页文章
24 | */
25 | const val WAN_ARTICLE = "article/list/"
26 |
27 | /**
28 | * 玩安卓Banner
29 | */
30 | const val WAN_BANNER = "banner"
31 |
32 |
33 | /**
34 | * 开眼推荐
35 | */
36 | const val EYE_COMMUNITY = "http://baobab.kaiyanapp.com/api/v7/community/tab/rec"
37 |
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/utils/EyeConstants.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.utils
2 |
3 | /**
4 | * ================================================
5 | * 作 者:wushaoge
6 | * 版 本:1.0
7 | * 创建日期:2020-08-27 10:56
8 | * 描 述:
9 | * 修订历史:
10 | * ================================================
11 | */
12 | object EyeConstants {
13 |
14 | const val STR_HORIZONTAL_SCROLLCARD_TYPE = "horizontalScrollCard"
15 | const val STR_COMMUNITY_COLUMNS_CARD = "communityColumnsCard"
16 |
17 | const val STR_HORIZONTAL_SCROLLCARD_DATA_TYPE = "HorizontalScrollCard"
18 | const val STR_ITEM_COLLECTION_DATA_TYPE = "ItemCollection"
19 | const val STR_FOLLOW_CARD_DATA_TYPE = "FollowCard"
20 |
21 | const val STR_VIDEO_TYPE = "video"
22 | const val STR_UGC_PICTURE_TYPE = "ugcPicture"
23 |
24 | const val HORIZONTAL_SCROLLCARD_ITEM_COLLECTION_TYPE = 1 //type:horizontalScrollCard -> dataType:ItemCollection
25 | const val HORIZONTAL_SCROLLCARD_TYPE = 2 //type:horizontalScrollCard -> dataType:HorizontalScrollCard
26 | const val FOLLOW_CARD_TYPE = 3 //type:communityColumnsCard -> dataType:FollowCard
27 | const val UN_KNOW = 4
28 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/utils/TablayoutUtils.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.utils
2 |
3 | import android.content.Context
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.widget.ImageView
7 | import android.widget.TextView
8 | import com.google.android.material.tabs.TabLayout
9 | import com.wsg.up.R
10 | import com.wsg.up.entity.BottomResourceData
11 | import com.wsg.up.ext.onTabSelected
12 | import java.util.*
13 |
14 | /**
15 | * ================================================
16 | * 作 者:wushaoge
17 | * 版 本:1.0
18 | * 创建日期:2018-09-05 10:21
19 | * 描 述:
20 | * 修订历史:
21 | * ================================================
22 | */
23 | object TablayoutUtils {
24 | /**
25 | * 首页设置tablayout布局
26 | * @param mContext
27 | * @param tlTablayout
28 | * @param bottomList
29 | */
30 | fun setHomeTablayoutCustomView(mContext: Context, tlTablayout: TabLayout, bottomList: ArrayList) {
31 | for (i in 0 until tlTablayout.tabCount) {
32 | val itemView: View = LayoutInflater.from(mContext).inflate(R.layout.tab_home_item, tlTablayout, false)
33 | val txtView = itemView.findViewById(R.id.tv_tab_title) as TextView
34 | txtView.text = bottomList[i].getTitle()
35 | val ivImg = itemView.findViewById(R.id.iv_img) as ImageView
36 |
37 | //默认选中第一项
38 | if (i == 0) {
39 | txtView.setTextColor(mContext.getColor(R.color.colorPrimary))
40 | ivImg.setImageResource(bottomList[i].getResource())
41 | } else {
42 | txtView.setTextColor(mContext.getColor(R.color.font_gray_deep))
43 | ivImg.setImageResource(bottomList[i].getUnCheckResource())
44 | }
45 | tlTablayout.getTabAt(i)!!.customView = itemView
46 | }
47 |
48 | //设置监听
49 | tlTablayout.onTabSelected {
50 | onTabSelected {
51 | for (i in 0 until tlTablayout.tabCount) {
52 | val itemView: View = tlTablayout.getTabAt(i)!!.customView!!
53 | val txtView = itemView.findViewById(R.id.tv_tab_title) as TextView
54 | val ivImg = itemView.findViewById(R.id.iv_img) as ImageView
55 | if(i != tlTablayout.selectedTabPosition){
56 | txtView.setTextColor(mContext.getColor(R.color.font_gray_deep))
57 | ivImg.setImageResource(bottomList[i].getUnCheckResource())
58 | }
59 | }
60 | customView?.let {
61 | (it.findViewById(R.id.tv_tab_title) as TextView).setTextColor(mContext.getColor(R.color.colorPrimary))
62 | (it.findViewById(R.id.iv_img) as ImageView).setImageResource(bottomList[tlTablayout.selectedTabPosition].getResource())
63 | }
64 | }
65 | }
66 |
67 |
68 | // tlTablayout.addOnTabSelectedListener(object: TabLayout.OnTabSelectedListener{
69 | //
70 | // override fun onTabSelected(tab: TabLayout.Tab?) {
71 | // for (i in 0 until tlTablayout.tabCount) {
72 | // val itemView: View = tlTablayout.getTabAt(i)!!.customView!!
73 | // val txtView = itemView.findViewById(R.id.tv_tab_title) as TextView
74 | // val ivImg = itemView.findViewById(R.id.iv_img) as ImageView
75 | // if(i != tlTablayout.selectedTabPosition){
76 | // txtView.setTextColor(mContext.getColor(R.color.font_gray_deep))
77 | // ivImg.setImageResource(bottomList[i].getUnCheckResource())
78 | // }
79 | // }
80 | // tab!!.customView?.let {
81 | // (it.findViewById(R.id.tv_tab_title) as TextView).setTextColor(mContext.getColor(R.color.colorPrimary))
82 | // (it.findViewById(R.id.iv_img) as ImageView).setImageResource(bottomList[tlTablayout.selectedTabPosition].getResource())
83 | // }
84 | // }
85 | // override fun onTabUnselected(tab: TabLayout.Tab?) {
86 | // }
87 | //
88 | // override fun onTabReselected(tab: TabLayout.Tab?) {
89 | // }
90 | //
91 | // })
92 | }
93 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/utils/Tools.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.utils
2 |
3 | import android.animation.ValueAnimator
4 | import android.content.Context
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import com.airbnb.lottie.LottieAnimationView
8 | import com.wsg.up.R
9 |
10 | /**
11 | * ================================================
12 | * 作 者:wushaoge
13 | * 版 本:1.0
14 | * 创建日期:2020-08-03 15:22
15 | * 描 述:
16 | * 修订历史:
17 | * ================================================
18 | */
19 | class Tools {
20 |
21 | companion object{
22 |
23 | /**
24 | * 加载列表的空布局
25 | * @param context
26 | * @return
27 | */
28 | fun getEmptyView(context: Context): View {
29 | val mLayoutInflater =
30 | context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
31 | val emptyView: View =
32 | mLayoutInflater.inflate(R.layout.common_empty, null, true)
33 | val lottieLoadingView =
34 | emptyView.findViewById(R.id.lottie_empty_view) as LottieAnimationView
35 | lottieLoadingView.setAnimation("halloween_smoothymon.json")
36 | lottieLoadingView.repeatCount = ValueAnimator.INFINITE
37 | lottieLoadingView.playAnimation()
38 | return emptyView
39 | }
40 |
41 |
42 |
43 |
44 |
45 | }
46 |
47 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/utils/TypeFaceUtil.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.utils
2 |
3 | import android.graphics.Typeface
4 | import com.wsg.base.application.BaseApplication
5 |
6 | /**
7 | * ================================================
8 | * 作 者:wushaoge
9 | * 版 本:1.0
10 | * 创建日期:2020-08-11 10:03
11 | * 描 述:
12 | * 修订历史:
13 | * ================================================
14 | */
15 | object TypeFaceUtil {
16 |
17 | var typeface: Typeface? = null
18 |
19 | fun getEyeTypeFace(): Typeface {
20 | typeface = if(typeface == null){
21 | Typeface.createFromAsset(BaseApplication.instance.assets, "fonts/eye.ttf")
22 | }else{
23 | Typeface.DEFAULT
24 | }
25 | return typeface!!
26 | }
27 |
28 |
29 | fun getAcfunTypeFace(): Typeface {
30 | typeface = if(typeface == null){
31 | Typeface.createFromAsset(BaseApplication.instance.assets, "fonts/acfun.ttf")
32 | }else{
33 | Typeface.DEFAULT
34 | }
35 | return typeface!!
36 | }
37 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/viewmodel/EyeViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.viewmodel
2 |
3 | import androidx.lifecycle.MutableLiveData
4 | import com.wsg.base.ext.VmLiveData
5 | import com.wsg.base.ext.launchVmRequest
6 | import com.wsg.base.model.BaseViewModel
7 | import com.wsg.up.entity.RecommendData
8 | import com.wsg.up.repository.EyeRepository
9 |
10 | /**
11 | * ================================================
12 | * 作 者:wushaoge
13 | * 版 本:1.0
14 | * 创建日期:2020-07-23 09:38
15 | * 描 述:
16 | * 修订历史:
17 | * ================================================
18 | */
19 | class EyeViewModel: BaseViewModel() {
20 | private val eyeRepository by lazy { EyeRepository() }
21 |
22 | /**
23 | * 刷新和加载更多
24 | * 这里其实可以只用一个data
25 | * 为什么我用两个~~因为懒
26 | */
27 | val refreshData: VmLiveData = MutableLiveData()
28 | val loadMoreData: VmLiveData = MutableLiveData()
29 |
30 |
31 | fun onRefresh(){
32 | launchVmRequest({
33 | eyeRepository.onRefresh()
34 | }, refreshData)
35 | }
36 |
37 | fun onLoadMore(url: String){
38 | launchVmRequest({
39 | eyeRepository.loadMore(url)
40 | }, loadMoreData)
41 | }
42 |
43 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/wsg/up/viewmodel/WanAndroidViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up.viewmodel
2 |
3 | import androidx.lifecycle.MutableLiveData
4 | import com.wsg.base.ext.VmLiveData
5 | import com.wsg.base.ext.launchVmRequest
6 | import com.wsg.base.model.BaseViewModel
7 | import com.wsg.up.entity.ArticleData
8 | import com.wsg.up.entity.BannerData
9 | import com.wsg.up.repository.WanAndroidRepository
10 |
11 | /**
12 | * ================================================
13 | * 作 者:wushaoge
14 | * 版 本:1.0
15 | * 创建日期:2020-07-23 09:38
16 | * 描 述:
17 | * 修订历史:
18 | * ================================================
19 | */
20 | class WanAndroidViewModel: BaseViewModel() {
21 | private val wanAndroidRepository by lazy { WanAndroidRepository() }
22 |
23 | val articleData: VmLiveData = MutableLiveData()
24 | val bannerData: VmLiveData = MutableLiveData()
25 |
26 |
27 | fun getArticleData(page: Int){
28 | launchVmRequest({
29 | wanAndroidRepository.getArticle(page)
30 | }, articleData)
31 | }
32 |
33 | fun getBannerData(){
34 | launchVmRequest({
35 | wanAndroidRepository.getBanner()
36 | }, bannerData)
37 | }
38 |
39 |
40 | }
--------------------------------------------------------------------------------
/app/src/main/res/anim/anl_push_bottom_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/anl_push_bottom_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/anl_push_top_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/anl_push_up_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/anl_push_up_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
24 |
25 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/confirm_dialog_box.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/confirm_dialog_cancel_btn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/confirm_dialog_cancel_btn_check.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/confirm_dialog_cancel_btn_uncheck.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/confirm_dialog_ok_btn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/confirm_dialog_ok_btn_check.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/confirm_dialog_ok_btn_uncheck.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/confirm_dialog_single_btn.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_avatar_gray_76dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_favorite_border_black_20dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_favorite_border_white_20dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_kabi.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
33 |
36 |
39 |
42 |
45 |
48 |
51 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_kabi_uncheck.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
33 |
36 |
39 |
42 |
45 |
48 |
51 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_layers_white_30dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_logo_black_76dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_pause_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_play_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_pull_down_white_30dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_refresh_white_24dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_reply_white_20dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_share_white_20dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_star_white_15dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_star_white_20dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_black_alpha_50_4dp_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_choiceness_radius_black_2dp_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_follow_radius_black_2dp_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_follow_radius_white_4dp_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_gray_4dp_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_primary_4dp_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
17 |
18 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main2.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_splash.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
22 |
23 |
34 |
35 |
40 |
41 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_ugc_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_web.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/common_confirm_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
16 |
17 |
24 |
25 |
34 |
35 |
48 |
49 |
50 |
51 |
52 |
56 |
57 |
64 |
65 |
76 |
77 |
87 |
88 |
94 |
95 |
104 |
105 |
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/common_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_find.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
18 |
19 |
23 |
24 |
28 |
29 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_banner.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_find.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
38 |
39 |
51 |
52 |
66 |
67 |
79 |
80 |
90 |
91 |
100 |
101 |
115 |
116 |
129 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_home_article.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
24 |
25 |
35 |
36 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_ugc_detail_video_player.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
23 |
24 |
29 |
30 |
40 |
41 |
49 |
50 |
64 |
65 |
73 |
74 |
79 |
80 |
88 |
89 |
90 |
91 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/tab_home_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ac_donghua.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/app/src/main/res/mipmap-hdpi/ac_donghua.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ac_fanju.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/app/src/main/res/mipmap-hdpi/ac_fanju.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ac_guichu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/app/src/main/res/mipmap-hdpi/ac_guichu.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ac_keji.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/app/src/main/res/mipmap-hdpi/ac_keji.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ac_shenghuo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/app/src/main/res/mipmap-hdpi/ac_shenghuo.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ac_tiyu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/app/src/main/res/mipmap-hdpi/ac_tiyu.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ac_wudao.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/app/src/main/res/mipmap-hdpi/ac_wudao.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ac_xuniouxiang.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/app/src/main/res/mipmap-hdpi/ac_xuniouxiang.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ac_yingshi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/app/src/main/res/mipmap-hdpi/ac_yingshi.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ac_yinyue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/app/src/main/res/mipmap-hdpi/ac_yinyue.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ac_youxi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/app/src/main/res/mipmap-hdpi/ac_youxi.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ac_yule.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/app/src/main/res/mipmap-hdpi/ac_yule.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ac_yutang.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/app/src/main/res/mipmap-hdpi/ac_yutang.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ac_zhengyi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/app/src/main/res/mipmap-hdpi/ac_zhengyi.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/btn_release_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/app/src/main/res/mipmap-hdpi/btn_release_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #EA5A60
5 | #EA5A60
6 | #D81B60
7 |
8 |
9 | #FF4C39
10 | #935656
11 |
12 |
13 | #444444
14 | #333333
15 | #888888
16 |
17 |
18 | #26ffffff
19 | #33ffffff
20 | #66ffffff
21 | #80ffffff
22 | #a6ffffff
23 | #bfffffff
24 | #ccffffff
25 | #e6ffffff
26 | #0d000000
27 | #26000000
28 | #33000000
29 | #4d000000
30 | #66000000
31 | #73000000
32 | #80000000
33 | #8c000000
34 | #cc000000
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | WsgMvvm
3 |
4 |
5 |
6 | /
7 | %1$d/%2$d
8 | +关注
9 | 私信
10 | 收藏
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
18 |
19 |
20 |
24 |
25 | ss
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/network_security_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/test/java/com/wsg/up/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.up
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/base/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/base/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion 29
8 | buildToolsVersion "29.0.3"
9 |
10 | defaultConfig {
11 | minSdkVersion 26
12 | targetSdkVersion 29
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | consumerProguardFiles "consumer-rules.pro"
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 |
27 | compileOptions {
28 | sourceCompatibility JavaVersion.VERSION_1_8
29 | targetCompatibility JavaVersion.VERSION_1_8
30 | }
31 |
32 | androidExtensions {
33 | experimental = true
34 | }
35 | }
36 | kotlin {
37 | experimental {
38 | coroutines "enable"
39 | }
40 | }
41 |
42 | dependencies {
43 | api fileTree(dir: "libs", include: ["*.jar"])
44 | api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72"
45 | api 'androidx.core:core-ktx:1.2.0'
46 | api 'androidx.appcompat:appcompat:1.2.0-alpha01'
47 | api 'androidx.constraintlayout:constraintlayout:2.0.0-beta8'
48 | api 'com.google.android:flexbox:2.0.1'
49 |
50 | api 'org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.3.72'
51 |
52 | //GSON
53 | api 'com.google.code.gson:gson:2.8.6'
54 |
55 | //必须3个为必须
56 | api 'com.ljx.rxhttp:rxhttp:2.2.8'
57 | api 'com.squareup.okhttp3:okhttp:4.7.2' //rxhttp v2.2.2版本起,需要手动依赖okhttp
58 | // kapt 'com.ljx.rxhttp:rxhttp-compiler:2.2.8' //生成RxHttp类,非kotlin项目,请使用annotationProcessor代替kapt
59 |
60 | //以下均为非必须
61 | api 'com.ljx.rxlife:rxlife-coroutine:2.0.0' //管理协程生命周期,页面销毁,关闭请求
62 |
63 | //MVVM
64 | api 'androidx.lifecycle:lifecycle-extensions:2.2.0'
65 | api 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
66 | api 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0'
67 |
68 | //kt的反射库(大小几百k)
69 | api 'org.jetbrains.kotlin:kotlin-reflect:1.3.72'
70 |
71 | //http开发神器
72 | debugApi 'com.readystatesoftware.chuck:library:1.1.0'
73 | releaseApi 'com.readystatesoftware.chuck:library-no-op:1.1.0'
74 |
75 | //lottie
76 | api 'com.airbnb.android:lottie:3.4.1'
77 |
78 | //沉浸式状态栏
79 | api 'com.jaeger.statusbarutil:library:1.5.1'
80 |
81 | //下拉刷新
82 | api 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.3'
83 |
84 | //BaseRecyclerViewAdapterHelper
85 | api 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4'
86 |
87 | //material-dialogs
88 | api 'com.afollestad.material-dialogs:input:3.3.0'
89 |
90 | //glide
91 | // api 'com.github.bumptech.glide:glide:4.11.0'
92 | // annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
93 |
94 | //coil图片加载框架基于Kotlin 协程 比glide更轻量
95 | api 'io.coil-kt:coil:0.11.0'
96 |
97 | //各种加载框
98 | api 'com.wang.avi:library:2.1.3'
99 |
100 | //各种工具类 方法查看 https://github.com/Blankj/AndroidUtilCode/blob/master/lib/utilcode/README-CN.md
101 | api 'com.blankj:utilcodex:1.29.0'
102 |
103 | //权限请求框架
104 | api 'com.permissionx.guolindev:permission-support:1.3.0'
105 |
106 | //doraemonkit
107 | debugApi 'com.didichuxing.doraemonkit:doraemonkit:1.1.5'
108 | releaseApi 'com.didichuxing.doraemonkit:doraemonkit-no-op:1.1.5'
109 |
110 | //banner
111 | api 'com.github.zhpanvip:BannerViewPager:3.1.5'
112 |
113 | //腾讯x5webview
114 | api files('libs/tbs_sdk_thirdapp_v3.6.0.jar')
115 | }
--------------------------------------------------------------------------------
/base/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/base/consumer-rules.pro
--------------------------------------------------------------------------------
/base/libs/tbs_sdk_thirdapp_v3.6.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/base/libs/tbs_sdk_thirdapp_v3.6.0.jar
--------------------------------------------------------------------------------
/base/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/base/src/androidTest/java/com/wsg/base/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.base
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.wsg.base.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/base/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | /
5 |
--------------------------------------------------------------------------------
/base/src/main/assets/whale.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/base/src/main/assets/whale.zip
--------------------------------------------------------------------------------
/base/src/main/java/com/wsg/base/application/BaseApplication.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.base.application
2 |
3 | import android.app.Application
4 | import androidx.lifecycle.ProcessLifecycleOwner
5 | import com.wsg.base.lifecycle.ProcessLifecycleObserver
6 | import kotlin.properties.Delegates
7 |
8 | /**
9 | * ================================================
10 | * 作 者:wushaoge
11 | * 版 本:1.0
12 | * 创建日期:2020-07-14 14:38
13 | * 描 述:
14 | * 修订历史:
15 | * ================================================
16 | */
17 | open class BaseApplication: Application() {
18 |
19 | companion object {
20 | var instance: BaseApplication by Delegates.notNull()
21 | }
22 |
23 | override fun onCreate() {
24 | super.onCreate()
25 | instance = this
26 | //添加应用生命周期观察者
27 | ProcessLifecycleOwner.get().lifecycle.addObserver(ProcessLifecycleObserver())
28 |
29 | }
30 |
31 |
32 | }
--------------------------------------------------------------------------------
/base/src/main/java/com/wsg/base/common/CommonExt.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.base.common
2 |
3 | import com.google.gson.Gson
4 |
5 |
6 | /**
7 | * ================================================
8 | * 作 者:wushaoge
9 | * 版 本:1.0
10 | * 创建日期:2020-07-14 14:38
11 | * 描 述:扩展类
12 | * 修订历史:
13 | * ================================================
14 | */
15 |
16 | /**
17 | * 转换String
18 | */
19 | fun Any?.toJsonString(): String {
20 | return Gson().toJson(this)
21 | }
22 |
23 | /**
24 | * 转换成对象
25 | */
26 | inline fun String.toJsonObject(): T {
27 | return Gson().fromJson(this, T::class.java)
28 | }
--------------------------------------------------------------------------------
/base/src/main/java/com/wsg/base/entity/BaseData.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.base.entity
2 |
3 | import androidx.annotation.Keep
4 |
5 | /**
6 | * ================================================
7 | * 作 者:wushaoge
8 | * 版 本:1.0
9 | * 创建日期:2020-07-16 14:47
10 | * 描 述:
11 | * 修订历史:
12 | * ================================================
13 | */
14 | @Keep
15 | open class BaseData(
16 | var code: Int = 1,
17 | var message: String = "",
18 | var data: T
19 | ) {
20 |
21 | /**
22 | * 数据是否正确,默认实现
23 | */
24 | open fun dataRight(): Boolean {
25 | return code == 200
26 | }
27 |
28 | /**
29 | * 获取错误信息,默认实现
30 | */
31 | open fun getMsg(): String {
32 | return message
33 | }
34 | }
--------------------------------------------------------------------------------
/base/src/main/java/com/wsg/base/exception/AppException.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.base.exception
2 |
3 | import com.wsg.base.ext.parseErrorString
4 | import java.lang.Exception
5 |
6 | /**
7 | * ================================================
8 | * 作 者:wushaoge
9 | * 版 本:1.0
10 | * 创建日期:2020-07-14 14:07
11 | * 描 述:
12 | * 修订历史:
13 | * ================================================
14 | */
15 | class AppException : Exception {
16 |
17 | var errorMsg: String
18 |
19 | constructor(error: String?): super(){
20 | errorMsg = error ?: parseError(null)
21 | }
22 |
23 | constructor(throwable: Throwable?): super(){
24 | errorMsg = parseError(throwable)
25 | }
26 |
27 | private fun parseError(throwable: Throwable?): String {
28 | return throwable.parseErrorString()
29 | }
30 | }
--------------------------------------------------------------------------------
/base/src/main/java/com/wsg/base/ext/ContextExt.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.base.ext
2 |
3 | import android.app.Activity
4 | import android.content.Context
5 | import android.view.View
6 | import android.view.inputmethod.InputMethodManager
7 | import androidx.fragment.app.Fragment
8 | import androidx.lifecycle.ViewModel
9 | import androidx.lifecycle.ViewModelProvider
10 | import com.blankj.utilcode.util.ToastUtils
11 | import com.wsg.base.activity.BaseActivity
12 | import com.wsg.base.fragment.BaseFragment
13 |
14 | /**
15 | * ================================================
16 | * 作 者:wushaoge
17 | * 版 本:1.0
18 | * 创建日期:2020-07-21 10:37
19 | * 描 述:
20 | * 修订历史:
21 | * ================================================
22 | */
23 |
24 | /**
25 | * 设置onclick事件
26 | */
27 | fun setViewsOnClickListener(listener: View.OnClickListener, vararg views: View){
28 | views.forEach { it.setOnClickListener(listener) }
29 | }
30 |
31 |
32 | /**
33 | * context显示toast
34 | */
35 | fun Context.showToast(tips: String){
36 | ToastUtils.showShort(tips)
37 | }
38 |
39 | /**
40 | * Fragment显示toast
41 | */
42 | fun Fragment.showToast(tips: String){
43 | ToastUtils.showShort(tips)
44 | }
45 |
46 | /**
47 | * 隐藏键盘
48 | */
49 | fun Context.hideSoftInput(){
50 | val imm: InputMethodManager =
51 | this.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
52 | imm?.hideSoftInputFromWindow((this as Activity).window.decorView.windowToken, 0)
53 | }
54 |
55 | /**
56 | * 快捷创建viewmodel
57 | */
58 | inline fun BaseActivity.getViewModel(): T = ViewModelProvider(this).get(T::class.java)
59 |
60 | /**
61 | * 快捷创建viewmodel
62 | */
63 | inline fun BaseFragment.getViewModel(): T = ViewModelProvider(this).get(T::class.java)
--------------------------------------------------------------------------------
/base/src/main/java/com/wsg/base/ext/DensityExt.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) guolin, Suzhou Quxiang Inc. Open source codes for study only.
3 | * Do not use for commercial purpose.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.wsg.base.ext
19 |
20 | import com.wsg.base.application.BaseApplication
21 |
22 |
23 | /**
24 | * 根据手机的分辨率将dp转成为px。
25 | */
26 | fun dp2px(dp: Float): Int {
27 | val scale = BaseApplication.instance.resources.displayMetrics.density
28 | return (dp * scale + 0.5f).toInt()
29 | }
30 |
31 | /**
32 | * 根据手机的分辨率将px转成dp。
33 | */
34 | fun px2dp(px: Float): Int {
35 | val scale = BaseApplication.instance.resources.displayMetrics.density
36 | return (px / scale + 0.5f).toInt()
37 | }
38 |
39 | /**
40 | * 获取屏幕宽值。
41 | */
42 | val screenWidth
43 | get() = BaseApplication.instance.resources.displayMetrics.widthPixels
44 |
45 | /**
46 | * 获取屏幕高值。
47 | */
48 | val screenHeight
49 | get() = BaseApplication.instance.resources.displayMetrics.heightPixels
50 |
51 | /**
52 | * 获取屏幕像素:对获取的宽高进行拼接。例:1080X2340。
53 | */
54 | fun screenPixel(): String {
55 | BaseApplication.instance.resources.displayMetrics.run {
56 | return "${widthPixels}X${heightPixels}"
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/base/src/main/java/com/wsg/base/ext/LiveDataExt.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.base.ext
2 |
3 | import androidx.annotation.MainThread
4 | import androidx.lifecycle.LifecycleOwner
5 | import androidx.lifecycle.LiveData
6 | import androidx.lifecycle.MutableLiveData
7 | import androidx.lifecycle.Observer
8 | import com.wsg.base.state.VmState
9 |
10 | /**
11 | * ================================================
12 | * 作 者:wushaoge
13 | * 版 本:1.0
14 | * 创建日期:2020-07-16 14:39
15 | * 描 述:
16 | * 修订历史:
17 | * ================================================
18 | */
19 | @MainThread
20 | inline fun LiveData.observe(
21 | owner: LifecycleOwner,
22 | crossinline onChanged: (T) -> Unit
23 | ): Observer {
24 | val wrappedObserver = Observer { t -> onChanged(t) }
25 | observe(owner, wrappedObserver)
26 | return wrappedObserver
27 | }
28 |
29 | typealias VmLiveData = MutableLiveData>
--------------------------------------------------------------------------------
/base/src/main/java/com/wsg/base/ext/ViewStateExt.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.base.ext
2 |
3 | import com.blankj.utilcode.util.LogUtils
4 | import com.wsg.base.entity.BaseData
5 | import com.wsg.base.exception.AppException
6 | import com.wsg.base.state.VmState
7 |
8 | /**
9 | * ================================================
10 | * 作 者:wushaoge
11 | * 版 本:1.0
12 | * 创建日期:2020-07-16 14:52
13 | * 描 述:
14 | * 修订历史:
15 | * ================================================
16 | */
17 |
18 |
19 |
20 | /**
21 | * 处理返回值
22 | *
23 | * @param result 请求结果
24 | */
25 | fun VmLiveData.paresVmResult(result: BaseData) {
26 | value = if (result.dataRight()) VmState.Success(result.data) else
27 | VmState.Error(AppException(result.getMsg()))
28 | }
29 |
30 | /**
31 | * 异常转换异常处理
32 | */
33 | fun VmLiveData.paresVmException(e: Throwable) {
34 | this.value = VmState.Error(AppException(e))
35 | }
--------------------------------------------------------------------------------
/base/src/main/java/com/wsg/base/lifecycle/ProcessLifecycleObserver.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.base.lifecycle
2 |
3 | import android.util.Log
4 | import androidx.lifecycle.Lifecycle
5 | import androidx.lifecycle.LifecycleObserver
6 | import androidx.lifecycle.OnLifecycleEvent
7 |
8 | /**
9 | * ================================================
10 | * 作 者:wushaoge
11 | * 版 本:1.0
12 | * 创建日期:2020-07-24 11:23
13 | * 描 述:监听整个app的生命周期
14 | * 修订历史:
15 | * ================================================
16 | */
17 | class ProcessLifecycleObserver: LifecycleObserver {
18 | /**
19 | * 当app变成前台进程时监听
20 | * 此方法一次app进入退出只会调用一次
21 | */
22 | @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
23 | fun enterAppListener(){
24 | Log.e("ProcessLifecycle","ON_CREATE")
25 | }
26 | @OnLifecycleEvent(Lifecycle.Event.ON_START)
27 | fun startAppListener(){
28 | Log.e("ProcessLifecycle","ON_START")
29 | }
30 | @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
31 | fun resumeAppListener(){
32 | Log.e("ProcessLifecycle","ON_RESUME")
33 | }
34 | @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
35 | fun pauseAppListener(){
36 | Log.e("ProcessLifecycle","ON_PAUSE")
37 | }
38 | /**
39 | * 当app变成后台进程或者退出调用
40 | * 此方法一次app进入退出只会调用一次
41 | */
42 | @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
43 | fun exitAppListener(){
44 | Log.e("ProcessLifecycle","ON_STOP")
45 | }
46 | }
--------------------------------------------------------------------------------
/base/src/main/java/com/wsg/base/model/BaseViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.base.model
2 |
3 | import androidx.lifecycle.ViewModel
4 |
5 | /**
6 | * ================================================
7 | * 作 者:wushaoge
8 | * 版 本:1.0
9 | * 创建日期:2020-07-16 14:47
10 | * 描 述:
11 | * 修订历史:
12 | * ================================================
13 | */
14 | open class BaseViewModel : ViewModel()
--------------------------------------------------------------------------------
/base/src/main/java/com/wsg/base/state/EBaseViewStatus.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.base.state
2 |
3 | /**
4 | * ================================================
5 | * 作 者:wushaoge
6 | * 版 本:1.0
7 | * 创建日期:2020-07-21 14:17
8 | * 描 述:
9 | * 修订历史:
10 | * ================================================
11 | */
12 | enum class EBaseViewStatus {
13 | LOADING, SUCCESS, ERROR
14 | }
--------------------------------------------------------------------------------
/base/src/main/java/com/wsg/base/state/IBaseUIView.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.base.state
2 |
3 | /**
4 | * ================================================
5 | * 作 者:wushaoge
6 | * 版 本:1.0
7 | * 创建日期:2020-07-21 14:45
8 | * 描 述:
9 | * 修订历史:
10 | * ================================================
11 | */
12 | interface IBaseUIView {
13 |
14 | /** 获取当前布局状态,方便在callBack中统一处理 */
15 | fun getBaseViewStatus(): EBaseViewStatus?
16 |
17 | /** 手动设置布局状态,一般情况不需要 */
18 | fun setBaseViewStatus(baseViewStatus: EBaseViewStatus?)
19 |
20 | /** 显示成功布局 */
21 | fun showSuccessLayout()
22 |
23 | /** 显示加载中布局 */
24 | fun showLoadingLayout()
25 |
26 | /** 显示失败布局 */
27 | fun showErrorLayout(errorMsg: String?)
28 | }
--------------------------------------------------------------------------------
/base/src/main/java/com/wsg/base/state/ViewState.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.base.state
2 |
3 | import com.wsg.base.exception.AppException
4 |
5 | /**
6 | * ================================================
7 | * 作 者:wushaoge
8 | * 版 本:1.0
9 | * 创建日期:2020-07-16 10:51
10 | * 描 述:
11 | * 修订历史:
12 | * ================================================
13 | */
14 |
15 | class VmResult {
16 | var onAppSuccess: (data: T) -> Unit = {}
17 | var onAppError: (exception: AppException) -> Unit = {}
18 | var onAppLoading: () -> Unit = {}
19 | var onAppComplete: () -> Unit = {}
20 | }
21 |
22 | sealed class VmState {
23 | object Loading: VmState()
24 | data class Success(val data: T) : VmState()
25 | data class Error(val error: AppException) : VmState()
26 | }
--------------------------------------------------------------------------------
/base/src/main/java/com/wsg/base/ui/dialog/MyProgressDialog.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.base.ui.dialog
2 |
3 | import android.app.Dialog
4 | import android.content.Context
5 | import android.text.TextUtils
6 | import android.view.View
7 | import android.view.Window
8 | import android.widget.TextView
9 | import com.wsg.base.R
10 |
11 | /**
12 | * ================================================
13 | * 作 者:wushaoge
14 | * 版 本:1.0
15 | * 创建日期:2020-07-21 15:25
16 | * 描 述:
17 | * 修订历史:
18 | * ================================================
19 | */
20 | class MyProgressDialog: Dialog{
21 |
22 | private var tv_loadingmsg: TextView? = null
23 |
24 | constructor(context: Context, content: String? = null) : super(context, R.style.dialog){
25 | initView(content)
26 | }
27 |
28 | private fun initView(content: String?) {
29 | requestWindowFeature(Window.FEATURE_NO_TITLE)
30 | setContentView(R.layout.common_progress_dialog)
31 | tv_loadingmsg = findViewById(R.id.tv_loadingmsg) as TextView
32 | setLoadingMsg(content)
33 | }
34 |
35 | /**
36 | * 设置提示语
37 | * @param content
38 | */
39 | fun setLoadingMsg(content: String?) {
40 | if (TextUtils.isEmpty(content)) {
41 | tv_loadingmsg!!.visibility = View.GONE
42 | } else {
43 | tv_loadingmsg!!.visibility = View.VISIBLE
44 | tv_loadingmsg!!.text = content
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/base/src/main/res/drawable/base_solid_stroke_corner.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/base/src/main/res/drawable/ic_back.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/base/src/main/res/drawable/ic_loading_bg.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/base/src/main/res/drawable/ic_loading_bg.9.png
--------------------------------------------------------------------------------
/base/src/main/res/drawable/web_progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
14 |
15 |
16 |
17 |
18 | -
19 |
20 |
21 |
22 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/base/src/main/res/layout/activity_base.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
9 |
10 |
18 |
19 |
20 |
21 |
28 |
29 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/base/src/main/res/layout/common_base_error.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
27 |
28 |
37 |
38 |
47 |
48 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/base/src/main/res/layout/common_base_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
33 |
34 |
--------------------------------------------------------------------------------
/base/src/main/res/layout/common_head_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
23 |
24 |
25 |
26 |
39 |
40 |
47 |
48 |
55 |
56 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/base/src/main/res/layout/common_progress_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
18 |
25 |
26 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/base/src/main/res/layout/fragment_base.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
17 |
18 |
25 |
26 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/base/src/main/res/values/string.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 未知错误
5 | 网络超时
6 | 网络超时
7 | 网络错误
8 | 网络错误
9 | 无网络连接
10 | 数据错误,json错误
11 |
12 |
--------------------------------------------------------------------------------
/base/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/base/src/test/java/com/wsg/base/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.wsg.base
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | ext.kotlin_version = "1.3.72"
4 | repositories {
5 | google()
6 | jcenter()
7 | }
8 | dependencies {
9 | classpath "com.android.tools.build:gradle:4.0.0"
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | classpath 'com.blankj:bus-gradle-plugin:2.6'
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | jcenter()
21 | maven { url "https://jitpack.io" }
22 | maven {
23 | url 'https://maven.google.com/'
24 | name 'Google'
25 | }
26 | maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
27 | }
28 | }
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wushaoge/WsgMvvm/d5c8722ecc013f17ae8a7d0419abb6daec8c7def/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jul 10 10:35:03 CST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':base'
2 | include ':app'
3 | rootProject.name = "WsgMvvm"
--------------------------------------------------------------------------------