Commit a828d202 authored by mengcuiguang's avatar mengcuiguang

首页开发

parent be2fc814
......@@ -38,12 +38,10 @@ object Constant {
const val CARRIERTYPE_DRAW_EXPRESS = "4"
/**
* app应用首页 0-主页 1-中间 2-我
*/
const val FRAGMENT_CLICK_ONE = 0
const val FRAGMENT_CLICK_TWO = 1
const val FRAGMENT_CLICK_THREE = 2
const val FRAGMENT_CLICK_FOUR = 3
// 协议地址
var REGISTER_URL = "http://mints-web.mints-id.com/agreements/helivideo/yhxy.html"//注册协议
......
package com.mints.helivideo.ui.activitys
import android.content.Context
import android.content.Intent
import android.media.AudioManager
import android.net.Uri
import android.os.Bundle
import android.view.KeyEvent
import android.view.View
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction
import com.mints.helivideo.MintsApplication
......@@ -16,35 +12,25 @@ import com.mints.helivideo.R
import com.mints.helivideo.common.AppConfig
import com.mints.helivideo.common.Constant
import com.mints.helivideo.ui.activitys.base.BaseActivity
import com.mints.helivideo.ui.fragment.MainFragment
import com.mints.helivideo.ui.fragment.MyFragment
import com.mints.helivideo.ui.fragment.RecommendFragment
import com.mints.helivideo.ui.widgets.DialogListener
import com.mints.helivideo.ui.widgets.PhoneDialog
import com.mints.helivideo.ui.fragment.*
import com.mints.helivideo.video.csj.DPHolderManager
import kotlinx.android.synthetic.main.activity_main.*
/**
* 描述:首页
* 作者:孟崔广
* 时间:2022/12/24 18:06
* 时间:2023/9/7 14:06
*/
class MainActivity : BaseActivity(), View.OnClickListener {
private var audioManager: AudioManager? = null
var tabIvLoan: TextView? = null
var tabIvRecommend: TextView? = null
var tabIvMy: TextView? = null
private var mShowBlack = false
// 底部标签切换的Fragment
private var mainFragment: Fragment? = null
private var recommendFragment: Fragment? = null
private var musicFragment: Fragment? = null
private var redpkgFragment: Fragment? = null
private var myFragment: Fragment? = null
private var currentFragment: Fragment? = null
private var phoneDialog: PhoneDialog? = null
override fun getContentViewLayoutID(): Int {
return R.layout.activity_main
......@@ -55,12 +41,12 @@ class MainActivity : BaseActivity(), View.OnClickListener {
audioManager = getSystemService(Context.AUDIO_SERVICE) as AudioManager
tabIvLoan = findViewById(R.id.tab_iv_loan)
tabIvRecommend = findViewById(R.id.tab_iv_recommend)
tabIvMy = findViewById(R.id.tab_iv_my)
findViewById<View>(R.id.tab_rl_loan).setOnClickListener(this)
findViewById<View>(R.id.tab_rl_recommend).setOnClickListener(this)
findViewById<View>(R.id.tab_rl_my).setOnClickListener(this)
tab_rl_main.setOnClickListener(this)
tab_rl_music.setOnClickListener(this)
tab_rl_redpkg.setOnClickListener(this)
tab_rl_my.setOnClickListener(this)
tab_iv_main.isSelected = true
tab_tv_main.isSelected = true
AppConfig.fragmentClickFlag = Constant.FRAGMENT_CLICK_ONE
if (mainFragment == null) {
mainFragment = MainFragment()
......@@ -73,12 +59,6 @@ class MainActivity : BaseActivity(), View.OnClickListener {
// 记录当前Fragment
currentFragment = mainFragment
}
if (tabIvLoan != null) {
tabIvLoan!!.isSelected = true
}
initEditView()
}
......@@ -133,9 +113,10 @@ class MainActivity : BaseActivity(), View.OnClickListener {
override fun onClick(view: View) {
when (view.id) {
R.id.tab_rl_loan -> clickTab1Layout()
R.id.tab_rl_recommend -> clickTab2Layout()
R.id.tab_rl_my -> clickTab3Layout()
R.id.tab_rl_main -> clickTab1Layout()
R.id.tab_rl_music -> clickTab2Layout()
R.id.tab_rl_redpkg -> clickTab3Layout()
R.id.tab_rl_my -> clickTab4Layout()
}
}
......@@ -148,10 +129,14 @@ class MainActivity : BaseActivity(), View.OnClickListener {
mainFragment = MainFragment()
}
addOrShowFragment(supportFragmentManager.beginTransaction(), mainFragment!!)
tabIvLoan!!.isSelected = true
tabIvRecommend!!.isSelected = false
tabIvMy!!.isSelected = false
changeBottomTabColor(false)
tab_iv_main.isSelected = true
tab_tv_main.isSelected = true
tab_iv_music.isSelected = false
tab_tv_music.isSelected = false
tab_iv_redpkg.isSelected = false
tab_tv_redpkg.isSelected = false
tab_iv_my.isSelected = false
tab_tv_my.isSelected = false
}
/**
......@@ -159,14 +144,18 @@ class MainActivity : BaseActivity(), View.OnClickListener {
*/
fun clickTab2Layout() {
AppConfig.fragmentClickFlag = Constant.FRAGMENT_CLICK_TWO
if (recommendFragment == null) {
recommendFragment = RecommendFragment()
if (musicFragment == null) {
musicFragment = MusicFragment()
}
addOrShowFragment(supportFragmentManager.beginTransaction(), recommendFragment!!)
tabIvLoan!!.isSelected = false
tabIvRecommend!!.isSelected = true
tabIvMy!!.isSelected = false
changeBottomTabColor(mShowBlack)
addOrShowFragment(supportFragmentManager.beginTransaction(), musicFragment!!)
tab_iv_main.isSelected = false
tab_tv_main.isSelected = false
tab_iv_music.isSelected = true
tab_tv_music.isSelected = true
tab_iv_redpkg.isSelected = false
tab_tv_redpkg.isSelected = false
tab_iv_my.isSelected = false
tab_tv_my.isSelected = false
}
/**
......@@ -174,14 +163,37 @@ class MainActivity : BaseActivity(), View.OnClickListener {
*/
fun clickTab3Layout() {
AppConfig.fragmentClickFlag = Constant.FRAGMENT_CLICK_THREE
if (redpkgFragment == null) {
redpkgFragment = RedpkgFragment()
}
addOrShowFragment(supportFragmentManager.beginTransaction(), redpkgFragment!!)
tab_iv_main.isSelected = false
tab_tv_main.isSelected = false
tab_iv_music.isSelected = false
tab_tv_music.isSelected = false
tab_iv_redpkg.isSelected = true
tab_tv_redpkg.isSelected = true
tab_iv_my.isSelected = false
tab_tv_my.isSelected = false
}
/**
* 点击第三个tab
*/
fun clickTab4Layout() {
AppConfig.fragmentClickFlag = Constant.FRAGMENT_CLICK_FOUR
if (myFragment == null) {
myFragment = MyFragment()
}
addOrShowFragment(supportFragmentManager.beginTransaction(), myFragment!!)
tabIvLoan!!.isSelected = false
tabIvRecommend!!.isSelected = false
tabIvMy!!.isSelected = true
changeBottomTabColor(false)
tab_iv_main.isSelected = false
tab_tv_main.isSelected = false
tab_iv_music.isSelected = false
tab_tv_music.isSelected = false
tab_iv_redpkg.isSelected = false
tab_tv_redpkg.isSelected = false
tab_iv_my.isSelected = true
tab_tv_my.isSelected = true
}
......@@ -204,86 +216,4 @@ class MainActivity : BaseActivity(), View.OnClickListener {
}
currentFragment = fragment
}
fun backPhoneDialog() {
phoneDialog = PhoneDialog(context, object : DialogListener() {
override fun onClick(v: View) {
if (!isFinishing() && phoneDialog != null && phoneDialog!!.isShowing()) {
phoneDialog!!.dismiss()
}
when (v.id) {
R.id.tv_phone_dialog_phone, R.id.tv_phone_dialog_phone2 -> {
val intent = Intent(Intent.ACTION_DIAL)
intent.data = Uri.parse("tel:" + "4000969950")
context.startActivity(intent)
}
}
}
})
phoneDialog!!.show()
}
private fun initEditView() {
tv_full.setOnClickListener {
recommendFragment?.apply {
(this as RecommendFragment).fullChoice()
}
}
tv_delete.setOnClickListener {
recommendFragment?.apply {
(this as RecommendFragment).delete()
}
}
}
fun changeRecommendTab(index: Int) {
recommendFragment?.apply {
(this as RecommendFragment).changeTab(index)
}
}
fun showEditView(show: Boolean) {
recommendFragment?.let {
(it as RecommendFragment).showEditView(show)
}
}
fun hideEditView(show: Boolean) {
recommendFragment?.let {
(it as RecommendFragment).hideEditView(show)
}
}
fun showEdit(isEdit: Boolean) {
if (isEdit) {
ll_edit.visibility = View.VISIBLE
} else {
ll_edit.visibility = View.GONE
}
}
fun showBlack(showBlack: Boolean) {
this.mShowBlack = showBlack
changeBottomTabColor(showBlack)
}
private fun changeBottomTabColor(showBlack: Boolean) {
if (showBlack) {
tabIvRecommend?.setTextColor(
ContextCompat.getColorStateList(
context,
R.color.item_text_sel2
)
)
ll_bottom_tab.background = ContextCompat.getDrawable(context, R.color.black)
} else {
tabIvRecommend?.setTextColor(
ContextCompat.getColorStateList(
context,
R.color.item_text_sel
)
)
ll_bottom_tab.background = ContextCompat.getDrawable(context, R.color.white)
}
}
}
\ No newline at end of file
......@@ -55,7 +55,7 @@ class FollowVideoFragment : BaseFragment(), FollowView {
LayoutInflater.from(requireContext()).inflate(R.layout.item_follow_empty, null)
emptyView.findViewById<View>(R.id.btn).setOnClickListener {
// 去剧场
(requireActivity() as MainActivity).changeRecommendTab(1)
// (requireActivity() as MainActivity).changeRecommendTab(1)
}
rv_follow.layoutManager = GridLayoutManager(requireContext(), 3)
followAdapter = FollowAdapter(requireActivity())
......@@ -87,11 +87,11 @@ class FollowVideoFragment : BaseFragment(), FollowView {
}
private fun showEditView(show: Boolean) {
(requireActivity() as MainActivity).showEditView(show)
// (requireActivity() as MainActivity).showEditView(show)
}
private fun hideEditView(hide: Boolean) {
(requireActivity() as MainActivity).hideEditView(hide)
// (requireActivity() as MainActivity).hideEditView(hide)
}
override fun getCollectListSuc(bannerList: BannerList) {
......@@ -112,7 +112,7 @@ class FollowVideoFragment : BaseFragment(), FollowView {
override fun cancelCollectSuc() {
followPresenter.getCollectList()
(requireActivity() as MainActivity).showEditView(true)
// (requireActivity() as MainActivity).showEditView(true)
}
override fun cancelCollectFail() {
......
package com.mints.helivideo.ui.fragment
import com.mints.helivideo.R
import com.mints.helivideo.ui.fragment.base.LazyLoadBaseFragment
class MusicFragment : LazyLoadBaseFragment() {
override fun getContentViewLayoutID() = R.layout.fragment_music
override fun initViewsAndEvents() {
}
}
\ No newline at end of file
......@@ -86,7 +86,7 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
override fun onFragmentResume() {
super.onFragmentResume()
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_THREE) {
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_FOUR) {
if (AntiShake.check(ll_my_record?.id)) return
if(userManager.vipFlag){
......
......@@ -178,13 +178,13 @@ class RecommendFragment : BaseFragment(), View.OnClickListener {
tab_recommend.visibility = View.VISIBLE
tv_edit_text.visibility = View.GONE
}
(requireActivity() as MainActivity).showEdit(isEdit)
// (requireActivity() as MainActivity).showEdit(isEdit)
(fragments[0] as FollowVideoFragment).getAdapter()?.setEditStyle(isEdit)
}
private fun changeBottomTabColor(showBlack: Boolean) {
(requireActivity() as MainActivity).showBlack(showBlack)
(requireActivity() as MainActivity).statusBarDark(!showBlack)
// (requireActivity() as MainActivity).showBlack(showBlack)
// (requireActivity() as MainActivity).statusBarDark(!showBlack)
}
fun showEditView(show: Boolean) {
......
package com.mints.helivideo.ui.fragment
import com.mints.helivideo.R
import com.mints.helivideo.ui.fragment.base.LazyLoadBaseFragment
class RedpkgFragment : LazyLoadBaseFragment() {
override fun getContentViewLayoutID() = R.layout.fragment_redpkg
override fun initViewsAndEvents() {
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item android:color="@color/main_mints" android:state_selected="true" />
<item android:color="@color/black" android:state_selected="false" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/ic_my_enable" android:state_selected="true" />
<item android:drawable="@mipmap/ic_my_none" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/ic_my_enable" android:state_selected="true" />
<item android:drawable="@mipmap/ic_my_none" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/ic_my_enable" android:state_selected="true" />
<item android:drawable="@mipmap/ic_my_none" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/ic_my_enable" android:state_selected="true" />
<item android:drawable="@mipmap/ic_my_none" />
</selector>
\ No newline at end of file
......@@ -8,110 +8,117 @@
android:id="@+id/content_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="56dp"
android:layout_marginBottom="50dp"
android:background="@color/white"
android:orientation="vertical" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_above="@+id/ll_bottom_tab"
android:background="#E1E1E1"
android:visibility="gone" />
android:background="#E1E1E1" />
<LinearLayout
android:id="@+id/ll_bottom_tab"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="@color/white"
android:elevation="2dp"
android:background="@color/authentic_text"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/tab_rl_loan"
android:id="@+id/tab_rl_main"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/tab_iv_main"
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/tab_main_btn" />
<TextView
android:id="@+id/tab_iv_loan"
android:id="@+id/tab_tv_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="剧场"
android:textColor="@color/item_text_sel"
android:textSize="16sp"
android:textStyle="bold" />
android:text="@string/bottom_tab_main"
android:textColor="@drawable/item_txt_sel"
android:textSize="11sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/tab_rl_recommend"
android:id="@+id/tab_rl_music"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/tab_iv_music"
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/tab_music_btn" />
<TextView
android:id="@+id/tab_iv_recommend"
android:id="@+id/tab_tv_music"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="推荐"
android:textColor="@color/item_text_sel2"
android:textSize="16sp"
android:textStyle="bold" />
android:text="@string/bottom_tab_music"
android:textColor="@drawable/item_txt_sel"
android:textSize="11sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/tab_rl_my"
android:id="@+id/tab_rl_redpkg"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/tab_iv_redpkg"
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/tab_redpkg_btn" />
<TextView
android:id="@+id/tab_iv_my"
android:id="@+id/tab_tv_redpkg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="我的"
android:textColor="@color/item_text_sel"
android:textSize="16sp"
android:textStyle="bold" />
android:text="@string/bottom_tab_redpkg"
android:textColor="@drawable/item_txt_sel"
android:textSize="11sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_edit"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_alignParentBottom="true"
android:background="@color/white"
android:elevation="2dp"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:id="@+id/tv_full"
<LinearLayout
android:id="@+id/tab_rl_my"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_weight="1.0"
android:gravity="center"
android:text="全选"
android:textColor="@color/black" />
android:orientation="vertical">
<TextView
android:id="@+id/tv_delete"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="删除"
android:textColor="@color/red" />
<ImageView
android:id="@+id/tab_iv_my"
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/tab_my_btn" />
<TextView
android:id="@+id/tab_tv_my"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bottom_tab_my"
android:textColor="@drawable/item_txt_sel"
android:textSize="11sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
\ No newline at end of file
......@@ -17,6 +17,11 @@
<string name="update_load">正在下载</string>
<string name="update_app">APP更新</string>
<string name="bottom_tab_main">福利</string>
<string name="bottom_tab_music">猜歌</string>
<string name="bottom_tab_redpkg">红包</string>
<string name="bottom_tab_my">提现</string>
<string name="str_agreement_vip">尊敬的河狸短视频用户:\n
鉴于本协议是河狸短视频用户(下称“用户”或“您”)(下称 “本公司”或“我们”)关于使用河狸短视频产品提供的自动续费委托扣款服务(下称“本服务”)所订立的协议。您使用本服务前,已经注册成为河狸短视频的用户,且已同意为使用河狸短视频及本服务的相关用户协议及其它平台规则。\n
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment