搜索结果页面跳转事件

This commit is contained in:
litingting 2024-10-28 11:54:07 +08:00
parent e80a4f97d3
commit f342e2ff7a
21 changed files with 196 additions and 110 deletions

View File

@ -73,4 +73,8 @@ dependencies {
implementation("androidx.media3:media3-session:1.4.1")
implementation("androidx.media3:media3-ui:1.4.1")
//----------media3
implementation ("com.geyifeng.immersionbar:immersionbar:3.2.2")
implementation ("com.geyifeng.immersionbar:immersionbar-components:3.2.2")
}

View File

@ -59,7 +59,7 @@ public class AdapterCategoryList extends BaseAdapter<ResponsePlayListInfo, ItemC
vb.tvSingerName.setText(describe);
vb.image.setVisibility(View.GONE);
vb.tvPosition.setVisibility(View.VISIBLE);
vb.tvPosition.setText(String.valueOf(position));
vb.tvPosition.setText(String.valueOf(position+1));
break;
default:
vb.tvSingerName.setText(singerName);

View File

@ -1,5 +1,6 @@
package com.hi.music.player.adapter;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.ViewGroup;
@ -10,26 +11,34 @@ import androidx.recyclerview.widget.RecyclerView;
import com.hi.music.player.MusicApplication;
import com.hi.music.player.databinding.ItemResultBinding;
import com.hi.music.player.helper.CommonUtils;
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>{
public AdapterResult(Context mContext) {
super(mContext);
}
@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();
String headerTitle = resultList.getHeaderTitle();
vb.tvHeaderTitle.setText(headerTitle);
vb.tvHeaderTitle.setText(resultList.getHeaderTitle());
CommonUtils.LogMsg("---------headerTitle="+headerTitle);
ItemDecoration itemDecoration ;
@ -38,7 +47,7 @@ public class AdapterResult extends BaseAdapter<ResponseResultList, ItemResultBin
AdapterResultListSong adapterResultListSong = new AdapterResultListSong();
adapterResultListSong.setData(resultList.getChildList());
vb.listChild.setAdapter(adapterResultListSong);
vb.listChild.setLayoutManager(new LinearLayoutManager(MusicApplication.myApplication));
vb.listChild.setLayoutManager(new LinearLayoutManager(mContext));
if(homeItemClickListener!= null)
adapterResultListSong.setHomeItemClickListener(homeItemClickListener);
}else {
@ -46,11 +55,11 @@ public class AdapterResult extends BaseAdapter<ResponseResultList, ItemResultBin
AdapterResultListAlbum adapterResultListAlbum = new AdapterResultListAlbum();
adapterResultListAlbum.setData(resultList.getChildList());
vb.listChild.setAdapter(adapterResultListAlbum);
vb.listChild.setLayoutManager(new LinearLayoutManager(MusicApplication.myApplication, LinearLayoutManager.HORIZONTAL,false));
vb.listChild.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL,false));
if(homeItemClickListener!= null)
adapterResultListAlbum.setHomeItemClickListener(homeItemClickListener);
}
vb.listChild.addItemDecoration(itemDecoration);
// vb.listChild.addItemDecoration(itemDecoration);
}
}

View File

@ -67,11 +67,12 @@ public class AdapterResultListAlbum extends BaseAdapter<ResponseResultListChild,
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);
}
homeItemClickListener.onClickResultSong(listChild,absoluteAdapterPosition);
// if(videoId == null||videoId.isEmpty()){
// homeItemClickListener.onClickResultAlbum(listChild,absoluteAdapterPosition);
// }else if(browserId!= null&&!browserId.isEmpty()){
// homeItemClickListener.onClickResultSong(listChild,absoluteAdapterPosition);
// }
}
}
});

View File

@ -64,11 +64,7 @@ public class AdapterResultListSong extends BaseAdapter<ResponseResultListChild,
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);
}
homeItemClickListener.onClickResultSong(listChild,absoluteAdapterPosition);
}
}

View File

@ -1,5 +1,6 @@
package com.hi.music.player.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;
@ -19,11 +20,18 @@ abstract public class BaseAdapter<K, T extends ViewBinding> extends RecyclerView
protected List<K> data = new ArrayList<>();
protected Context mContext;
protected static final int TYPE_ITEM = 0;
protected static final int TYPE_FOOTER = 1;
protected boolean isLoadingAdded = false;
public BaseAdapter() {
}
public BaseAdapter(Context mContext) {
this.mContext = mContext;
}
protected HomeItemClickListener homeItemClickListener;

View File

@ -526,13 +526,12 @@ public class JsonHelper {
/**
* 搜索结果返回的browserId 进行请求返回的数据列表
* 根据搜索结果返回的browserId 进行请求返回的数据列表
*
* @return
*/
public static ResponseResult ResolveSearchResultList(JSONObject jsonObject) {
try {
ResponseResult responseResult = new ResponseResult();
JSONObject contents = jsonObject.getJSONObject("contents");
@ -566,7 +565,7 @@ public class JsonHelper {
if (musicShelfRenderer != null) {
String headerTitle = getJsonTitle(musicShelfRenderer.getJSONObject("title"), 0);
resultList.setHeaderTitle(headerTitle);
CommonUtils.LogMsg("----------结果子页面111--------------------headerTitle"+headerTitle);
JSONArray contents1 = musicShelfRenderer.getJSONArray("contents");
for (int f = 0; f < contents1.length(); f++) {
ResponseResultListChild responseResultListChild = new ResponseResultListChild();
@ -611,6 +610,7 @@ public class JsonHelper {
responseResultListChild.setVideoId(videoId);
responseResultListChild.setPlayListId(playLIstId);
CommonUtils.LogMsg("----------结果子页面111 songName="+songName+"---videoId="+videoId+"--playLIstId="+playLIstId);
childList.add(responseResultListChild);
}
} else if (musicCarouselShelfRenderer != null) {
@ -618,7 +618,7 @@ public class JsonHelper {
.getJSONObject("musicCarouselShelfBasicHeaderRenderer")
.getJSONObject("title"),0);
resultList.setHeaderTitle(headerTitle);
CommonUtils.LogMsg("----------结果子页面222--------------------headerTitle"+headerTitle);
JSONArray contents1 = musicCarouselShelfRenderer.getJSONArray("contents");
for (int f = 0; f < contents1.length(); f++) {
ResponseResultListChild responseResultListChild = new ResponseResultListChild();
@ -637,20 +637,32 @@ public class JsonHelper {
if(browser!= null){
String browserId = browser[0];
responseResultListChild.setBrowserId(browserId);
responseResultListChild.setPageType(browser[1]);
}
String[] watchEndPoint = getWatchEndPoint(musicTwoRowItemRenderer);
if(watchEndPoint!=null){
responseResultListChild.setVideoId(watchEndPoint[0]);
responseResultListChild.setPlayListId(watchEndPoint[1]);
}
responseResultListChild.setThumbnail(thumbnail1);
responseResultListChild.setSongName(albumName);
responseResultListChild.setSubTitle(subtitle);
CommonUtils.LogMsg("----------结果子页面222 songName="+albumName+"---videoId="+responseResultListChild.getVideoId()+"--playLIstId="+responseResultListChild.getPlayListId()
+"---BrowserId="+responseResultListChild.getBrowserId()+"---PageType="+responseResultListChild.getPageType());
childList.add(responseResultListChild);
}
}
resultList.setChildList(childList);
list.add(resultList);
}
responseResult.setList(list);
}
CommonUtils.LogMsg("-- responseResult=" + responseResult);
return responseResult;
} catch (JSONException e) {

View File

@ -15,6 +15,7 @@ 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;
@ -25,7 +26,9 @@ 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;
@ -70,7 +73,8 @@ public abstract class BaseActivity<T extends ViewBinding> extends AppCompatActiv
initPanel();
setStatusBar();
if (isFullScreen()) {
root.setPadding(0, 100, 0, 0);
// ImmersionBar.with(this).init();//设置沉浸式效果
// ImmersionBar.setStatusBarView(this,0);
initFullScreen();
}
onCreateInit();
@ -104,8 +108,10 @@ 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();
}

View File

@ -76,7 +76,7 @@ public class ResultListActivity extends BaseActivity<ActivityResultListBinding>
})
.into(vb.covert);
vb.mainTitle.setText(result.getMainTitle());
AdapterResult adapterResult = new AdapterResult();
AdapterResult adapterResult = new AdapterResult(this);
adapterResult.setHomeItemClickListener(this);
adapterResult.setData(result.getList());
vb.listRecycler.setAdapter(adapterResult);
@ -85,7 +85,7 @@ public class ResultListActivity extends BaseActivity<ActivityResultListBinding>
@Override
protected void onInitClick() {
vb.imBack.setOnClickListener(this);
}
@Override
@ -105,21 +105,61 @@ public class ResultListActivity extends BaseActivity<ActivityResultListBinding>
@Override
public void onClick(View v) {
if(v.equals(vb.imBack)){
finish();
}
}
@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);
String videoId = child.getVideoId();
String playListId = child.getPlayListId();
String browserId = child.getBrowserId();
String pageType = child.getPageType();
String thumbnail = child.getThumbnail();
String songName = child.getSongName();
String subTitle = child.getSubTitle();
if(videoId!= null&&!videoId.isEmpty()){
ResponseSingle responseSingle = new ResponseSingle();
responseSingle.setSongTitle(songName);
responseSingle.setSingerHead(thumbnail);
responseSingle.setVideoId(videoId);
responseSingle.setPlaylistId(playListId);
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);
}else {
switch (pageType){
case "MUSIC_PAGE_TYPE_ALBUM":
//专辑
case "MUSIC_PAGE_TYPE_PLAYLIST":
//精选
Intent intent1 = new Intent(this, CategoryListActivity.class);
intent1.putExtra(MyValue.KEY_CATEGORY_LIST_TYPE, pageType);
intent1.putExtra(MyValue.KEY_CATEGORY_LIST_SINGER_NAME, subTitle);
intent1.putExtra(MyValue.KEY_CATEGORY_LIST_BROWSER_ID, browserId);
startActivity(intent1);
break;
case "MUSIC_PAGE_TYPE_ARTIST":
//粉丝可能还喜欢
Intent intent = new Intent(this, ResultListActivity.class);
intent.putExtra("key", browserId);
startActivity(intent);
finish();
break;
}
}
}
@Override

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="@color/black_view"
android:endColor="@color/black"
android:angle="270"/>
</shape>

View File

@ -1,22 +1,26 @@
<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="@color/black"
android:strokeLineCap="round"/>
<path
android:pathData="M6.429,2.57V21.57"
android:strokeWidth="5"
android:fillColor="#00000000"
android:strokeColor="@color/black"
android:strokeLineCap="round"/>
</group>
android:width="34dp"
android:height="34dp"
android:viewportWidth="34"
android:viewportHeight="34">
<path
android:pathData="M17,31.167C24.824,31.167 31.167,24.824 31.167,17C31.167,9.176 24.824,2.833 17,2.833C9.176,2.833 2.833,9.176 2.833,17C2.833,24.824 9.176,31.167 17,31.167Z"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="@color/black"
android:strokeColor="@color/black"/>
<path
android:pathData="M13.458,12.75V21.25"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="@color/white"
android:strokeLineCap="round"/>
<path
android:pathData="M20.542,12.75V21.25"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="@color/white"
android:strokeLineCap="round"/>
</vector>

View File

@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="39dp"
android:height="39dp"
android:width="49dp"
android:height="49dp"
android:viewportWidth="34"
android:viewportHeight="34">
<path

View File

@ -1,22 +0,0 @@
<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>

View File

@ -1,7 +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_play"/>
<item android:state_selected="false" android:drawable="@drawable/panel_icon_play"/>
<item android:state_selected="true" android:drawable="@drawable/panel_icon_pause"/>
</selector>

View File

@ -18,7 +18,7 @@
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginStart="16dp"
android:layout_marginTop="25dp"
android:layout_marginTop="35dp"
android:padding="9dp"
android:src="@drawable/arrow_bottom"
app:layout_constraintLeft_toLeftOf="parent"

View File

@ -1,51 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:background="@color/black"
tools:context=".ui.activity.ResultListActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/relayout_top"
android:layout_width="match_parent"
android:layout_height="280dp"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/covert"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/covert"
android:scaleType="centerCrop"/>
android:src="@mipmap/ic_launcher"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/im_back"
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_marginStart="16dp"
android:layout_marginTop="35dp"
android:padding="9dp"
android:src="@drawable/arrow_bottom" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:background="@drawable/black_gradient"/>
</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" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="200dp"
android:orientation="vertical">
<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" />
<TextView
android:id="@+id/main_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="@string/app_name"
android:textColor="@color/white"
android:textSize="17sp" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/main_title" />
</LinearLayout>
</RelativeLayout>
</androidx.core.widget.NestedScrollView>

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"
android:layout_marginTop="35dp"
android:orientation="vertical">
<LinearLayout

View File

@ -2,6 +2,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:paddingEnd="16dp"
android:layout_marginBottom="10dp"
android:layout_height="wrap_content">

View File

@ -13,7 +13,7 @@
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_centerVertical="true"
android:layout_marginStart="4dp"
android:layout_marginStart="2dp"
android:src="@drawable/placeholder" />
<LinearLayout
@ -60,7 +60,7 @@
android:layout_width="34dp"
android:layout_height="34dp"
android:layout_gravity="center"
android:src="@drawable/selector_panel_play" />
android:src="@drawable/selector_panel_icon_play" />
</FrameLayout>
<ImageView

View File

@ -5,7 +5,7 @@
<color name="color_transparent">#00000000</color>
<color name="text_color_1">#FFFFFF</color>
<color name="text_color_2">#DFD0D0</color>
<color name="black_view">#26000000</color>
<color name="seek_bg_color">#4DFFFFFF</color>
<color name="white_60_color">#99FFFFFF</color>
<color name="progress_buffer_color">#59FFFFFF</color>

View File

@ -3,7 +3,7 @@
<style name="Base.Theme.MusicApp" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your light theme here. -->
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
<item name="android:windowBackground">@color/black</item>
<item name="android:windowBackground">@color/white</item>
</style>
<style name="Theme.MusicApp" parent="Base.Theme.MusicApp" />