Commit 4198c514 authored by jyx's avatar jyx

代码优化

parent 4b851896
...@@ -36,6 +36,8 @@ android { ...@@ -36,6 +36,8 @@ android {
} }
sourceSets { main { jniLibs.srcDirs = ['libs'] } }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
...@@ -175,8 +177,6 @@ dependencies { ...@@ -175,8 +177,6 @@ dependencies {
// 工具类 // 工具类
// gson // gson
// implementation files('libs/gson-2.3.1.jar')
implementation 'com.google.code.gson:gson:2.8.1' implementation 'com.google.code.gson:gson:2.8.1'
// BASE64Decoder // BASE64Decoder
// implementation files('libs/sun.misc.BASE64Decoder.jar') // implementation files('libs/sun.misc.BASE64Decoder.jar')
...@@ -254,8 +254,6 @@ dependencies { ...@@ -254,8 +254,6 @@ dependencies {
implementation 'com.just.agentweb:agentweb:4.1.2' implementation 'com.just.agentweb:agentweb:4.1.2'
// 喜马拉雅 已集成 // 喜马拉雅 已集成
// testImplementation 'junit:junit:4.13' // testImplementation 'junit:junit:4.13'
// androidTestImplementation 'androidx.test.ext:junit:1.1.2' // androidTestImplementation 'androidx.test.ext:junit:1.1.2'
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' // androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
android:name="com.mints.goodmoney.permission.JPUSH_MESSAGE" android:name="com.mints.goodmoney.permission.JPUSH_MESSAGE"
android:protectionLevel="signature" /> android:protectionLevel="signature" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="com.mints.goodmoney.permission.JPUSH_MESSAGE" /> <uses-permission android:name="com.mints.goodmoney.permission.JPUSH_MESSAGE" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /> <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
...@@ -49,6 +51,14 @@ ...@@ -49,6 +51,14 @@
android:name="org.apache.http.legacy" android:name="org.apache.http.legacy"
android:required="false" /> android:required="false" />
<meta-data
android:name="app_key"
android:value="ff71a11162f20808f9f349452dd9e141" />
<meta-data
android:name="pack_id"
android:value="com.mints.goodmoney" />
<!-- 适配小米(xiaomi)刘海屏 --> <!-- 适配小米(xiaomi)刘海屏 -->
<meta-data <meta-data
android:name="android.max_aspect" android:name="android.max_aspect"
...@@ -197,10 +207,8 @@ ...@@ -197,10 +207,8 @@
android:name=".ui.activitys.XmlyAwardActivity" android:name=".ui.activitys.XmlyAwardActivity"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity <activity
android:name=".ui.activitys.XmlyActivity" android:name=".ui.activitys.XmlyPlayActivity"
android:screenOrientation="portrait"> android:screenOrientation="portrait" />
</activity>
<service <service
android:name=".service.UpdateService" android:name=".service.UpdateService"
...@@ -217,7 +225,6 @@ ...@@ -217,7 +225,6 @@
android:exported="true" android:exported="true"
android:process=":player" /> android:process=":player" />
<!-- JPUSH 用户自定义的广播接收器 --> <!-- JPUSH 用户自定义的广播接收器 -->
<receiver <receiver
android:name="com.mints.goodmoney.service.JpushReceiver" android:name="com.mints.goodmoney.service.JpushReceiver"
......
...@@ -79,15 +79,6 @@ class InitAppService : IntentService("InitializeService") { ...@@ -79,15 +79,6 @@ class InitAppService : IntentService("InitializeService") {
// 变现猫 // 变现猫
initBxm(this.application) initBxm(this.application)
// // 喜马拉雅
// val mXimalaya = CommonRequest.getInstanse()
// val mAppSecret = "db3cb9e3ec5943f4987e78ddc5aec728"
// val mAppKey = "ff71a11162f20808f9f349452dd9e141"
// mXimalaya.setAppkey(mAppKey)
// mXimalaya.setPackid("com.mints.goodmoney")
// mXimalaya.init(this, mAppSecret)
// ConstantsOpenSdk.isDebug = true
} }
/** /**
......
...@@ -8,7 +8,6 @@ import android.text.TextUtils; ...@@ -8,7 +8,6 @@ import android.text.TextUtils;
import android.webkit.WebView; import android.webkit.WebView;
import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication; import androidx.multidex.MultiDexApplication;
import com.bun.miitmdid.core.JLibrary; import com.bun.miitmdid.core.JLibrary;
...@@ -30,6 +29,7 @@ import com.ximalaya.ting.android.opensdk.constants.ConstantsOpenSdk; ...@@ -30,6 +29,7 @@ import com.ximalaya.ting.android.opensdk.constants.ConstantsOpenSdk;
import com.ximalaya.ting.android.opensdk.datatrasfer.CommonRequest; import com.ximalaya.ting.android.opensdk.datatrasfer.CommonRequest;
import com.ximalaya.ting.android.opensdk.player.service.XmPlayerConfig; import com.ximalaya.ting.android.opensdk.player.service.XmPlayerConfig;
import com.ximalaya.ting.android.opensdk.util.BaseUtil; import com.ximalaya.ting.android.opensdk.util.BaseUtil;
import com.ximalaya.ting.android.player.XMediaPlayerConstants;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
...@@ -62,6 +62,22 @@ public class MintsApplication extends MultiDexApplication { ...@@ -62,6 +62,22 @@ public class MintsApplication extends MultiDexApplication {
// 判断应用是否在前台 // 判断应用是否在前台
ForegroundOrBackground.init(this); ForegroundOrBackground.init(this);
ConstantsOpenSdk.isDebug = true;
XMediaPlayerConstants.isDebug = true;
XmPlayerConfig.getInstance(this).setDefualtNotificationNickNameAndInfo("开心麻花", "开心开心,无敌开心");
if (BaseUtil.isMainProcess(this)) {
// 喜马拉雅
CommonRequest instanse = CommonRequest.getInstanse();
String mAppSecret = "db3cb9e3ec5943f4987e78ddc5aec728";
String mAppKey = "ff71a11162f20808f9f349452dd9e141";
instanse.setAppkey(mAppKey);
instanse.setAppsecret(mAppSecret);
instanse.setPackid("com.mints.goodmoney");
instanse.setUseHttps(false);
instanse.init(this, mAppSecret);
}
// 三方配置 // 三方配置
thirdConfig(); thirdConfig();
} }
...@@ -145,7 +161,7 @@ public class MintsApplication extends MultiDexApplication { ...@@ -145,7 +161,7 @@ public class MintsApplication extends MultiDexApplication {
RsNewsManager.INSTANCE.initX5Environment(this); RsNewsManager.INSTANCE.initX5Environment(this);
// 喜马拉雅 // 喜马拉雅
initXmly(); // initXmly();
} }
private void initXmly() { private void initXmly() {
......
...@@ -5,19 +5,19 @@ import android.view.LayoutInflater ...@@ -5,19 +5,19 @@ 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.ImageView
import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.mints.goodmoney.R import com.mints.goodmoney.R
import com.mints.library.utils.GlideUtils
import com.ximalaya.ting.android.opensdk.model.album.Album
class XmlyPageAdapter(val xmlyPageList: Any?) : class XmlyPageAdapter(val xmlyPageList: MutableList<Album>) :
RecyclerView.Adapter<XmlyPageAdapter.ViewHolder>() { RecyclerView.Adapter<XmlyPageAdapter.ViewHolder>() {
lateinit var context: Context lateinit var context: Context
lateinit var mOnItemClickListener: OnItemClickListener lateinit var mOnItemClickListener: OnItemClickListener
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 ivXmlyPage: ImageView = view.findViewById(R.id.ivXmlyPage)
val tvXmlyPageContent: TextView = view.findViewById(R.id.tvXmlyPageContent) val tvXmlyPageContent: TextView = view.findViewById(R.id.tvXmlyPageContent)
...@@ -32,13 +32,19 @@ class XmlyPageAdapter(val xmlyPageList: Any?) : ...@@ -32,13 +32,19 @@ class XmlyPageAdapter(val xmlyPageList: Any?) :
} }
override fun onBindViewHolder(holder: ViewHolder, position: Int) { override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val album = xmlyPageList[position]
holder.tvXmlyPageContent.text = album.recommendReason
holder.tvXmlyPagecount.text = album.playCount.toString()
GlideUtils.loadImageView(holder.itemView.context, album.coverUrlMiddle, holder.ivXmlyPage)
holder.itemView.setOnClickListener { holder.itemView.setOnClickListener {
mOnItemClickListener.onItemClick(position) if (::mOnItemClickListener.isInitialized) {
mOnItemClickListener.onItemClick(position)
}
} }
} }
// override fun getItemCount() = xmlyPageList?.size override fun getItemCount() = xmlyPageList.size
override fun getItemCount() = 15
interface OnItemClickListener { interface OnItemClickListener {
fun onItemClick(position: Int) fun onItemClick(position: Int)
......
package com.mints.goodmoney.ui.adapter
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.mints.goodmoney.R
import com.ximalaya.ting.android.opensdk.model.track.Track
class XmlyPlayAdapter(val xmlyPageList: MutableList<Track>) :
RecyclerView.Adapter<XmlyPlayAdapter.ViewHolder>() {
lateinit var context: Context
lateinit var mOnItemClickListener: OnItemClickListener
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val tvIndex: TextView = view.findViewById(R.id.tv_index)
val tvTitle: TextView = view.findViewById(R.id.tv_title)
val tvCount: TextView = view.findViewById(R.id.tv_count)
val tvFree: TextView = view.findViewById(R.id.tv_free)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
context = parent.context
val view = LayoutInflater.from(context).inflate(R.layout.item_rv_xmly_play, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val track = xmlyPageList[position]
holder.tvIndex.text = (position + 1).toString()
holder.tvTitle.text = track.trackTitle
holder.tvCount.text = track.playCount.toString()
holder.tvFree.text = track.isFree.toString()
holder.itemView.setOnClickListener {
if (::mOnItemClickListener.isInitialized) {
mOnItemClickListener.onItemClick(position)
}
}
}
override fun getItemCount() = xmlyPageList.size
interface OnItemClickListener {
fun onItemClick(position: Int)
}
fun setOnItemClickListener(listener: OnItemClickListener) {
mOnItemClickListener = listener
}
}
\ No newline at end of file
...@@ -2,6 +2,7 @@ package com.mints.goodmoney.ui.fragment ...@@ -2,6 +2,7 @@ package com.mints.goodmoney.ui.fragment
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.viewpager.widget.ViewPager import androidx.viewpager.widget.ViewPager
import com.fly.scenemodule.util.GsonUtils
import com.mints.goodmoney.R import com.mints.goodmoney.R
import com.mints.goodmoney.common.AppConfig import com.mints.goodmoney.common.AppConfig
import com.mints.goodmoney.common.Constant import com.mints.goodmoney.common.Constant
...@@ -22,6 +23,8 @@ class XmlyFragment : LazyLoadBaseFragment() { ...@@ -22,6 +23,8 @@ class XmlyFragment : LazyLoadBaseFragment() {
// 听书分类数据 // 听书分类数据
private var mCategoryList: CategoryList? = null private var mCategoryList: CategoryList? = null
private var mCurrentIndex = 0
override fun getContentViewLayoutID() = R.layout.fragment_main_xmly override fun getContentViewLayoutID() = R.layout.fragment_main_xmly
override fun initViewsAndEvents() { override fun initViewsAndEvents() {
...@@ -30,9 +33,9 @@ class XmlyFragment : LazyLoadBaseFragment() { ...@@ -30,9 +33,9 @@ class XmlyFragment : LazyLoadBaseFragment() {
override fun onFragmentFirstVisible() { override fun onFragmentFirstVisible() {
super.onFragmentFirstVisible() super.onFragmentFirstVisible()
showLoading("加载中...")
// 获取tab loadData()
initView()
} }
private fun loadData() { private fun loadData() {
...@@ -40,11 +43,15 @@ class XmlyFragment : LazyLoadBaseFragment() { ...@@ -40,11 +43,15 @@ class XmlyFragment : LazyLoadBaseFragment() {
val vo = hashMapOf<String, String>() val vo = hashMapOf<String, String>()
CommonRequest.getCategories(vo, object : IDataCallBack<CategoryList> { CommonRequest.getCategories(vo, object : IDataCallBack<CategoryList> {
override fun onSuccess(p0: CategoryList?) { override fun onSuccess(p0: CategoryList?) {
hideLoading()
mCategoryList = p0 mCategoryList = p0
initView()
} }
override fun onError(p0: Int, p1: String?) { override fun onError(p0: Int, p1: String?) {
LogUtil.e(p1) LogUtil.e(p1)
hideLoading()
} }
}) })
...@@ -58,19 +65,22 @@ class XmlyFragment : LazyLoadBaseFragment() { ...@@ -58,19 +65,22 @@ class XmlyFragment : LazyLoadBaseFragment() {
} }
private fun initView() { private fun initView() {
val tabs: MutableList<String> = ArrayList() mCategoryList?.let {
val fragments: MutableList<Fragment> = ArrayList() val tabs: MutableList<String> = ArrayList()
for (i in 1..10) { val fragments: MutableList<Fragment> = ArrayList()
tabs.add("视频" + i) for (i in 0 until it.categories.size) {
fragments.add(XmlyPageFragment(i)) tabs.add(it.categories[i].categoryName)
fragments.add(XmlyPageFragment(it.categories[i].id))
}
//去除两侧应阴影
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)
} }
//去除两侧应阴影
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 package com.mints.goodmoney.ui.fragment
import android.os.Bundle
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import com.fly.scenemodule.util.GsonUtils import com.fly.scenemodule.util.GsonUtils
import com.mints.goodmoney.R import com.mints.goodmoney.R
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.ui.activitys.AwardActivity
import com.mints.goodmoney.ui.activitys.XmlyPlayActivity
import com.mints.goodmoney.ui.adapter.XmlyPageAdapter import com.mints.goodmoney.ui.adapter.XmlyPageAdapter
import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment
import com.mints.goodmoney.utils.LogUtil import com.mints.goodmoney.utils.LogUtil
...@@ -13,31 +17,29 @@ import com.ximalaya.ting.android.opensdk.model.album.AlbumList ...@@ -13,31 +17,29 @@ import com.ximalaya.ting.android.opensdk.model.album.AlbumList
import com.scwang.smartrefresh.layout.api.RefreshLayout import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener
import com.scwang.smartrefresh.layout.listener.OnRefreshListener import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import com.ximalaya.ting.android.opensdk.model.album.Album
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: Long) : LazyLoadBaseFragment(),
XmlyPageAdapter.OnItemClickListener, XmlyPageAdapter.OnItemClickListener,
OnRefreshListener, OnRefreshListener,
OnLoadMoreListener { OnLoadMoreListener {
private lateinit var xmlyPageAdapter: XmlyPageAdapter private lateinit var xmlyPageAdapter: XmlyPageAdapter
private var xmlyData: MutableList<Any> = mutableListOf() private var xmlyData: MutableList<Album> = mutableListOf()
// 分页 // 分页
private var xmlyPage = 1 private var xmlyPage = 1
private val PAGE_SIZE = 15 private val PAGE_SIZE = 10
private var mAlbumList: AlbumList? = null
private var mPage = 1
private var mCount = 10
override fun getContentViewLayoutID() = R.layout.fragment_main_xmly_page override fun getContentViewLayoutID() = R.layout.fragment_main_xmly_page
override fun initViewsAndEvents() { override fun initViewsAndEvents() {
loadData()
} }
private fun loadData() { private fun loadData() {
...@@ -46,15 +48,23 @@ class XmlyPageFragment(private val categoryId: Int) : LazyLoadBaseFragment(), ...@@ -46,15 +48,23 @@ class XmlyPageFragment(private val categoryId: Int) : LazyLoadBaseFragment(),
vo[DTransferConstants.CATEGORY_ID] = categoryId.toString() vo[DTransferConstants.CATEGORY_ID] = categoryId.toString()
// 1-最火 2-最新 3-最多播放 // 1-最火 2-最新 3-最多播放
vo[DTransferConstants.CALC_DIMENSION] = "1" vo[DTransferConstants.CALC_DIMENSION] = "1"
vo[DTransferConstants.PAGE] = mPage.toString() vo[DTransferConstants.PAGE] = xmlyPage.toString()
vo["count"] = mCount.toString() vo[DTransferConstants.PAGE_SIZE] = PAGE_SIZE.toString()
CommonRequest.getAlbumList(vo, object : IDataCallBack<AlbumList> { CommonRequest.getAlbumList(vo, object : IDataCallBack<AlbumList> {
override fun onSuccess(p0: AlbumList?) { override fun onSuccess(p0: AlbumList?) {
mAlbumList = p0 if (p0 != null && p0.albums != null && p0.albums.size != 0) {
activity?.runOnUiThread {
getDataSuc(p0.albums)
}
} else {
getDataFail()
}
} }
override fun onError(p0: Int, p1: String?) { override fun onError(p0: Int, p1: String?) {
LogUtil.e(p1) LogUtil.e(p1)
getDataFail()
} }
}) })
...@@ -68,23 +78,26 @@ class XmlyPageFragment(private val categoryId: Int) : LazyLoadBaseFragment(), ...@@ -68,23 +78,26 @@ class XmlyPageFragment(private val categoryId: Int) : LazyLoadBaseFragment(),
} }
override fun onItemClick(position: Int) { override fun onItemClick(position: Int) {
showToast("界面:视频 item:${position}") val bundle = Bundle()
bundle.putLong(XmlyPlayActivity.ALBUM_ID, xmlyData[position].id)
readyGo(XmlyPlayActivity::class.java, bundle)
} }
override fun onRefresh(refreshLayout: RefreshLayout) { override fun onRefresh(refreshLayout: RefreshLayout) {
xmlyPage = 1 xmlyPage = 1
xmlyData.clear() xmlyData.clear()
// presenter.getData(xmlyPage) loadData()
} }
override fun onLoadMore(refreshLayout: RefreshLayout) { override fun onLoadMore(refreshLayout: RefreshLayout) {
// presenter.getData(++xmlyPage,PAGE_SIZE) xmlyPage = ++xmlyPage
loadData()
} }
private fun initRvView() { private fun initRvView() {
val gridLayoutManager = GridLayoutManager(context, 2) val gridLayoutManager = GridLayoutManager(context, 2)
xmlyPageVip.layoutManager = gridLayoutManager xmlyPageVip.layoutManager = gridLayoutManager
xmlyPageAdapter = XmlyPageAdapter(null) xmlyPageAdapter = XmlyPageAdapter(xmlyData)
xmlyPageVip.adapter = xmlyPageAdapter xmlyPageVip.adapter = xmlyPageAdapter
xmlyPageAdapter.setOnItemClickListener(this) xmlyPageAdapter.setOnItemClickListener(this)
} }
...@@ -106,18 +119,20 @@ class XmlyPageFragment(private val categoryId: Int) : LazyLoadBaseFragment(), ...@@ -106,18 +119,20 @@ class XmlyPageFragment(private val categoryId: Int) : LazyLoadBaseFragment(),
/** /**
* 获取数据成功 * 获取数据成功
*/ */
private fun getDataSuc(list: Any) { private fun getDataSuc(list: List<Album>) {
// xmlyData.addAll(list) if (::xmlyPageAdapter.isInitialized) {
// if (xmlyPage == 1) { xmlyData.addAll(list)
// srl_xmly.finishRefresh(true) if (xmlyPage == 1) {
// xmlyPageAdapter?.notifyDataSetChanged() srl_xmly.finishRefresh(true)
// } else { xmlyPageAdapter.notifyDataSetChanged()
// if (list.size < PAGE_SIZE) { } else {
// srl_xmly.finishLoadMoreWithNoMoreData() if (list.size < PAGE_SIZE) {
// } else { srl_xmly.finishLoadMoreWithNoMoreData()
// srl_xmly.finishLoadMore() } else {
// } srl_xmly.finishLoadMore()
// xmlyPageAdapter?.notifyItemChanged(list.size) }
// } xmlyPageAdapter.notifyItemChanged(list.size)
}
}
} }
} }
\ No newline at end of file
/**
* ToolUtil.java
* com.chad.android.library.util
* <p/>
* <p/>
* ver date author
* ---------------------------------------
* 2015-4-9 chadwii
* <p/>
* Copyright (c) 2015, chadwii All Rights Reserved.
*/
package com.mints.goodmoney.utils;
import android.content.Context;
import android.text.TextUtils;
import com.ximalaya.ting.android.opensdk.constants.ConstantsOpenSdk;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/**
* ClassName:ToolUtil
*
* @author chadwii
* @version
* @since Ver 1.1
* @Date 2015-4-9 5:17:32
*
* @see
*/
public class ToolUtil {
/**one hour in ms*/
private static final int ONE_HOUR = 1 * 60 * 60 * 1000;
/**one minute in ms*/
private static final int ONE_MIN = 1 * 60 * 1000;
/**one second in ms*/
private static final int ONE_SECOND = 1 * 1000;
private static int sScreenWidth;
private static int sScreenHeight;
private static float sDensity;
public static int dp2px(Context ctx, int dp) {
if (sDensity == 0) {
sDensity = ctx.getResources().getDisplayMetrics().density;
}
return (int) (dp * sDensity + 0.5f);
}
public static int px2dp(Context ctx, int px) {
if (sDensity == 0) {
sDensity = ctx.getResources().getDisplayMetrics().density;
}
return (int) (px / sDensity + 0.5f);
}
public static int getScreenWidth(Context ctx) {
if (sScreenWidth == 0) {
sScreenWidth = ctx.getResources().getDisplayMetrics().widthPixels;
}
return sScreenWidth;
}
public static int getScreenHeight(Context ctx) {
if (sScreenHeight == 0) {
sScreenHeight = ctx.getResources().getDisplayMetrics().heightPixels;
}
return sScreenHeight;
}
/**HH:mm:ss*/
public static String formatTime(long ms) {
StringBuilder sb = new StringBuilder();
int hour = (int) (ms / ONE_HOUR);
int min = (int) ((ms % ONE_HOUR) / ONE_MIN);
int sec = (int) (ms % ONE_MIN) / ONE_SECOND;
if (hour == 0) {
// sb.append("00:");
} else if (hour < 10) {
sb.append("0").append(hour).append(":");
} else {
sb.append(hour).append(":");
}
if (min == 0) {
sb.append("00:");
} else if (min < 10) {
sb.append("0").append(min).append(":");
} else {
sb.append(min).append(":");
}
if (sec == 0) {
sb.append("00");
} else if (sec < 10) {
sb.append("0").append(sec);
} else {
sb.append(sec);
}
return sb.toString();
}
public static boolean isEmpty(String str) {
if (str == null || str.trim().equals("") || str.trim().equals("null")) {
return true;
}
return false;
}
public static int isInTime(String time) throws IllegalArgumentException {
if (TextUtils.isEmpty(time) || !time.contains("-")
|| !time.contains(":")) {
if(ConstantsOpenSdk.isDebug) {
throw new IllegalArgumentException("Illegal Argument arg:" + time);
}else {
return -2;
}
}
String[] args = time.split("-");
boolean onlyHasHour = (args[0].split(":")).length == 2;
boolean hasDay = (args[0].split(":")).length == 3;
boolean hasYear = (args[0].split(":")).length == 5;
SimpleDateFormat sdf = null;
if (hasDay) {
sdf = new SimpleDateFormat("dd:HH:mm", Locale.getDefault());
} else if (hasYear) {
sdf = new SimpleDateFormat("yy:MM:dd:HH:mm", Locale.getDefault());
} else if (onlyHasHour) {
sdf = new SimpleDateFormat("HH:mm", Locale.getDefault());
}
if (sdf != null) {
String nowStr = sdf.format(new Date(System.currentTimeMillis()));
try {
long now = sdf.parse(nowStr).getTime();
long start = sdf.parse(args[0]).getTime();
if (args[1].contains("00:00") && hasDay) {
args[1] = (args[1].split(":"))[0] + ":" + "23:59";
} else if (args[1].contains("00:00") && hasYear) {
args[1] = (args[1].split(":"))[0] + ":"
+ (args[1].split(":"))[1] + ":"
+ (args[1].split(":"))[2] + ":" + "23:59";
} else if (args[1].contains("00:00") && onlyHasHour) {
args[1] = "23:59";
}
long end = sdf.parse(args[1]).getTime();
if (now >= end) {
return -1;
} else if (now >= start && now < end) {
return 0;
} else {
return 1;
}
} catch (ParseException e) {
e.printStackTrace();
if(ConstantsOpenSdk.isDebug) {
throw new IllegalArgumentException("Illegal Argument arg:"
+ time);
}else {
return -2;
}
}
}
return -2;
}
}
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/pre_icon_transparent_disable" android:state_enabled="false"></item>
<item android:drawable="@mipmap/pre_icon_transparent_pressed" android:state_enabled="true" android:state_pressed="true"></item>
<item android:drawable="@mipmap/pre_icon_transparent_normal" android:state_enabled="true" android:state_pressed="false"></item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<include layout="@layout/header_layout" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/control_bar"
android:layout_width="match_parent"
android:layout_height="120dp"
android:gravity="center"
android:padding="10dp"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="3dp">
<ImageView
android:id="@+id/sound_cover"
android:layout_width="110dp"
android:layout_height="110dp"
android:layout_alignParentLeft="true"
android:scaleType="fitCenter"
android:src="@mipmap/ic_draw_phone" />
<TextView
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/sound_cover"
android:maxLines="1"
android:text="no play sound"
android:textColor="@color/color_333" />
<TextView
android:id="@+id/time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/message"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/sound_cover"
android:maxLines="1"
android:textColor="@color/color_333" />
<SeekBar
android:id="@+id/seek_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/time"
android:layout_alignParentRight="true"
android:layout_marginBottom="10dp"
android:layout_toRightOf="@+id/sound_cover"
android:maxHeight="10dp"
android:minHeight="10dp" />
<ProgressBar
android:id="@+id/buffering_progress"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:visibility="gone" />
<ImageButton
android:id="@+id/pre_sound"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/seek_bar"
android:layout_alignParentBottom="true"
android:scaleType="fitCenter"
android:src="@mipmap/pre_icon_transparent_normal" />
<ImageButton
android:id="@+id/play_or_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/pre_sound"
android:layout_toRightOf="@+id/pre_sound"
android:scaleType="fitCenter"
android:src="@mipmap/widget_play_normal" />
<ImageButton
android:id="@+id/next_sound"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignTop="@+id/pre_sound"
android:layout_toRightOf="@+id/play_or_pause"
android:scaleType="fitCenter"
android:src="@mipmap/next_icon_transparent_normal" />
</RelativeLayout>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/srl_xmly"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/control_bar"
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:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:overScrollMode="never" />
<com.scwang.smartrefresh.layout.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
...@@ -42,12 +42,6 @@ ...@@ -42,12 +42,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="播放专辑内容" /> android:text="播放专辑内容" />
<Button
android:id="@+id/btn5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="播放音频" />
</LinearLayout> </LinearLayout>
</com.mints.goodmoney.ui.widgets.ElasticScrollView> </com.mints.goodmoney.ui.widgets.ElasticScrollView>
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
android:id="@+id/tv_title" android:id="@+id/tv_title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:maxLength="12"
android:textColor="@color/color_121B32" android:textColor="@color/color_121B32"
android:textSize="18sp" android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
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:layout_margin="6dp" android:layout_margin="6dp"
...@@ -20,6 +18,7 @@ ...@@ -20,6 +18,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="6dp" android:layout_margin="6dp"
android:ellipsize="end"
android:lines="1" android:lines="1"
android:singleLine="true" android:singleLine="true"
android:text="123213112321311232131123213112321311232131123213112321311232131123213112321311232131" android:text="123213112321311232131123213112321311232131123213112321311232131123213112321311232131"
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="100dp">
<TextView
android:id="@+id/tv_index"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="1"
android:textColor="@color/color_333"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_title"
android:layout_width="260dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:ellipsize="end"
android:maxLines="2"
android:text="111111111111111"
android:textColor="@color/color_333"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@id/tv_count"
app:layout_constraintStart_toEndOf="@+id/tv_index"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:drawableLeft="@mipmap/ic_headset"
android:drawablePadding="6dp"
android:gravity="center_vertical"
android:text="7.2亿"
android:textColor="@color/color_AAA"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/tv_index"
app:layout_constraintTop_toBottomOf="@id/tv_title" />
<TextView
android:id="@+id/tv_free"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:gravity="center_vertical"
android:text="7.2亿"
android:textColor="@color/color_AAA"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="@+id/tv_count"
app:layout_constraintStart_toEndOf="@+id/tv_count"
app:layout_constraintTop_toTopOf="@+id/tv_count" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -16,7 +16,7 @@ buildscript { ...@@ -16,7 +16,7 @@ buildscript {
} }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.0.0' classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }
} }
......
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