Commit 68b4b32d authored by mengcuiguang's avatar mengcuiguang

添加听书模块

parent 8b5dd9be
......@@ -9,8 +9,8 @@ android {
applicationId "com.mints.goodmoney"
minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion
versionCode 8
versionName "1.0.7"
versionCode 9
versionName "1.0.8"
flavorDimensions "default"
// dex突破65535的限制
......
......@@ -57,7 +57,7 @@ class WrapperActivity : BaseActivity(), View.OnClickListener {
}
Constant.WRAPPER_TYPE_BOOK -> {
tv_title.text = "书城"
val zhangyueFragment = ZhangyueFragment()
val zhangyueFragment = MyZhangyueFragment()
if (!zhangyueFragment.isAdded()) {
// 提交事务
supportFragmentManager.beginTransaction()
......
......@@ -14,6 +14,7 @@ import com.mints.goodmoney.mvp.presenters.GamePresenter
import com.mints.goodmoney.mvp.views.GameView
import com.mints.goodmoney.ui.activitys.AwardActivity
import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment
import com.mints.goodmoney.utils.LogUtil
import com.mints.goodmoney.utils.SpanUtils
import com.mints.library.utils.json.JsonUtil
import kotlinx.android.synthetic.main.activity_liebao_game.*
......@@ -52,12 +53,15 @@ class LiebaoGameFragment : LazyLoadBaseFragment(), GameView,
override fun onFragmentResume() {
super.onFragmentResume()
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_MAIN) {
gvGameLiebao.inflate(activity)
LogUtil.d("LiebaoGameFragment","onFragmentResume")
gamePresenter.getGameInfo()
}
}
override fun onDestroy() {
super.onDestroy()
LogUtil.d("LiebaoGameFragment","LiebaoGameFragment")
CmGameSdk.removeGameClickCallback()
CmGameSdk.setMoveView(null)
CmGameSdk.removeGamePlayTimeCallback()
......@@ -66,7 +70,6 @@ class LiebaoGameFragment : LazyLoadBaseFragment(), GameView,
}
private fun initListener() {
gvGameLiebao.inflate(activity)
// 默认游戏中心页面,点击游戏试,触发回调
CmGameSdk.setGameClickCallback(this)
// 点击游戏右上角或物理返回键,退出游戏时触发回调,并返回游戏时长
......
......@@ -20,6 +20,7 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
const val FRAGMENT_TAG_BOOKSTORE = "FRAGMENT_TAG_BOOKSTORE"
const val FRAGMENT_TAG_NEWS = "FRAGMENT_TAG_NEWS"
const val FRAGMENT_TAG_GAME = "FRAGMENT_TAG_GAME"
const val FRAGMENT_TAG_XMLY = "FRAGMENT_TAG_XMLY"
}
// private var mainFragment: MainFragment? = null
......@@ -29,6 +30,7 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
private var mainFragment: Fragment? = null
private var bookStoreFragment: Fragment? = null
private var newsFragment: Fragment? = null
private var xmlyGameFragment: Fragment? = null
private var liebaoGameFragment: Fragment? = null
private var curPosition = 0//当前标签选中的下标
......@@ -42,7 +44,7 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
override fun onHiddenChanged(hidden: Boolean) {
if (curPosition == 0) {
mainFragment?.onHiddenChanged(hidden)
} else if (curPosition == 3) {
} else if (curPosition == 4) {
liebaoGameFragment?.onHiddenChanged(hidden)
}
super.onHiddenChanged(hidden)
......@@ -88,7 +90,7 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
currentFragment = mainFragment
}
xtFragmentMoney.setxTabDisplayNum(4)
xtFragmentMoney.setxTabDisplayNum(5)
val newTab1 = xtFragmentMoney.newTab()
newTab1.text = "视频"
val newTab2 = xtFragmentMoney.newTab()
......@@ -96,11 +98,14 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
val newTab3 = xtFragmentMoney.newTab()
newTab3.text = "新闻"
val newTab4 = xtFragmentMoney.newTab()
newTab4.text = "游戏"
newTab4.text = "听书"
val newTab5 = xtFragmentMoney.newTab()
newTab5.text = "游戏"
xtFragmentMoney.addTab(newTab1)
xtFragmentMoney.addTab(newTab2)
xtFragmentMoney.addTab(newTab3)
xtFragmentMoney.addTab(newTab4)
xtFragmentMoney.addTab(newTab5)
xtFragmentMoney.addOnTabSelectedListener(this)
}
......@@ -163,7 +168,7 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
}
1 -> {
if (bookStoreFragment == null) {
bookStoreFragment = MyZhangyueFragment()
bookStoreFragment = ZhangyueFragment()
}
addOrShowFragment(childFragmentManager, bookStoreFragment!!, FRAGMENT_TAG_BOOKSTORE)
}
......@@ -174,6 +179,12 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
addOrShowFragment(childFragmentManager, newsFragment!!, FRAGMENT_TAG_NEWS)
}
3 -> {
if (xmlyGameFragment == null) {
xmlyGameFragment = XmlyFragment()
}
addOrShowFragment(childFragmentManager, xmlyGameFragment!!, FRAGMENT_TAG_XMLY)
}
4 -> {
if (liebaoGameFragment == null) {
liebaoGameFragment = LiebaoGameFragment()
}
......
package com.mints.goodmoney.ui.fragment
import android.os.Build
import android.view.View
import android.webkit.WebSettings
import androidx.fragment.app.Fragment
import androidx.viewpager.widget.ViewPager
import com.mints.goodmoney.R
import com.mints.goodmoney.mvp.presenters.BookPresenter
import com.mints.goodmoney.common.AppConfig
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.ui.adapter.MessageFragAdapter
import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment
import kotlinx.android.synthetic.main.fragment_main_xmly.*
......@@ -12,64 +13,41 @@ import kotlinx.android.synthetic.main.fragment_main_xmly.*
* 描述:喜马拉雅
* 作者:孟崔广
*/
class XmlyFragment : LazyLoadBaseFragment(), View.OnClickListener {
private val bookPresenter by lazy { BookPresenter() }
class XmlyFragment : LazyLoadBaseFragment() {
override fun getContentViewLayoutID() = R.layout.fragment_main_xmly
override fun initViewsAndEvents() {
// bookPresenter.attachView(this)
}
override fun onFragmentFirstVisible() {
loadUrl()
initListener()
super.onFragmentFirstVisible()
// 获取tab
initView()
}
override fun onFragmentResume() {
super.onFragmentResume()
// if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_MAIN) {
// bookPresenter.getReadInfo()
// }
}
override fun onClick(v: View) {
when (v.id) {
R.id.ivXmlyBack -> {
xmly_webview.goBack()
}
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_MAIN) {
}
}
override fun onDestroy() {
super.onDestroy()
// bookPresenter.detachView()
}
/**
* 加载H5Game
*/
private fun loadUrl() {
xmly_webview?.let {
val loadUrl = "http://open.ximalaya.com/new-site/#index/448/ff71a11162f20808f9f349452dd9e141"
val settings = it.settings
// 本地 DOM 存储(解决加载某些网页出现白板现象)
settings.domStorageEnabled = true
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// 解决 Android 5.0 上 WebView 默认不允许加载 Http 与 Https 混合内容
settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
}
settings.javaScriptEnabled = true
settings.javaScriptCanOpenWindowsAutomatically = true
it.loadUrl(loadUrl)
private fun initView() {
val tabs: MutableList<String> = ArrayList()
val fragments: MutableList<Fragment> = ArrayList()
for (i in 1..10) {
tabs.add("视频" + i)
fragments.add(XmlyPageFragment(i))
}
}
private fun initListener() {
ivXmlyBack.setOnClickListener(this)
//去除两侧应阴影
xtFragmentXmly.overScrollMode = ViewPager.OVER_SCROLL_NEVER
vpFragmentXmly.offscreenPageLimit = tabs.size + 3
val adapter = MessageFragAdapter(childFragmentManager, fragments, tabs)
vpFragmentXmly.adapter = adapter
xtFragmentXmly.setxTabDisplayNum(tabs.size)
xtFragmentXmly.setupWithViewPager(vpFragmentXmly)
}
}
\ No newline at end of file
package com.mints.goodmoney.ui.fragment
import com.mints.goodmoney.R
import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment
/**
* 描述:喜马拉雅封面
* 作者:孟崔广
*/
class XmlyPageFragment(val data: Int) : LazyLoadBaseFragment() {
override fun getContentViewLayoutID() = R.layout.fragment_main_xmly_page
override fun initViewsAndEvents() {
}
override fun onFragmentFirstVisible() {
super.onFragmentFirstVisible()
showToast("" + data)
//recyclerview 加载封面
//recyclerview 事件监听
}
}
\ No newline at end of file
......@@ -2,26 +2,27 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/ivXmlyBack"
android:layout_width="wrap_content"
<com.androidkun.xtablayout.XTabLayout
android:id="@+id/xtFragmentXmly"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="6dp"
android:text="返回"
android:textColor="@color/black"
android:textSize="14sp" />
app:xTabIndicatorColor="#F28335"
app:xTabIndicatorHeight="4dp"
app:xTabIndicatorRoundX="30dp"
app:xTabIndicatorRoundY="30dp"
app:xTabIndicatorWidth="20dp"
app:xTabMode="scrollable"
app:xTabSelectedTextColor="@color/color_FF9837"
app:xTabSelectedTextSize="18sp"
app:xTabTextColor="#000"
app:xTabTextSize="14sp" />
<WebView
android:id="@+id/xmly_webview"
<com.mints.goodmoney.ui.widgets.MyViewPager
android:id="@+id/vpFragmentXmly"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadingEdge="none"
android:overScrollMode="never" />
</LinearLayout>
\ No newline at end of file
android:layout_height="wrap_content" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<com.mints.goodmoney.ui.widgets.MyViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/vpFragmentXmly"
android:background="#0f0"
android:layout_width="match_parent"
android:layout_height="match_parent" />
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment