修改logo和占位图

This commit is contained in:
litingting 2024-11-11 15:40:01 +08:00
parent f58d8d8bf3
commit 3aac60e3ca
48 changed files with 277 additions and 201 deletions

View File

@ -18,7 +18,7 @@ android {
defaultConfig {
//com.hi.music.player
applicationId = "com.hi.music.player.test"
applicationId = "com.hi.music.player.test1"
minSdk = 23
targetSdk = 34
versionCode = 1
@ -70,7 +70,7 @@ dependencies {
implementation("io.reactivex.rxjava2:rxandroid:2.1.1")
implementation("com.squareup.okhttp3:logging-interceptor:4.11.0")
implementation("androidx.paging:paging-runtime-ktx:3.3.2")
// implementation("androidx.paging:paging-runtime-ktx:3.3.2")
implementation("com.github.bumptech.glide:glide:4.16.0")
// kapt("com.github.bumptech.glide:compiler:4.16.0")
@ -92,12 +92,6 @@ dependencies {
implementation ("androidx.media3:media3-database:1.4.1")
//----------media3
// implementation ("com.geyifeng.immersionbar:immersionbar:3.2.2")
// implementation ("com.geyifeng.immersionbar:immersionbar-components:3.2.2")
//------------------firebase
implementation(platform("com.google.firebase:firebase-bom:33.1.1"))
implementation("com.google.firebase:firebase-crashlytics")

View File

@ -9,7 +9,7 @@
"client_info": {
"mobilesdk_app_id": "1:550960818622:android:96fd4141e43410fb24f1ef",
"android_client_info": {
"package_name": "com.hi.music.player.test"
"package_name": "com.hi.music.player.test1"
}
},
"oauth_client": [],

View File

@ -17,9 +17,9 @@
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:icon="@mipmap/im_logo"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/im_logo"
android:supportsRtl="true"
android:theme="@style/Theme.MusicApp"
tools:targetApi="31">

View File

@ -5,11 +5,15 @@ import android.content.Context;
import androidx.annotation.OptIn;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.database.StandaloneDatabaseProvider;
import androidx.media3.datasource.cache.LeastRecentlyUsedCacheEvictor;
import androidx.media3.datasource.cache.SimpleCache;
import com.hi.music.player.api.MediaControllerStatusListener;
import com.hi.music.player.firebase.RemoteConfigJava;
import com.hi.music.player.firebase.Sp;
import com.hi.music.player.helper.CommonUtils;
import com.hi.music.player.media3.MyDownloadService;
import com.hi.music.player.media3.MyMediaControllerManager;
import com.hi.music.player.objectbox.ObjectBoxManager;
@ -38,6 +42,9 @@ public class MusicApplication extends Application {
Sp.init(this);
RemoteConfigJava.getInstance().init(this);
ObjectBoxManager.init(this);
StandaloneDatabaseProvider databaseProvider = new StandaloneDatabaseProvider(this);
MyDownloadService.init(this,databaseProvider);
MyMediaControllerManager.getInstance().init(new MediaControllerStatusListener() {
@Override
public void onMediaControllerComplete(boolean isOk) {

View File

@ -42,7 +42,7 @@ public class AdapterCategory extends BaseAdapter<ResponseCategory, ItemCategoryB
Glide.with(MusicApplication.myApplication)
.asDrawable()
.load(responseCategory.getCovert())
.placeholder(R.drawable.placeholder)
.placeholder(R.mipmap.im_placeholder)
.into(vb.header);
vb.tvTitle.setText(responseCategory.getTwoTitle());
vb.tvSubtitle.setText(responseCategory.getTwoSubtitle());

View File

@ -70,7 +70,7 @@ public class AdapterCategoryList extends BaseAdapter<ResponsePlayListInfo, ItemC
Glide.with(MusicApplication.myApplication)
.asDrawable()
.load(child.getSmallCovert())
.placeholder(R.drawable.placeholder)
.placeholder(R.mipmap.im_placeholder)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {

View File

@ -48,7 +48,7 @@ public class AdapterDownloadSong extends BaseAdapter<Download, ItemLikeSongBindi
.asDrawable()
.load(boxDownloadSong.getCovert())
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(4))))
.placeholder(R.drawable.placeholder)
.placeholder(R.mipmap.im_placeholder)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {

View File

@ -36,10 +36,10 @@ public class AdapterHome extends BaseAdapter<ResponseHomeChild, ItemHomeBinding>
ItemHomeBinding vb = itemHolder.getVb();
ResponseHomeChild responseHomeChild = data.get(position);
vb.headTitle.setText(responseHomeChild.getHeaderTitle());
CommonUtils.LogMsg("position="+position+"-----------headTitle-=" + responseHomeChild.getHeaderTitle());
List<ResponseSingle> singleList = responseHomeChild.getSingleList();
List<ResponseCategory> categoryList = responseHomeChild.getCategoryList();
CommonUtils.LogMsg("position="+position+"-----------headTitle-=" + responseHomeChild.getHeaderTitle()+"--singleList="+singleList+"---categoryList="+categoryList);
if (singleList != null && singleList.size() > 0) {
vb.recyclerSinger.setVisibility(View.VISIBLE);
AdapterSinger adapterSinger = new AdapterSinger();

View File

@ -182,7 +182,7 @@ public class AdapterLikeSong extends BaseAdapter<BoxLikeSong, ItemLikeSongBindin
.asDrawable()
.load(boxLikeSong.getCovert())
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(4))))
.placeholder(R.drawable.placeholder)
.placeholder(R.mipmap.im_placeholder)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {

View File

@ -84,7 +84,7 @@ public class AdapterPlayList extends BaseAdapter<ResponsePlayListInfo, ItemPlayL
.asDrawable()
// .apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(10))))
.load(covert)
.placeholder(R.drawable.placeholder)
.placeholder(R.mipmap.im_placeholder)
.into(vb.imCovert);
MediaItem currentMediaItem = instance.getCurMediaItem();

View File

@ -44,7 +44,7 @@ public class AdapterResultListAlbum extends BaseAdapter<ResponseResultListChild,
.asDrawable()
.load(listChild.getThumbnail())
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(4))))
.placeholder(R.drawable.placeholder)
.placeholder(R.mipmap.im_placeholder)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {

View File

@ -39,7 +39,7 @@ public class AdapterResultListSong extends BaseAdapter<ResponseResultListChild,
.asDrawable()
.load(listChild.getThumbnail())
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(4))))
.placeholder(R.drawable.placeholder)
.placeholder(R.mipmap.im_placeholder)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {

View File

@ -41,7 +41,7 @@ public class AdapterSearchChild extends BaseAdapter<ResponseSearchChild, ItemSea
.asDrawable()
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(13))))
.load(responseSearchChild.getSongCovert())
.placeholder(R.drawable.placeholder)
.placeholder(R.mipmap.im_placeholder)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {

View File

@ -41,7 +41,7 @@ public class AdapterSinger extends BaseAdapter<ResponseSingle, ItemSingerBinding
.asDrawable()
.load(responseSingle.getSingerHead())
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(4))))
.placeholder(R.drawable.placeholder)
.placeholder(R.mipmap.im_placeholder)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {

View File

@ -57,7 +57,7 @@ public class DialogPlayList extends BaseDialog<DialogPlayListBinding> {
.asDrawable()
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(10))))
.load(artworkUri)
.placeholder(R.drawable.placeholder)
.placeholder(R.mipmap.im_placeholder)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {

View File

@ -10,9 +10,9 @@ public class ContextBody {
private ThirdParty thirdParty = new ThirdParty();
public ThirdParty getThirdParty() {
return thirdParty;
}
// public ThirdParty getThirdParty() {
// return thirdParty;
// }
public Client getClient() {
return client;

View File

@ -41,6 +41,8 @@ public class MyDownloadService extends DownloadService {
private static DownloadManager mDownloadManager;
private static SimpleCache downloadCache;
public MyDownloadService() {
super(FOREGROUND_NOTIFICATION_ID,
DEFAULT_FOREGROUND_NOTIFICATION_UPDATE_INTERVAL,
@ -50,9 +52,13 @@ public class MyDownloadService extends DownloadService {
);
}
public static SimpleCache getDownloadCache() {
return downloadCache;
}
public static void init(Context context, StandaloneDatabaseProvider databaseProvider) {
if (mDownloadManager == null) {
SimpleCache downloadCache = MyDownloadCacheManager.getMyCache(databaseProvider);
downloadCache = MyDownloadCacheManager.getMyCache(databaseProvider);
DefaultHttpDataSource.Factory factory = new DefaultHttpDataSource.Factory();
Executor downloadExecutor = Runnable::run;
@ -83,7 +89,7 @@ public class MyDownloadService extends DownloadService {
if (download.state == Download.STATE_COMPLETED) {
// 下载完成
vmApplication.setDownloadChange(new Pair<>(true,download));
vmApplication.setDownloadChange(new Pair<>(true, download));
CommonUtils.LogMsg("----------------下载完成 id=" + id + "--thread=" + Thread.currentThread().getName());
updateDownloadUi(vmApplication);
@ -91,7 +97,7 @@ public class MyDownloadService extends DownloadService {
// 下载失败
CommonUtils.LogMsg("----------------下载失败 id=" + id + "---finalException=" + finalException.getMessage());
vmApplication.setDownloadChange(new Pair<>(false,download));
vmApplication.setDownloadChange(new Pair<>(false, download));
}

View File

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

View File

@ -25,7 +25,7 @@ public class MyPlayCacheManager {
long maxCacheSize = 100 * 1024 * 1024; // 缓存大小 100MB
StandaloneDatabaseProvider databaseProvider = new StandaloneDatabaseProvider(context);
playCache = new SimpleCache(cacheDir, new LeastRecentlyUsedCacheEvictor(maxCacheSize), databaseProvider);
MyDownloadService.init(context,databaseProvider);
// MyDownloadService.init(context,databaseProvider);
}
return playCache;
}

View File

@ -12,9 +12,11 @@ import androidx.media3.common.util.UnstableApi;
import androidx.media3.datasource.DataSource;
import androidx.media3.datasource.DataSpec;
import androidx.media3.datasource.DefaultDataSource;
import androidx.media3.datasource.DefaultHttpDataSource;
import androidx.media3.datasource.ResolvingDataSource;
import androidx.media3.datasource.TransferListener;
import androidx.media3.datasource.cache.CacheDataSource;
import androidx.media3.datasource.cache.SimpleCache;
import androidx.media3.exoplayer.DefaultLoadControl;
import androidx.media3.exoplayer.ExoPlayer;
@ -26,17 +28,21 @@ import androidx.media3.session.MediaSessionService;
import com.hi.music.player.helper.CommonUtils;
import java.io.IOException;
public class PlaybackService extends MediaSessionService {
private MediaSession mediaSession = null;
private ExoPlayer player;
private SimpleCache playCache, downloadCache;
@OptIn(markerClass = UnstableApi.class)
@Override
public void onCreate() {
super.onCreate();
DynamicMediaSourceFactory customMediaSourceFactory = new DynamicMediaSourceFactory(getCacheDataSourceFactory(this));
DefaultMediaSourceFactory defaultMediaSourceFactory1 = new DefaultMediaSourceFactory(getUrlFactory());
ProgressiveMediaSource.Factory factory = new ProgressiveMediaSource.Factory(getUrlFactory());
// 创建 DefaultLoadControl配置缓冲参数
@ -53,7 +59,7 @@ public class PlaybackService extends MediaSessionService {
CacheDataSource dataSource = cacheDataSourceFactory.createDataSource();
player = new ExoPlayer.Builder(this)
.setMediaSourceFactory(mediaSourceFactory)
.setMediaSourceFactory(factory)
.setLoadControl(loadControl)
.build();
mediaSession = new MediaSession.Builder(this, player)
@ -62,30 +68,81 @@ public class PlaybackService extends MediaSessionService {
}
// 创建带缓存的数据源工厂
// 创建带缓存的数据源工厂
@OptIn(markerClass = UnstableApi.class)
private CacheDataSource.Factory getCacheDataSourceFactory(Context context) {
private CacheDataSource.Factory getCacheDataSourceFactory(Context context) {
DefaultDataSource.Factory factory = new DefaultDataSource.Factory(this);
playCache = MyPlayCacheManager.getInitPlayCache(context);
CacheDataSource.Factory factory1 = new CacheDataSource.Factory().setCache(playCache)
.setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory()
.setConnectTimeoutMs(16000)
.setReadTimeoutMs(8000)
.setUserAgent("Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"))
.setEventListener(new CacheDataSource.EventListener() {
@Override
public void onCachedBytesRead(long cacheSizeBytes, long cachedBytesRead) {
CommonUtils.LogMsg("-----------缓存2 -PlayCache-" + cacheSizeBytes + "----cacheSizeBytes=" + cachedBytesRead);
}
@Override
public void onCacheIgnored(int reason) {
CommonUtils.LogMsg("-----------缓存2忽略 PlayCache=" + reason);
}
});
downloadCache = MyDownloadService.getDownloadCache();
return new CacheDataSource.Factory()
.setCache(MyPlayCacheManager.getInitPlayCache(context))
.setUpstreamDataSourceFactory(factory)
.setFlags(CacheDataSource.FLAG_BLOCK_ON_CACHE | CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR);
.setCache(downloadCache)
.setUpstreamDataSourceFactory(factory1)
.setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR)
.setEventListener(new CacheDataSource.EventListener() {
@Override
public void onCachedBytesRead(long cacheSizeBytes, long cachedBytesRead) {
CommonUtils.LogMsg("-----------缓存1 DownloadCache --" + cacheSizeBytes + "----cacheSizeBytes=" + cachedBytesRead);
}
@Override
public void onCacheIgnored(int reason) {
CommonUtils.LogMsg("-----------缓存1忽略DownloadCache =" + reason);
}
});
// .setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR);
}
@OptIn(markerClass = UnstableApi.class)
private DataSource.Factory getUrlFactory() {
CommonUtils.LogMsg("--------getUrlFactory");
long chunkLength = 512 * 1024L;
return new ResolvingDataSource.Factory(getCacheDataSourceFactory(this), new ResolvingDataSource.Resolver() {
@Override
public DataSpec resolveDataSpec(DataSpec dataSpec) {
public DataSpec resolveDataSpec(DataSpec dataSpec) {
CommonUtils.LogMsg("--------resolveDataSpec dataSpec.key=" + dataSpec.key+"---dataSpec.uri="+dataSpec.uri);
return dataSpec;
CommonUtils.LogMsg("--------resolveDataSpec=" + dataSpec.key);
// long length = 1L;
// String videoId = dataSpec.key;
// long position = dataSpec.position;
// if (dataSpec.length >= 0) {
// length = dataSpec.length;
// }
//
// if (downloadCache.isCached(videoId,position,length)){
// CommonUtils.LogMsg("--------resolveDataSpec downloadCache" );
// return dataSpec;
// }else if(playCache.isCached(videoId,position,chunkLength)){
// CommonUtils.LogMsg("--------resolveDataSpec playCache" );
// return dataSpec;
// }else {
// CommonUtils.LogMsg("--------resolveDataSpec uri" );
// return dataSpec;
// }
}
String string = "https://rr5---sn-ab5sznzy.googlevideo.com//videoplayback?expire=1730814877&ei=PM8pZ_37PL6b2_gP1LeTsQY&ip=146.19.167.8&id=o-AOdAohYUdM95I2jXmxqV5-JBeVgnMYAS3AKn2fsaiz72&itag=18&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&met=1730793277%2C&mh=Od&mm=31%2C29&mn=sn-ab5sznzy%2Csn-tt1e7nls&ms=au%2Crdu&mv=m&mvi=5&pl=24&rms=au%2Cau&gcr=us&initcwndbps=7066250&vprv=1&svpuc=1&xtags=heaudio%3Dtrue&mime=video%2Fmp4&rqh=1&cnr=14&ratebypass=yes&dur=181.394&lmt=1711913129189608&mt=1730792707&fvip=2&fexp=51312688%2C51326932&c=ANDROID&txp=4538434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cgcr%2Cvprv%2Csvpuc%2Cxtags%2Cmime%2Crqh%2Ccnr%2Cratebypass%2Cdur%2Clmt&sig=AJfQdSswRgIhAMmdioipTMb9rGt1ZIzbhTPL0yWZGnuorRv7jOS9THllAiEAnkSJJhOkXt3SdMYmeNuRMEosaJl2H00SQxORzbbGRP4%3D&lsparams=met%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Crms%2Cinitcwndbps&lsig=ACJ0pHgwRQIhANId6hdBj5z2g7IWnbCdzQ6MyYO_wit31Zaxh3VWahe7AiAIlubSJiPZP4deLNaBQ8eyT12Zf7nPkJ_ZZYBHeFf9XA%3D%3D";
return dataSpec.withUri(Uri.parse(dataSpec.key));
@Override
public Uri resolveReportedUri(Uri uri) {
CommonUtils.LogMsg("--------resolveDataSpec uri=" + uri);
return ResolvingDataSource.Resolver.super.resolveReportedUri(Uri.parse("---"));
}
});
}

View File

@ -79,7 +79,7 @@ public class JsonHelper {
getCommonHome(sectionListContinuation, responseHome);
} catch (JSONException exception) {
CommonUtils.LogMsg("----------exception="+exception.getMessage());
CommonUtils.LogMsg("----------exception=" + exception.getMessage());
exception.printStackTrace();
}
@ -120,7 +120,7 @@ public class JsonHelper {
long ms = CommonUtils.convertToMilliseconds(SongDuration);
String textTime = CommonUtils.convertMillisToTime(ms);
CommonUtils.LogMsg("----------SongDuration=" + SongDuration + "---ms="+ms+"---textTime="+textTime);
CommonUtils.LogMsg("----------SongDuration=" + SongDuration + "---ms=" + ms + "---textTime=" + textTime);
String[] watchEndPoint = getWatchEndPoint(playlistPanelVideoRenderer);
@ -519,9 +519,9 @@ public class JsonHelper {
if (list.size() > 0) {
responseSearch.setList(list);
}
if(musicCardShelfRenderer!= null){
if (musicCardShelfRenderer != null) {
searchList.add(responseSearch);
}else if(list.size() > 0){
} else if (list.size() > 0) {
searchList.add(responseSearch);
}
@ -708,7 +708,7 @@ public class JsonHelper {
.getJSONObject("text");
String text = getJsonTitle(jsonObjectText, 0);
CommonUtils.LogMsg("---------g=" + g + "---text="+text);
CommonUtils.LogMsg("---------g=" + g + "---text=" + text);
if (g == 0) {
SongTitle = text;
@ -726,7 +726,7 @@ public class JsonHelper {
listInfo.setMusicVideoType(watchEndPoint[3]);
}
if (g == 1){
if (g == 1) {
SingerName = text;
}
if (g == 2) {
@ -768,7 +768,7 @@ public class JsonHelper {
//模块标题
String title = getJsonTitle(musicCarouselShelfRenderer.getJSONObject("header").getJSONObject("musicCarouselShelfBasicHeaderRenderer").getJSONObject("title"), 0);
CommonUtils.LogMsg("----------模块标题=" + title);
responseHomeChild.setHeaderTitle(title);
JSONArray childContents = musicCarouselShelfRenderer.getJSONArray("contents");
@ -900,8 +900,10 @@ public class JsonHelper {
}
responseHomeChild.setCategoryList(categoryList);
responseHomeChild.setSingleList(singleList);
childList.add(responseHomeChild);
}
childList.add(responseHomeChild);
}
responseHome.setChildList(childList);

View File

@ -43,11 +43,6 @@ public class RetrofitManager {
musicApi = getRetrofit().create(MusicApi.class);
}
// public <T> T getService(Class<T> cls){
// return getRetrofit().create(cls);
// }
private synchronized Retrofit getRetrofit() {
if (retrofit == null) {
long DEFAULT_TIMEOUT = 5;
@ -141,7 +136,7 @@ public class RetrofitManager {
String visitorData = MusicApplication.getVisitorData();
// client.setVisitorData("CgtWN1RXaURPN3LNZyiZK9e4BjIKCgJVUXIEGgAgPW%3D%3D");
client.setVisitorData(visitorData);
bodyPlay.getContext().getThirdParty().setEmbedUrl("https://www.youtube.com/watch?v="+videoId);
// bodyPlay.getContext().getThirdParty().setEmbedUrl("https://www.youtube.com/watch?v="+videoId);
Gson gson = new Gson();

View File

@ -167,6 +167,7 @@ public abstract class BaseActivity<T extends ViewBinding> extends AppCompatActiv
CommonUtils.LogMsg("----------artworkUri="+artworkUri.toString());
Glide.with(MusicApplication.myApplication)
.load(artworkUri.toString())
.placeholder(R.mipmap.im_placeholder)
.transform(new CircleCrop())
.into(panelVb.image);
}

View File

@ -208,7 +208,7 @@ public class CategoryListActivity extends BaseActivity<ActivityCategoryListBindi
.asDrawable()
// .apply(bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(10))))
.load(url)
.placeholder(R.drawable.placeholder)
.placeholder(R.mipmap.im_placeholder)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {

View File

@ -461,7 +461,7 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
Glide.with(MusicApplication.myApplication)
.asDrawable()
.load(url)
.placeholder(R.drawable.placeholder)
.placeholder(R.mipmap.im_placeholder)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {
@ -758,7 +758,7 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
.asDrawable()
// .apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(10))))
.load(artworkUri)
.placeholder(R.drawable.placeholder)
.placeholder(R.mipmap.im_placeholder)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {

View File

@ -64,7 +64,7 @@ public class ResultListActivity extends BaseActivity<ActivityResultListBinding>
.asDrawable()
.load(result.getMainCovert())
.apply(RequestOptions.bitmapTransform(new RoundedCorners(CommonUtils.dpToPx(4))))
.placeholder(R.drawable.placeholder)
.placeholder(R.mipmap.im_placeholder)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {

View File

@ -3,6 +3,7 @@ package com.hi.music.player.ui.fragmnt;
import android.content.Intent;
import android.content.RestrictionsManager;
import android.graphics.drawable.Drawable;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -71,7 +72,13 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> implements H
vmHome = getFragmentScopeViewModel(VMHome.class);
adapterHome.addLoadingFooter();
vmHome.getHome();
Vb.tvRetry.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
adapterHome.addLoadingFooter();
vmHome.getHome();
}
});
vmHome.data.observe(getViewLifecycleOwner(), new Observer<ResponseHome>() {
@Override
@ -79,27 +86,15 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> implements H
if (responseHome == null) {
adapterHome.removeLoadingFooter();
requestCount--;
if(requestCount == 0){
Vb.layoutError.setVisibility(View.VISIBLE);
Vb.recyclerSongOfTheDay.setVisibility(View.GONE);
}
return;
}
Vb.layoutError.setVisibility(View.GONE);
Vb.recyclerSongOfTheDay.setVisibility(View.VISIBLE);
Glide.with(requireContext())
.asDrawable()
.load(responseHome.getBackgroundUrl())
.placeholder(R.drawable.placeholder)
.error(R.drawable.placeholder)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(@NonNull Drawable resource, @NonNull Object model, Target<Drawable> target, @NonNull DataSource dataSource, boolean isFirstResource) {
// Vb.linearLayout.setBackground(resource);
return false;
}
})
.preload();
List<ResponseHomeChild> childList1 = responseHome.getChildList();
if (childList1 == null) return;
childList.addAll(childList1);
@ -159,13 +154,6 @@ public class HomeFragment extends BaseFragment<FragmentHomeBinding> implements H
intent.putExtra(MyValue.KEY_ENTER_SOURCE, MyValue.TYPE_ENTER_SOURCE_MV);
startActivity(intent);
}
// else if (pageType.equals(MyValue.PAGE_TYPE_ALBUM)) {
// Intent intent = new Intent(activity, CategoryListActivity.class);
// intent.putExtra(MyValue.KEY_CATEGORY_LIST_TYPE, pageType);
// intent.putExtra(MyValue.KEY_CATEGORY_LIST_SINGER_NAME, twoSubtitle);
// intent.putExtra(MyValue.KEY_CATEGORY_LIST_BROWSER_ID, browseId);
// startActivity(intent);
// }
else {
Intent intent = new Intent(activity, CategoryListActivity.class);
intent.putExtra(MyValue.KEY_CATEGORY_LIST_TYPE, pageType);

View File

@ -64,8 +64,8 @@ public class ProfileFragment extends BaseFragment<FragmentProfileBinding> implem
Glide.with(requireContext())
.asDrawable()
.load(boxLikeSong.getCovert())
.placeholder(R.drawable.placeholder)
.error(R.drawable.placeholder)
.placeholder(R.mipmap.im_placeholder)
.error(R.mipmap.im_placeholder)
.into(Vb.likeCovert);
}
}
@ -87,8 +87,8 @@ public class ProfileFragment extends BaseFragment<FragmentProfileBinding> implem
Glide.with(requireContext())
.asDrawable()
.load(boxDownloadSong.getCovert())
.placeholder(R.drawable.placeholder)
.error(R.drawable.placeholder)
.placeholder(R.mipmap.im_placeholder)
.error(R.mipmap.im_placeholder)
.into(Vb.downloadCovert);
} else {
Vb.downloadCovert.setVisibility(View.GONE);

View File

@ -107,16 +107,22 @@ public class SearchFragment extends BaseFragment<FragmentSearchBinding> implemen
vmSearch.result.observe(getViewLifecycleOwner(), new Observer<List<ResponseSearch>>() {
@Override
public void onChanged(List<ResponseSearch> responseSearches) {
Vb.pbloading.setVisibility(View.GONE);
if(responseSearches == null){
Vb.recyclerResult.setVisibility(View.GONE);
Vb.layoutError.setVisibility(View.VISIBLE);
CommonUtils.LogMsg("------------更新结果 null");
return;
}
Vb.recyclerResult.setVisibility(View.VISIBLE);
Vb.layoutError.setVisibility(View.GONE);
adapterSearch.setData(responseSearches);
}
});
}
private void startQuery(String query){
Vb.pbloading.setVisibility(View.VISIBLE);
Vb.recyclerSuggestion.setVisibility(View.GONE);
Vb.recyclerResult.setVisibility(View.VISIBLE);
vmSearch.getSearchResult(query);

View File

@ -1,61 +0,0 @@
package com.hi.music.player.ui.paging;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.paging.PagingSource;
import androidx.paging.PagingState;
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.network.JsonHelper;
import com.hi.music.player.network.RetrofitManager;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.Single;
import kotlin.coroutines.Continuation;
import okhttp3.ResponseBody;
public class MyPagingSource extends PagingSource<Integer, ResponseHome> {
@Nullable
@Override
public Integer getRefreshKey(@NonNull PagingState<Integer, ResponseHome> pagingState) {
return null;
}
@Nullable
@Override
public Object load(@NonNull LoadParams<Integer> loadParams, @NonNull Continuation<? super PagingSource.LoadResult<Integer, ResponseHome>> continuation) {
int nextPage = 1;
Integer key = loadParams.getKey();
if (key != null) {
nextPage = key + 1;
}
// try {
// // 使用 Single 来处理异步请求
//
// List<ResponseHome> result = Single.<List<ResponseHome>>create(emitter -> {
// RetrofitManager.getInstance().getHomeData();
// })
// .blockingGet(); // 阻塞获取结果
//
// return new LoadResult.Page<>(
// result,
// page == 1 ? null : page - 1,
// result.isEmpty() ? null : page + 1
// );
// } catch (Exception e) {
// return new LoadResult.Error<>(e);
// }
//
return null;
}
}

View File

@ -60,7 +60,7 @@
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center"
android:src="@mipmap/default_image" />
android:src="@mipmap/im_placeholder" />
</FrameLayout>
<!-- 中间的两排 TextView -->

View File

@ -42,6 +42,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/card_im"
app:cardBackgroundColor="@color/color_transparent"
android:layout_centerHorizontal="true"
app:cardCornerRadius="10dp"
app:cardElevation="0dp">

View File

@ -24,7 +24,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/placeholder" />
android:src="@mipmap/im_placeholder" />
<ImageView
android:id="@+id/im_back"

View File

@ -36,7 +36,7 @@
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:src="@drawable/placeholder" />
android:src="@mipmap/im_placeholder" />
</androidx.cardview.widget.CardView>
<LinearLayout

View File

@ -1,21 +1,21 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/linearLayout"
android:background="@color/color_transparent"
android:orientation="vertical"
tools:context=".ui.fragmnt.HomeFragment">
<TextView
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textSize="22sp"
android:padding="15dp"
android:textColor="@color/white"/>
<TextView
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dp"
android:text="@string/app_name"
android:textColor="@color/white"
android:textSize="22sp" />
<androidx.recyclerview.widget.RecyclerView
@ -25,4 +25,42 @@
android:paddingStart="6dp" />
<RelativeLayout
android:id="@+id/layout_error"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="match_parent">
<TextView
android:id="@+id/tv_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="200dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:gravity="center"
android:text="@string/net_error"
android:textColor="@color/white"
android:textSize="16sp" />
<TextView
android:id="@+id/tv_retry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tv_error"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:background="@drawable/bg_retry_btn"
android:paddingStart="15dp"
android:paddingTop="8dp"
android:paddingEnd="15dp"
android:paddingBottom="8dp"
android:text="@string/retry"
android:textColor="@color/white"
android:textSize="17sp" />
</RelativeLayout>
</LinearLayout>

View File

@ -7,29 +7,29 @@
tools:context=".ui.fragmnt.SearchFragment">
<RelativeLayout
android:id="@+id/layout_et"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="22dp"
android:layout_marginEnd="22dp"
android:layout_marginTop="16dp"
android:id="@+id/layout_et"
android:background="@drawable/bg_search" >
android:layout_marginEnd="22dp"
android:background="@drawable/bg_search">
<EditText
android:id="@+id/et_search"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null"
android:layout_toStartOf="@id/im_cancel"
android:textColorHint="@color/seek_bg_color"
android:paddingStart="20dp"
android:background="@null"
android:focusable="true"
android:focusableInTouchMode="true"
android:id="@+id/et_search"
android:textColor="@color/white"
android:maxLines="1"
android:inputType="text"
android:hint="@string/search_hint"
android:imeOptions="actionSearch"
android:hint="@string/search_hint"/>
android:inputType="text"
android:maxLines="1"
android:paddingStart="20dp"
android:textColor="@color/white"
android:textColorHint="@color/seek_bg_color" />
<ImageView
android:id="@+id/im_cancel"
@ -38,26 +38,57 @@
android:layout_alignParentEnd="true"
android:paddingStart="13dp"
android:paddingEnd="13dp"
android:src="@drawable/icon_cancel"/>
android:src="@drawable/icon_cancel" />
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_suggestion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/layout_et"
android:layout_alignStart="@id/layout_et"
android:layout_alignEnd="@id/layout_et"
android:id="@+id/recycler_suggestion"/>
android:layout_alignEnd="@id/layout_et" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/layout_et"
android:layout_alignStart="@id/layout_et"
android:layout_alignEnd="@id/layout_et"
android:visibility="gone"
android:id="@+id/recycler_result"/>
android:visibility="gone" />
<RelativeLayout
android:id="@+id/layout_error"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/layout_et"
android:visibility="gone">
<TextView
android:id="@+id/tv_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginStart="15dp"
android:layout_marginTop="200dp"
android:layout_marginEnd="15dp"
android:gravity="center"
android:text="@string/no_result"
android:textColor="@color/white"
android:textSize="16sp" />
</RelativeLayout>
<ProgressBar
android:id="@+id/pbloading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/layout_et"
android:layout_centerHorizontal="true"
android:layout_marginTop="200dp"
android:visibility="gone"
android:indeterminateTint="@color/white" />
</RelativeLayout>

View File

@ -16,7 +16,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@mipmap/default_image" />
android:src="@mipmap/im_placeholder" />
<LinearLayout
android:id="@+id/overlay"

View File

@ -17,7 +17,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@mipmap/default_image" />
android:src="@mipmap/im_placeholder" />
</androidx.cardview.widget.CardView>

View File

@ -20,7 +20,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@mipmap/default_image" />
android:src="@mipmap/im_placeholder" />
</androidx.cardview.widget.CardView>

View File

@ -22,7 +22,7 @@
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:background="@color/black"
android:src="@mipmap/default_image" />
android:src="@mipmap/im_placeholder" />
</androidx.cardview.widget.CardView>

View File

@ -6,7 +6,7 @@
<TextView
android:id="@+id/head_title"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:textColor="@color/text_color_1"

View File

@ -19,7 +19,7 @@
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:src="@drawable/placeholder" />
android:src="@mipmap/im_placeholder" />
</androidx.cardview.widget.CardView>

View File

@ -11,7 +11,7 @@
android:id="@+id/header"
android:layout_width="170dp"
android:layout_height="170dp"
android:src="@drawable/placeholder" />
android:src="@mipmap/im_placeholder" />
<TextView
android:id="@+id/tv_title"

View File

@ -13,7 +13,7 @@
android:scaleType="fitXY"
android:layout_marginStart="14dp"
android:layout_centerVertical="true"
android:src="@drawable/placeholder" />
android:src="@mipmap/im_placeholder" />
<LinearLayout
android:layout_width="wrap_content"

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layout_panel"
android:layout_width="match_parent"
android:layout_height="74dp"
@ -8,22 +9,30 @@
android:paddingStart="14dp"
android:paddingEnd="14dp">
<ImageView
android:id="@+id/image"
android:layout_width="52dp"
android:layout_height="52dp"
<androidx.cardview.widget.CardView
android:id="@+id/cardimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="2dp"
android:src="@mipmap/ic_launcher" />
app:cardCornerRadius="200dp"
app:cardElevation="0dp">
<ImageView
android:id="@+id/image"
android:layout_width="52dp"
android:layout_height="52dp"
android:src="@mipmap/im_placeholder" />
</androidx.cardview.widget.CardView>
<com.hi.music.player.helper.CircularProgressBar
android:id="@+id/circular_pb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/image"
android:layout_alignBottom="@id/image"
android:layout_alignStart="@id/image"
android:layout_alignEnd="@id/image"
android:layout_alignStart="@id/cardimage"
android:layout_alignTop="@id/cardimage"
android:layout_alignEnd="@id/cardimage"
android:layout_alignBottom="@id/cardimage"
android:layout_gravity="center" />
<LinearLayout
@ -50,9 +59,9 @@
android:id="@+id/singer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/app_name"
android:textColor="@color/panel_singer_color"
android:textSize="12sp" />
</LinearLayout>
@ -84,7 +93,7 @@
android:layout_marginEnd="10dp"
android:paddingStart="5dp"
android:paddingEnd="5dp"
android:visibility="visible"
android:src="@drawable/icon_next_black" />
android:src="@drawable/icon_next_black"
android:visibility="visible" />
</RelativeLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 KiB

View File

@ -39,4 +39,6 @@
<string name="text_like_song">Favorite Songs</string>
<string name="text_offline_song">Offline Songs</string>
<string name="text_has_downloaded">It\'s already downloaded</string>
<string name="net_error">An error occurred in the network request. Please try again.</string>
<string name="no_result">No results yet</string>
</resources>