Commit bd0b9144 authored by mengcuiguang's avatar mengcuiguang

添加xmly封面

parent 10b31189
...@@ -80,14 +80,14 @@ class InitAppService : IntentService("InitializeService") { ...@@ -80,14 +80,14 @@ class InitAppService : IntentService("InitializeService") {
// 变现猫 // 变现猫
initBxm(this.application) initBxm(this.application)
// 喜马拉雅 // // 喜马拉雅
val mXimalaya = CommonRequest.getInstanse() // val mXimalaya = CommonRequest.getInstanse()
val mAppSecret = "db3cb9e3ec5943f4987e78ddc5aec728" // val mAppSecret = "db3cb9e3ec5943f4987e78ddc5aec728"
val mAppKey = "ff71a11162f20808f9f349452dd9e141" // val mAppKey = "ff71a11162f20808f9f349452dd9e141"
mXimalaya.setAppkey(mAppKey) // mXimalaya.setAppkey(mAppKey)
mXimalaya.setPackid("com.mints.goodmoney") // mXimalaya.setPackid("com.mints.goodmoney")
mXimalaya.init(this, mAppSecret) // mXimalaya.init(this, mAppSecret)
ConstantsOpenSdk.isDebug = true // ConstantsOpenSdk.isDebug = true
} }
/** /**
......
...@@ -26,6 +26,10 @@ import com.mints.goodmoney.net.LoanService; ...@@ -26,6 +26,10 @@ import com.mints.goodmoney.net.LoanService;
import com.mints.goodmoney.utils.ForegroundOrBackground; import com.mints.goodmoney.utils.ForegroundOrBackground;
import com.mints.goodmoney.utils.LogUtil; import com.mints.goodmoney.utils.LogUtil;
import com.mints.goodmoney.utils.SystemUtils; import com.mints.goodmoney.utils.SystemUtils;
import com.ximalaya.ting.android.opensdk.constants.ConstantsOpenSdk;
import com.ximalaya.ting.android.opensdk.datatrasfer.CommonRequest;
import com.ximalaya.ting.android.opensdk.player.service.XmPlayerConfig;
import com.ximalaya.ting.android.opensdk.util.BaseUtil;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
...@@ -139,6 +143,22 @@ public class MintsApplication extends MultiDexApplication { ...@@ -139,6 +143,22 @@ public class MintsApplication extends MultiDexApplication {
// 瑞狮新闻 // 瑞狮新闻
RsNewsManager.INSTANCE.initX5Environment(this); RsNewsManager.INSTANCE.initX5Environment(this);
// 喜马拉雅
initXmly();
}
private void initXmly() {
XmPlayerConfig.getInstance(this).setDefualtNotificationNickNameAndInfo("好赚钱", "好赚钱");
if (BaseUtil.isMainProcess(this)) {
ConstantsOpenSdk.isDebug = BuildConfig.DEBUG;
CommonRequest mXimalaya = CommonRequest.getInstanse();
String mAppSecret = "db3cb9e3ec5943f4987e78ddc5aec728";
String mAppKey = "ff71a11162f20808f9f349452dd9e141";
mXimalaya.setAppkey(mAppKey);
mXimalaya.setPackid(Constant.MINTS_PKG_NAME);
mXimalaya.init(this, mAppSecret);
}
} }
private MiitHelper.AppIdsUpdater appIdsUpdater = ids -> OAID = ids; private MiitHelper.AppIdsUpdater appIdsUpdater = ids -> OAID = ids;
......
package com.mints.goodmoney.ui.activitys package com.mints.goodmoney.ui.activitys
import android.os.Environment
import android.util.Log import android.util.Log
import android.view.View import android.view.View
import android.widget.Toast import android.widget.Toast
...@@ -28,7 +27,6 @@ import com.ximalaya.ting.android.opensdk.player.service.XmPlayListControl ...@@ -28,7 +27,6 @@ import com.ximalaya.ting.android.opensdk.player.service.XmPlayListControl
import com.ximalaya.ting.android.opensdk.player.service.XmPlayerException import com.ximalaya.ting.android.opensdk.player.service.XmPlayerException
import kotlinx.android.synthetic.main.activity_xmly_test.* import kotlinx.android.synthetic.main.activity_xmly_test.*
import kotlinx.android.synthetic.main.header_layout.* import kotlinx.android.synthetic.main.header_layout.*
import java.io.File
/** /**
* 描述:关于我们 * 描述:关于我们
...@@ -54,10 +52,8 @@ class XmlyActivity : BaseActivity(), View.OnClickListener { ...@@ -54,10 +52,8 @@ class XmlyActivity : BaseActivity(), View.OnClickListener {
iv_left_icon.visibility = View.VISIBLE iv_left_icon.visibility = View.VISIBLE
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back) iv_left_icon.setImageResource(R.mipmap.ic_arrow_back)
val mNotification = XmNotificationCreater.getInstanse(this).initNotification(this.applicationContext, XmlyActivity::class.java)
mPlayerManager = XmPlayerManager.getInstance(this) mPlayerManager = XmPlayerManager.getInstance(this)
val mNotification = XmNotificationCreater.getInstanse(this).initNotification(this.applicationContext, XmlyActivity::class.java)
// 如果之前贵方使用了 `XmPlayerManager.init(int id, Notification notification)` 这个初始化的方式 // 如果之前贵方使用了 `XmPlayerManager.init(int id, Notification notification)` 这个初始化的方式
// 请参考`4.8 播放器通知栏使用`重新添加新的通知栏布局,否则直接升级可能导致在部分手机播放时崩溃 // 请参考`4.8 播放器通知栏使用`重新添加新的通知栏布局,否则直接升级可能导致在部分手机播放时崩溃
// 如果不想使用sdk内部搞好的notification,或者想自建notification 可以使用下面的 init()函数进行初始化 // 如果不想使用sdk内部搞好的notification,或者想自建notification 可以使用下面的 init()函数进行初始化
...@@ -114,16 +110,30 @@ class XmlyActivity : BaseActivity(), View.OnClickListener { ...@@ -114,16 +110,30 @@ class XmlyActivity : BaseActivity(), View.OnClickListener {
} }
R.id.btn3 -> { R.id.btn3 -> {
val vo = hashMapOf<String, String>() val vo = hashMapOf<String, String>()
// vo[DTransferConstants.ALBUM_ID] = "4519297"
// vo[DTransferConstants.SORT] = "asc"
// vo[DTransferConstants.PAGE] = "1"
// vo["count"] = "200"
vo[DTransferConstants.ALBUM_ID] = "4519297" vo[DTransferConstants.ALBUM_ID] = "4519297"
vo[DTransferConstants.SORT] = "asc"
vo[DTransferConstants.PAGE] = "1" vo[DTransferConstants.PAGE] = "1"
vo["count"] = "10" vo[DTransferConstants.PAGE_SIZE] = "200"
CommonRequest.getTracks(vo, object : IDataCallBack<TrackList> { CommonRequest.getTracks(vo, object : IDataCallBack<TrackList> {
override fun onSuccess(p0: TrackList?) { override fun onSuccess(p0: TrackList?) {
// val toJson = GsonUtils.toJson(p0) //// val toJson = GsonUtils.toJson(p0)
val fromJson = GsonUtils.fromJson<TrackList>(json, TrackList::class.java) // val fromJson = GsonUtils.fromJson<TrackList>(json, TrackList::class.java)
mTrackList = fromJson // mTrackList = fromJson
// LogUtil.d(toJson) //// LogUtil.d(toJson)
if (p0 != null && p0.getTracks() != null &&p0.getTracks().size != 0) {
if (mTrackList == null) {
mTrackList = p0
} else {
mTrackList?.getTracks()?.addAll(p0.getTracks())
}
}
println("MainFragmentActivity.mTrackList === $mTrackList")
} }
override fun onError(p0: Int, p1: String?) { override fun onError(p0: Int, p1: String?) {
...@@ -141,16 +151,21 @@ class XmlyActivity : BaseActivity(), View.OnClickListener { ...@@ -141,16 +151,21 @@ class XmlyActivity : BaseActivity(), View.OnClickListener {
} }
R.id.btn5 -> { R.id.btn5 -> {
val track = Track() // val track = Track()
//
track.kind = PlayableModel.KIND_TRACK // track.kind = PlayableModel.KIND_TRACK
track.downloadedSaveFilePath = Environment.getExternalStorageDirectory().absolutePath + File.separator + "a.mp3" // track.downloadedSaveFilePath = Environment.getExternalStorageDirectory().absolutePath + File.separator + "a.mp3"
LogUtil.d("AAAAAAAAAA" + track.downloadedSaveFilePath) // LogUtil.d("AAAAAAAAAA" + track.downloadedSaveFilePath)
track.trackTitle = "a.mp3" // track.trackTitle = "a.mp3"
track.dataId = (-1 * track.trackTitle.hashCode()).toLong() // track.dataId = (-1 * track.trackTitle.hashCode()).toLong()
val tarcks = arrayListOf<Track>() // val tarcks = arrayListOf<Track>()
tarcks.add(track) // tarcks.add(track)
mPlayerManager.playList(tarcks, 0) if(mTrackList!=null&&mTrackList!!.tracks!=null){
mPlayerManager.playList(mTrackList!!.tracks, 1)
}
// val playList = XmPlayerManager.getInstance(mContext).playList
// println("MainFragmentActivity.onOptionsItemSelected === $playList")
} }
} }
......
...@@ -4,6 +4,9 @@ import android.content.Context ...@@ -4,6 +4,9 @@ import android.content.Context
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.mints.goodmoney.R import com.mints.goodmoney.R
...@@ -16,7 +19,9 @@ class XmlyPageAdapter(val xmlyPageList: Any?) : ...@@ -16,7 +19,9 @@ class XmlyPageAdapter(val xmlyPageList: Any?) :
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val ivXmlyPage: ImageView = view.findViewById(R.id.ivXmlyPage)
val tvXmlyPageContent: TextView = view.findViewById(R.id.tvXmlyPageContent)
val tvXmlyPagecount: TextView = view.findViewById(R.id.tvXmlyPagecount)
} }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
...@@ -27,11 +32,13 @@ class XmlyPageAdapter(val xmlyPageList: Any?) : ...@@ -27,11 +32,13 @@ class XmlyPageAdapter(val xmlyPageList: Any?) :
} }
override fun onBindViewHolder(holder: ViewHolder, position: Int) { override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.itemView.setTag(position) holder.itemView.setOnClickListener {
mOnItemClickListener.onItemClick(position)
}
} }
// override fun getItemCount() = xmlyPageList?.size // override fun getItemCount() = xmlyPageList?.size
override fun getItemCount() = 10 override fun getItemCount() = 15
interface OnItemClickListener { interface OnItemClickListener {
fun onItemClick(position: Int) fun onItemClick(position: Int)
......
...@@ -10,15 +10,26 @@ import com.ximalaya.ting.android.opensdk.constants.DTransferConstants ...@@ -10,15 +10,26 @@ import com.ximalaya.ting.android.opensdk.constants.DTransferConstants
import com.ximalaya.ting.android.opensdk.datatrasfer.CommonRequest import com.ximalaya.ting.android.opensdk.datatrasfer.CommonRequest
import com.ximalaya.ting.android.opensdk.datatrasfer.IDataCallBack import com.ximalaya.ting.android.opensdk.datatrasfer.IDataCallBack
import com.ximalaya.ting.android.opensdk.model.album.AlbumList import com.ximalaya.ting.android.opensdk.model.album.AlbumList
import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener
import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import kotlinx.android.synthetic.main.fragment_main_xmly_page.* import kotlinx.android.synthetic.main.fragment_main_xmly_page.*
/** /**
* 描述:喜马拉雅封面 * 描述:喜马拉雅封面
* 作者:孟崔广 * 作者:孟崔广
*/ */
class XmlyPageFragment(private val categoryId: Int) : LazyLoadBaseFragment() { class XmlyPageFragment(private val categoryId: Int) : LazyLoadBaseFragment(),
XmlyPageAdapter.OnItemClickListener,
OnRefreshListener,
OnLoadMoreListener {
private lateinit var xmlyPageAdapter: XmlyPageAdapter private lateinit var xmlyPageAdapter: XmlyPageAdapter
private var xmlyData: MutableList<Any> = mutableListOf()
// 分页
private var xmlyPage = 1
private val PAGE_SIZE = 15
private var mAlbumList: AlbumList? = null private var mAlbumList: AlbumList? = null
private var mPage = 1 private var mPage = 1
...@@ -27,7 +38,6 @@ class XmlyPageFragment(private val categoryId: Int) : LazyLoadBaseFragment() { ...@@ -27,7 +38,6 @@ class XmlyPageFragment(private val categoryId: Int) : LazyLoadBaseFragment() {
override fun getContentViewLayoutID() = R.layout.fragment_main_xmly_page override fun getContentViewLayoutID() = R.layout.fragment_main_xmly_page
override fun initViewsAndEvents() { override fun initViewsAndEvents() {
} }
private fun loadData() { private fun loadData() {
...@@ -52,14 +62,23 @@ class XmlyPageFragment(private val categoryId: Int) : LazyLoadBaseFragment() { ...@@ -52,14 +62,23 @@ class XmlyPageFragment(private val categoryId: Int) : LazyLoadBaseFragment() {
override fun onFragmentFirstVisible() { override fun onFragmentFirstVisible() {
super.onFragmentFirstVisible() super.onFragmentFirstVisible()
showToast("" + categoryId)
//recyclerview 加载封面
initRvView() initRvView()
//recyclerview 事件监听 initListener()
}
loadData() override fun onItemClick(position: Int) {
showToast("界面:视频 item:${position}")
}
override fun onRefresh(refreshLayout: RefreshLayout) {
xmlyPage = 1
xmlyData.clear()
// presenter.getData(xmlyPage)
}
override fun onLoadMore(refreshLayout: RefreshLayout) {
// presenter.getData(++xmlyPage,PAGE_SIZE)
} }
private fun initRvView() { private fun initRvView() {
...@@ -67,5 +86,38 @@ class XmlyPageFragment(private val categoryId: Int) : LazyLoadBaseFragment() { ...@@ -67,5 +86,38 @@ class XmlyPageFragment(private val categoryId: Int) : LazyLoadBaseFragment() {
xmlyPageVip.layoutManager = gridLayoutManager xmlyPageVip.layoutManager = gridLayoutManager
xmlyPageAdapter = XmlyPageAdapter(null) xmlyPageAdapter = XmlyPageAdapter(null)
xmlyPageVip.adapter = xmlyPageAdapter xmlyPageVip.adapter = xmlyPageAdapter
xmlyPageAdapter.setOnItemClickListener(this)
}
private fun initListener() {
srl_xmly.setOnRefreshListener(this)
srl_xmly.setOnLoadMoreListener(this)
}
/**
* 获取数据失败
*/
private fun getDataFail() {
srl_xmly.finishRefresh(false)
srl_xmly.finishLoadMore(false)
xmlyPage = if (xmlyPage == 1) 1 else xmlyPage - 1
}
/**
* 获取数据成功
*/
private fun getDataSuc(list: Any) {
// xmlyData.addAll(list)
// if (xmlyPage == 1) {
// srl_xmly.finishRefresh(true)
// xmlyPageAdapter?.notifyDataSetChanged()
// } else {
// if (list.size < PAGE_SIZE) {
// srl_xmly.finishLoadMoreWithNoMoreData()
// } else {
// srl_xmly.finishLoadMore()
// }
// xmlyPageAdapter?.notifyItemChanged(list.size)
// }
} }
} }
\ No newline at end of file
...@@ -16,7 +16,7 @@ public class MyViewPager extends ViewPager { ...@@ -16,7 +16,7 @@ public class MyViewPager extends ViewPager {
super(context, attrs); super(context, attrs);
} }
private boolean isCanScroll = false; private boolean isCanScroll = true;
public void setCanScroll(boolean isCanScroll) { public void setCanScroll(boolean isCanScroll) {
this.isCanScroll = isCanScroll; this.isCanScroll = isCanScroll;
......
File mode changed from 100755 to 100644
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" <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/color_50E8E8E8"
android:orientation="vertical">
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/srl_xmly"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srlAccentColor="@color/gray"
app:srlPrimaryColor="@color/color_50E8E8E8">
<com.scwang.smartrefresh.layout.header.ClassicsHeader
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/xmlyPageVip" android:id="@+id/xmlyPageVip"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center_horizontal" android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:background="@null" android:background="@null"
android:overScrollMode="never" /> android:overScrollMode="never" />
<com.scwang.smartrefresh.layout.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</LinearLayout>
...@@ -4,17 +4,39 @@ ...@@ -4,17 +4,39 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:layout_margin="6dp"
android:background="#0f0" android:background="@color/white"
android:layout_margin="10dp"
android:orientation="vertical"> android:orientation="vertical">
<ImageView
android:id="@+id/ivXmlyPage"
android:layout_width="match_parent"
android:layout_height="180dp"
android:scaleType="fitXY"
android:src="@mipmap/bg_eat" />
<TextView <TextView
android:id="@+id/tvXmlyPageContent"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="6dp" android:layout_margin="6dp"
android:layout_marginBottom="16dp" android:lines="1"
android:textSize="14sp" android:singleLine="true"
android:text="123213112321311232131123213112321311232131123213112321311232131123213112321311232131"
android:textColor="@color/black" android:textColor="@color/black"
android:text="原价:123" /> android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tvXmlyPagecount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginBottom="6dp"
android:drawableLeft="@mipmap/ic_headset"
android:drawablePadding="6dp"
android:gravity="center_vertical"
android:text="7.2亿"
android:textColor="@color/color_AAA"
android:textSize="12sp" />
</LinearLayout> </LinearLayout>
\ 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