播放视频

This commit is contained in:
litingting 2024-10-29 17:34:49 +08:00
parent f342e2ff7a
commit 26eb76deb3
37 changed files with 705 additions and 443 deletions

View File

@ -39,38 +39,32 @@ public class AdapterCategory extends BaseAdapter<ResponseCategory, ItemCategoryB
ItemCategoryBinding vb = itemHolder.getVb();
ResponseCategory responseCategory = data.get(position);
String pageType = responseCategory.getPageType();
if(pageType.equals(MyValue.PAGE_TYPE_MV)){
ViewGroup.LayoutParams layoutParams = vb.header.getLayoutParams();
layoutParams.width = CommonUtils.dpToPx(260);
vb.header.setLayoutParams(layoutParams);
}else {
ViewGroup.LayoutParams layoutParams = vb.header.getLayoutParams();
layoutParams.width = CommonUtils.dpToPx(170);
vb.header.setLayoutParams(layoutParams);
}
Glide.with(MusicApplication.myApplication)
.asDrawable()
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(13))))
.load(responseCategory.getCovert())
.placeholder(R.drawable.placeholder)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {
CommonUtils.LogMsg(e.getMessage());
return false;
}
@Override
public boolean onResourceReady(@NonNull Drawable resource, @NonNull Object model, Target<Drawable> target, @NonNull DataSource dataSource, boolean isFirstResource) {
return false;
}
})
.into(vb.header);
vb.tvTitle.setText(responseCategory.getTwoTitle());
vb.tvSubtitle.setText(responseCategory.getTwoSubtitle());
CommonUtils.LogMsg("title="+responseCategory.getTwoTitle()+"----------pageType="+pageType
+"---browserId="+responseCategory.getBrowseId()+"---videoId="+responseCategory.getVideoId()+"---playListId="+responseCategory.getPlayListId());
if(pageType == null){
return;
}
// if(pageType.equals(MyValue.PAGE_TYPE_MV)||pageType.equals(MyValue.PAGE_TYPE_MV_LIST)){
// ViewGroup.LayoutParams layoutParams = vb.header.getLayoutParams();
// layoutParams.width = CommonUtils.dpToPx(280);
// vb.header.setLayoutParams(layoutParams);
// vb.header.setBackgroundResource(R.drawable.bg_black_13);
//
// }else {
// ViewGroup.LayoutParams layoutParams = vb.header.getLayoutParams();
// layoutParams.width = CommonUtils.dpToPx(170);
// vb.header.setLayoutParams(layoutParams);
// vb.header.setBackground(null);
// }
vb.header.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View File

@ -57,19 +57,18 @@ public class AdapterCategoryList extends BaseAdapter<ResponsePlayListInfo, ItemC
switch (mPageType){
case MyValue.PAGE_TYPE_ALBUM:
vb.tvSingerName.setText(describe);
vb.image.setVisibility(View.GONE);
vb.imCard.setVisibility(View.GONE);
vb.tvPosition.setVisibility(View.VISIBLE);
vb.tvPosition.setText(String.valueOf(position+1));
break;
default:
vb.tvSingerName.setText(singerName);
vb.image.setVisibility(View.VISIBLE);
vb.imCard.setVisibility(View.VISIBLE);
vb.tvPosition.setVisibility(View.GONE);
Glide.with(MusicApplication.myApplication)
.asDrawable()
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(16))))
.load(child.getSmallCovert())
.placeholder(R.drawable.placeholder)
.listener(new RequestListener<Drawable>() {
@ -94,6 +93,12 @@ public class AdapterCategoryList extends BaseAdapter<ResponsePlayListInfo, ItemC
homeItemClickListener.onClickItemCategoryList(child, itemHolder.getAbsoluteAdapterPosition());
}
});
if(position == data.size() - 1){
vb.place.setVisibility(View.VISIBLE);
}else {
vb.place.setVisibility(View.GONE);
}
}

View File

@ -36,12 +36,12 @@ public class AdapterHome extends BaseAdapter<ResponseHomeChild, ItemHomeBinding>
ItemHomeBinding vb = itemHolder.getVb();
ResponseHomeChild responseHomeChild = data.get(position);
vb.headTitle.setText(responseHomeChild.getHeaderTitle());
CommonUtils.LogMsg("position="+position+"-----------headTitle-=" + responseHomeChild.getHeaderTitle());
List<ResponseSingle> singleList = responseHomeChild.getSingleList();
List<ResponseCategory> categoryList = responseHomeChild.getCategoryList();
if (singleList != null && singleList.size() > 0) {
vb.recyclerSinger.setVisibility(View.VISIBLE);
CommonUtils.LogMsg("-----------singleList-=" + singleList.size());
AdapterSinger adapterSinger = new AdapterSinger();
adapterSinger.setHomeItemClickListener(homeItemClickListener);
adapterSinger.addData(singleList);
@ -50,10 +50,9 @@ public class AdapterHome extends BaseAdapter<ResponseHomeChild, ItemHomeBinding>
} else {
vb.recyclerSinger.setVisibility(View.GONE);
}
List<ResponseCategory> categoryList = responseHomeChild.getCategoryList();
if (categoryList != null && categoryList.size() > 0) {
vb.recyclerCategory.setVisibility(View.VISIBLE);
CommonUtils.LogMsg("-----------categoryList-=" + categoryList.size());
AdapterCategory adapterCategory = new AdapterCategory();
adapterCategory.setHomeItemClickListener(homeItemClickListener);
adapterCategory.addData(categoryList);
@ -62,6 +61,12 @@ public class AdapterHome extends BaseAdapter<ResponseHomeChild, ItemHomeBinding>
} else {
vb.recyclerCategory.setVisibility(View.GONE);
}
if(position == data.size() - 1){
vb.place.setVisibility(View.VISIBLE);
}else {
vb.place.setVisibility(View.GONE);
}
} else {
VHolder<ItemFooterLoadingBinding> footerHolder = (VHolder<ItemFooterLoadingBinding>) holder;
FrameLayout root = footerHolder.getVb().getRoot();

View File

@ -88,7 +88,7 @@ public class AdapterPlayList extends BaseAdapter<ResponsePlayListInfo, ItemPlayL
String covert = listInfo.getSmallCovert();
Glide.with(MusicApplication.myApplication)
.asDrawable()
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(10))))
// .apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(10))))
.load(covert)
.placeholder(R.drawable.placeholder)
.into(vb.imCovert);

View File

@ -3,6 +3,7 @@ package com.hi.music.player.adapter;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
@ -61,5 +62,11 @@ public class AdapterResult extends BaseAdapter<ResponseResultList, ItemResultBin
}
// vb.listChild.addItemDecoration(itemDecoration);
if(position == data.size() - 1){
vb.place.setVisibility(View.VISIBLE);
}else {
vb.place.setVisibility(View.GONE);
}
}
}

View File

@ -16,6 +16,9 @@ import com.hi.music.player.R;
import com.hi.music.player.databinding.ItemSearchBinding;
import com.hi.music.player.helper.CommonUtils;
import com.hi.music.player.javabean.response.ResponseSearch;
import com.hi.music.player.javabean.response.child.ResponseSearchChild;
import java.util.List;
public class AdapterSearch extends BaseAdapter<ResponseSearch, ItemSearchBinding> {
@Override
@ -58,12 +61,22 @@ public class AdapterSearch extends BaseAdapter<ResponseSearch, ItemSearchBinding
vb.layout.setPadding(0, 0, 0, 0);
}
AdapterSearchChild adapterSearchChild = new AdapterSearchChild();
adapterSearchChild.setData(responseSearch.getList());
vb.list.setAdapter(adapterSearchChild);
if (homeItemClickListener != null)
adapterSearchChild.setHomeItemClickListener(homeItemClickListener);
vb.list.setLayoutManager(new LinearLayoutManager(MusicApplication.myApplication));
List<ResponseSearchChild> list = responseSearch.getList();
if(list!= null&&list.size()>0){
AdapterSearchChild adapterSearchChild = new AdapterSearchChild();
adapterSearchChild.setData(list);
vb.list.setAdapter(adapterSearchChild);
if (homeItemClickListener != null)
adapterSearchChild.setHomeItemClickListener(homeItemClickListener);
vb.list.setLayoutManager(new LinearLayoutManager(MusicApplication.myApplication));
}
if(position == data.size() - 1){
vb.place.setVisibility(View.VISIBLE);
}else {
vb.place.setVisibility(View.GONE);
}
}
}

View File

@ -152,6 +152,29 @@ public class CommonUtils {
}
public static void getMainColor(Drawable imDraw, onImageColorListener listener){
BitmapDrawable drawable = (BitmapDrawable) imDraw;
// 使用 Palette 提取颜色
if (drawable != null) {
Bitmap bitmap = drawable.getBitmap();
Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
// 获取占比最大的颜色
Palette.Swatch dominantSwatch = palette.getDominantSwatch();
if (dominantSwatch != null) {
int dominantColor = dominantSwatch.getRgb(); // 获取 RGB 颜色
listener.onImageColor(dominantColor);
}else {
listener.onImageColor(-1);
}
}
});
}
}
public static Drawable getNewDrawable(int color, float RadiusTopLeft, float RadiusTopRight, float RadiusBottomRight, float RadiusBottomLeft) {
// 创建 GradientDrawable
GradientDrawable drawable = new GradientDrawable();

View File

@ -4,7 +4,7 @@ public class MyValue {
//live合集
// 现场表演
public static final String PAGE_TYPE_MV_LIST="MUSIC_PAGE_TYPE_USER_CHANNEL";
@ -94,4 +94,10 @@ public class MyValue {
//-----------------------------CategoryListActivity
//------------------------ResultListActivity
public static String KEY_SEARCH_RESULT_BROWSER_ID= "search_result_browser_id";
//-------------------------------------ResultListActivity
}

View File

@ -12,9 +12,19 @@ public class ResponseCategoryList implements Serializable {
private String description;
private String secondSubtitle;
private String singName;
private List<ResponsePlayListInfo> list;
public String getSingName() {
return singName;
}
public void setSingName(String singName) {
this.singName = singName;
}
public String getCovert() {
return covert;
}

View File

@ -13,8 +13,17 @@ public class ResponsePlayUrl {
private String videoId;
private String BigCovert;
private String videoUrlMedium;
public String getVideoUrlMedium() {
return videoUrlMedium;
}
public void setVideoUrlMedium(String videoUrlMedium) {
this.videoUrlMedium = videoUrlMedium;
}
public String getBigCovert() {
return BigCovert;
}

View File

@ -220,11 +220,12 @@ public class MyMediaControllerManager {
MediaItem.Builder builder = mediaItemAt.buildUpon();
builder.setMediaId(playUrl.getVideoId());
if (playUrl.getAudioUrlMedium() != null) {
builder.setUri(playUrl.getAudioUrlMedium());
} else {
builder.setUri(playUrl.getAudioUrlLow());
}
builder.setUri(playUrl.getVideoUrlMedium());
// if (playUrl.getAudioUrlMedium() != null) {
// builder.setUri(playUrl.getAudioUrlMedium());
// } else {
// builder.setUri(playUrl.getAudioUrlLow());
// }
//针对于已经从分类合集列表页面进入播放页面的数据(只有小的封面图)
if (mediaItemAt.mediaMetadata.artworkUri == null) {

View File

@ -163,36 +163,46 @@ public class JsonHelper {
try {
ResponsePlayUrl responsePlayUrl = new ResponsePlayUrl();
String status = jsonObject.getJSONObject("playabilityStatus").getString("status");
JSONObject streamingData = jsonObject.getJSONObject("streamingData");
// JSONArray jsonArray = streamingData.getJSONArray("adaptiveFormats");
// for (int i = 0; i < jsonArray.length(); i++) {
// JSONObject jsonIndex = jsonArray.getJSONObject(i);
//
// String mimeType = jsonIndex.getString("mimeType");
// String itag = jsonIndex.getString("itag");
// String url = jsonIndex.getString("url");
// if (mimeType.contains("video/mp4")) {
// String quality = jsonIndex.optString("quality");
// if(quality.equals("medium")){
// responsePlayUrl.setVideoUrlMedium(url);
// }
//
// }
// if (mimeType.contains("audio/mp4")) {
// String audioQuality1 = jsonIndex.optString("audioQuality");
// if (audioQuality1.equals("AUDIO_QUALITY_MEDIUM")) {
// responsePlayUrl.setAudioUrlMedium(url);
// } else {
// responsePlayUrl.setAudioUrlLow(url);
// }
//
// }
//
// }
JSONArray jsonArray = jsonObject.getJSONObject("streamingData").getJSONArray("adaptiveFormats");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonIndex = jsonArray.getJSONObject(i);
String videoUrl = streamingData.getJSONArray("formats").getJSONObject(0).getString("url");
responsePlayUrl.setVideoUrlMedium(videoUrl);
String mimeType = jsonIndex.getString("mimeType");
String itag = jsonIndex.getString("itag");
if (mimeType.contains("audio/mp4")) {
String url = jsonIndex.getString("url");
boolean audioQuality1 = jsonIndex.has("audioQuality");
if (jsonIndex.has("audioQuality")) {
String audioQuality = jsonIndex.getString("audioQuality");
if (audioQuality.equals("AUDIO_QUALITY_MEDIUM")) {
responsePlayUrl.setAudioUrlMedium(url);
} else {
responsePlayUrl.setAudioUrlLow(url);
}
}
}
}
JSONObject videoDetails = jsonObject.getJSONObject("videoDetails");
String videoId = videoDetails.getString("videoId");
String title = videoDetails.getString("title");
JSONArray thumbnails = videoDetails.getJSONObject("thumbnail").getJSONArray("thumbnails");
String url = thumbnails.getJSONObject(thumbnails.length() - 1).getString("url");
CommonUtils.LogMsg("title="+title+"-------videoUrl="+videoUrl);
responsePlayUrl.setBigCovert(url);
responsePlayUrl.setVideoId(videoId);
@ -245,6 +255,12 @@ public class JsonHelper {
String description = "";
JSONObject straplineTextOne = musicResponsiveHeaderRenderer.optJSONObject("straplineTextOne");
if (straplineTextOne != null) {
String jsonTitle = getJsonTitle(straplineTextOne, 0);
responseCategoryList.setSingName(jsonTitle);
}
//110 首歌曲.超过6小时
String secondSubtitle = getJsonTextNew(musicResponsiveHeaderRenderer.getJSONObject("secondSubtitle"));
@ -390,95 +406,95 @@ public class JsonHelper {
JSONObject contents = jsonArray.getJSONObject(i);
//最佳结果
//最佳结果
JSONObject musicCardShelfRenderer = contents.optJSONObject("musicCardShelfRenderer");
JSONObject musicShelfRenderer = contents.optJSONObject("musicShelfRenderer");
if(musicCardShelfRenderer!= null){
String covertUrl = getCovertUrl(musicCardShelfRenderer.getJSONObject("thumbnail"), true);
String title = getJsonTitle(musicCardShelfRenderer.getJSONObject("title"), 0);
String subtitle = getJsonTextNew(musicCardShelfRenderer.getJSONObject("subtitle"));
if (musicCardShelfRenderer != null) {
String covertUrl = getCovertUrl(musicCardShelfRenderer.getJSONObject("thumbnail"), true);
String title = getJsonTitle(musicCardShelfRenderer.getJSONObject("title"), 0);
String subtitle = getJsonTextNew(musicCardShelfRenderer.getJSONObject("subtitle"));
headerTitle = getJsonTitle(musicCardShelfRenderer.getJSONObject("header")
.getJSONObject("musicCardShelfHeaderBasicRenderer")
.getJSONObject("title"), 0);
contents1 = musicCardShelfRenderer.getJSONArray("contents");
headerTitle = getJsonTitle(musicCardShelfRenderer.getJSONObject("header")
.getJSONObject("musicCardShelfHeaderBasicRenderer")
.getJSONObject("title"), 0);
contents1 = musicCardShelfRenderer.optJSONArray("contents");
JSONObject jsonObject1 = musicCardShelfRenderer.getJSONObject("title")
.getJSONArray("runs")
.getJSONObject(0);
String[] browser = getBrowser(jsonObject1);
if (browser != null) {
responseSearch.setBeastBrowserId(browser[0]);
responseSearch.setPageType(browser[1]);
JSONObject jsonObject1 = musicCardShelfRenderer.getJSONObject("title")
.getJSONArray("runs")
.getJSONObject(0);
String[] browser = getBrowser(jsonObject1);
if (browser != null) {
responseSearch.setBeastBrowserId(browser[0]);
responseSearch.setPageType(browser[1]);
}
String[] watchEndPoint = getWatchEndPoint(jsonObject1);
if(watchEndPoint!= null){
responseSearch.setBeastVideoId(watchEndPoint[0]);
}
responseSearch.setBeastSongTCovert(covertUrl);
responseSearch.setBeastSongTitle(title);
responseSearch.setBeastSongDescribe(subtitle);
CommonUtils.LogMsg("--搜索结果 最佳" + "--songTitle=" + responseSearch.getBeastSongTitle() + "---videoId="+responseSearch.getBeastVideoId()+"---browserId="+responseSearch.getBeastBrowserId() );
}else if(musicShelfRenderer!= null){
headerTitle = getJsonTitle(musicShelfRenderer.getJSONObject("title"), 0);
contents1 = musicShelfRenderer.getJSONArray("contents");
}
String[] watchEndPoint = getWatchEndPoint(jsonObject1);
if (watchEndPoint != null) {
responseSearch.setBeastVideoId(watchEndPoint[0]);
}
responseSearch.setBeastSongTCovert(covertUrl);
responseSearch.setBeastSongTitle(title);
responseSearch.setBeastSongDescribe(subtitle);
CommonUtils.LogMsg("--搜索结果 最佳" + "--songTitle=" + responseSearch.getBeastSongTitle() + "---videoId=" + responseSearch.getBeastVideoId() + "---browserId=" + responseSearch.getBeastBrowserId());
} else if (musicShelfRenderer != null) {
headerTitle = getJsonTitle(musicShelfRenderer.getJSONObject("title"), 0);
contents1 = musicShelfRenderer.optJSONArray("contents");
}
responseSearch.setHeaderTitle(headerTitle);
List<ResponseSearchChild> list = new ArrayList<>();
if(contents1!=null){
for (int k = 0; k < contents1.length(); k++) {
ResponseSearchChild responseSearchChild = new ResponseSearchChild();
if (contents1 != null) {
for (int k = 0; k < contents1.length(); k++) {
ResponseSearchChild responseSearchChild = new ResponseSearchChild();
JSONObject musicResponsiveListItemRenderer = contents1.getJSONObject(k)
.optJSONObject("musicResponsiveListItemRenderer");
JSONObject musicResponsiveListItemRenderer = contents1.getJSONObject(k)
.optJSONObject("musicResponsiveListItemRenderer");
String playCount = "";
String songTitle = "";
String videoId = "";
String describe = "";
String browserId = "";
String pageType = "";
String playCount = "";
String songTitle = "";
String videoId = "";
String describe = "";
String browserId = "";
String pageType = "";
String covertUrl1 = "";
if(musicResponsiveListItemRenderer!= null){
covertUrl1 = getCovertUrl(musicResponsiveListItemRenderer.
getJSONObject("thumbnail")
.getJSONObject("musicThumbnailRenderer"), true);
String covertUrl1 = "";
if (musicResponsiveListItemRenderer != null) {
covertUrl1 = getCovertUrl(musicResponsiveListItemRenderer.
getJSONObject("thumbnail")
.getJSONObject("musicThumbnailRenderer"), true);
String[] browser1 = getBrowser(musicResponsiveListItemRenderer);
if (browser1 != null) {
browserId = browser1[0];
pageType = browser1[1];
if(Objects.equals(pageType, "MUSIC_PAGE_TYPE_PODCAST_SHOW_DETAIL_PAGE") ||pageType.equals("MUSIC_PAGE_TYPE_USER_CHANNEL")){
//博客或者个人资料
continue;
}
}
String[] browser1 = getBrowser(musicResponsiveListItemRenderer);
if (browser1 != null) {
browserId = browser1[0];
pageType = browser1[1];
if (Objects.equals(pageType, "MUSIC_PAGE_TYPE_PODCAST_SHOW_DETAIL_PAGE") || pageType.equals("MUSIC_PAGE_TYPE_USER_CHANNEL")) {
//博客或者个人资料
continue;
}
}
JSONArray flexColumns = musicResponsiveListItemRenderer.getJSONArray("flexColumns");
for (int h = 0; h < flexColumns.length(); h++) {
JSONObject musicResponsiveListItemFlexColumnRenderer = flexColumns.getJSONObject(h)
.getJSONObject("musicResponsiveListItemFlexColumnRenderer");
JSONObject text = musicResponsiveListItemFlexColumnRenderer.getJSONObject("text");
if (h == 0) {
songTitle = getJsonTitle(text, 0);
String[] runs = getWatchEndPoint(text.getJSONArray("runs").getJSONObject(0));
videoId = runs[0];
} else if (h == 1) {
describe = getJsonTextNew(text);
} else {
playCount = getJsonTitle(text, 0);
}
JSONArray flexColumns = musicResponsiveListItemRenderer.getJSONArray("flexColumns");
for (int h = 0; h < flexColumns.length(); h++) {
JSONObject musicResponsiveListItemFlexColumnRenderer = flexColumns.getJSONObject(h)
.getJSONObject("musicResponsiveListItemFlexColumnRenderer");
JSONObject text = musicResponsiveListItemFlexColumnRenderer.getJSONObject("text");
if (h == 0) {
songTitle = getJsonTitle(text, 0);
String[] runs = getWatchEndPoint(text.getJSONArray("runs").getJSONObject(0));
videoId = runs[0];
} else if (h == 1) {
describe = getJsonTextNew(text);
} else {
playCount = getJsonTitle(text, 0);
}
// JSONArray runs = text.getJSONArray("runs");
// for (int g = 0; g < runs.length(); g++) {
@ -490,30 +506,29 @@ public class JsonHelper {
// }
// }
}
boolean b = videoId == null || videoId.isEmpty();
if(b&&pageType.isEmpty()){
continue;
}
responseSearchChild.setBrowserId(browserId);
responseSearchChild.setPageType(pageType);
responseSearchChild.setSongCovert(covertUrl1);
responseSearchChild.setSongTitle(songTitle);
responseSearchChild.setSongDescribe(describe);
responseSearchChild.setSongPlayCount(playCount);
responseSearchChild.setSongVideoId(videoId);
CommonUtils.LogMsg("--搜索结果 videoId=" + videoId + "--songTitle=" + songTitle + "---browserId=" + browserId+"---pageType="+pageType);
list.add(responseSearchChild);
}
}
boolean b = videoId == null || videoId.isEmpty();
if (b && pageType.isEmpty()) {
continue;
}
responseSearchChild.setBrowserId(browserId);
responseSearchChild.setPageType(pageType);
responseSearchChild.setSongCovert(covertUrl1);
responseSearchChild.setSongTitle(songTitle);
responseSearchChild.setSongDescribe(describe);
responseSearchChild.setSongPlayCount(playCount);
responseSearchChild.setSongVideoId(videoId);
CommonUtils.LogMsg("--搜索结果 videoId=" + videoId + "--songTitle=" + songTitle + "---browserId=" + browserId + "---pageType=" + pageType);
list.add(responseSearchChild);
}
}
}
if(list.size()>0){
responseSearch.setList(list);
searchList.add(responseSearch);
}
}
if (list.size() > 0) {
responseSearch.setList(list);
}
searchList.add(responseSearch);
}
return searchList;
@ -565,7 +580,7 @@ public class JsonHelper {
if (musicShelfRenderer != null) {
String headerTitle = getJsonTitle(musicShelfRenderer.getJSONObject("title"), 0);
resultList.setHeaderTitle(headerTitle);
CommonUtils.LogMsg("----------结果子页面111--------------------headerTitle"+headerTitle);
CommonUtils.LogMsg("----------结果子页面111--------------------headerTitle" + headerTitle);
JSONArray contents1 = musicShelfRenderer.getJSONArray("contents");
for (int f = 0; f < contents1.length(); f++) {
ResponseResultListChild responseResultListChild = new ResponseResultListChild();
@ -610,15 +625,15 @@ public class JsonHelper {
responseResultListChild.setVideoId(videoId);
responseResultListChild.setPlayListId(playLIstId);
CommonUtils.LogMsg("----------结果子页面111 songName="+songName+"---videoId="+videoId+"--playLIstId="+playLIstId);
CommonUtils.LogMsg("----------结果子页面111 songName=" + songName + "---videoId=" + videoId + "--playLIstId=" + playLIstId);
childList.add(responseResultListChild);
}
} else if (musicCarouselShelfRenderer != null) {
String headerTitle = getJsonTitle(musicCarouselShelfRenderer.getJSONObject("header")
String headerTitle = getJsonTitle(musicCarouselShelfRenderer.getJSONObject("header")
.getJSONObject("musicCarouselShelfBasicHeaderRenderer")
.getJSONObject("title"),0);
.getJSONObject("title"), 0);
resultList.setHeaderTitle(headerTitle);
CommonUtils.LogMsg("----------结果子页面222--------------------headerTitle"+headerTitle);
CommonUtils.LogMsg("----------结果子页面222--------------------headerTitle" + headerTitle);
JSONArray contents1 = musicCarouselShelfRenderer.getJSONArray("contents");
for (int f = 0; f < contents1.length(); f++) {
ResponseResultListChild responseResultListChild = new ResponseResultListChild();
@ -634,13 +649,13 @@ public class JsonHelper {
String[] browser = getBrowser(title.getJSONArray("runs").getJSONObject(0));
String subtitle = getJsonTextNew(musicTwoRowItemRenderer.getJSONObject("subtitle"));
if(browser!= null){
if (browser != null) {
String browserId = browser[0];
responseResultListChild.setBrowserId(browserId);
responseResultListChild.setPageType(browser[1]);
}
String[] watchEndPoint = getWatchEndPoint(musicTwoRowItemRenderer);
if(watchEndPoint!=null){
if (watchEndPoint != null) {
responseResultListChild.setVideoId(watchEndPoint[0]);
responseResultListChild.setPlayListId(watchEndPoint[1]);
}
@ -648,8 +663,8 @@ public class JsonHelper {
responseResultListChild.setSongName(albumName);
responseResultListChild.setSubTitle(subtitle);
CommonUtils.LogMsg("----------结果子页面222 songName="+albumName+"---videoId="+responseResultListChild.getVideoId()+"--playLIstId="+responseResultListChild.getPlayListId()
+"---BrowserId="+responseResultListChild.getBrowserId()+"---PageType="+responseResultListChild.getPageType());
CommonUtils.LogMsg("----------结果子页面222 songName=" + albumName + "---videoId=" + responseResultListChild.getVideoId() + "--playLIstId=" + responseResultListChild.getPlayListId()
+ "---BrowserId=" + responseResultListChild.getBrowserId() + "---PageType=" + responseResultListChild.getPageType());
childList.add(responseResultListChild);
}
}
@ -672,27 +687,6 @@ public class JsonHelper {
}
private static ResponsePlayListInfo getCommonCategoryList(JSONObject musicResponsiveListItemRenderer) throws JSONException {
JSONObject jsonText = musicResponsiveListItemRenderer.getJSONArray("fixedColumns")
.getJSONObject(0)
@ -831,7 +825,6 @@ public class JsonHelper {
//------------------------音乐合集或者专辑
ResponseCategory responseCategory = new ResponseCategory();
String covert = getCovertUrl(musicTwoRowItemRenderer.getJSONObject("thumbnailRenderer"), true);
CommonUtils.LogMsg("----图片-------------音乐合集或者专辑=" + covert);
JSONObject title1 = musicTwoRowItemRenderer.getJSONObject("title");
String twoTitle = getJsonTitle(title1, 0);
@ -839,6 +832,7 @@ public class JsonHelper {
String browseId = "";
String pageType = "";
JSONObject runs = title1
.getJSONArray("runs")
.getJSONObject(0);
@ -847,24 +841,22 @@ public class JsonHelper {
.getJSONArray("runs")
.getJSONObject(0);
JSONObject browseEndpoint = null;
if (runs.has("navigationEndpoint")) {
//-------------当pageType="MUSIC_PAGE_TYPE_PLAYLIST""MUSIC_PAGE_TYPE_ALBUM" 走这里
browseEndpoint = runs.getJSONObject("navigationEndpoint")
.getJSONObject("browseEndpoint");
String[] browser = null;
String[] browserTiTle = getBrowser(runs);
String[] browserSub = getBrowser(subtitle);
if (browserTiTle != null) {
browser = browserTiTle;
} else {
browser = browserSub;
}
if (browseEndpoint != null) {
browseId = browseEndpoint
.getString("browseId");
CommonUtils.LogMsg(" ----------2222222222----twoTitle=" + twoTitle + "-browseId=" + browseId);
String pageType = browseEndpoint.getJSONObject("browseEndpointContextSupportedConfigs")
.getJSONObject("browseEndpointContextMusicConfig")
.getString("pageType");
if (browser != null) {
//-------------当pageType="MUSIC_PAGE_TYPE_PLAYLIST""MUSIC_PAGE_TYPE_ALBUM" 走这里
browseId = browser[0];
pageType = browser[1];
responseCategory.setPageType(pageType);
responseCategory.setBrowseId(browseId);
if (pageType.equals(MyValue.PAGE_TYPE_MV)) {
if (pageType.equals(MyValue.PAGE_TYPE_MV) || pageType.equals(MyValue.PAGE_TYPE_MV_LIST)) {
//视频mv 需要获取videoId 和PlayListId 用于进入播放页面请求播放列表数据
JSONObject jsonObject = musicTwoRowItemRenderer.getJSONObject("menu")
@ -969,9 +961,6 @@ public class JsonHelper {
index = length - 2;
}
String pngUrl = jsonArray.getJSONObject(index).getString("url");
CommonUtils.LogMsg("----------取封面index=" + index);
return pngUrl;
} catch (JSONException exception) {
return null;

View File

@ -42,10 +42,10 @@ public interface MusicApi {
// "X-Goog-FieldMask:playabilityStatus.status,playerConfig.audioConfig,streamingData.adaptiveFormats,videoDetails.videoId,videoDetails.thumbnail"
//获取播放音频资源url "X-Goog-Api-Key:AIzaSyC9XL3ZjwddXya6X74dJOCTL-WEYFDNX30"
@POST("youtubei/v1/player?prettyPrint=false")
@Headers({"X-Goog-Api-Key:AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8",
"X-Goog-FieldMask:playabilityStatus.status,playerConfig.audioConfig,streamingData.adaptiveFormats,videoDetails.videoId,videoDetails.thumbnail"})
@Headers({"X-Goog-Api-Key:AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8"})
Observable<ResponseBody> getMusicPlayUrl(@Body RequestBody requestBody);

View File

@ -1,8 +1,5 @@
package com.hi.music.player.ui.activity;
import static android.view.Gravity.CENTER_HORIZONTAL;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
@ -11,11 +8,9 @@ import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.MediaController;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsControllerCompat;
import androidx.lifecycle.Observer;
@ -26,9 +21,7 @@ import androidx.viewbinding.ViewBinding;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.gyf.immersionbar.ImmersionBar;
import com.hi.music.player.MusicApplication;
import com.hi.music.player.R;
import com.hi.music.player.databinding.ActivityBaseBinding;
import com.hi.music.player.databinding.LayoutPanelBinding;
import com.hi.music.player.helper.CommonUtils;
@ -37,8 +30,6 @@ import com.hi.music.player.helper.ViewModelScope;
import com.hi.music.player.media3.MyMediaControllerManager;
import com.hi.music.player.ui.activity.viewmodel.VMApplication;
import java.io.IOException;
public abstract class BaseActivity<T extends ViewBinding> extends AppCompatActivity implements View.OnClickListener {
private final ViewModelScope mViewModelScope = new ViewModelScope();
@ -108,10 +99,8 @@ public abstract class BaseActivity<T extends ViewBinding> extends AppCompatActiv
public void onClick(View v) {
panelVb.imPlay.setSelected(!panelVb.imPlay.isSelected());
if (panelVb.imPlay.isSelected()) {
// panelVb.imPlay.setImageResource(R.drawable.panel_icon_pause);
mediaControllerManager.play();
} else {
// panelVb.imPlay.setImageResource(R.drawable.panel_icon_play);
mediaControllerManager.pause();
}
@ -163,7 +152,7 @@ public abstract class BaseActivity<T extends ViewBinding> extends AppCompatActiv
case Player.STATE_ENDED:
case Player.STATE_READY:
case MyValue.PLAY_STATUS_CHANGE_MUSIC:
case MyValue.PLAY_STATUS_CODE_PAUSE:
case Player.STATE_BUFFERING:
case MyValue.PLAY_STATUS_CODE_ERROR:
@ -172,6 +161,7 @@ public abstract class BaseActivity<T extends ViewBinding> extends AppCompatActiv
//播放完成
panelVb.imPlay.setSelected(false);
break;
case MyValue.PLAY_STATUS_CHANGE_MUSIC:
case MyValue.PLAY_STATUS_CODE_PLAYING:
panelVb.imPlay.setSelected(true);
break;

View File

@ -85,7 +85,8 @@ public class CategoryListActivity extends BaseActivity<ActivityCategoryListBindi
@Override
public void onChanged(ResponseCategoryList responseCategoryList) {
if (responseCategoryList == null) {
vb.pbLoading.setVisibility(View.GONE);
updateErrorLayout(getString(R.string.playList_loading_failed),true);
return;
}
mCategoryList = responseCategoryList;
@ -94,11 +95,20 @@ public class CategoryListActivity extends BaseActivity<ActivityCategoryListBindi
}
});
}
private void updateErrorLayout(String msg, boolean isShow) {
if (isShow)
vb.layoutError.linearRetry.setVisibility(View.VISIBLE);
else vb.layoutError.linearRetry.setVisibility(View.GONE);
if(msg!= null&&!msg.isEmpty()){
vb.layoutError.tvErrorMsg.setText(msg);
}
}
@Override
protected void onInitClick() {
vb.imBack.setOnClickListener(this);
vb.btnPlay.setOnClickListener(this);
vb.layoutError.tvRetry.setOnClickListener(this);
}
@Override
@ -128,6 +138,10 @@ public class CategoryListActivity extends BaseActivity<ActivityCategoryListBindi
intent.putExtra(MyValue.KEY_ENTER_SOURCE, MyValue.TYPE_ENTER_SOURCE_CATEGORY);
startActivity(intent);
vmApplication.reSetPlayList(mCategoryList.getList());
}else if(v.equals(vb.layoutError.tvRetry)){
vb.pbLoading.setVisibility(View.VISIBLE);
updateErrorLayout(null,false);
vm.getList(browseId);
}
}
@ -139,14 +153,20 @@ public class CategoryListActivity extends BaseActivity<ActivityCategoryListBindi
break;
case MyValue.PAGE_TYPE_ALBUM:
vb.tvSingerName.setVisibility(View.VISIBLE);
String[] split = twoSubtitle.split("");
CommonUtils.LogMsg("twoSubtitle=" + twoSubtitle);
if (split != null && split.length > 1) {
vb.tvSingerName.setText(split[1]);
for (ResponsePlayListInfo playListInfo : info.getList()) {
playListInfo.setSingerName(split[1]);
String singNameValue = "";
String singName = info.getSingName();
if(singName!= null&&!singName.isEmpty()){
singNameValue= singName;
}else {
String[] split = twoSubtitle.split("");
if (split != null && split.length > 1) {
singNameValue = split[1];
}
}
CommonUtils.LogMsg("singNameValue=" + singNameValue);
vb.tvSingerName.setText(singNameValue);
for (ResponsePlayListInfo playListInfo : info.getList()) {
playListInfo.setSingerName(singNameValue);
}
break;
}
@ -177,8 +197,7 @@ public class CategoryListActivity extends BaseActivity<ActivityCategoryListBindi
@Override
public boolean onResourceReady(@NonNull Drawable resource, @NonNull Object model, Target<Drawable> target, @NonNull DataSource dataSource, boolean isFirstResource) {
// CommonUtils.extractColorsFromImage(resource,vb.imBg);
CommonUtils.extractColorsFromImage(resource,vb.imBg);
return false;
}
})

View File

@ -56,17 +56,10 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
private ResponseSingle responseSingle;
private VMPlay vmPlay;
// private VMApplication vmApplication;
private ResponsePlayUrl mCurPlayInfo;
private Handler mHandler;
private Runnable mRunnable;
// private MyMediaControllerManager mediaControllerManager;
private AdapterPlayList adapterPlayList;
@ -112,16 +105,18 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
vmPlay = getActivityScopeViewModel(VMPlay.class);
// vmApplication = getApplicationScopeViewModel(VMApplication.class);
initMediaController();
vb.progressBarLoading.setVisibility(View.VISIBLE);
// vb.progressBarLoading.setVisibility(View.VISIBLE);
Intent intent = getIntent();
mEnterType = intent.getIntExtra(MyValue.KEY_ENTER_SOURCE, MyValue.TYPE_ENTER_SOURCE_SINGLE);
initPlayerView();
initProgressHandler();
CommonUtils.LogMsg("--------mEnterType=" + mEnterType);
switch (mEnterType) {
case MyValue.TYPE_ENTER_SOURCE_SINGLE:
// 0--首页单曲进入
// 0--首页单曲进入
updateMediaPlayList();
responseSingle = (ResponseSingle) intent.getSerializableExtra(MyValue.KEY_PLAY_ACTIVITY_SINGER);
playlistId = responseSingle.getPlaylistId();
@ -138,17 +133,16 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
});
break;
case MyValue.TYPE_ENTER_SOURCE_CATEGORY:
// 1--首页音乐分类合集列表进入
// 1--首页音乐分类合集列表进入
updateMediaPlayList();
ResponsePlayListInfo playListInfo = (ResponsePlayListInfo) intent.getSerializableExtra(MyValue.KEY_PLAY_ACTIVITY_CATEGORY_LIST);
mDefaultPlayStartIndex = intent.getIntExtra(MyValue.KEY_PLAY_ACTIVITY_CATEGORY_LIST_INDEX, mDefaultPlayStartIndex);
videoId = playListInfo.getVideoId();
CommonUtils.LogMsg("--------更新---videoId=" + videoId);
break;
case MyValue.TYPE_ENTER_SOURCE_MV:
// 2--首页单个视频mv进入
// 2--首页单个视频mv进入
updateMediaPlayList();
ResponseCategory responseCategory = (ResponseCategory) intent.getSerializableExtra(MyValue.KEY_PLAY_ACTIVITY_MV);
@ -183,16 +177,15 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
if (customerUrlInfo.isNeedPlayNow() && customerUrlInfo.getPlayUrl() == null) {
// TODO: 2024/9/26 需要马上播放这首歌曲但是此次网络请求失败
CommonUtils.LogErrorMsg("-------------需要马上播放这首歌曲,但是此次网络请求失败");
updateErrorLayout(getString(R.string.song_loading_failed),true);
netError = 1;
mCustomerUrlInfo = customerUrlInfo;
initShowPlayList(false);
vb.linearRetry.setVisibility(View.VISIBLE);
vb.progressBarLoading.setVisibility(View.GONE);
mediaControllerManager.pause();
return;
}
mCurPlayInfo = customerUrlInfo.getPlayUrl();
int second = customerUrlInfo.getPlayMusicIndex();
boolean needPlayNow = customerUrlInfo.isNeedPlayNow();
if (needPlayNow) {
@ -211,12 +204,13 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
if (playList == null) {
CommonUtils.LogErrorMsg("--------更新-playList null");
netError = 0;
vb.linearRetry.setVisibility(View.VISIBLE);
updateErrorLayout(getString(R.string.playList_loading_failed),true);
vb.progressBarLoading.setVisibility(View.GONE);
return;
}
CommonUtils.LogMsg("--------更新-playList " + playList.size() + "--videoId=" + videoId);
if (playList.size() > 0) {
vb.linearRetry.setVisibility(View.GONE);
updateErrorLayout(null,false);
setPlayListAndGetUrl(playList, videoId, mDefaultPlayStartIndex);
}
@ -224,6 +218,16 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
});
}
private void updateErrorLayout(String msg, boolean isShow) {
if (isShow)
vb.layoutError.linearRetry.setVisibility(View.VISIBLE);
else vb.layoutError.linearRetry.setVisibility(View.GONE);
if(msg!= null&&!msg.isEmpty()){
vb.layoutError.tvErrorMsg.setText(msg);
}
}
/**
* 设置播放列表并请求当前需要播放的音乐url
*
@ -241,7 +245,7 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
private void initPlayerView() {
vb.playerView.setShowRewindButton(false);
vb.playerView.setShowPreviousButton(false);
vb.playerView.setDefaultArtwork(ContextCompat.getDrawable(this, R.mipmap.ic_launcher));
vb.playerView.setPlayer(mediaControllerManager.getMediaController());
}
private void initMediaController() {
@ -270,7 +274,7 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
case Player.STATE_BUFFERING:
//快进没有缓冲的时候触发
vb.btnPlay.setSelected(false);
vb.progressBarLoading.setVisibility(View.VISIBLE);
// vb.progressBarLoading.setVisibility(View.VISIBLE);
CommonUtils.LogMsg("-------------缓冲");
break;
case Player.STATE_READY:
@ -297,7 +301,7 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
CommonUtils.LogMsg("------------- 播放ing getCurIndex=" + mediaControllerManager.getCurIndex());
vb.progressBarLoading.setVisibility(View.GONE);
vb.linearRetry.setVisibility(View.GONE);
updateErrorLayout(null,false);
vb.btnPlay.setSelected(true);
vb.layoutPlayList.imPlay.setSelected(true);
break;
@ -315,7 +319,7 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
@Override
public void onRequestNextUri(String videoId, int playListIndex, boolean playNow) {
if (playNow) {
vb.progressBarLoading.setVisibility(View.VISIBLE);
// vb.progressBarLoading.setVisibility(View.VISIBLE);
}
vmPlay.getPlayUrl(videoId, playListIndex, playNow);
}
@ -338,7 +342,7 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
vb.btnPrevious.setOnClickListener(this);
vb.imBack.setOnClickListener(this);
vb.btnMusicList.setOnClickListener(this);
vb.tvRetry.setOnClickListener(this);
vb.layoutError.tvRetry.setOnClickListener(this);
vb.btnLoop.setOnClickListener(this);
}
@ -396,6 +400,7 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
}
private void loadCovert(String url) {
Glide.with(MusicApplication.myApplication)
.asDrawable()
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(16))))
@ -405,22 +410,25 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
@Override
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {
CommonUtils.LogMsg(e.getMessage());
netError = 2;
vb.linearRetry.setVisibility(View.VISIBLE);
// netError = 2;
// vb.tvErrorMsg.setText(getString(R.string.image_loading_failed));
// vb.linearRetry.setVisibility(View.VISIBLE);
return false;
}
@OptIn(markerClass = UnstableApi.class)
@Override
public boolean onResourceReady(@NonNull Drawable resource, @NonNull Object model, Target<Drawable> target, @NonNull DataSource dataSource, boolean isFirstResource) {
CommonUtils.getDominantDarkColor1(resource, new onImageColorListener() {
vb.playerView.setDefaultArtwork(resource);
CommonUtils.getMainColor(resource, new onImageColorListener() {
@Override
public void onImageColor(int color) {
if (color == -1) {
return;
}
lighterColor = CommonUtils.adjustBrightness(color, 1.2f); // 比原始颜色亮 20%
darkerColor = CommonUtils.adjustBrightness(color, 0.8f); // 比原始颜色暗 20%
lighterColor = CommonUtils.adjustBrightness(color, 1f); // 比原始颜色亮 20%
darkerColor = CommonUtils.adjustBrightness(color, 0.6f); // 比原始颜色暗 20%
gradientDrawable = new GradientDrawable(
GradientDrawable.Orientation.TOP_BOTTOM,
new int[]{lighterColor, darkerColor} // 浅到深渐变
@ -430,15 +438,34 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
if (vb.layoutPlayList.linearLayout.getVisibility() == View.VISIBLE) {
updatePlayListColor();
}
}
});
// CommonUtils.getDominantDarkColor1(resource, new onImageColorListener() {
// @Override
// public void onImageColor(int color) {
// if (color == -1) {
// return;
// }
// lighterColor = CommonUtils.adjustBrightness(color, 1f); // 比原始颜色亮 20%
// darkerColor = CommonUtils.adjustBrightness(color, 0.6f); // 比原始颜色暗 20%
// gradientDrawable = new GradientDrawable(
// GradientDrawable.Orientation.TOP_BOTTOM,
// new int[]{lighterColor, darkerColor} // 浅到深渐变
// );
// vb.rootLayout.setBackground(gradientDrawable);
//
// if (vb.layoutPlayList.linearLayout.getVisibility() == View.VISIBLE) {
// updatePlayListColor();
// }
//
//
// }
// });
return false;
}
})
.into(vb.imCovert);
.preload();
}
@ -483,8 +510,8 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
mediaControllerManager.playNext(new onPlayNextListener() {
@Override
public void onPlayNext(boolean hasNext) {
if(!hasNext){
Toast.makeText(PlayActivity.this,getString(R.string.no_next_song_yet),Toast.LENGTH_SHORT).show();
if (!hasNext) {
Toast.makeText(PlayActivity.this, getString(R.string.no_next_song_yet), Toast.LENGTH_SHORT).show();
}
}
});
@ -505,10 +532,10 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
if (adapterPlayList != null) {
adapterPlayList.updateCurMusicAnimation();
}
} else if (v.equals(vb.tvRetry)) {
} else if (v.equals(vb.layoutError.tvRetry)) {
//重试按钮
vb.linearRetry.setVisibility(View.GONE);
switch (netError){
updateErrorLayout(null,false);
switch (netError) {
case 0:
switch (mEnterType) {
case MyValue.TYPE_ENTER_SOURCE_SINGLE:
@ -601,7 +628,7 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
updatePlayListColor();
Glide.with(MusicApplication.myApplication)
.asDrawable()
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(10))))
// .apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(10))))
.load(artworkUri)
.placeholder(R.drawable.placeholder)
.listener(new RequestListener<Drawable>() {

View File

@ -40,7 +40,7 @@ public class ResultListActivity extends BaseActivity<ActivityResultListBinding>
@Override
protected void onCreateInit() {
vm = getActivityScopeViewModel(VMResultList.class);
String key = getIntent().getStringExtra("key");
String key = getIntent().getStringExtra(MyValue.KEY_SEARCH_RESULT_BROWSER_ID);
vm.getList(key);
vm.data.observe(this, new Observer<ResponseResult>() {
@ -136,8 +136,7 @@ public class ResultListActivity extends BaseActivity<ActivityResultListBinding>
switch (pageType){
case "MUSIC_PAGE_TYPE_ALBUM":
//专辑
CommonUtils.LogMsg("------------专辑-index="+index+"--subTitle="+subTitle);
case "MUSIC_PAGE_TYPE_PLAYLIST":
//精选
Intent intent1 = new Intent(this, CategoryListActivity.class);
@ -149,7 +148,7 @@ public class ResultListActivity extends BaseActivity<ActivityResultListBinding>
case "MUSIC_PAGE_TYPE_ARTIST":
//粉丝可能还喜欢
Intent intent = new Intent(this, ResultListActivity.class);
intent.putExtra("key", browserId);
intent.putExtra(MyValue.KEY_SEARCH_RESULT_BROWSER_ID, browserId);
startActivity(intent);
finish();
break;

View File

@ -66,20 +66,24 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> implements H
vmHome.getHome();
vmHome.data.observe(getViewLifecycleOwner(), new Observer<ResponseHome>() {
@Override
public void onChanged(ResponseHome responseHome) {
if(responseHome == null){
if (responseHome == null) {
adapterHome.removeLoadingFooter();
requestCount--;
return;
}
List<ResponseHomeChild> childList1 = responseHome.getChildList();
if(childList1 == null) return;
if (childList1 == null) return;
childList.addAll(childList1);
adapterHome.removeLoadingFooter();
adapterHome.addData(childList1);
if (requestCount == 1) {
adapterHome.addLoadingFooter();
vmHome.getHomeMore();
requestCount++;
}
}
@ -92,7 +96,7 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> implements H
super.onScrolled(recyclerView, dx, dy);
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
if (layoutManager != null && layoutManager.findLastVisibleItemPosition() == childList.size() - 1) {
if (requestCount < totalPage&&!adapterHome.isLoadingAdded()) {
if (requestCount < totalPage && !adapterHome.isLoadingAdded()) {
CommonUtils.LogMsg("------loadmore--");
adapterHome.addLoadingFooter();
vmHome.getHomeMore();
@ -109,7 +113,7 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> implements H
@Override
public void onClickItemSinger(ResponseSingle data) {
FragmentActivity activity = getActivity();
if(activity!= null){
if (activity != null) {
Intent intent = new Intent(activity, PlayActivity.class);
intent.putExtra(MyValue.KEY_PLAY_ACTIVITY_SINGER, data);
startActivity(intent);
@ -119,22 +123,24 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> implements H
@Override
public void onClickItemCategory(ResponseCategory data) {
FragmentActivity activity = getActivity();
if(activity!= null){
if (activity != null) {
String pageType = data.getPageType();
String browseId = data.getBrowseId();
String twoSubtitle = data.getTwoSubtitle();
if(pageType.equals(MyValue.PAGE_TYPE_MV)){
if (pageType.equals(MyValue.PAGE_TYPE_MV)||pageType.equals(MyValue.PAGE_TYPE_MV_LIST)) {
Intent intent = new Intent(activity, PlayActivity.class);
intent.putExtra(MyValue.KEY_PLAY_ACTIVITY_MV, data);
intent.putExtra(MyValue.KEY_ENTER_SOURCE, MyValue.TYPE_ENTER_SOURCE_MV);
startActivity(intent);
}else if(pageType.equals(MyValue.PAGE_TYPE_ALBUM)){
Intent intent = new Intent(activity, CategoryListActivity.class);
intent.putExtra(MyValue.KEY_CATEGORY_LIST_TYPE, pageType);
intent.putExtra(MyValue.KEY_CATEGORY_LIST_SINGER_NAME, twoSubtitle);
intent.putExtra(MyValue.KEY_CATEGORY_LIST_BROWSER_ID, browseId);
startActivity(intent);
}else {
}
// else if (pageType.equals(MyValue.PAGE_TYPE_ALBUM)) {
// Intent intent = new Intent(activity, CategoryListActivity.class);
// intent.putExtra(MyValue.KEY_CATEGORY_LIST_TYPE, pageType);
// intent.putExtra(MyValue.KEY_CATEGORY_LIST_SINGER_NAME, twoSubtitle);
// intent.putExtra(MyValue.KEY_CATEGORY_LIST_BROWSER_ID, browseId);
// startActivity(intent);
// }
else {
Intent intent = new Intent(activity, CategoryListActivity.class);
intent.putExtra(MyValue.KEY_CATEGORY_LIST_TYPE, pageType);
intent.putExtra(MyValue.KEY_CATEGORY_LIST_SINGER_NAME, twoSubtitle);

View File

@ -150,7 +150,7 @@ public class SearchFragment extends BaseFragment<FragmentSearchBinding> implemen
if(beastBrowserId!= null&&!beastBrowserId.isEmpty()){
Intent intent = new Intent(requireActivity(), ResultListActivity.class);
intent.putExtra("key", beastBrowserId);
intent.putExtra(MyValue.KEY_SEARCH_RESULT_BROWSER_ID, beastBrowserId);
startActivity(intent);
}else {
CommonUtils.LogMsg("---------击搜索结果的play按钮--beastVideoId="+beastVideoId);
@ -184,7 +184,7 @@ public class SearchFragment extends BaseFragment<FragmentSearchBinding> implemen
switch (pageType){
case "MUSIC_PAGE_TYPE_ARTIST":
Intent intent = new Intent(requireActivity(), ResultListActivity.class);
intent.putExtra("key", browserId);
intent.putExtra(MyValue.KEY_SEARCH_RESULT_BROWSER_ID, browserId);
startActivity(intent);
break;
default:

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="13dp"/>
<solid android:color="@color/black"/>
</shape>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp"/>
<corners android:radius="8dp"/>
<solid android:color="@color/retry_bg"/>
</shape>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp"/>
<corners android:radius="8dp"/>
<solid android:color="@color/panel_bg"/>
</shape>

View File

@ -5,6 +5,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="@+id/frame_layout"
android:background="@color/color_transparent"
android:layout_height="match_parent">

View File

@ -3,17 +3,22 @@
<FrameLayout 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:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
android:id="@+id/root_layout"
tools:context=".ui.activity.CategoryListActivity">
<ImageView
android:id="@+id/im_bg"
android:layout_width="match_parent"
android:layout_height="200dp" />
android:layout_height="390dp" />
<View
android:layout_width="match_parent"
android:layout_height="390dp"
android:background="@drawable/black_gradient" />
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
@ -29,9 +34,9 @@
<RelativeLayout
android:id="@+id/layout_covert"
android:layout_marginTop="60dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginTop="77dp">
<ImageView
android:id="@+id/imCovert"
@ -58,8 +63,8 @@
android:layout_height="wrap_content"
android:layout_below="@id/tvTitle"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="20dp"
android:gravity="center"
android:textColor="@color/white"
@ -71,8 +76,8 @@
android:layout_height="wrap_content"
android:layout_below="@id/tvSingerName"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="20dp"
android:gravity="center"
android:textColor="@color/white"
@ -85,16 +90,16 @@
android:layout_below="@id/tvSubTitle"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:visibility="invisible"
android:src="@drawable/selector_icon_play" />
android:src="@drawable/selector_icon_play"
android:visibility="invisible" />
<ProgressBar
android:id="@+id/pb_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminateTint="@color/white"
android:id="@+id/pb_loading"/>
android:indeterminateTint="@color/white" />
</RelativeLayout>
@ -106,18 +111,20 @@
</androidx.core.widget.NestedScrollView>
<ImageView
android:id="@+id/im_back"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginStart="16dp"
android:layout_marginTop="35dp"
android:padding="9dp"
android:src="@drawable/arrow_bottom" />
<FrameLayout
android:layout_width="match_parent"
android:background="@color/black"
android:layout_height="60dp">
<ImageView
android:id="@+id/im_back"
android:layout_width="42dp"
android:layout_height="match_parent"
android:layout_marginStart="16dp"
android:padding="9dp"
android:src="@drawable/arrow_bottom" />
</FrameLayout>
<include
layout="@layout/layout_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="80dp"
android:id="@+id/layout_error"
android:layout_gravity="center" />
</FrameLayout>

View File

@ -24,68 +24,89 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/im_covert"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginStart="40dp"
android:layout_marginTop="30dp"
android:layout_marginEnd="40dp"
android:scaleType="fitCenter"
android:src="@drawable/placeholder"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/im_back" />
<LinearLayout
android:id="@+id/linear_retry"
android:layout_width="210dp"
android:layout_height="120dp"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone"
android:background="@drawable/bg_retry"
app:layout_constraintBottom_toBottomOf="@id/im_covert"
app:layout_constraintLeft_toLeftOf="@id/im_covert"
app:layout_constraintRight_toRightOf="@id/im_covert"
app:layout_constraintTop_toTopOf="@id/im_covert">
<!-- <ImageView-->
<!-- android:id="@+id/im_covert"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="300dp"-->
<!-- android:layout_marginStart="40dp"-->
<!-- android:layout_marginTop="30dp"-->
<!-- android:layout_marginEnd="40dp"-->
<!-- android:scaleType="centerCrop"-->
<!-- android:visibility="gone"-->
<!-- android:src="@drawable/placeholder"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@id/im_back" />-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/An_error_occurred"
android:textColor="@color/white"
android:textSize="18sp" />
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginTop="30dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
app:cardBackgroundColor="@color/black"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/im_back"
android:id="@+id/card_playerView"
app:cardElevation="0dp"
app:cardCornerRadius="8dp">
<androidx.media3.ui.PlayerView
android:id="@+id/player_view"
app:resize_mode="zoom"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:show_buffering="when_playing"
app:show_shuffle_button="false"
app:use_controller="false" />
</androidx.cardview.widget.CardView>
<TextView
android:id="@+id/tv_retry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:text="@string/retry"
android:background="@drawable/bg_retry_btn"
android:textColor="@color/white"
android:textSize="17sp" />
</LinearLayout>
<include layout="@layout/layout_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/layout_error"
app:layout_constraintBottom_toBottomOf="@id/card_playerView"
app:layout_constraintLeft_toLeftOf="@id/card_playerView"
app:layout_constraintRight_toRightOf="@id/card_playerView"
app:layout_constraintTop_toTopOf="@id/card_playerView"/>
<!-- <LinearLayout-->
<!-- android:id="@+id/linear_retry"-->
<!-- android:layout_width="210dp"-->
<!-- android:layout_height="120dp"-->
<!-- android:background="@drawable/bg_retry"-->
<!-- android:gravity="center"-->
<!-- android:orientation="vertical"-->
<!-- android:visibility="gone"-->
<!-- app:layout_constraintBottom_toBottomOf="@id/card_playerView"-->
<!-- app:layout_constraintLeft_toLeftOf="@id/card_playerView"-->
<!-- app:layout_constraintRight_toRightOf="@id/card_playerView"-->
<!-- app:layout_constraintTop_toTopOf="@id/card_playerView">-->
<androidx.media3.ui.PlayerView
android:id="@+id/player_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/im_back"
app:show_buffering="when_playing"
app:show_shuffle_button="true" />
<!-- <TextView-->
<!-- android:id="@+id/tv_error_msg"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="@string/An_error_occurred"-->
<!-- android:textColor="@color/white"-->
<!-- android:textSize="18sp" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_retry"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="15dp"-->
<!-- android:background="@drawable/bg_retry_btn"-->
<!-- android:paddingStart="15dp"-->
<!-- android:paddingTop="8dp"-->
<!-- android:paddingEnd="15dp"-->
<!-- android:paddingBottom="8dp"-->
<!-- android:text="@string/retry"-->
<!-- android:textColor="@color/white"-->
<!-- android:textSize="17sp" />-->
<!-- </LinearLayout>-->
<TextView
@ -95,11 +116,12 @@
android:layout_marginTop="25dp"
android:layout_marginEnd="40dp"
android:text=""
android:layout_marginStart="10dp"
android:textColor="@color/text_color_1"
android:textSize="19sp"
app:layout_constraintLeft_toLeftOf="@id/im_covert"
app:layout_constraintLeft_toLeftOf="@id/card_playerView"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/im_covert" />
app:layout_constraintTop_toBottomOf="@id/card_playerView" />
<TextView
android:id="@+id/tv_singer_name"
@ -117,19 +139,17 @@
android:id="@+id/play_progress"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="25dp"
android:layout_marginEnd="35dp"
android:maxHeight="3dp"
android:paddingStart="5dp"
android:paddingLeft="0dp"
android:paddingEnd="5dp"
android:paddingRight="0dp"
android:progress="30"
android:progress="3"
android:progressDrawable="@drawable/seekbar_progress_drawable"
android:thumb="@drawable/seekbar_thumb"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="@id/card_playerView"
app:layout_constraintRight_toRightOf="@id/card_playerView"
app:layout_constraintTop_toBottomOf="@id/tv_singer_name" />
@ -140,7 +160,7 @@
android:layout_height="3dp"
android:paddingStart="5dp"
android:paddingEnd="5dp"
android:progress="100"
android:progress="10"
android:progressDrawable="@drawable/horizontal_progressbar"
app:layout_constraintBottom_toBottomOf="@id/play_progress"
app:layout_constraintLeft_toLeftOf="@id/play_progress"
@ -196,8 +216,8 @@
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_marginStart="24dp"
android:src="@mipmap/icon_next_true"
android:padding="12dp"
android:src="@mipmap/icon_next_true"
app:layout_constraintBottom_toBottomOf="@id/btn_play"
app:layout_constraintStart_toEndOf="@id/btn_play"
app:layout_constraintTop_toTopOf="@id/btn_play" />
@ -206,8 +226,8 @@
android:id="@+id/btn_music_list"
android:layout_width="44dp"
android:layout_height="44dp"
android:src="@mipmap/icon_list"
android:padding="10dp"
android:src="@mipmap/icon_list"
app:layout_constraintBottom_toBottomOf="@id/btn_play"
app:layout_constraintLeft_toRightOf="@id/btn_next"
app:layout_constraintRight_toRightOf="parent"
@ -218,8 +238,8 @@
android:id="@+id/btn_loop"
android:layout_width="44dp"
android:layout_height="44dp"
android:src="@drawable/icon_looper_no"
android:padding="10dp"
android:src="@drawable/icon_looper_no"
app:layout_constraintBottom_toBottomOf="@id/btn_play"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/btn_previous"

View File

@ -2,6 +2,7 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginTop="35dp"
android:orientation="vertical">
@ -22,22 +23,30 @@
android:paddingEnd="10dp"
android:paddingBottom="25dp">
<androidx.cardview.widget.CardView
android:layout_width="60dp"
android:layout_height="60dp"
app:cardCornerRadius="6dp"
android:id="@+id/card_view"
android:layout_marginStart="10dp"
app:cardElevation="0dp">
<ImageView
android:id="@+id/top_im"
android:layout_width="60dp"
android:layout_height="60dp"
android:scaleType="fitCenter"
android:layout_marginStart="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:src="@drawable/placeholder" />
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/top_im"
android:layout_alignBottom="@id/top_im"
android:layout_alignTop="@id/card_view"
android:layout_alignBottom="@id/card_view"
android:layout_marginStart="15dp"
android:layout_toStartOf="@id/im_play"
android:layout_toEndOf="@id/top_im"
android:layout_toEndOf="@id/card_view"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingEnd="15dp">

View File

@ -6,8 +6,6 @@
android:orientation="vertical"
tools:context=".ui.fragmnt.HomeFragment">
<TextView
android:id="@+id/toolbar"
android:layout_width="match_parent"
@ -18,14 +16,11 @@
android:textColor="@color/white"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_song_of_the_day"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="74dp"
android:orientation="horizontal" />
android:paddingStart="6dp" />
</LinearLayout>

View File

@ -1,40 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="5dp"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:id="@+id/header_card"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/black"
app:cardCornerRadius="8dp"
app:cardElevation="0dp">
<ImageView
android:id="@+id/header"
android:layout_width="170dp"
android:layout_height="170dp"
android:src="@drawable/placeholder" />
<ImageView
android:id="@+id/header"
android:layout_width="180dp"
android:layout_height="180dp"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<TextView
android:id="@+id/tv_title"
android:layout_width="169dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:layout_below="@id/header_card"
android:layout_alignStart="@id/header_card"
android:layout_alignEnd="@id/header_card"
android:layout_marginTop="10dp"
android:text="@string/app_name"
android:ellipsize="end"
android:gravity="start"
android:maxLines="2"
android:text="999999"
android:textColor="@color/text_color_1"
android:textSize="14sp" />
<TextView
android:id="@+id/tv_subtitle"
android:layout_width="169dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@id/tv_title"
android:layout_alignStart="@id/header_card"
android:layout_alignEnd="@id/header_card"
android:layout_marginTop="4dp"
android:ellipsize="end"
android:gravity="start"
android:maxLines="2"
android:text="@string/app_name"
android:text="ddddddd"
android:textColor="@color/text_color_2"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>

View File

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="70dp"
android:layout_height="wrap_content"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:paddingTop="5dp"
android:paddingEnd="15dp"
android:paddingBottom="5dp">
<LinearLayout
@ -12,32 +13,43 @@
android:layout_width="wrap_content"
android:layout_height="60dp">
<ImageView
android:id="@+id/image"
<androidx.cardview.widget.CardView
android:id="@+id/im_card"
android:layout_width="60dp"
android:layout_height="60dp"
android:scaleType="centerCrop"
android:visibility="gone" />
android:visibility="gone"
app:cardCornerRadius="6dp"
app:cardElevation="0dp">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<TextView
android:id="@+id/tv_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/app_name"
android:textColor="@color/white"
android:textSize="14sp"
android:textStyle="bold"
android:layout_gravity="center"
android:text="@string/app_name" />
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignTop="@id/left_layout"
android:layout_alignBottom="@id/left_layout"
android:layout_marginStart="12dp"
android:layout_toStartOf="@id/tv_duration"
android:layout_toEndOf="@id/left_layout"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
@ -62,10 +74,19 @@
<TextView
android:id="@+id/tv_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:layout_height="0dp"
android:layout_alignTop="@id/left_layout"
android:layout_alignBottom="@id/left_layout"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:text="@string/app_name"
android:textColor="@color/white_60_color"
android:textSize="12sp" />
<View
android:id="@+id/place"
android:layout_width="wrap_content"
android:layout_height="74dp"
android:layout_below="@id/left_layout" />
</RelativeLayout>

View File

@ -11,19 +11,27 @@
android:layout_marginStart="15dp"
android:textColor="@color/text_color_1"
android:paddingBottom="10dp"
android:paddingTop="15dp"
android:paddingTop="10dp"
android:textSize="18sp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_singer"
android:layout_width="match_parent"
android:layout_height="400dp" />
android:visibility="gone"
android:layout_height="wrap_content" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="5dp"
android:paddingEnd="5dp" />
android:visibility="gone"
android:paddingStart="7dp"
android:paddingEnd="14dp"
android:layout_height="wrap_content" />
<View
android:layout_width="wrap_content"
android:id="@+id/place"
android:layout_height="74dp" />
</LinearLayout>

View File

@ -6,22 +6,31 @@
android:id="@+id/item_layout"
android:paddingStart="20dp">
<ImageView
android:id="@+id/im_covert"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerVertical="true"
android:src="@drawable/placeholder" />
<androidx.cardview.widget.CardView
android:id="@+id/card"
android:layout_width="60dp"
android:layout_height="60dp"
app:cardElevation="0dp"
android:layout_centerVertical="true"
app:cardCornerRadius="6dp">
<ImageView
android:id="@+id/im_covert"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:src="@drawable/placeholder" />
</androidx.cardview.widget.CardView>
<com.hi.music.player.customerview.AnimaPlayingView
android:id="@+id/view_playing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@id/im_covert"
android:layout_alignTop="@id/im_covert"
android:layout_alignEnd="@id/im_covert"
android:layout_alignBottom="@id/im_covert"
android:layout_alignStart="@id/card"
android:layout_alignTop="@id/card"
android:layout_alignEnd="@id/card"
android:layout_alignBottom="@id/card"
android:layout_marginBottom="10dp" />
@ -30,7 +39,7 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="12dp"
android:layout_toEndOf="@id/im_covert"
android:layout_toEndOf="@id/card"
android:orientation="vertical">
<TextView

View File

@ -20,8 +20,13 @@
android:id="@+id/list_child"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:layout_below="@id/tv_header_title" />
<View
android:layout_width="wrap_content"
android:id="@+id/place"
android:layout_below="@id/list_child"
android:layout_height="74dp" />
</RelativeLayout>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<TextView
@ -17,7 +18,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@id/tv_header_title"
android:id="@+id/layout"
android:orientation="vertical">
@ -85,5 +85,8 @@
android:layout_below="@id/layout_best" />
</LinearLayout>
</RelativeLayout>
<View
android:layout_width="wrap_content"
android:id="@+id/place"
android:layout_height="74dp" />
</LinearLayout>

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="vertical">
@ -15,10 +16,9 @@
android:src="@drawable/placeholder" />
<LinearLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="50dp"
android:paddingEnd="10dp"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/header"
@ -28,8 +28,9 @@
android:id="@+id/tv_song_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:text="99999999999999999999999999999999999"
android:maxLines="1"
android:maxWidth="200dp"
android:ellipsize="end"
android:textColor="@color/text_color_1"
android:textSize="14sp" />
@ -42,9 +43,10 @@
android:layout_marginTop="4dp"
android:text="@string/app_name"
android:maxLines="1"
android:maxWidth="200dp"
android:ellipsize="end"
android:textColor="@color/text_color_1"
android:textSize="14sp" />
android:textColor="@color/text_color_2"
android:textSize="12sp" />
<!-- <TextView-->
<!-- android:id="@+id/tv_describe"-->

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/linear_retry"
android:layout_width="210dp"
android:layout_height="120dp"
android:background="@drawable/bg_retry"
android:gravity="center"
android:visibility="gone"
android:orientation="vertical">
<TextView
android:id="@+id/tv_error_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/An_error_occurred"
android:textColor="@color/white"
android:textSize="18sp" />
<TextView
android:id="@+id/tv_retry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="@drawable/bg_retry_btn"
android:paddingStart="15dp"
android:paddingTop="8dp"
android:paddingEnd="15dp"
android:paddingBottom="8dp"
android:text="@string/retry"
android:textColor="@color/white"
android:textSize="17sp" />
</LinearLayout>
</FrameLayout>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="@+id/place_view"
android:layout_height="74dp">
</View>

View File

@ -27,4 +27,7 @@
<string name="search_hint">Search songs, artists…</string>
<string name="play">Play</string>
<string name="no_next_song_yet">There is no next song yet</string>
<string name="image_loading_failed">Image loading failed</string>
<string name="song_loading_failed">Song loading failed</string>
<string name="playList_loading_failed">Playlist loading failed</string>
</resources>