搜索结果的点击功能
This commit is contained in:
parent
f341f3efe6
commit
e80a4f97d3
@ -22,6 +22,9 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.MusicApp"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".ui.activity.ResultListActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ui.activity.CategoryListActivity"
|
||||
android:exported="false" />
|
||||
@ -38,9 +41,7 @@
|
||||
<activity
|
||||
android:name=".ui.activity.A_HomeActivity"
|
||||
android:exported="true"
|
||||
android:screenOrientation="portrait">
|
||||
|
||||
</activity>
|
||||
android:screenOrientation="portrait"></activity>
|
||||
<activity
|
||||
android:name=".ui.activity.HomeActivity"
|
||||
android:exported="true">
|
||||
@ -50,10 +51,9 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ui.activity.A_SplashActivity"
|
||||
android:exported="true"></activity>
|
||||
android:exported="true" />
|
||||
|
||||
<service
|
||||
android:name=".media3.PlaybackService"
|
||||
|
||||
@ -14,8 +14,15 @@ public class MusicApplication extends Application {
|
||||
|
||||
public static Context myApplication;
|
||||
|
||||
public static String visitorData;
|
||||
|
||||
public static void setVisitorData(String visitorData) {
|
||||
MusicApplication.visitorData = visitorData;
|
||||
}
|
||||
|
||||
public static String getVisitorData() {
|
||||
return visitorData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
|
||||
@ -0,0 +1,56 @@
|
||||
package com.hi.music.player.adapter;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.hi.music.player.MusicApplication;
|
||||
import com.hi.music.player.databinding.ItemResultBinding;
|
||||
import com.hi.music.player.helper.ItemDecoration;
|
||||
import com.hi.music.player.helper.MyValue;
|
||||
import com.hi.music.player.javabean.response.ResponseResultList;
|
||||
import com.hi.music.player.ui.activity.PlayActivity;
|
||||
|
||||
public class AdapterResult extends BaseAdapter<ResponseResultList, ItemResultBinding>{
|
||||
@Override
|
||||
protected ItemResultBinding getViewBinding(ViewGroup parent) {
|
||||
return ItemResultBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
ResponseResultList resultList = data.get(position);
|
||||
|
||||
VHolder<ItemResultBinding> itemHolder = (VHolder<ItemResultBinding>) holder;
|
||||
ItemResultBinding vb = itemHolder.getVb();
|
||||
|
||||
vb.tvHeaderTitle.setText(resultList.getHeaderTitle());
|
||||
|
||||
|
||||
ItemDecoration itemDecoration ;
|
||||
|
||||
if(position == 0){
|
||||
itemDecoration = new ItemDecoration(10,0,0);
|
||||
AdapterResultListSong adapterResultListSong = new AdapterResultListSong();
|
||||
adapterResultListSong.setData(resultList.getChildList());
|
||||
vb.listChild.setAdapter(adapterResultListSong);
|
||||
vb.listChild.setLayoutManager(new LinearLayoutManager(MusicApplication.myApplication));
|
||||
if(homeItemClickListener!= null)
|
||||
adapterResultListSong.setHomeItemClickListener(homeItemClickListener);
|
||||
}else {
|
||||
itemDecoration = new ItemDecoration(0,10,0);
|
||||
AdapterResultListAlbum adapterResultListAlbum = new AdapterResultListAlbum();
|
||||
adapterResultListAlbum.setData(resultList.getChildList());
|
||||
vb.listChild.setAdapter(adapterResultListAlbum);
|
||||
vb.listChild.setLayoutManager(new LinearLayoutManager(MusicApplication.myApplication, LinearLayoutManager.HORIZONTAL,false));
|
||||
if(homeItemClickListener!= null)
|
||||
adapterResultListAlbum.setHomeItemClickListener(homeItemClickListener);
|
||||
}
|
||||
vb.listChild.addItemDecoration(itemDecoration);
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
package com.hi.music.player.adapter;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.engine.GlideException;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.hi.music.player.MusicApplication;
|
||||
import com.hi.music.player.R;
|
||||
import com.hi.music.player.databinding.ItemResultListAlbumBinding;
|
||||
import com.hi.music.player.helper.CommonUtils;
|
||||
import com.hi.music.player.javabean.response.child.ResponseResultListChild;
|
||||
|
||||
public class AdapterResultListAlbum extends BaseAdapter<ResponseResultListChild, ItemResultListAlbumBinding>{
|
||||
@Override
|
||||
protected ItemResultListAlbumBinding getViewBinding(ViewGroup parent) {
|
||||
return ItemResultListAlbumBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
ResponseResultListChild listChild = data.get(position);
|
||||
|
||||
|
||||
VHolder<ItemResultListAlbumBinding> itemHolder = (VHolder<ItemResultListAlbumBinding>) holder;
|
||||
ItemResultListAlbumBinding vb = itemHolder.getVb();
|
||||
if(position == data.size()-1){
|
||||
vb.view.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
vb.view.setVisibility(View.GONE);
|
||||
}
|
||||
Glide.with(MusicApplication.myApplication)
|
||||
.asDrawable()
|
||||
.load(listChild.getThumbnail())
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(4))))
|
||||
.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(listChild.getSongName());
|
||||
vb.tvSubtitle.setText(listChild.getSubTitle());
|
||||
vb.header.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(homeItemClickListener != null){
|
||||
int absoluteAdapterPosition = itemHolder.getAbsoluteAdapterPosition();
|
||||
String videoId = listChild.getVideoId();
|
||||
String browserId = listChild.getBrowserId();
|
||||
if(videoId == null||videoId.isEmpty()){
|
||||
homeItemClickListener.onClickResultAlbum(listChild,absoluteAdapterPosition);
|
||||
}else if(browserId!= null&&!browserId.isEmpty()){
|
||||
homeItemClickListener.onClickResultSong(listChild,absoluteAdapterPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
CommonUtils.LogMsg("-------Album getBrowserId="+listChild.getBrowserId()+"---getPlayListId= "+listChild.getPlayListId()+"---getVideoId="+listChild.getVideoId());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
package com.hi.music.player.adapter;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.engine.GlideException;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.hi.music.player.MusicApplication;
|
||||
import com.hi.music.player.R;
|
||||
import com.hi.music.player.databinding.ItemResultListSongBinding;
|
||||
import com.hi.music.player.helper.CommonUtils;
|
||||
import com.hi.music.player.javabean.response.child.ResponseResultListChild;
|
||||
|
||||
public class AdapterResultListSong extends BaseAdapter<ResponseResultListChild, ItemResultListSongBinding>{
|
||||
@Override
|
||||
protected ItemResultListSongBinding getViewBinding(ViewGroup parent) {
|
||||
return ItemResultListSongBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
ResponseResultListChild listChild = data.get(position);
|
||||
|
||||
VHolder<ItemResultListSongBinding> itemHolder = (VHolder<ItemResultListSongBinding>) holder;
|
||||
ItemResultListSongBinding vb = itemHolder.getVb();
|
||||
|
||||
Glide.with(MusicApplication.myApplication)
|
||||
.asDrawable()
|
||||
.load(listChild.getThumbnail())
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(4))))
|
||||
.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.imCovert);
|
||||
vb.tvSongName.setText(listChild.getSongName());
|
||||
String s = listChild.getSubTitle() +" • "+listChild.getPlayCount();
|
||||
vb.tvSubtitle.setText(s);
|
||||
|
||||
vb.getRoot().setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(homeItemClickListener != null){
|
||||
int absoluteAdapterPosition = itemHolder.getAbsoluteAdapterPosition();
|
||||
String videoId = listChild.getVideoId();
|
||||
String browserId = listChild.getBrowserId();
|
||||
if(videoId == null||videoId.isEmpty()){
|
||||
homeItemClickListener.onClickResultAlbum(listChild,absoluteAdapterPosition);
|
||||
}else if(browserId!= null&&!browserId.isEmpty()){
|
||||
homeItemClickListener.onClickResultSong(listChild,absoluteAdapterPosition);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CommonUtils.LogMsg("-------Song getBrowserId="+listChild.getBrowserId()+"---getPlayListId= "+listChild.getPlayListId()+"---getVideoId="+listChild.getVideoId());
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package com.hi.music.player.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
|
||||
import com.hi.music.player.MusicApplication;
|
||||
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;
|
||||
|
||||
public class AdapterSearch extends BaseAdapter<ResponseSearch, ItemSearchBinding> {
|
||||
@Override
|
||||
protected ItemSearchBinding getViewBinding(ViewGroup parent) {
|
||||
return ItemSearchBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
ResponseSearch responseSearch = data.get(position);
|
||||
|
||||
VHolder<ItemSearchBinding> itemHolder = (VHolder<ItemSearchBinding>) holder;
|
||||
ItemSearchBinding vb = itemHolder.getVb();
|
||||
|
||||
vb.tvHeaderTitle.setText(responseSearch.getHeaderTitle());
|
||||
|
||||
String beastSongTCovert = responseSearch.getBeastSongTCovert();
|
||||
if (beastSongTCovert != null && !beastSongTCovert.isEmpty()) {
|
||||
vb.layoutBest.setVisibility(View.VISIBLE);
|
||||
Glide.with(MusicApplication.myApplication)
|
||||
.load(beastSongTCovert)
|
||||
.transform(new CircleCrop())
|
||||
.into(vb.imBestCovert);
|
||||
vb.tvBestTitle.setText(responseSearch.getBeastSongTitle());
|
||||
vb.tvBestSubtitle.setText(responseSearch.getBeastSongDescribe());
|
||||
vb.layout.setBackground(ContextCompat.getDrawable(MusicApplication.myApplication, R.drawable.bg_best_bg));
|
||||
vb.layout.setPadding(CommonUtils.dpToPx(6), CommonUtils.dpToPx(10), 0, 0);
|
||||
vb.tvPlay.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (homeItemClickListener != null) {
|
||||
homeItemClickListener.onClickSearchResultBest(responseSearch);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
vb.layoutBest.setVisibility(View.GONE);
|
||||
vb.layout.setBackground(null);
|
||||
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));
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
package com.hi.music.player.adapter;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.engine.GlideException;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.hi.music.player.MusicApplication;
|
||||
import com.hi.music.player.R;
|
||||
import com.hi.music.player.databinding.ItemSearchBinding;
|
||||
import com.hi.music.player.databinding.ItemSearchChildBinding;
|
||||
import com.hi.music.player.helper.CommonUtils;
|
||||
import com.hi.music.player.javabean.response.ResponseSearch;
|
||||
import com.hi.music.player.javabean.response.child.ResponseSearchChild;
|
||||
|
||||
public class AdapterSearchChild extends BaseAdapter<ResponseSearchChild, ItemSearchChildBinding> {
|
||||
@Override
|
||||
protected ItemSearchChildBinding getViewBinding(ViewGroup parent) {
|
||||
return ItemSearchChildBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
ResponseSearchChild responseSearchChild = data.get(position);
|
||||
VHolder<ItemSearchChildBinding> itemHolder = (VHolder<ItemSearchChildBinding>) holder;
|
||||
ItemSearchChildBinding vb = itemHolder.getVb();
|
||||
|
||||
|
||||
Glide.with(MusicApplication.myApplication)
|
||||
.asDrawable()
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(13))))
|
||||
.load(responseSearchChild.getSongCovert())
|
||||
.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.imCovert);
|
||||
|
||||
vb.tvTitle.setText(responseSearchChild.getSongTitle());
|
||||
vb.tvSubtitle.setText(responseSearchChild.getSongDescribe());
|
||||
vb.getRoot().setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (homeItemClickListener != null) {
|
||||
homeItemClickListener.onClickSearchResult(responseSearchChild);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,10 @@
|
||||
package com.hi.music.player.api;
|
||||
|
||||
import com.hi.music.player.javabean.response.ResponsePlayListInfo;
|
||||
import com.hi.music.player.javabean.response.ResponseSearch;
|
||||
import com.hi.music.player.javabean.response.child.ResponseCategory;
|
||||
import com.hi.music.player.javabean.response.child.ResponseResultListChild;
|
||||
import com.hi.music.player.javabean.response.child.ResponseSearchChild;
|
||||
import com.hi.music.player.javabean.response.child.ResponseSingle;
|
||||
|
||||
public interface HomeItemClickListener {
|
||||
@ -34,4 +37,33 @@ public interface HomeItemClickListener {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 点击搜索最佳结果第一个
|
||||
* @param
|
||||
*/
|
||||
default void onClickSearchResultBest(ResponseSearch responseSearch){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击搜索结果第
|
||||
* @param
|
||||
*/
|
||||
default void onClickSearchResult(ResponseSearchChild responseSearchChild){
|
||||
|
||||
}
|
||||
/**
|
||||
* 搜索结果详情页面点击单曲
|
||||
* @param child
|
||||
* @param index
|
||||
*/
|
||||
default void onClickResultSong(ResponseResultListChild child,int index){
|
||||
|
||||
}
|
||||
|
||||
default void onClickResultAlbum(ResponseResultListChild child,int index){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
package com.hi.music.player.api;
|
||||
|
||||
public interface onPlayNextListener {
|
||||
void onPlayNext(boolean hasNext);
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
package com.hi.music.player.helper;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
|
||||
import com.hi.music.player.MusicApplication;
|
||||
|
||||
public class ItemDecoration extends RecyclerView.ItemDecoration {
|
||||
|
||||
private int v, h, ex;
|
||||
|
||||
public ItemDecoration(int v, int h, int ex) {
|
||||
this.v = Math.round(dpToPx(v));
|
||||
this.h = Math.round(dpToPx(h));
|
||||
this.ex = Math.round(dpToPx(ex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
int spanCount = 1;
|
||||
int spanSize = 1;
|
||||
int spanIndex = 0;
|
||||
|
||||
int childAdapterPosition = parent.getChildAdapterPosition(view);
|
||||
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
|
||||
if (layoutManager instanceof StaggeredGridLayoutManager) {
|
||||
StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
|
||||
StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams();
|
||||
spanCount = staggeredGridLayoutManager.getSpanCount();
|
||||
if (layoutParams.isFullSpan()) {
|
||||
spanSize = spanCount;
|
||||
}
|
||||
spanIndex = layoutParams.getSpanIndex();
|
||||
} else if (layoutManager instanceof GridLayoutManager) {
|
||||
GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
|
||||
GridLayoutManager.LayoutParams layoutParams = (GridLayoutManager.LayoutParams) view.getLayoutParams();
|
||||
spanCount = gridLayoutManager.getSpanCount();
|
||||
spanSize = gridLayoutManager.getSpanSizeLookup().getSpanSize(childAdapterPosition);
|
||||
spanIndex = layoutParams.getSpanIndex();
|
||||
} else if (layoutManager instanceof LinearLayoutManager) {
|
||||
outRect.left = v;
|
||||
outRect.right = v;
|
||||
outRect.bottom = h;
|
||||
}
|
||||
|
||||
if (spanSize == spanCount) {
|
||||
outRect.left = v + ex;
|
||||
outRect.right = v + ex;
|
||||
outRect.bottom = h;
|
||||
|
||||
} else {
|
||||
int itemAllSpacing = (v * (spanCount + 1) + ex * 2) / spanCount;
|
||||
int left = v * (spanIndex + 1) - itemAllSpacing * spanIndex + ex;
|
||||
int right = itemAllSpacing - left;
|
||||
outRect.left = left;
|
||||
outRect.right = right;
|
||||
outRect.bottom = h;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static float dpToPx(float dpValue) {
|
||||
float density = MusicApplication.myApplication.getResources().getDisplayMetrics().density;
|
||||
return density * dpValue + 0.5f;
|
||||
}
|
||||
}
|
||||
@ -87,7 +87,10 @@ public class MyValue {
|
||||
//-----------------------------CategoryListActivity
|
||||
public static String KEY_PLAY_ACTIVITY_CATEGORY= "click_category";
|
||||
|
||||
public static String KEY_CATEGORY_LIST_TYPE= "page_type";
|
||||
public static String KEY_CATEGORY_LIST_SINGER_NAME= "singer_name";
|
||||
|
||||
public static String KEY_CATEGORY_LIST_BROWSER_ID= "browser_id";
|
||||
|
||||
|
||||
//-----------------------------CategoryListActivity
|
||||
|
||||
@ -14,7 +14,8 @@ public class BodyPlayUrl implements Serializable {
|
||||
|
||||
private ContextBody context = new ContextBody();
|
||||
|
||||
|
||||
// private String key = "AIzaSyC9XL3ZjwddXya6X74dJOCTL-WEYFDNX30" ;
|
||||
private String params ="CgIQBg";
|
||||
|
||||
|
||||
public String getVideoId() {
|
||||
|
||||
@ -34,5 +34,22 @@ public class Client implements Serializable {
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
|
||||
public String getGl() {
|
||||
return gl;
|
||||
}
|
||||
|
||||
public void setGl(String gl) {
|
||||
this.gl = gl;
|
||||
}
|
||||
|
||||
public String getHl() {
|
||||
return hl;
|
||||
}
|
||||
|
||||
public void setHl(String hl) {
|
||||
this.hl = hl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
package com.hi.music.player.javabean.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ResponseResult {
|
||||
|
||||
private String mainTitle;
|
||||
private String mainCovert;
|
||||
|
||||
private List<ResponseResultList> list;
|
||||
|
||||
|
||||
public String getMainTitle() {
|
||||
return mainTitle;
|
||||
}
|
||||
|
||||
public void setMainTitle(String mainTitle) {
|
||||
this.mainTitle = mainTitle;
|
||||
}
|
||||
|
||||
public String getMainCovert() {
|
||||
return mainCovert;
|
||||
}
|
||||
|
||||
public void setMainCovert(String mainCovert) {
|
||||
this.mainCovert = mainCovert;
|
||||
}
|
||||
|
||||
public List<ResponseResultList> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<ResponseResultList> list) {
|
||||
this.list = list;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.hi.music.player.javabean.response;
|
||||
|
||||
import com.hi.music.player.javabean.response.child.ResponseResultListChild;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ResponseResultList {
|
||||
|
||||
private String headerTitle;
|
||||
|
||||
private List<ResponseResultListChild> childList;
|
||||
|
||||
|
||||
public String getHeaderTitle() {
|
||||
return headerTitle;
|
||||
}
|
||||
|
||||
public void setHeaderTitle(String headerTitle) {
|
||||
this.headerTitle = headerTitle;
|
||||
}
|
||||
|
||||
public List<ResponseResultListChild> getChildList() {
|
||||
return childList;
|
||||
}
|
||||
|
||||
public void setChildList(List<ResponseResultListChild> childList) {
|
||||
this.childList = childList;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
package com.hi.music.player.javabean.response;
|
||||
|
||||
import com.hi.music.player.javabean.response.child.ResponseSearchChild;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ResponseSearch {
|
||||
|
||||
private String headerTitle;
|
||||
|
||||
|
||||
private String beastSongTitle;
|
||||
private String beastSongTCovert;
|
||||
private String beastSongDescribe;
|
||||
|
||||
private String beastBrowserId;
|
||||
|
||||
private String beastVideoId;
|
||||
|
||||
private String pageType;
|
||||
|
||||
|
||||
private List<ResponseSearchChild> list;
|
||||
|
||||
|
||||
public String getBeastVideoId() {
|
||||
return beastVideoId;
|
||||
}
|
||||
|
||||
public void setBeastVideoId(String beastVideoId) {
|
||||
this.beastVideoId = beastVideoId;
|
||||
}
|
||||
|
||||
public String getHeaderTitle() {
|
||||
return headerTitle;
|
||||
}
|
||||
|
||||
public void setHeaderTitle(String headerTitle) {
|
||||
this.headerTitle = headerTitle;
|
||||
}
|
||||
|
||||
public List<ResponseSearchChild> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<ResponseSearchChild> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
|
||||
public String getBeastSongTitle() {
|
||||
return beastSongTitle;
|
||||
}
|
||||
|
||||
public void setBeastSongTitle(String beastSongTitle) {
|
||||
this.beastSongTitle = beastSongTitle;
|
||||
}
|
||||
|
||||
public String getBeastSongTCovert() {
|
||||
return beastSongTCovert;
|
||||
}
|
||||
|
||||
public void setBeastSongTCovert(String beastSongTCovert) {
|
||||
this.beastSongTCovert = beastSongTCovert;
|
||||
}
|
||||
|
||||
public String getBeastSongDescribe() {
|
||||
return beastSongDescribe;
|
||||
}
|
||||
|
||||
public void setBeastSongDescribe(String beastSongDescribe) {
|
||||
this.beastSongDescribe = beastSongDescribe;
|
||||
}
|
||||
|
||||
public String getBeastBrowserId() {
|
||||
return beastBrowserId;
|
||||
}
|
||||
|
||||
public void setBeastBrowserId(String beastBrowserId) {
|
||||
this.beastBrowserId = beastBrowserId;
|
||||
}
|
||||
|
||||
public String getPageType() {
|
||||
return pageType;
|
||||
}
|
||||
|
||||
public void setPageType(String pageType) {
|
||||
this.pageType = pageType;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
package com.hi.music.player.javabean.response.child;
|
||||
|
||||
public class ResponseResultListChild {
|
||||
private String thumbnail;
|
||||
|
||||
|
||||
private String songName;
|
||||
private String subTitle;
|
||||
private String playCount;
|
||||
private String videoId;
|
||||
private String playListId;
|
||||
|
||||
private String browserId;
|
||||
|
||||
private String pageType;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public String getThumbnail() {
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
public void setThumbnail(String thumbnail) {
|
||||
this.thumbnail = thumbnail;
|
||||
}
|
||||
|
||||
public String getSongName() {
|
||||
return songName;
|
||||
}
|
||||
|
||||
public void setSongName(String songName) {
|
||||
this.songName = songName;
|
||||
}
|
||||
|
||||
public String getSubTitle() {
|
||||
return subTitle;
|
||||
}
|
||||
|
||||
public void setSubTitle(String subTitle) {
|
||||
this.subTitle = subTitle;
|
||||
}
|
||||
|
||||
public String getBrowserId() {
|
||||
return browserId;
|
||||
}
|
||||
|
||||
public void setBrowserId(String browserId) {
|
||||
this.browserId = browserId;
|
||||
}
|
||||
|
||||
public String getPageType() {
|
||||
return pageType;
|
||||
}
|
||||
|
||||
public void setPageType(String pageType) {
|
||||
this.pageType = pageType;
|
||||
}
|
||||
|
||||
public String getPlayCount() {
|
||||
return playCount;
|
||||
}
|
||||
|
||||
public void setPlayCount(String playCount) {
|
||||
this.playCount = playCount;
|
||||
}
|
||||
|
||||
public String getVideoId() {
|
||||
return videoId;
|
||||
}
|
||||
|
||||
public void setVideoId(String videoId) {
|
||||
this.videoId = videoId;
|
||||
}
|
||||
|
||||
public String getPlayListId() {
|
||||
return playListId;
|
||||
}
|
||||
|
||||
public void setPlayListId(String playListId) {
|
||||
this.playListId = playListId;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
package com.hi.music.player.javabean.response.child;
|
||||
|
||||
public class ResponseSearchChild {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private String songTitle;
|
||||
private String songCovert;
|
||||
private String songDescribe;
|
||||
private String songPlayCount;
|
||||
private String songVideoId;
|
||||
|
||||
private String browserId;
|
||||
|
||||
private String pageType;
|
||||
|
||||
|
||||
public String getBrowserId() {
|
||||
return browserId;
|
||||
}
|
||||
|
||||
public void setBrowserId(String browserId) {
|
||||
this.browserId = browserId;
|
||||
}
|
||||
|
||||
public String getPageType() {
|
||||
return pageType;
|
||||
}
|
||||
|
||||
public void setPageType(String pageType) {
|
||||
this.pageType = pageType;
|
||||
}
|
||||
|
||||
public String getSongTitle() {
|
||||
return songTitle;
|
||||
}
|
||||
|
||||
public void setSongTitle(String songTitle) {
|
||||
this.songTitle = songTitle;
|
||||
}
|
||||
|
||||
public String getSongCovert() {
|
||||
return songCovert;
|
||||
}
|
||||
|
||||
public void setSongCovert(String songCovert) {
|
||||
this.songCovert = songCovert;
|
||||
}
|
||||
|
||||
public String getSongDescribe() {
|
||||
return songDescribe;
|
||||
}
|
||||
|
||||
public void setSongDescribe(String songDescribe) {
|
||||
this.songDescribe = songDescribe;
|
||||
}
|
||||
|
||||
public String getSongPlayCount() {
|
||||
return songPlayCount;
|
||||
}
|
||||
|
||||
public void setSongPlayCount(String songPlayCount) {
|
||||
this.songPlayCount = songPlayCount;
|
||||
}
|
||||
|
||||
public String getSongVideoId() {
|
||||
return songVideoId;
|
||||
}
|
||||
|
||||
public void setSongVideoId(String songVideoId) {
|
||||
this.songVideoId = songVideoId;
|
||||
}
|
||||
}
|
||||
@ -19,6 +19,7 @@ import com.hi.music.player.MusicApplication;
|
||||
import com.hi.music.player.api.MediaControllerListener;
|
||||
import com.hi.music.player.api.MediaControllerStatusListener;
|
||||
import com.hi.music.player.api.OnHasUrlAction;
|
||||
import com.hi.music.player.api.onPlayNextListener;
|
||||
import com.hi.music.player.helper.CommonUtils;
|
||||
import com.hi.music.player.helper.MyValue;
|
||||
import com.hi.music.player.javabean.response.ResponsePlayListInfo;
|
||||
@ -351,7 +352,7 @@ public class MyMediaControllerManager {
|
||||
mediaController.stop();
|
||||
}
|
||||
|
||||
public void playNext() {
|
||||
public void playNext(onPlayNextListener listener) {
|
||||
if (mediaController.hasNextMediaItem()) {
|
||||
int nextMediaItemIndex = mediaController.getNextMediaItemIndex();
|
||||
|
||||
@ -363,13 +364,7 @@ public class MyMediaControllerManager {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// int currentMediaItemIndex = mediaController.getCurrentMediaItemIndex();
|
||||
// if (currentMediaItemIndex < playList.size() - 1) {
|
||||
// //应该有下一首,可能是歌曲url请求失败,需要重新请求
|
||||
// int nextIndex = currentMediaItemIndex + 1;
|
||||
// mListener.onRequestNextUri(playList.get(nextIndex).getVideoId(), nextIndex, true);
|
||||
// CommonUtils.LogMsg("-------------应该有下一首,可能是歌曲url请求失败,需要重新请求");
|
||||
// }
|
||||
listener.onPlayNext(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,9 +5,14 @@ import com.hi.music.player.helper.MyValue;
|
||||
import com.hi.music.player.javabean.response.ResponseCategoryList;
|
||||
import com.hi.music.player.javabean.response.ResponsePlayListInfo;
|
||||
import com.hi.music.player.javabean.response.ResponsePlayUrl;
|
||||
import com.hi.music.player.javabean.response.ResponseResult;
|
||||
import com.hi.music.player.javabean.response.ResponseResultList;
|
||||
import com.hi.music.player.javabean.response.ResponseSearch;
|
||||
import com.hi.music.player.javabean.response.child.ResponseCategory;
|
||||
import com.hi.music.player.javabean.response.ResponseHome;
|
||||
import com.hi.music.player.javabean.response.child.ResponseHomeChild;
|
||||
import com.hi.music.player.javabean.response.child.ResponseResultListChild;
|
||||
import com.hi.music.player.javabean.response.child.ResponseSearchChild;
|
||||
import com.hi.music.player.javabean.response.child.ResponseSingle;
|
||||
|
||||
import org.json.JSONArray;
|
||||
@ -15,7 +20,9 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class JsonHelper {
|
||||
|
||||
@ -363,7 +370,7 @@ public class JsonHelper {
|
||||
*
|
||||
* @param jsonObject
|
||||
*/
|
||||
public static void ResolveSearchResult(JSONObject jsonObject) {
|
||||
public static List<ResponseSearch> ResolveSearchResult(JSONObject jsonObject) {
|
||||
try {
|
||||
JSONArray jsonArray = jsonObject.getJSONObject("contents")
|
||||
.getJSONObject("tabbedSearchResultsRenderer")
|
||||
@ -373,25 +380,298 @@ public class JsonHelper {
|
||||
.getJSONObject("content")
|
||||
.getJSONObject("sectionListRenderer")
|
||||
.getJSONArray("contents");
|
||||
for(int i =0;i<jsonArray.length();i++){
|
||||
if(i ==0){
|
||||
|
||||
List<ResponseSearch> searchList = new ArrayList<>();
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
ResponseSearch responseSearch = new ResponseSearch();
|
||||
JSONArray contents1 = null;
|
||||
|
||||
String headerTitle = "";
|
||||
|
||||
JSONObject contents = jsonArray.getJSONObject(i);
|
||||
|
||||
//最佳结果
|
||||
JSONObject musicCardShelfRenderer = contents.optJSONObject("musicCardShelfRenderer");
|
||||
|
||||
}else {
|
||||
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"));
|
||||
|
||||
headerTitle = getJsonTitle(musicCardShelfRenderer.getJSONObject("header")
|
||||
.getJSONObject("musicCardShelfHeaderBasicRenderer")
|
||||
.getJSONObject("title"), 0);
|
||||
contents1 = musicCardShelfRenderer.getJSONArray("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]);
|
||||
|
||||
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
responseSearch.setHeaderTitle(headerTitle);
|
||||
|
||||
List<ResponseSearchChild> list = new ArrayList<>();
|
||||
if(contents1!=null){
|
||||
for (int k = 0; k < contents1.length(); k++) {
|
||||
ResponseSearchChild responseSearchChild = new ResponseSearchChild();
|
||||
|
||||
JSONObject musicResponsiveListItemRenderer = contents1.getJSONObject(k)
|
||||
.optJSONObject("musicResponsiveListItemRenderer");
|
||||
|
||||
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[] 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 runs = text.getJSONArray("runs");
|
||||
// for (int g = 0; g < runs.length(); g++) {
|
||||
// JSONObject jsonObject1 = runs.getJSONObject(g);
|
||||
// String[] browser = getBrowser(jsonObject1);
|
||||
// if (browser != null) {
|
||||
// browserId = browser[0];
|
||||
// pageType = browser[1];
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return searchList;
|
||||
|
||||
} catch (JSONException e) {
|
||||
CommonUtils.LogErrorMsg("--" + e.getMessage());
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 搜索结果返回的browserId 进行请求返回的数据列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static ResponseResult ResolveSearchResultList(JSONObject jsonObject) {
|
||||
try {
|
||||
|
||||
ResponseResult responseResult = new ResponseResult();
|
||||
|
||||
JSONObject contents = jsonObject.getJSONObject("contents");
|
||||
JSONObject musicImmersiveHeaderRenderer = jsonObject.getJSONObject("header")
|
||||
.getJSONObject("musicImmersiveHeaderRenderer");
|
||||
|
||||
String mainTitle = getJsonTitle(musicImmersiveHeaderRenderer.getJSONObject("title"), 0);
|
||||
String thumbnail = getCovertUrl(musicImmersiveHeaderRenderer.getJSONObject("thumbnail"), true);
|
||||
|
||||
responseResult.setMainTitle(mainTitle);
|
||||
responseResult.setMainCovert(thumbnail);
|
||||
|
||||
JSONObject singleColumnBrowseResultsRenderer = contents.optJSONObject("singleColumnBrowseResultsRenderer");
|
||||
if (singleColumnBrowseResultsRenderer != null) {
|
||||
JSONArray contentsArray = singleColumnBrowseResultsRenderer
|
||||
.getJSONArray("tabs")
|
||||
.getJSONObject(0)
|
||||
.getJSONObject("tabRenderer")
|
||||
.getJSONObject("content")
|
||||
.getJSONObject("sectionListRenderer")
|
||||
.getJSONArray("contents");
|
||||
List<ResponseResultList> list = new ArrayList<>();
|
||||
for (int a = 0; a < contentsArray.length(); a++) {
|
||||
ResponseResultList resultList = new ResponseResultList();
|
||||
List<ResponseResultListChild> childList = new ArrayList<>();
|
||||
|
||||
|
||||
JSONObject arrayJSONObject = contentsArray.getJSONObject(a);
|
||||
JSONObject musicShelfRenderer = arrayJSONObject.optJSONObject("musicShelfRenderer");
|
||||
JSONObject musicCarouselShelfRenderer = arrayJSONObject.optJSONObject("musicCarouselShelfRenderer");
|
||||
if (musicShelfRenderer != null) {
|
||||
String headerTitle = getJsonTitle(musicShelfRenderer.getJSONObject("title"), 0);
|
||||
resultList.setHeaderTitle(headerTitle);
|
||||
|
||||
JSONArray contents1 = musicShelfRenderer.getJSONArray("contents");
|
||||
for (int f = 0; f < contents1.length(); f++) {
|
||||
ResponseResultListChild responseResultListChild = new ResponseResultListChild();
|
||||
|
||||
JSONObject musicResponsiveListItemRenderer = contents1.getJSONObject(f)
|
||||
.getJSONObject("musicResponsiveListItemRenderer");
|
||||
|
||||
String thumbnail1 = getCovertUrl(musicResponsiveListItemRenderer.getJSONObject("thumbnail"), true);
|
||||
|
||||
JSONArray flexColumns = musicResponsiveListItemRenderer.getJSONArray("flexColumns");
|
||||
|
||||
String songName = "";
|
||||
String singerName = "";
|
||||
String playCount = "";
|
||||
String videoId = "";
|
||||
String playLIstId = "";
|
||||
for (int b = 0; b < flexColumns.length(); b++) {
|
||||
JSONObject jsonObject1 = flexColumns.getJSONObject(b)
|
||||
.getJSONObject("musicResponsiveListItemFlexColumnRenderer")
|
||||
.getJSONObject("text");
|
||||
|
||||
switch (b) {
|
||||
case 0:
|
||||
songName = getJsonTitle(jsonObject1, 0);
|
||||
String[] watchEndPoint = getWatchEndPoint(jsonObject1.getJSONArray("runs").getJSONObject(0));
|
||||
videoId = watchEndPoint[0];
|
||||
playLIstId = watchEndPoint[1];
|
||||
break;
|
||||
case 1:
|
||||
singerName = getJsonTitle(jsonObject1, 0);
|
||||
break;
|
||||
case 2:
|
||||
playCount = getJsonTitle(jsonObject1, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
responseResultListChild.setThumbnail(thumbnail1);
|
||||
responseResultListChild.setSongName(songName);
|
||||
responseResultListChild.setSubTitle(singerName);
|
||||
responseResultListChild.setPlayCount(playCount);
|
||||
responseResultListChild.setVideoId(videoId);
|
||||
responseResultListChild.setPlayListId(playLIstId);
|
||||
|
||||
childList.add(responseResultListChild);
|
||||
}
|
||||
} else if (musicCarouselShelfRenderer != null) {
|
||||
String headerTitle = getJsonTitle(musicCarouselShelfRenderer.getJSONObject("header")
|
||||
.getJSONObject("musicCarouselShelfBasicHeaderRenderer")
|
||||
.getJSONObject("title"),0);
|
||||
resultList.setHeaderTitle(headerTitle);
|
||||
|
||||
JSONArray contents1 = musicCarouselShelfRenderer.getJSONArray("contents");
|
||||
for (int f = 0; f < contents1.length(); f++) {
|
||||
ResponseResultListChild responseResultListChild = new ResponseResultListChild();
|
||||
|
||||
JSONObject musicTwoRowItemRenderer = contents1.getJSONObject(f)
|
||||
.getJSONObject("musicTwoRowItemRenderer");
|
||||
|
||||
String thumbnail1 = getCovertUrl(musicTwoRowItemRenderer.getJSONObject("thumbnailRenderer"), true);
|
||||
|
||||
JSONObject title = musicTwoRowItemRenderer.getJSONObject("title");
|
||||
String albumName = getJsonTitle(title, 0);
|
||||
|
||||
String[] browser = getBrowser(title.getJSONArray("runs").getJSONObject(0));
|
||||
String subtitle = getJsonTextNew(musicTwoRowItemRenderer.getJSONObject("subtitle"));
|
||||
|
||||
if(browser!= null){
|
||||
String browserId = browser[0];
|
||||
responseResultListChild.setBrowserId(browserId);
|
||||
}
|
||||
responseResultListChild.setThumbnail(thumbnail1);
|
||||
responseResultListChild.setSongName(albumName);
|
||||
responseResultListChild.setSubTitle(subtitle);
|
||||
childList.add(responseResultListChild);
|
||||
}
|
||||
}
|
||||
resultList.setChildList(childList);
|
||||
list.add(resultList);
|
||||
}
|
||||
responseResult.setList(list);
|
||||
|
||||
}
|
||||
CommonUtils.LogMsg("-- responseResult=" + responseResult);
|
||||
return responseResult;
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -562,13 +842,6 @@ public class JsonHelper {
|
||||
.getJSONObject("browseEndpoint");
|
||||
|
||||
}
|
||||
|
||||
// else if (subtitle.has("navigationEndpoint")) {
|
||||
// //-------------当pageType="MUSIC_PAGE_TYPE_ARTIST" 走这里
|
||||
// browseEndpoint = subtitle.getJSONObject("navigationEndpoint")
|
||||
// .getJSONObject("browseEndpoint");
|
||||
// // browsID = UCTruu07wXSulRSQ2sOPR5mQ
|
||||
// }
|
||||
if (browseEndpoint != null) {
|
||||
browseId = browseEndpoint
|
||||
.getString("browseId");
|
||||
@ -630,7 +903,11 @@ public class JsonHelper {
|
||||
|
||||
String[] strings = new String[4];
|
||||
try {
|
||||
JSONObject watchEndpoint = job.getJSONObject("navigationEndpoint").getJSONObject("watchEndpoint");
|
||||
JSONObject navigationEndpoint = job.optJSONObject("navigationEndpoint");
|
||||
if (navigationEndpoint == null) {
|
||||
return strings;
|
||||
}
|
||||
JSONObject watchEndpoint = navigationEndpoint.getJSONObject("watchEndpoint");
|
||||
if (watchEndpoint.has("videoId")) {
|
||||
strings[0] = watchEndpoint.getString("videoId");
|
||||
}
|
||||
@ -643,12 +920,7 @@ public class JsonHelper {
|
||||
if (watchEndpoint.has("watchEndpointMusicSupportedConfigs")) {
|
||||
strings[3] = watchEndpoint.getJSONObject("watchEndpointMusicSupportedConfigs").getJSONObject("watchEndpointMusicConfig").getString("musicVideoType");
|
||||
}
|
||||
// String videoId = watchEndpoint.getString("videoId");
|
||||
// String playlistId = watchEndpoint.getString("playlistId");
|
||||
// String params = watchEndpoint.getString("params");
|
||||
// String musicVideoType = watchEndpoint.getJSONObject("watchEndpointMusicSupportedConfigs")
|
||||
// .getJSONObject("watchEndpointMusicConfig")
|
||||
// .getString("musicVideoType");
|
||||
|
||||
} catch (JSONException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
@ -695,6 +967,24 @@ public class JsonHelper {
|
||||
}
|
||||
|
||||
|
||||
private static String[] getBrowser(JSONObject jsonObject) throws JSONException {
|
||||
|
||||
String[] strings = new String[2];
|
||||
JSONObject navigationEndpoint = jsonObject.optJSONObject("navigationEndpoint");
|
||||
if (navigationEndpoint != null) {
|
||||
|
||||
JSONObject browseEndpoint = navigationEndpoint.optJSONObject("browseEndpoint");
|
||||
if (browseEndpoint == null) return null;
|
||||
strings[0] = browseEndpoint.getString("browseId");
|
||||
|
||||
strings[1] = browseEndpoint.getJSONObject("browseEndpointContextSupportedConfigs")
|
||||
.getJSONObject("browseEndpointContextMusicConfig")
|
||||
.getString("pageType");
|
||||
return strings;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String getJsonTitle(JSONObject jsonObject, int index) {
|
||||
String text = "";
|
||||
try {
|
||||
|
||||
@ -35,14 +35,14 @@ public interface MusicApi {
|
||||
|
||||
// X-Goog-FieldMask: contents.singleColumnMusicWatchNextResultsRenderer.tabbedRenderer.watchNextTabbedResultsRenderer.tabs.tabRenderer.content.musicQueueRenderer.content.playlistPanelRenderer(continuations,contents(automixPreviewVideoRenderer,playlistPanelVideoRenderer(title,navigationEndpoint,longBylineText,shortBylineText,thumbnail,lengthText)))
|
||||
|
||||
//获取播放列表
|
||||
//获取播放列表(返回的是每首歌曲详情列表)
|
||||
@POST("youtubei/v1/next?prettyPrint=false")
|
||||
@Headers("X-Goog-Api-Key:AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8")
|
||||
Observable<ResponseBody> getMusicPlayPage(@Header("X-Goog-FieldMask") String customHeader, @Body RequestBody requestBody);
|
||||
|
||||
|
||||
|
||||
//获取播放音频资源url
|
||||
//获取播放音频资源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"})
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.hi.music.player.network;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.hi.music.player.MusicApplication;
|
||||
import com.hi.music.player.api.RequestListener;
|
||||
import com.hi.music.player.javabean.requestbody.BodyHome;
|
||||
import com.hi.music.player.javabean.requestbody.BodyPlay;
|
||||
@ -134,10 +135,13 @@ public class RetrofitManager {
|
||||
BodyPlayUrl bodyPlay = new BodyPlayUrl();
|
||||
bodyPlay.setVideoId(videoId);
|
||||
Client client = bodyPlay.getContext().getClient();
|
||||
client.setClientName("ANDROID_MUSIC");
|
||||
client.setClientVersion("5.28.1");
|
||||
client.setPlatform("MOBILE");
|
||||
bodyPlay.getContext().getThirdParty().setEmbedUrl("https://www.youtube.com/watch?v=" + videoId);
|
||||
client.setClientName("ANDROID");
|
||||
client.setClientVersion("19.05.36");
|
||||
client.setPlatform("DESKTOP");
|
||||
String visitorData = MusicApplication.getVisitorData();
|
||||
// client.setVisitorData("CgtWN1RXaURPN3LNZyiZK9e4BjIKCgJVUXIEGgAgPW%3D%3D");
|
||||
client.setVisitorData(visitorData);
|
||||
bodyPlay.getContext().getThirdParty().setEmbedUrl("https://www.youtube.com/watch?v="+videoId);
|
||||
|
||||
|
||||
Gson gson = new Gson();
|
||||
|
||||
@ -59,6 +59,7 @@ public class CategoryListActivity extends BaseActivity<ActivityCategoryListBindi
|
||||
private ResponseCategoryList mCategoryList;
|
||||
private String mPageType;
|
||||
private String twoSubtitle;
|
||||
private String browseId;
|
||||
|
||||
@Override
|
||||
protected ActivityCategoryListBinding getViewBinding() {
|
||||
@ -74,18 +75,12 @@ public class CategoryListActivity extends BaseActivity<ActivityCategoryListBindi
|
||||
return;
|
||||
}
|
||||
|
||||
if (!intent.hasExtra(MyValue.KEY_PLAY_ACTIVITY_CATEGORY)) {
|
||||
return;
|
||||
}
|
||||
ResponseCategory category = (ResponseCategory) intent.getSerializableExtra(MyValue.KEY_PLAY_ACTIVITY_CATEGORY);
|
||||
if (category == null)
|
||||
return;
|
||||
mPageType = category.getPageType();
|
||||
twoSubtitle = category.getTwoSubtitle();
|
||||
|
||||
mPageType= intent.getStringExtra(MyValue.KEY_CATEGORY_LIST_TYPE);
|
||||
twoSubtitle = intent.getStringExtra(MyValue.KEY_CATEGORY_LIST_SINGER_NAME);
|
||||
browseId = intent.getStringExtra(MyValue.KEY_CATEGORY_LIST_BROWSER_ID);
|
||||
|
||||
vb.pbLoading.setVisibility(View.VISIBLE);
|
||||
vm.getList(category.getBrowseId());
|
||||
vm.getList(browseId);
|
||||
vm.data.observe(this, new Observer<ResponseCategoryList>() {
|
||||
@Override
|
||||
public void onChanged(ResponseCategoryList responseCategoryList) {
|
||||
|
||||
@ -9,6 +9,7 @@ import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -33,6 +34,7 @@ import com.hi.music.player.R;
|
||||
import com.hi.music.player.adapter.AdapterPlayList;
|
||||
import com.hi.music.player.api.MediaControllerListener;
|
||||
import com.hi.music.player.api.onImageColorListener;
|
||||
import com.hi.music.player.api.onPlayNextListener;
|
||||
import com.hi.music.player.databinding.ActivityPlayBinding;
|
||||
import com.hi.music.player.helper.CommonUtils;
|
||||
import com.hi.music.player.helper.MyValue;
|
||||
@ -57,12 +59,11 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
// private VMApplication vmApplication;
|
||||
|
||||
|
||||
//接口返回的播放列表(没有音频数据)
|
||||
private List<ResponsePlayListInfo> mPlayList;
|
||||
|
||||
|
||||
|
||||
private ResponsePlayUrl mCurPlayInfo;
|
||||
private ResponsePlayListInfo musicInfo;
|
||||
|
||||
private Handler mHandler;
|
||||
private Runnable mRunnable;
|
||||
// private MyMediaControllerManager mediaControllerManager;
|
||||
@ -127,6 +128,7 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
videoId = responseSingle.getVideoId();
|
||||
params = responseSingle.getParams();
|
||||
musicVideoType = responseSingle.getMusicVideoType();
|
||||
mDefaultPlayStartIndex = intent.getIntExtra(MyValue.KEY_PLAY_ACTIVITY_CATEGORY_LIST_INDEX, mDefaultPlayStartIndex);
|
||||
vmPlay.getPlayMusicList(playlistId, videoId, params, musicVideoType);
|
||||
vmPlay.playList.observe(this, new Observer<List<ResponsePlayListInfo>>() {
|
||||
@Override
|
||||
@ -215,8 +217,6 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
CommonUtils.LogMsg("--------更新-playList " + playList.size() + "--videoId=" + videoId);
|
||||
if (playList.size() > 0) {
|
||||
vb.linearRetry.setVisibility(View.GONE);
|
||||
mPlayList = playList;
|
||||
musicInfo = playList.get(0);
|
||||
setPlayListAndGetUrl(playList, videoId, mDefaultPlayStartIndex);
|
||||
}
|
||||
|
||||
@ -480,7 +480,14 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
mediaControllerManager.pause();
|
||||
}
|
||||
} else if (v.equals(vb.btnNext)) {
|
||||
mediaControllerManager.playNext();
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} else if (v.equals(vb.btnPrevious)) {
|
||||
mediaControllerManager.playPrevious();
|
||||
|
||||
@ -0,0 +1,133 @@
|
||||
package com.hi.music.player.ui.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.engine.GlideException;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.hi.music.player.MusicApplication;
|
||||
import com.hi.music.player.R;
|
||||
import com.hi.music.player.adapter.AdapterResult;
|
||||
import com.hi.music.player.api.HomeItemClickListener;
|
||||
import com.hi.music.player.databinding.ActivityResultListBinding;
|
||||
import com.hi.music.player.helper.CommonUtils;
|
||||
import com.hi.music.player.helper.MyValue;
|
||||
import com.hi.music.player.javabean.response.ResponseResult;
|
||||
import com.hi.music.player.javabean.response.child.ResponseResultListChild;
|
||||
import com.hi.music.player.javabean.response.child.ResponseSingle;
|
||||
import com.hi.music.player.ui.fragmnt.viewmodel.VMCategoryList;
|
||||
import com.hi.music.player.ui.fragmnt.viewmodel.VMResultList;
|
||||
|
||||
public class ResultListActivity extends BaseActivity<ActivityResultListBinding> implements HomeItemClickListener {
|
||||
private VMResultList vm;
|
||||
|
||||
@Override
|
||||
protected ActivityResultListBinding getViewBinding() {
|
||||
return ActivityResultListBinding.inflate(getLayoutInflater());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreateInit() {
|
||||
vm = getActivityScopeViewModel(VMResultList.class);
|
||||
String key = getIntent().getStringExtra("key");
|
||||
vm.getList(key);
|
||||
|
||||
vm.data.observe(this, new Observer<ResponseResult>() {
|
||||
@Override
|
||||
public void onChanged(ResponseResult responseResult) {
|
||||
if(responseResult == null){
|
||||
|
||||
return;
|
||||
}
|
||||
loadInfo(responseResult);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void loadInfo(ResponseResult result){
|
||||
Glide.with(this)
|
||||
.asDrawable()
|
||||
.load(result.getMainCovert())
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(4))))
|
||||
.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.covert);
|
||||
vb.mainTitle.setText(result.getMainTitle());
|
||||
AdapterResult adapterResult = new AdapterResult();
|
||||
adapterResult.setHomeItemClickListener(this);
|
||||
adapterResult.setData(result.getList());
|
||||
vb.listRecycler.setAdapter(adapterResult);
|
||||
vb.listRecycler.setLayoutManager(new LinearLayoutManager(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitClick() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullScreen() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean statusBarLight() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showPanel() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickResultSong(ResponseResultListChild child,int index) {
|
||||
ResponseSingle responseSingle = new ResponseSingle();
|
||||
responseSingle.setSongTitle(child.getSongName());
|
||||
responseSingle.setSingerHead(child.getThumbnail());
|
||||
responseSingle.setVideoId(child.getVideoId());
|
||||
responseSingle.setPlaylistId(child.getPlayListId());
|
||||
Intent intent = new Intent(this, PlayActivity.class);
|
||||
intent.putExtra(MyValue.KEY_PLAY_ACTIVITY_SINGER, responseSingle);
|
||||
intent.putExtra(MyValue.KEY_PLAY_ACTIVITY_CATEGORY_LIST_INDEX,index);
|
||||
CommonUtils.LogMsg("-------------index="+index);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickResultAlbum(ResponseResultListChild child, int index) {
|
||||
Intent intent = new Intent(this, CategoryListActivity.class);
|
||||
// intent.putExtra(MyValue.KEY_CATEGORY_LIST_TYPE, pageType);
|
||||
intent.putExtra(MyValue.KEY_CATEGORY_LIST_SINGER_NAME, child.getSongName());
|
||||
intent.putExtra(MyValue.KEY_CATEGORY_LIST_BROWSER_ID, child.getBrowserId());
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
@ -121,6 +121,8 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> implements H
|
||||
FragmentActivity activity = getActivity();
|
||||
if(activity!= null){
|
||||
String pageType = data.getPageType();
|
||||
String browseId = data.getBrowseId();
|
||||
String twoSubtitle = data.getTwoSubtitle();
|
||||
if(pageType.equals(MyValue.PAGE_TYPE_MV)){
|
||||
Intent intent = new Intent(activity, PlayActivity.class);
|
||||
intent.putExtra(MyValue.KEY_PLAY_ACTIVITY_MV, data);
|
||||
@ -128,11 +130,15 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> implements H
|
||||
startActivity(intent);
|
||||
}else if(pageType.equals(MyValue.PAGE_TYPE_ALBUM)){
|
||||
Intent intent = new Intent(activity, CategoryListActivity.class);
|
||||
intent.putExtra(MyValue.KEY_PLAY_ACTIVITY_CATEGORY, data);
|
||||
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_PLAY_ACTIVITY_CATEGORY, data);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.hi.music.player.ui.fragmnt;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.KeyEvent;
|
||||
@ -10,10 +11,18 @@ import android.widget.TextView;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.hi.music.player.adapter.AdapterSearch;
|
||||
import com.hi.music.player.adapter.AdapterSuggestion;
|
||||
import com.hi.music.player.api.HomeItemClickListener;
|
||||
import com.hi.music.player.databinding.FragmentSearchBinding;
|
||||
import com.hi.music.player.helper.CommonUtils;
|
||||
import com.hi.music.player.helper.MyValue;
|
||||
import com.hi.music.player.javabean.response.ResponseSearch;
|
||||
import com.hi.music.player.javabean.response.child.ResponseSearchChild;
|
||||
import com.hi.music.player.javabean.response.child.ResponseSingle;
|
||||
import com.hi.music.player.ui.activity.CategoryListActivity;
|
||||
import com.hi.music.player.ui.activity.PlayActivity;
|
||||
import com.hi.music.player.ui.activity.ResultListActivity;
|
||||
import com.hi.music.player.ui.fragmnt.viewmodel.VMSearch;
|
||||
|
||||
import java.util.List;
|
||||
@ -67,6 +76,8 @@ public class SearchFragment extends BaseFragment<FragmentSearchBinding> implemen
|
||||
}
|
||||
});
|
||||
initSuggestionRecycler();
|
||||
initResultRecycler();
|
||||
|
||||
}
|
||||
|
||||
private void initSuggestionRecycler() {
|
||||
@ -87,6 +98,24 @@ public class SearchFragment extends BaseFragment<FragmentSearchBinding> implemen
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void initResultRecycler(){
|
||||
AdapterSearch adapterSearch = new AdapterSearch();
|
||||
adapterSearch.setHomeItemClickListener(this);
|
||||
Vb.recyclerResult.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
Vb.recyclerResult.setAdapter(adapterSearch);
|
||||
vmSearch.result.observe(getViewLifecycleOwner(), new Observer<List<ResponseSearch>>() {
|
||||
@Override
|
||||
public void onChanged(List<ResponseSearch> responseSearches) {
|
||||
if(responseSearches == null){
|
||||
CommonUtils.LogMsg("------------更新结果 null");
|
||||
return;
|
||||
}
|
||||
adapterSearch.setData(responseSearches);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void startQuery(String query){
|
||||
Vb.recyclerSuggestion.setVisibility(View.GONE);
|
||||
Vb.recyclerResult.setVisibility(View.VISIBLE);
|
||||
@ -109,4 +138,75 @@ public class SearchFragment extends BaseFragment<FragmentSearchBinding> implemen
|
||||
Vb.etSearch.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//点击搜索结果的play按钮
|
||||
@Override
|
||||
public void onClickSearchResultBest(ResponseSearch responseSearch) {
|
||||
String beastBrowserId = responseSearch.getBeastBrowserId();
|
||||
String beastVideoId = responseSearch.getBeastVideoId();
|
||||
String beastSongTitle = responseSearch.getBeastSongTitle();
|
||||
String beastSongTCovert = responseSearch.getBeastSongTCovert();
|
||||
|
||||
if(beastBrowserId!= null&&!beastBrowserId.isEmpty()){
|
||||
Intent intent = new Intent(requireActivity(), ResultListActivity.class);
|
||||
intent.putExtra("key", beastBrowserId);
|
||||
startActivity(intent);
|
||||
}else {
|
||||
CommonUtils.LogMsg("---------击搜索结果的play按钮--beastVideoId="+beastVideoId);
|
||||
|
||||
ResponseSingle responseSingle = new ResponseSingle();
|
||||
responseSingle.setSongTitle(beastSongTitle);
|
||||
responseSingle.setSingerHead(beastSongTCovert);
|
||||
responseSingle.setVideoId(beastVideoId);
|
||||
responseSingle.setPlaylistId("");
|
||||
Intent intent = new Intent(requireActivity(), PlayActivity.class);
|
||||
intent.putExtra(MyValue.KEY_PLAY_ACTIVITY_SINGER, responseSingle);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//点击搜索结果普通项
|
||||
@Override
|
||||
public void onClickSearchResult(ResponseSearchChild responseSearchChild) {
|
||||
String browserId = responseSearchChild.getBrowserId();
|
||||
String songVideoId = responseSearchChild.getSongVideoId();
|
||||
String songCovert = responseSearchChild.getSongCovert();
|
||||
String songTitle = responseSearchChild.getSongTitle();
|
||||
String songDescribe = responseSearchChild.getSongDescribe();
|
||||
|
||||
if(browserId!= null&&!browserId.isEmpty()){
|
||||
|
||||
|
||||
String pageType = responseSearchChild.getPageType();
|
||||
CommonUtils.LogMsg("---------点击搜索结果--pageType="+pageType);
|
||||
switch (pageType){
|
||||
case "MUSIC_PAGE_TYPE_ARTIST":
|
||||
Intent intent = new Intent(requireActivity(), ResultListActivity.class);
|
||||
intent.putExtra("key", browserId);
|
||||
startActivity(intent);
|
||||
break;
|
||||
default:
|
||||
Intent intent1 = new Intent(requireActivity(), CategoryListActivity.class);
|
||||
intent1.putExtra(MyValue.KEY_CATEGORY_LIST_TYPE, pageType);
|
||||
intent1.putExtra(MyValue.KEY_CATEGORY_LIST_SINGER_NAME, songDescribe);
|
||||
intent1.putExtra(MyValue.KEY_CATEGORY_LIST_BROWSER_ID, browserId);
|
||||
startActivity(intent1);
|
||||
break;
|
||||
}
|
||||
|
||||
}else {
|
||||
CommonUtils.LogMsg("---------点击搜索结果--VideoId="+songVideoId);
|
||||
|
||||
ResponseSingle responseSingle = new ResponseSingle();
|
||||
responseSingle.setSongTitle(songTitle);
|
||||
responseSingle.setSingerHead(songCovert);
|
||||
responseSingle.setVideoId(songVideoId);
|
||||
responseSingle.setPlaylistId("");
|
||||
Intent intent = new Intent(requireActivity(), PlayActivity.class);
|
||||
intent.putExtra(MyValue.KEY_PLAY_ACTIVITY_SINGER, responseSingle);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,8 +4,10 @@ import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.hi.music.player.MusicApplication;
|
||||
import com.hi.music.player.api.RequestListener;
|
||||
import com.hi.music.player.helper.CommonUtils;
|
||||
import com.hi.music.player.helper.MyValue;
|
||||
import com.hi.music.player.javabean.response.ResponseHome;
|
||||
import com.hi.music.player.network.JsonHelper;
|
||||
import com.hi.music.player.network.RetrofitManager;
|
||||
@ -39,6 +41,7 @@ public class VMHome extends ViewModel {
|
||||
continuation = responseHome.getContinuation();
|
||||
clickTrackingParams = responseHome.getClickTrackingParams();
|
||||
visitorData = responseHome.getVisitorData();
|
||||
MusicApplication.setVisitorData(visitorData);
|
||||
_data.setValue(responseHome);
|
||||
} else {
|
||||
_data.setValue(null);
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
package com.hi.music.player.ui.fragmnt.viewmodel;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.hi.music.player.api.RequestListener;
|
||||
import com.hi.music.player.javabean.response.ResponseCategoryList;
|
||||
import com.hi.music.player.javabean.response.ResponseResult;
|
||||
import com.hi.music.player.network.JsonHelper;
|
||||
import com.hi.music.player.network.RetrofitManager;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
public class VMResultList extends ViewModel {
|
||||
private MutableLiveData<ResponseResult> _data = new MutableLiveData<>();
|
||||
public LiveData<ResponseResult> data = _data;
|
||||
|
||||
|
||||
public void getList(String browseId) {
|
||||
|
||||
RetrofitManager.getInstance().getCategoryList(browseId, new RequestListener<ResponseBody>() {
|
||||
@Override
|
||||
public void onFail(String errorMsg) {
|
||||
_data.setValue(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(JSONObject data) {
|
||||
if (data != null) {
|
||||
ResponseResult responseResult = JsonHelper.ResolveSearchResultList(data);
|
||||
_data.setValue(responseResult);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@ import androidx.lifecycle.ViewModel;
|
||||
import com.hi.music.player.api.RequestListener;
|
||||
import com.hi.music.player.helper.CommonUtils;
|
||||
import com.hi.music.player.javabean.response.ResponseHome;
|
||||
import com.hi.music.player.javabean.response.ResponseSearch;
|
||||
import com.hi.music.player.network.JsonHelper;
|
||||
import com.hi.music.player.network.RetrofitManager;
|
||||
|
||||
@ -19,6 +20,10 @@ import okhttp3.ResponseBody;
|
||||
public class VMSearch extends ViewModel {
|
||||
private MutableLiveData<List<String>> _suggestion = new MutableLiveData<List<String>>();
|
||||
public LiveData<List<String>> suggestion = _suggestion;
|
||||
|
||||
|
||||
private MutableLiveData<List<ResponseSearch>> _result= new MutableLiveData<List<ResponseSearch>>();
|
||||
public LiveData<List<ResponseSearch>> result = _result;
|
||||
public void getSuggestion(String input) {
|
||||
RetrofitManager.getInstance().getSearchSuggestion(input,new RequestListener<ResponseBody>() {
|
||||
|
||||
@ -47,16 +52,16 @@ public class VMSearch extends ViewModel {
|
||||
|
||||
@Override
|
||||
public void onFail(String errorMsg) {
|
||||
// _data.setValue(null);
|
||||
_result.setValue(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(JSONObject data) {
|
||||
if (data != null) {
|
||||
JsonHelper.ResolveSearchResult(data);
|
||||
// _data.setValue(responseHome);
|
||||
List<ResponseSearch> responseSearches = JsonHelper.ResolveSearchResult(data);
|
||||
_result.setValue(responseSearches);
|
||||
} else {
|
||||
// _data.setValue(null);
|
||||
_result.setValue(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
7
app/src/main/res/drawable/bg_best_bg.xml
Normal file
7
app/src/main/res/drawable/bg_best_bg.xml
Normal 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="10dp"/>
|
||||
<solid android:color="@color/best_result_bg"/>
|
||||
|
||||
</shape>
|
||||
7
app/src/main/res/drawable/bg_search_result_play.xml
Normal file
7
app/src/main/res/drawable/bg_search_result_play.xml
Normal 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="20dp"/>
|
||||
<solid android:color="@color/white"/>
|
||||
|
||||
</shape>
|
||||
22
app/src/main/res/drawable/panel_play.xml
Normal file
22
app/src/main/res/drawable/panel_play.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<group>
|
||||
<clip-path
|
||||
android:pathData="M0,0h24v24h-24z"/>
|
||||
<path
|
||||
android:pathData="M17.571,2.57V21.57"
|
||||
android:strokeWidth="5"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#000000"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M6.429,2.57V21.57"
|
||||
android:strokeWidth="5"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#000000"
|
||||
android:strokeLineCap="round"/>
|
||||
</group>
|
||||
</vector>
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_selected="true" android:drawable="@drawable/panel_icon_pause"/>
|
||||
<item android:state_selected="true" android:drawable="@drawable/panel_play"/>
|
||||
<item android:state_selected="false" android:drawable="@drawable/panel_icon_play"/>
|
||||
|
||||
|
||||
|
||||
51
app/src/main/res/layout/activity_result_list.xml
Normal file
51
app/src/main/res/layout/activity_result_list.xml
Normal file
@ -0,0 +1,51 @@
|
||||
<?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"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.activity.ResultListActivity">
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/relayout_top"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="280dp"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/covert"
|
||||
android:scaleType="centerCrop"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/im_back"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:padding="9dp"
|
||||
android:src="@drawable/arrow_bottom" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/main_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="260dp"
|
||||
android:layout_marginBottom="-20dp"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="17sp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/list_recycler"
|
||||
app:layout_constraintTop_toBottomOf="@id/main_title" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
27
app/src/main/res/layout/item_result.xml
Normal file
27
app/src/main/res/layout/item_result.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_header_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp" />
|
||||
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/list_child"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tv_header_title" />
|
||||
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
46
app/src/main/res/layout/item_result_list_album.xml
Normal file
46
app/src/main/res/layout/item_result_list_album.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/header"
|
||||
android:layout_width="170dp"
|
||||
android:layout_height="170dp"
|
||||
android:src="@drawable/placeholder" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="169dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/text_color_1"
|
||||
android:textSize="14sp" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_subtitle"
|
||||
android:layout_width="169dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/text_color_2"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/view"
|
||||
android:visibility="gone"
|
||||
android:layout_height="100dp"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
42
app/src/main/res/layout/item_result_list_song.xml
Normal file
42
app/src/main/res/layout/item_result_list_song.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:paddingEnd="16dp"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/im_covert"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:scaleType="fitXY" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/im_covert"
|
||||
android:layout_alignBottom="@id/im_covert"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_toEndOf="@id/im_covert"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_song_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_subtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/white_60_color"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
89
app/src/main/res/layout/item_search.xml
Normal file
89
app/src/main/res/layout/item_search.xml
Normal file
@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_header_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<LinearLayout
|
||||
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">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/layout_best"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="20dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/im_best_covert"
|
||||
android:layout_width="60dp"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_height="60dp" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/im_best_covert"
|
||||
android:layout_alignBottom="@id/im_best_covert"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_toEndOf="@id/im_best_covert"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_best_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_best_subtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/white_60_color"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_play"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_below="@id/im_best_covert"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="@drawable/bg_search_result_play"
|
||||
android:paddingTop="6dp"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="10dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:text="@string/play"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="15sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/layout_best" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
41
app/src/main/res/layout/item_search_child.xml
Normal file
41
app/src/main/res/layout/item_search_child.xml
Normal file
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/im_covert"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/im_covert"
|
||||
android:layout_alignBottom="@id/im_covert"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_toEndOf="@id/im_covert"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_subtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/white_60_color"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
@ -57,8 +57,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/im_play"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="34dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/selector_panel_play" />
|
||||
</FrameLayout>
|
||||
|
||||
@ -18,4 +18,5 @@
|
||||
<color name="panel_singer_color">#99000000</color>
|
||||
<color name="retry_layout">#000000</color>
|
||||
<color name="test">#2D9C31</color>
|
||||
<color name="best_result_bg">#282A2C</color>
|
||||
</resources>
|
||||
@ -25,4 +25,6 @@
|
||||
<string name="retry">Try again</string>
|
||||
<string name="An_error_occurred">An error occurred</string>
|
||||
<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>
|
||||
</resources>
|
||||
Loading…
Reference in New Issue
Block a user