接入max插页和原生广告
This commit is contained in:
parent
872a535cc0
commit
1b27a928b9
@ -3,13 +3,17 @@ import java.text.SimpleDateFormat
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
// id("org.jetbrains.kotlin.android")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
// id ("kotlin-kapt")
|
||||
id("io.objectbox")
|
||||
id("com.google.gms.google-services")
|
||||
id("com.google.firebase.crashlytics")
|
||||
}
|
||||
|
||||
id("applovin-quality-service")
|
||||
}
|
||||
applovin {
|
||||
apiKey = "4CFHxOfvQvy95EqDxa_eNPe4pmq_KfoZPJeVscTMt2uT3VL2fO3iyZyBFMTOOTRbKw6WelbaDEhNzxOxVrlQTE"
|
||||
}
|
||||
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||
|
||||
android {
|
||||
@ -17,7 +21,7 @@ android {
|
||||
compileSdk = 34
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.offline.music.playermp3.test"
|
||||
applicationId = "com.offline.music.playermp3"
|
||||
minSdk = 23
|
||||
targetSdk = 34
|
||||
versionCode = 1
|
||||
@ -40,9 +44,9 @@ android {
|
||||
)
|
||||
}
|
||||
}
|
||||
// kotlinOptions{
|
||||
// jvmTarget = "1.8"
|
||||
// }
|
||||
kotlinOptions{
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
@ -98,4 +102,27 @@ dependencies {
|
||||
implementation("com.google.firebase:firebase-crashlytics")
|
||||
implementation("com.google.firebase:firebase-analytics")
|
||||
implementation("com.google.firebase:firebase-config")
|
||||
|
||||
|
||||
//-----------------------applovin
|
||||
implementation("com.applovin:applovin-sdk:+")
|
||||
implementation("com.applovin.mediation:bigoads-adapter:+")
|
||||
implementation("com.applovin.mediation:chartboost-adapter:+")
|
||||
implementation("com.google.android.gms:play-services-base:16.1.0")
|
||||
implementation("com.applovin.mediation:fyber-adapter:+")
|
||||
// implementation("com.applovin.mediation:google-ad-manager-adapter:+")
|
||||
// implementation("com.applovin.mediation:google-adapter:+")
|
||||
implementation("com.applovin.mediation:inmobi-adapter:+")
|
||||
implementation("com.squareup.picasso:picasso:2.71828")
|
||||
implementation("androidx.recyclerview:recyclerview:1.1.0")
|
||||
implementation("com.applovin.mediation:ironsource-adapter:+")
|
||||
implementation("com.applovin.mediation:vungle-adapter:+")
|
||||
implementation("com.applovin.mediation:facebook-adapter:+")
|
||||
implementation("com.applovin.mediation:moloco-adapter:+")
|
||||
implementation("com.applovin.mediation:bytedance-adapter:+")
|
||||
implementation("com.applovin.mediation:unityads-adapter:+")
|
||||
|
||||
|
||||
//applovin The SDK collects the Google Advertising ID. This requires the Android Advertising ID (AAID) module (com.google.android.gms:play-services-ads-identifier).
|
||||
implementation("com.google.android.gms:play-services-ads-identifier:18.1.0")
|
||||
}
|
||||
@ -1,21 +1,21 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "550960818622",
|
||||
"project_id": "himelody-and",
|
||||
"storage_bucket": "himelody-and.appspot.com"
|
||||
"project_number": "764712897094",
|
||||
"project_id": "offline-music-player-176ab",
|
||||
"storage_bucket": "offline-music-player-176ab.firebasestorage.app"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:550960818622:android:96fd4141e43410fb24f1ef",
|
||||
"mobilesdk_app_id": "1:764712897094:android:2d533528b5ff4271a45847",
|
||||
"android_client_info": {
|
||||
"package_name": "com.offline.music.playermp3.test"
|
||||
"package_name": "com.offline.music.playermp3"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyCp3XR60onMqiGj9pD8ADmrDEOOn__sQDk"
|
||||
"current_key": "AIzaSyDohnv8AScCd1A7RTR-6LLLtQcE7EuJmIw"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
|
||||
@ -2,11 +2,17 @@ package com.offline.music.playermp3;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.annotation.OptIn;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.media3.database.StandaloneDatabaseProvider;
|
||||
|
||||
import com.applovin.sdk.AppLovinMediationProvider;
|
||||
import com.applovin.sdk.AppLovinSdk;
|
||||
import com.applovin.sdk.AppLovinSdkConfiguration;
|
||||
import com.applovin.sdk.AppLovinSdkInitializationConfiguration;
|
||||
import com.offline.music.playermp3.api.MediaControllerStatusListener;
|
||||
import com.offline.music.playermp3.firebase.RemoteConfigJava;
|
||||
import com.offline.music.playermp3.firebase.Sp;
|
||||
@ -21,7 +27,10 @@ public class MusicApplication extends Application {
|
||||
|
||||
public static String visitorData;
|
||||
|
||||
private String MAx_SDK_key = "tAh5Z8CtFiG05NfRWh9UuOHCp3h3SaFvlh6Phw5ucaxFMCRs2d97F7lywfBKOEKSipdaGq8vZOaDLZkrL1fDDc";
|
||||
|
||||
public static boolean initSDkOK = false;
|
||||
public static String initAction = "MUSIC_ACTION_INIT";
|
||||
|
||||
|
||||
public static void setVisitorData(String visitorData) {
|
||||
@ -37,6 +46,7 @@ public class MusicApplication extends Application {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
myApplication = this;
|
||||
InitializeMax();
|
||||
Sp.init(this);
|
||||
RemoteConfigJava.getInstance().init(this);
|
||||
ObjectBoxManager.init(this);
|
||||
@ -49,6 +59,24 @@ public class MusicApplication extends Application {
|
||||
CommonUtils.LogMsg("=-----mediaController+" + isOk);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void InitializeMax(){
|
||||
AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder( MAx_SDK_key, this )
|
||||
.setMediationProvider( AppLovinMediationProvider.MAX )
|
||||
.build();
|
||||
|
||||
// Initialize the SDK with the configuration
|
||||
AppLovinSdk.getInstance( this ).initialize( initConfig, new AppLovinSdk.SdkInitializationListener()
|
||||
{
|
||||
@Override
|
||||
public void onSdkInitialized(final AppLovinSdkConfiguration sdkConfig)
|
||||
{
|
||||
initSDkOK = true;
|
||||
LocalBroadcastManager.getInstance(MusicApplication.this).sendBroadcast(new Intent(initAction));
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ public class AdapterHome extends BaseAdapter<ResponseHomeChild, ItemHomeBinding>
|
||||
|
||||
List<ResponseSingle> singleList = responseHomeChild.getSingleList();
|
||||
List<ResponseCategory> categoryList = responseHomeChild.getCategoryList();
|
||||
CommonUtils.LogMsg("position="+position+"-----------headTitle-=" + responseHomeChild.getHeaderTitle()+"--singleList="+singleList+"---categoryList="+categoryList);
|
||||
// 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();
|
||||
|
||||
@ -92,7 +92,7 @@ public class AdapterLikeSong extends BaseAdapter<BoxLikeSong, ItemLikeSongBindin
|
||||
vb.imDownload.setSelected(pair.first);
|
||||
vb.imDownload.setVisibility(View.VISIBLE);
|
||||
vb.downloadPb.setVisibility(View.GONE);
|
||||
CommonUtils.LogMsg("--------------------状态更新");
|
||||
// CommonUtils.LogMsg("--------------------状态更新");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -76,6 +76,6 @@ public class AdapterResultListAlbum extends BaseAdapter<ResponseResultListChild,
|
||||
}
|
||||
}
|
||||
});
|
||||
CommonUtils.LogMsg("-------Album getBrowserId="+listChild.getBrowserId()+"---getPlayListId= "+listChild.getPlayListId()+"---getVideoId="+listChild.getVideoId());
|
||||
// CommonUtils.LogMsg("-------Album getBrowserId="+listChild.getBrowserId()+"---getPlayListId= "+listChild.getPlayListId()+"---getVideoId="+listChild.getVideoId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ public class AdapterResultListSong extends BaseAdapter<ResponseResultListChild,
|
||||
}
|
||||
});
|
||||
|
||||
CommonUtils.LogMsg("-------Song getBrowserId=" + listChild.getBrowserId() + "---getPlayListId= " + listChild.getPlayListId() + "---getVideoId=" + listChild.getVideoId());
|
||||
// CommonUtils.LogMsg("-------Song getBrowserId=" + listChild.getBrowserId() + "---getPlayListId= " + listChild.getPlayListId() + "---getVideoId=" + listChild.getVideoId());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ public class RemoteConfigJava {
|
||||
mFirebaseRemoteConfig.addOnConfigUpdateListener(new ConfigUpdateListener() {
|
||||
@Override
|
||||
public void onUpdate(@NonNull ConfigUpdate configUpdate) {
|
||||
CommonUtils.LogMsg("Updated keys: " + configUpdate.getUpdatedKeys());
|
||||
CommonUtils.LogMsg("---FirebaseRemote---Updated keys: " + configUpdate.getUpdatedKeys());
|
||||
try {
|
||||
mFirebaseRemoteConfig.activate().addOnCompleteListener(new OnCompleteListener<Boolean>() {
|
||||
@Override
|
||||
@ -113,13 +113,13 @@ public class RemoteConfigJava {
|
||||
}
|
||||
});
|
||||
} catch (Exception ignore) {
|
||||
CommonUtils.LogErrorMsg("onConfigUpdate Exception " + ignore.getMessage());
|
||||
CommonUtils.LogMsg("---FirebaseRemote---onConfigUpdate Exception " + ignore.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull FirebaseRemoteConfigException error) {
|
||||
CommonUtils.LogErrorMsg("onConfigUpdate onError " + error.getMessage());
|
||||
CommonUtils.LogMsg("---FirebaseRemote---onConfigUpdate onError " + error.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -147,7 +147,7 @@ public class RemoteConfigJava {
|
||||
}
|
||||
});
|
||||
} catch (Exception exception) {
|
||||
CommonUtils.LogErrorMsg(" exception = " + exception.getMessage());
|
||||
CommonUtils.LogMsg("---FirebaseRemote--- exception = " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ public class RemoteConfigJava {
|
||||
for (Map.Entry<String, FirebaseRemoteConfigValue> entry : all.entrySet()) {
|
||||
FirebaseRemoteConfigValue value = entry.getValue();
|
||||
String key = entry.getKey();
|
||||
CommonUtils.LogMsg("from = " + from + "Key = " + key + " Value = " + value.asString());
|
||||
CommonUtils.LogMsg("---FirebaseRemote---from = " + from + "Key = " + key + " Value = " + value.asString());
|
||||
|
||||
if (TextUtils.equals(key_open_type, key)) {
|
||||
Sp.getInstance()
|
||||
|
||||
@ -39,6 +39,6 @@ public class Sp {
|
||||
}
|
||||
|
||||
public String getStringValue(String key) {
|
||||
return preferences.getString(key, RemoteConfigJava.value_open_type_1);
|
||||
return preferences.getString(key, RemoteConfigJava.value_open_type_0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,9 +150,9 @@ public class CommonUtils {
|
||||
int dominantDarkColor = darkVibrantSwatch.getRgb();
|
||||
listener.onImageColor(dominantDarkColor);
|
||||
String dominantColorHex = String.format("#%06X", (0xFFFFFF & dominantDarkColor));
|
||||
Log.d("Dominant Dark Color", "主色调: " + dominantColorHex); // 打印主色调
|
||||
|
||||
} else {
|
||||
Log.d("Dominant Dark Color", "未找到深色主色调");
|
||||
|
||||
listener.onImageColor(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
package com.offline.music.playermp3.max;
|
||||
|
||||
import com.applovin.mediation.MaxAd;
|
||||
|
||||
public interface MaxListener {
|
||||
void onFail(MaxAd ad);
|
||||
|
||||
void onShowSuccess(MaxAd ad);
|
||||
|
||||
void onHidden();
|
||||
}
|
||||
@ -0,0 +1,219 @@
|
||||
package com.offline.music.playermp3.max;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.applovin.mediation.MaxAd;
|
||||
import com.applovin.mediation.MaxAdListener;
|
||||
import com.applovin.mediation.MaxError;
|
||||
import com.applovin.mediation.ads.MaxInterstitialAd;
|
||||
import com.applovin.mediation.nativeAds.MaxNativeAdListener;
|
||||
import com.applovin.mediation.nativeAds.MaxNativeAdLoader;
|
||||
import com.applovin.mediation.nativeAds.MaxNativeAdView;
|
||||
import com.offline.music.playermp3.MusicApplication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MaxManager {
|
||||
|
||||
|
||||
|
||||
public static final String AD_TAG = "------MAX---------";
|
||||
|
||||
|
||||
/**
|
||||
* 原生广告
|
||||
*/
|
||||
//small
|
||||
public static final String native_Ad1 = "318a8ed92bb2596d";
|
||||
//small
|
||||
public static final String native_Ad2 = "63e3d50c36c627d2";
|
||||
/**
|
||||
* 插页广告
|
||||
*/
|
||||
private static final String one_AD = "6510769676690c4d";
|
||||
private static final String two_Ad = "7c6b55091a9aaf39";
|
||||
private static final String three_ad = "39c6f571b5939dde";
|
||||
|
||||
|
||||
public static final int type_no_cache = 0;
|
||||
public static final int type_has_cache = 1;
|
||||
public static final int type_show_success = 2;
|
||||
public static final int type_show_close = 3;
|
||||
public static final int type_show_fail = 4;
|
||||
|
||||
private static List<MaxInterstitialAd> adList = new ArrayList<>();
|
||||
|
||||
public static MaxInterstitialAd getAd(List<MaxInterstitialAd> list) {
|
||||
Collections.shuffle(list);
|
||||
for (MaxInterstitialAd ad : list) {
|
||||
if (ad.isReady()) {
|
||||
return ad;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void onLoadNativeAd(ViewGroup nativeAdContainer, String adPlace,NativeMaxListener listener) {
|
||||
MaxNativeAdLoader nativeAdLoader;
|
||||
|
||||
nativeAdLoader = new MaxNativeAdLoader(adPlace, MusicApplication.myApplication);
|
||||
nativeAdLoader.setNativeAdListener(new MaxNativeAdListener() {
|
||||
MaxAd nativeAd;
|
||||
@Override
|
||||
public void onNativeAdLoaded(@Nullable MaxNativeAdView maxNativeAdView, @NonNull MaxAd maxAd) {
|
||||
// Clean up any pre-existing native ad to prevent memory leaks.
|
||||
if (nativeAd != null) {
|
||||
nativeAdLoader.destroy(nativeAd);
|
||||
}
|
||||
|
||||
// Save ad for cleanup.
|
||||
nativeAd = maxAd;
|
||||
|
||||
// Add ad view to view.
|
||||
nativeAdContainer.removeAllViews();
|
||||
nativeAdContainer.addView(maxNativeAdView);
|
||||
nativeAdContainer.setVisibility(View.VISIBLE);
|
||||
listener.onLoaded(maxAd,nativeAdLoader);
|
||||
Log.d(AD_TAG, "-------onNativeAdLoaded-----maxAd=" + maxAd.getAdUnitId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNativeAdLoadFailed(@NonNull String s, @NonNull MaxError maxError) {
|
||||
super.onNativeAdLoadFailed(s, maxError);
|
||||
Log.d(AD_TAG, "-------onNativeAdLoadFailed-----maxAd=" + maxError.getMessage());
|
||||
}
|
||||
});
|
||||
nativeAdLoader.loadAd();
|
||||
}
|
||||
|
||||
public static void clearNativeAd(MaxAd nativeAd, MaxNativeAdLoader nativeAdLoader) {
|
||||
if (nativeAd != null) {
|
||||
nativeAdLoader.destroy(nativeAd);
|
||||
}
|
||||
nativeAdLoader.destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static List<MaxInterstitialAd> onLoadAd() {
|
||||
if (adList.isEmpty()) {
|
||||
MaxInterstitialAd AdT = new MaxInterstitialAd(two_Ad, MusicApplication.myApplication);
|
||||
MaxInterstitialAd AdOne = new MaxInterstitialAd(one_AD, MusicApplication.myApplication);
|
||||
MaxInterstitialAd AdThree = new MaxInterstitialAd(three_ad, MusicApplication.myApplication);
|
||||
adList.add(AdOne);
|
||||
adList.add(AdT);
|
||||
adList.add(AdThree);
|
||||
}
|
||||
|
||||
for (MaxInterstitialAd ad : adList) {
|
||||
if (!ad.isReady()) {
|
||||
setMyListener(ad, new MaxListener() {
|
||||
@Override
|
||||
public void onFail(MaxAd ad) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowSuccess(MaxAd ad) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHidden() {
|
||||
|
||||
}
|
||||
});
|
||||
ad.loadAd();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return adList;
|
||||
}
|
||||
|
||||
public static void setMyListener(MaxInterstitialAd ad, MaxListener maxListener) {
|
||||
ad.setListener(new MaxAdListener() {
|
||||
@Override
|
||||
public void onAdLoaded(@NonNull MaxAd maxAd) {
|
||||
Log.d(AD_TAG, "-------onAdLoaded-----maxAd=" + maxAd.getAdUnitId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdDisplayed(@NonNull MaxAd maxAd) {
|
||||
Log.d(AD_TAG, "-------onAdDisplayed-----maxAd=" + maxAd.getAdUnitId());
|
||||
maxListener.onShowSuccess(maxAd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdHidden(@NonNull MaxAd maxAd) {
|
||||
Log.d(AD_TAG, "-------onAdHidden-----maxAd=" + maxAd.getAdUnitId());
|
||||
maxListener.onHidden();
|
||||
ad.loadAd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdClicked(@NonNull MaxAd maxAd) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdLoadFailed(@NonNull String s, @NonNull MaxError maxError) {
|
||||
Log.d(AD_TAG, "-------onAdLoadFailed-----s=" + s + "----maxError=" + maxError.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdDisplayFailed(@NonNull MaxAd maxAd, @NonNull MaxError maxError) {
|
||||
maxListener.onFail(maxAd);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected static void ShowAd(Activity activity, onAdStatusListener listener) {
|
||||
MaxInterstitialAd ad = MaxManager.getAd(adList);
|
||||
if (ad == null) {
|
||||
listener.onAdStatus(type_no_cache);
|
||||
} else {
|
||||
listener.onAdStatus(type_has_cache);
|
||||
MaxManager.setMyListener(ad, new MaxListener() {
|
||||
@Override
|
||||
public void onFail(MaxAd ad) {
|
||||
listener.onAdStatus(type_show_fail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowSuccess(MaxAd ad) {
|
||||
listener.onAdStatus(type_show_success);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHidden() {
|
||||
listener.onAdStatus(type_show_close);
|
||||
}
|
||||
});
|
||||
ad.showAd(activity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void startShowMaxAd(Activity activity, onAdAfterAction listener) {
|
||||
MaxManager.ShowAd(activity, new onAdStatusListener() {
|
||||
@Override
|
||||
public void onAdStatus(int type) {
|
||||
if (type == MaxManager.type_show_close || type == MaxManager.type_show_fail || type == MaxManager.type_no_cache) {
|
||||
if (listener != null)
|
||||
listener.onAction();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.offline.music.playermp3.max;
|
||||
|
||||
import com.applovin.mediation.MaxAd;
|
||||
import com.applovin.mediation.nativeAds.MaxNativeAdLoader;
|
||||
|
||||
public interface NativeMaxListener {
|
||||
void onLoaded(MaxAd ad, MaxNativeAdLoader maxNativeAdLoader);
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
package com.offline.music.playermp3.max
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.os.CountDownTimer
|
||||
import android.util.Log
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
|
||||
import com.applovin.mediation.ads.MaxInterstitialAd
|
||||
import com.offline.music.playermp3.MusicApplication
|
||||
|
||||
|
||||
object WelComManager {
|
||||
|
||||
private lateinit var timer: CountDownTimer
|
||||
|
||||
private var need_Show = true
|
||||
|
||||
private lateinit var lists: List<MaxInterstitialAd>
|
||||
|
||||
|
||||
|
||||
@JvmStatic
|
||||
fun initTimer(activity: Activity, countTime: Long,countAction: (Long) -> Unit, goMainAction: () -> Unit): CountDownTimer {
|
||||
need_Show = true
|
||||
timer = object : CountDownTimer(countTime, 100) {
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
countAction.invoke(millisUntilFinished)
|
||||
if (need_Show) {
|
||||
MaxManager.ShowAd(activity) {
|
||||
Log.d(MaxManager.AD_TAG, "--onTick----------it=$it")
|
||||
if (it == MaxManager.type_has_cache) {
|
||||
need_Show = false
|
||||
}
|
||||
if (it == MaxManager.type_show_close || it == MaxManager.type_show_fail) {
|
||||
Log.d(MaxManager.AD_TAG, "--onTick---------enter")
|
||||
goMainAction.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
if (need_Show) {
|
||||
MaxManager.ShowAd(activity) {
|
||||
if (it == MaxManager.type_show_close || it == MaxManager.type_show_fail || it == MaxManager.type_no_cache) {
|
||||
Log.d(MaxManager.AD_TAG, "--onFinish---------enter")
|
||||
goMainAction.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
startAd(activity)
|
||||
return timer
|
||||
}
|
||||
|
||||
private fun startAd(activity: Activity) {
|
||||
if (!MusicApplication.initSDkOK) {
|
||||
timer.start()
|
||||
LocalBroadcastManager.getInstance(activity)
|
||||
.registerReceiver(object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
lists = MaxManager.onLoadAd()
|
||||
|
||||
Log.d(MaxManager.AD_TAG, "------------1sucess")
|
||||
}
|
||||
}, IntentFilter(MusicApplication.initAction))
|
||||
} else {
|
||||
lists = MaxManager.onLoadAd()
|
||||
timer.start()
|
||||
Log.d(MaxManager.AD_TAG, "------------2sucess")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.offline.music.playermp3.max;
|
||||
|
||||
public interface onAdAfterAction {
|
||||
|
||||
void onAction();
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.offline.music.playermp3.max;
|
||||
|
||||
public interface onAdStatusListener {
|
||||
|
||||
void onAdStatus(int type);
|
||||
}
|
||||
@ -90,14 +90,15 @@ public class MyDownloadService extends DownloadService {
|
||||
if (download.state == Download.STATE_COMPLETED) {
|
||||
// 下载完成
|
||||
vmApplication.setDownloadChange(new Pair<>(true, download));
|
||||
CommonUtils.LogMsg("----------------下载完成 id=" + id + "--thread=" + Thread.currentThread().getName());
|
||||
// CommonUtils.LogMsg("----------------下载完成 id=" + id + "--thread=" + Thread.currentThread().getName());
|
||||
updateDownloadUi(vmApplication);
|
||||
|
||||
} else if (download.state == Download.STATE_FAILED) {
|
||||
// 下载失败
|
||||
CommonUtils.LogMsg("----------------下载失败 id=" + id + "---finalException=" + finalException.getMessage());
|
||||
// CommonUtils.LogMsg("----------------下载失败 id=" + id + "---finalException=" + finalException.getMessage());
|
||||
|
||||
vmApplication.setDownloadChange(new Pair<>(false, download));
|
||||
updateDownloadUi(vmApplication);
|
||||
}
|
||||
|
||||
|
||||
@ -118,7 +119,7 @@ public class MyDownloadService extends DownloadService {
|
||||
DownloadIndex downloadIndex = mDownloadManager.getDownloadIndex();
|
||||
Download download = downloadIndex.getDownload(videoId);
|
||||
|
||||
return new CustomerDownload(download, download != null);
|
||||
return new CustomerDownload(download, download != null && download.state == Download.STATE_COMPLETED);
|
||||
|
||||
}).subscribeOn(Schedulers.io())
|
||||
|
||||
@ -162,7 +163,7 @@ public class MyDownloadService extends DownloadService {
|
||||
}
|
||||
|
||||
|
||||
CommonUtils.LogMsg("----------------下载总数量 -count=" + downloadList.size());
|
||||
// CommonUtils.LogMsg("----------------下载总数量 -count=" + downloadList.size());
|
||||
vmApplication.setDownloadData(downloadList);
|
||||
|
||||
});
|
||||
|
||||
@ -143,7 +143,7 @@ public class MyMediaControllerManager {
|
||||
onCallRequestUrl(nextMediaItemIndex, playNextNow, new OnHasUrlAction() {
|
||||
@Override
|
||||
public void onHasUrl() {
|
||||
CommonUtils.LogMsg("-------------有有效URl--播放检查下一首 位置=" + nextMediaItemIndex);
|
||||
// CommonUtils.LogMsg("-------------有有效URl--播放检查下一首 位置=" + nextMediaItemIndex);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -152,7 +152,7 @@ public class MyMediaControllerManager {
|
||||
onCallRequestUrl(previousMediaItemIndex, false, new OnHasUrlAction() {
|
||||
@Override
|
||||
public void onHasUrl() {
|
||||
CommonUtils.LogMsg("-------------有有效URl--播放检查上一首 位置=" + previousMediaItemIndex);
|
||||
// CommonUtils.LogMsg("-------------有有效URl--播放检查上一首 位置=" + previousMediaItemIndex);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -252,7 +252,7 @@ public class MyMediaControllerManager {
|
||||
}
|
||||
|
||||
CharSequence title = mediaController.getMediaItemAt(i).mediaMetadata.title;
|
||||
CommonUtils.LogMsg("-------------更新播放列表中的音频--id=" + playUrl.getVideoId());
|
||||
// CommonUtils.LogMsg("-------------更新播放列表中的音频--id=" + playUrl.getVideoId());
|
||||
mediaController.replaceMediaItem(i, builder.build());
|
||||
break;
|
||||
}
|
||||
@ -301,7 +301,7 @@ public class MyMediaControllerManager {
|
||||
MediaMetadata_builder.setArtworkUri(Uri.parse(playInfo.getCovert()));
|
||||
MediaMetadata_builder.setTitle(playInfo.getSongTitle());
|
||||
|
||||
CommonUtils.LogMsg("----------添加播放列表 i=" + i + "---" + playInfo.getSingerName() + "-------VideoId=" + videoId + "---playInfo.getDuration()=" + playInfo.getDuration());
|
||||
// CommonUtils.LogMsg("----------添加播放列表 i=" + i + "---" + playInfo.getSingerName() + "-------VideoId=" + videoId + "---playInfo.getDuration()=" + playInfo.getDuration());
|
||||
// MediaMetadata_builder.setRecordingYear(Integer.parseInt(playInfo.getYear()));
|
||||
builder.setMediaMetadata(MediaMetadata_builder.build());
|
||||
mediaController.addMediaItem(builder.build());
|
||||
@ -386,7 +386,7 @@ public class MyMediaControllerManager {
|
||||
@Override
|
||||
public void onHasUrl() {
|
||||
mediaController.play();
|
||||
CommonUtils.LogMsg("-------------有有效URl--播放指定播放列表位置的歌曲 index=" + index);
|
||||
// CommonUtils.LogMsg("-------------有有效URl--播放指定播放列表位置的歌曲 index=" + index);
|
||||
}
|
||||
});
|
||||
|
||||
@ -404,9 +404,9 @@ public class MyMediaControllerManager {
|
||||
if (customerDownload.isDownload()) {
|
||||
MediaItem mediaItem = CommonUtils.downloadToMediaItem(customerDownload.getDownloadData());
|
||||
mediaController.replaceMediaItem(index, mediaItem);
|
||||
CommonUtils.LogMsg("-------------请求URl 已经下载过 index" + index + "---playNow=" + playNow);
|
||||
// CommonUtils.LogMsg("-------------请求URl 已经下载过 index" + index + "---playNow=" + playNow);
|
||||
} else {
|
||||
CommonUtils.LogMsg("-------------请求URl index" + index + "---playNow=" + playNow);
|
||||
// CommonUtils.LogMsg("-------------请求URl index" + index + "---playNow=" + playNow);
|
||||
mListener.onRequestNextUri(mediaItemAt.mediaId, index, playNow);
|
||||
}
|
||||
|
||||
|
||||
@ -83,12 +83,12 @@ public class PlaybackService extends MediaSessionService {
|
||||
.setEventListener(new CacheDataSource.EventListener() {
|
||||
@Override
|
||||
public void onCachedBytesRead(long cacheSizeBytes, long cachedBytesRead) {
|
||||
CommonUtils.LogMsg("-----------缓存1 DownloadCache --" + cacheSizeBytes + "----cacheSizeBytes=" + cachedBytesRead);
|
||||
// CommonUtils.LogMsg("-----------缓存1 DownloadCache --" + cacheSizeBytes + "----cacheSizeBytes=" + cachedBytesRead);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCacheIgnored(int reason) {
|
||||
CommonUtils.LogMsg("-----------缓存1忽略DownloadCache =" + reason);
|
||||
// CommonUtils.LogMsg("-----------缓存1忽略DownloadCache =" + reason);
|
||||
}
|
||||
});
|
||||
// .setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR);
|
||||
|
||||
@ -42,7 +42,7 @@ public class JsonHelper {
|
||||
JSONObject responseContext = jsonObject.getJSONObject("responseContext");
|
||||
JSONArray serviceTrackingParams = responseContext.getJSONArray("serviceTrackingParams");
|
||||
String visitorData = responseContext.getString("visitorData");
|
||||
CommonUtils.LogMsg("---------参数-visitorData=" + visitorData);
|
||||
|
||||
|
||||
responseHome.setBackgroundUrl(bgUrl);
|
||||
responseHome.setVisitorData(visitorData);
|
||||
@ -50,7 +50,7 @@ public class JsonHelper {
|
||||
|
||||
|
||||
} catch (JSONException exception) {
|
||||
CommonUtils.LogMsg("---------首页-exception=");
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
@ -78,7 +78,7 @@ public class JsonHelper {
|
||||
getCommonHome(sectionListContinuation, responseHome);
|
||||
|
||||
} catch (JSONException exception) {
|
||||
CommonUtils.LogMsg("----------exception=" + exception.getMessage());
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
@ -106,7 +106,7 @@ public class JsonHelper {
|
||||
|
||||
String smallUrl = getCovertUrl(playlistPanelVideoRenderer, false);
|
||||
|
||||
CommonUtils.LogMsg("--图片--------maxUrl=" + maxUrl + "---smallUrl=" + smallUrl);
|
||||
|
||||
|
||||
String songName = getJsonTitle(playlistPanelVideoRenderer.getJSONObject("title"), 0);
|
||||
|
||||
@ -247,7 +247,7 @@ public class JsonHelper {
|
||||
|
||||
//封面图
|
||||
String covert = getCovertUrl(musicResponsiveHeaderRenderer.getJSONObject("thumbnail"), true);
|
||||
CommonUtils.LogMsg("----图片-------------covert=" + covert);
|
||||
|
||||
|
||||
//轻松愉悦的经典摇滚乐
|
||||
String title = getJsonTitle(musicResponsiveHeaderRenderer.getJSONObject("title"), 0);
|
||||
@ -300,13 +300,13 @@ public class JsonHelper {
|
||||
JSONObject arrayJSONObject = jsonArray.getJSONObject(i).getJSONObject("musicResponsiveListItemRenderer");
|
||||
ResponsePlayListInfo child = getCommonCategoryList(arrayJSONObject);
|
||||
String thumbnail = getCovertUrl(arrayJSONObject.getJSONObject("thumbnail"), true);
|
||||
CommonUtils.LogMsg("----图片-------------thumbnail=" + thumbnail);
|
||||
// CommonUtils.LogMsg("----图片-------------thumbnail=" + thumbnail);
|
||||
child.setSmallCovert(thumbnail);
|
||||
// child.setCovert(thumbnail);
|
||||
|
||||
|
||||
if (child.getVideoId() == null || child.getVideoId().isEmpty()) {
|
||||
CommonUtils.LogErrorMsg("--歌曲" + i + "-------------SongTitle=" + child.getSongTitle() + "--getVideoId=" + child.getVideoId() + "---请求参数browseId=" + browseId);
|
||||
// CommonUtils.LogErrorMsg("--歌曲" + i + "-------------SongTitle=" + child.getSongTitle() + "--getVideoId=" + child.getVideoId() + "---请求参数browseId=" + browseId);
|
||||
continue;
|
||||
}
|
||||
mList.add(child);
|
||||
@ -782,7 +782,7 @@ public class JsonHelper {
|
||||
ResponseSingle responseSingle = new ResponseSingle();
|
||||
|
||||
String SingerHead = getCovertUrl(musicResponsiveListItemRenderer.getJSONObject("thumbnail"), true);
|
||||
CommonUtils.LogMsg("----图片-------------SingerHead=" + SingerHead);
|
||||
// CommonUtils.LogMsg("----图片-------------SingerHead=" + SingerHead);
|
||||
|
||||
JSONArray flexColumns = musicResponsiveListItemRenderer.getJSONArray("flexColumns");
|
||||
|
||||
@ -889,10 +889,7 @@ public class JsonHelper {
|
||||
responseCategory.setTwoSubtitle(twoSubtitle);
|
||||
categoryList.add(responseCategory);
|
||||
if (j == 0) {
|
||||
CommonUtils.LogMsg(" ----------2222222222----twoTitle=" + twoTitle + "--BrowseId="
|
||||
+ responseCategory.getBrowseId() + "---pageType=" + responseCategory.getPageType()
|
||||
+ "--VideoId=" + responseCategory.getVideoId()
|
||||
+ "---PlayListId=" + responseCategory.getPlayListId());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ public class RetrofitManager {
|
||||
.connectTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS)
|
||||
.writeTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS)
|
||||
.readTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS)
|
||||
.addInterceptor(httpLoggingInterceptor)
|
||||
// .addInterceptor(httpLoggingInterceptor)
|
||||
.build();
|
||||
retrofit = new Retrofit.Builder()
|
||||
.baseUrl(base_Host)
|
||||
|
||||
@ -69,19 +69,19 @@ public class MusicPlayerForegroundService extends Service {
|
||||
// 服务启动时调用
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Log.d("MusicPlayerService", "Service started");
|
||||
|
||||
audioItem = (AudioItem) intent.getSerializableExtra("Path"); // 获取音频路径
|
||||
|
||||
if (audioItem != null) {
|
||||
String newAudioPath = audioItem.getFile();
|
||||
// 如果新音频路径不同于当前路径,则重新初始化播放器
|
||||
if (newAudioPath != null && !newAudioPath.equals(currentAudioPath)) {
|
||||
Log.d("MusicPlayerService", "检测到新的音频路径,初始化播放器");
|
||||
// Log.d("MusicPlayerService", "检测到新的音频路径,初始化播放器");
|
||||
currentAudioPath = newAudioPath; // 更新路径
|
||||
stopAndResetMediaPlayer(); // 停止并重置播放器
|
||||
initializePlayer(newAudioPath); // 初始化播放器
|
||||
} else {
|
||||
Log.d("MusicPlayerService", "音频路径相同,无需重新初始化播放器");
|
||||
// Log.d("MusicPlayerService", "音频路径相同,无需重新初始化播放器");
|
||||
}
|
||||
} else {
|
||||
stopSelf(); // 路径为空,停止服务
|
||||
|
||||
@ -7,11 +7,16 @@ import android.view.View;
|
||||
import com.offline.music.playermp3.databinding.ActivityAsplashBinding;
|
||||
import com.offline.music.playermp3.firebase.RemoteConfigJava;
|
||||
import com.offline.music.playermp3.firebase.Sp;
|
||||
import com.offline.music.playermp3.max.WelComManager;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
|
||||
public class A_SplashActivity extends BaseActivity<ActivityAsplashBinding> {
|
||||
|
||||
private static final int SPLASH_TIME_OUT = 1500;
|
||||
private static final int SPLASH_TIME_OUT = 14000;
|
||||
private CountDownTimer countDownTimer;
|
||||
|
||||
@Override
|
||||
@ -47,26 +52,23 @@ public class A_SplashActivity extends BaseActivity<ActivityAsplashBinding> {
|
||||
}
|
||||
|
||||
public void intData() {
|
||||
|
||||
countDownTimer = new CountDownTimer(SPLASH_TIME_OUT, 100) {
|
||||
|
||||
countDownTimer = WelComManager.initTimer(this, SPLASH_TIME_OUT, new Function1<Long, Unit>() {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
|
||||
float v = 100 - (float) millisUntilFinished / SPLASH_TIME_OUT * 100;
|
||||
public Unit invoke(Long aLong) {
|
||||
float v = 100 - (float) aLong / SPLASH_TIME_OUT * 100;
|
||||
int v1 = (int) v;
|
||||
vb.progressBar.setProgress(v1);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}, new Function0<Unit>() {
|
||||
@Override
|
||||
public void onFinish() {
|
||||
public Unit invoke() {
|
||||
vb.progressBar.setProgress(100);
|
||||
enterHome();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
countDownTimer.start();
|
||||
|
||||
}
|
||||
|
||||
@ -75,16 +77,25 @@ public class A_SplashActivity extends BaseActivity<ActivityAsplashBinding> {
|
||||
|
||||
}
|
||||
|
||||
private void enterHome(){
|
||||
private void enterHome() {
|
||||
String stringValue = Sp.getInstance().getStringValue(RemoteConfigJava.key_open_type);
|
||||
Intent intent;
|
||||
if(stringValue.equals(RemoteConfigJava.value_open_type_0)){
|
||||
if (stringValue.equals(RemoteConfigJava.value_open_type_0)) {
|
||||
intent = new Intent(A_SplashActivity.this, A_HomeActivity.class);
|
||||
}else {
|
||||
} else {
|
||||
intent = new Intent(A_SplashActivity.this, HomeActivity.class);
|
||||
}
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel();
|
||||
countDownTimer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -147,9 +147,9 @@ public abstract class BaseActivity<T extends ViewBinding> extends AppCompatActiv
|
||||
@OptIn(markerClass = UnstableApi.class)
|
||||
@Override
|
||||
public void onChanged(Integer integer) {
|
||||
CommonUtils.LogMsg("----------面板 播放状态更新=" + integer);
|
||||
|
||||
if (panelView.getParent() == null) {
|
||||
CommonUtils.LogMsg("----------显示面板");
|
||||
// CommonUtils.LogMsg("----------显示面板");
|
||||
rootVb.frameLayout.addView(panelView, layoutParams);
|
||||
mHandler.post(mRunnable);
|
||||
}
|
||||
|
||||
@ -10,6 +10,8 @@ import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.media3.exoplayer.offline.Download;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.applovin.mediation.MaxAd;
|
||||
import com.applovin.mediation.nativeAds.MaxNativeAdLoader;
|
||||
import com.offline.music.playermp3.R;
|
||||
import com.offline.music.playermp3.adapter.AdapterDownloadSong;
|
||||
import com.offline.music.playermp3.adapter.AdapterLikeSong;
|
||||
@ -19,6 +21,8 @@ import com.offline.music.playermp3.helper.CommonUtils;
|
||||
import com.offline.music.playermp3.helper.MyValue;
|
||||
import com.offline.music.playermp3.javabean.BoxLikeSong;
|
||||
import com.offline.music.playermp3.javabean.response.ResponsePlayListInfo;
|
||||
import com.offline.music.playermp3.max.MaxManager;
|
||||
import com.offline.music.playermp3.max.NativeMaxListener;
|
||||
import com.offline.music.playermp3.media3.MyDownloadService;
|
||||
import com.offline.music.playermp3.objectbox.ObjectBoxManager;
|
||||
|
||||
@ -30,7 +34,8 @@ public class LikeSongActivity extends BaseActivity<ActivityLikeSongBinding> impl
|
||||
|
||||
private List<BoxLikeSong> boxLikeSongs;
|
||||
private int mType;
|
||||
|
||||
private MaxAd nativeAd;
|
||||
private MaxNativeAdLoader nativeAdLoader;
|
||||
private List<Pair<Integer, String>> downloadList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
@ -44,6 +49,14 @@ public class LikeSongActivity extends BaseActivity<ActivityLikeSongBinding> impl
|
||||
Intent intent = getIntent();
|
||||
mType = intent.getIntExtra(MyValue.KEY_ENTER_LIKE_ACTIVITY_TYPE, MyValue.KEY_ENTER_LIKE_ACTIVITY_TYPE_LIKE);
|
||||
|
||||
MaxManager.onLoadNativeAd(vb.adLayout, MaxManager.native_Ad2, new NativeMaxListener() {
|
||||
@Override
|
||||
public void onLoaded(MaxAd ad, MaxNativeAdLoader maxNativeAdLoader) {
|
||||
nativeAd = ad;
|
||||
nativeAdLoader = maxNativeAdLoader;
|
||||
}
|
||||
});
|
||||
|
||||
switch (mType) {
|
||||
case MyValue.KEY_ENTER_LIKE_ACTIVITY_TYPE_LIKE:
|
||||
vb.tvTitle.setText(getString(R.string.text_like_song));
|
||||
@ -93,6 +106,14 @@ public class LikeSongActivity extends BaseActivity<ActivityLikeSongBinding> impl
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if(nativeAd!= null&&nativeAdLoader!= null){
|
||||
MaxManager.clearNativeAd(nativeAd,nativeAdLoader);
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitClick() {
|
||||
vb.imBack.setOnClickListener(this);
|
||||
@ -137,7 +158,7 @@ public class LikeSongActivity extends BaseActivity<ActivityLikeSongBinding> impl
|
||||
vmApplication.reSetPlayList(playList);
|
||||
|
||||
String videoId = boxLikeSong.getVideoId();
|
||||
CommonUtils.LogMsg("-------------like进入 传值 videoId= " + videoId);
|
||||
|
||||
Intent intent = new Intent(this, PlayActivity.class);
|
||||
intent.putExtra(MyValue.KEY_PLAY_VIDEO_ID, videoId);
|
||||
intent.putExtra(MyValue.KEY_PLAY_INDEX, index);
|
||||
@ -154,7 +175,7 @@ public class LikeSongActivity extends BaseActivity<ActivityLikeSongBinding> impl
|
||||
// MyDownloadService.updateDownloadUi(vmApplication)
|
||||
|
||||
String videoId = download.request.id;
|
||||
CommonUtils.LogMsg("------------Download进入 传值 videoId= " + videoId);
|
||||
|
||||
Intent intent = new Intent(this, PlayActivity.class);
|
||||
intent.putExtra(MyValue.KEY_PLAY_VIDEO_ID, videoId);
|
||||
intent.putExtra(MyValue.KEY_PLAY_INDEX, index);
|
||||
|
||||
@ -5,6 +5,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.util.Pair;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
@ -48,6 +49,8 @@ import com.offline.music.playermp3.javabean.CustomerUrlInfo;
|
||||
import com.offline.music.playermp3.javabean.response.ResponsePlayListInfo;
|
||||
import com.offline.music.playermp3.javabean.response.child.ResponseCategory;
|
||||
import com.offline.music.playermp3.javabean.response.child.ResponseSingle;
|
||||
import com.offline.music.playermp3.max.MaxManager;
|
||||
import com.offline.music.playermp3.max.onAdAfterAction;
|
||||
import com.offline.music.playermp3.media3.MyDownloadService;
|
||||
import com.offline.music.playermp3.media3.MyMediaControllerManager;
|
||||
import com.offline.music.playermp3.media3.MyPlayCacheManager;
|
||||
@ -113,7 +116,12 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
|
||||
@Override
|
||||
protected void onCreateInit() {
|
||||
// vb.progressBarLoading.setVisibility(View.VISIBLE);
|
||||
MaxManager.startShowMaxAd(this, new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
|
||||
}
|
||||
});
|
||||
vmPlay = getActivityScopeViewModel(VMPlay.class);
|
||||
initMediaController();
|
||||
Intent intent = getIntent();
|
||||
@ -195,7 +203,7 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
// 5--从下载歌曲进入
|
||||
videoId = intent.getStringExtra(MyValue.KEY_PLAY_VIDEO_ID);
|
||||
mDefaultPlayStartIndex = intent.getIntExtra(MyValue.KEY_PLAY_INDEX, mDefaultPlayStartIndex);
|
||||
CommonUtils.LogMsg("-------------下载歌曲 videoId= " + videoId + "---mDefaultPlayStartIndex=" + mDefaultPlayStartIndex);
|
||||
// CommonUtils.LogMsg("-------------下载歌曲 videoId= " + videoId + "---mDefaultPlayStartIndex=" + mDefaultPlayStartIndex);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -240,7 +248,7 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
vb.progressBarLoading.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
CommonUtils.LogMsg("--------更新-playList " + playList.size() + "--videoId=" + videoId);
|
||||
// CommonUtils.LogMsg("--------更新-playList " + playList.size() + "--videoId=" + videoId);
|
||||
if (playList.size() > 0) {
|
||||
updateErrorLayout(null, false);
|
||||
setPlayListAndGetUrl(playList, videoId, mDefaultPlayStartIndex);
|
||||
@ -276,10 +284,10 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
if(customerDownload.isDownload()){
|
||||
MediaItem mediaItem = CommonUtils.downloadToMediaItem(customerDownload.getDownloadData());
|
||||
mediaControllerManager.replaceMediaItem(index,mediaItem);
|
||||
CommonUtils.LogMsg("-------------setPlayListAndGetUrl已经下载过 index" + index + "---playNow=" + true);
|
||||
// CommonUtils.LogMsg("-------------setPlayListAndGetUrl已经下载过 index" + index + "---playNow=" + true);
|
||||
mediaControllerManager.playPositionMusic(index);
|
||||
}else {
|
||||
CommonUtils.LogMsg("-------------setPlayListAndGetUrl index" + index + "---playNow=" + true);
|
||||
// CommonUtils.LogMsg("-------------setPlayListAndGetUrl index" + index + "---playNow=" + true);
|
||||
vmPlay.getPlayUrl(id, index, true);
|
||||
}
|
||||
|
||||
@ -311,31 +319,31 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
//快进没有缓冲的时候触发
|
||||
vb.btnPlay.setSelected(false);
|
||||
// vb.progressBarLoading.setVisibility(View.VISIBLE);
|
||||
CommonUtils.LogMsg("-------------缓冲");
|
||||
// CommonUtils.LogMsg("-------------缓冲");
|
||||
break;
|
||||
case Player.STATE_READY:
|
||||
vb.btnPlay.setSelected(true);
|
||||
mHandler.post(mRunnable);
|
||||
vb.progressBarLoading.setVisibility(View.GONE);
|
||||
CommonUtils.LogMsg("-------------准备");
|
||||
// CommonUtils.LogMsg("-------------准备");
|
||||
break;
|
||||
|
||||
case Player.STATE_ENDED:
|
||||
//播放完成
|
||||
vb.btnPlay.setSelected(false);
|
||||
CommonUtils.LogMsg("------------- 播放完成");
|
||||
// CommonUtils.LogMsg("------------- 播放完成");
|
||||
mHandler.removeCallbacks(mRunnable); // 停止更新
|
||||
updatePlayComplete();
|
||||
break;
|
||||
|
||||
case MyValue.PLAY_STATUS_CODE_PAUSE:
|
||||
CommonUtils.LogMsg("------------- 暂停");
|
||||
// CommonUtils.LogMsg("------------- 暂停");
|
||||
vb.btnPlay.setSelected(false);
|
||||
vb.layoutPlayList.imPlay.setSelected(false);
|
||||
break;
|
||||
case MyValue.PLAY_STATUS_CODE_PLAYING:
|
||||
|
||||
CommonUtils.LogMsg("------------- 播放ing getCurIndex=" + mediaControllerManager.getCurIndex());
|
||||
// CommonUtils.LogMsg("------------- 播放ing getCurIndex=" + mediaControllerManager.getCurIndex());
|
||||
vb.progressBarLoading.setVisibility(View.GONE);
|
||||
updateErrorLayout(null, false);
|
||||
vb.btnPlay.setSelected(true);
|
||||
@ -344,7 +352,7 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
case MyValue.PLAY_STATUS_CODE_ERROR:
|
||||
vb.progressBarLoading.setVisibility(View.GONE);
|
||||
int currentMediaItemIndex = mediaControllerManager.getMediaController().getCurrentMediaItemIndex();
|
||||
CommonUtils.LogMsg("------------- 播放错误 currentMediaItemIndex=" + currentMediaItemIndex);
|
||||
// CommonUtils.LogMsg("------------- 播放错误 currentMediaItemIndex=" + currentMediaItemIndex);
|
||||
mediaControllerManager.playPositionMusic(currentMediaItemIndex);
|
||||
// TODO: 2024/10/16
|
||||
break;
|
||||
@ -363,7 +371,7 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
|
||||
@Override
|
||||
public void onChangeMusic(MediaItem mediaItem) {
|
||||
CommonUtils.LogMsg("歌曲切换-" + mediaItem.mediaMetadata.title + "---id=" + mediaItem.mediaId);
|
||||
// CommonUtils.LogMsg("歌曲切换-" + mediaItem.mediaMetadata.title + "---id=" + mediaItem.mediaId);
|
||||
loadInfo(mediaItem);
|
||||
}
|
||||
|
||||
@ -382,7 +390,12 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
vb.btnLoop.setOnClickListener(this);
|
||||
vb.layoutLike.setOnClickListener(this);
|
||||
vb.layoutDownload.setOnClickListener(this);
|
||||
vmApplication.downloadChange.observe(this, new Observer<Pair<Boolean, Download>>() {
|
||||
@Override
|
||||
public void onChanged(Pair<Boolean, Download> booleanDownloadPair) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -533,17 +546,29 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
mediaControllerManager.pause();
|
||||
}
|
||||
} else if (v.equals(vb.btnNext)) {
|
||||
mediaControllerManager.playNext(new onPlayNextListener() {
|
||||
MaxManager.startShowMaxAd(this, new onAdAfterAction() {
|
||||
@Override
|
||||
public void onPlayNext(boolean hasNext) {
|
||||
if (!hasNext) {
|
||||
Toast.makeText(PlayActivity.this, getString(R.string.no_next_song_yet), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
public void onAction() {
|
||||
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();
|
||||
MaxManager.startShowMaxAd(this, new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
mediaControllerManager.playPrevious();
|
||||
}
|
||||
});
|
||||
|
||||
} else if (v.equals(vb.imBack)) {
|
||||
finish();
|
||||
} else if (v.equals(vb.btnMusicList)) {
|
||||
@ -617,34 +642,41 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
|
||||
|
||||
} else if (v.equals(vb.layoutDownload)) {
|
||||
if (vb.imDownload.isSelected()) {
|
||||
//已经下载
|
||||
Toast.makeText(this,getText(R.string.text_has_downloaded),Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
vb.downloadPb.setVisibility(View.VISIBLE);
|
||||
vb.imDownload.setVisibility(View.INVISIBLE);
|
||||
BoxDownloadSong curMediaItemInfo = getCurMediaItemInfo();
|
||||
if (curMediaItemInfo != null) {
|
||||
Gson gson = new Gson();
|
||||
String info = gson.toJson(curMediaItemInfo);
|
||||
byte[] data = info.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
String videoId1 = curMediaItemInfo.getVideoId();
|
||||
CommonUtils.LogMsg("----------------开始下载 id=" + videoId1);
|
||||
DownloadRequest downloadRequest = new DownloadRequest.Builder(videoId1, Uri.parse(curMediaItemInfo.getVideoUrl()))
|
||||
.setMimeType("video/mp4")
|
||||
.setData(data)
|
||||
.build();
|
||||
MaxManager.startShowMaxAd(this, new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
if (vb.imDownload.isSelected()) {
|
||||
//已经下载
|
||||
Toast.makeText(PlayActivity.this,getText(R.string.text_has_downloaded),Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
vb.downloadPb.setVisibility(View.VISIBLE);
|
||||
vb.imDownload.setVisibility(View.INVISIBLE);
|
||||
BoxDownloadSong curMediaItemInfo = getCurMediaItemInfo();
|
||||
if (curMediaItemInfo != null) {
|
||||
Gson gson = new Gson();
|
||||
String info = gson.toJson(curMediaItemInfo);
|
||||
byte[] data = info.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
String videoId1 = curMediaItemInfo.getVideoId();
|
||||
CommonUtils.LogMsg("----------------开始下载 id=" + videoId1);
|
||||
DownloadRequest downloadRequest = new DownloadRequest.Builder(videoId1, Uri.parse(curMediaItemInfo.getVideoUrl()))
|
||||
.setMimeType("video/mp4")
|
||||
.setData(data)
|
||||
.build();
|
||||
|
||||
// 启动 DownloadService 进行下载
|
||||
DownloadService.sendAddDownload(
|
||||
PlayActivity.this,
|
||||
MyDownloadService.class, // 上面定义的下载服务类
|
||||
downloadRequest,
|
||||
true // 是否在前台运行
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 启动 DownloadService 进行下载
|
||||
DownloadService.sendAddDownload(
|
||||
this,
|
||||
MyDownloadService.class, // 上面定义的下载服务类
|
||||
downloadRequest,
|
||||
true // 是否在前台运行
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -821,6 +853,9 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
@Override
|
||||
public void onChanged(List<Download> downloads) {
|
||||
if (downloads == null || downloads.size() == 0) {
|
||||
vb.downloadPb.setVisibility(View.GONE);
|
||||
vb.imDownload.setVisibility(View.VISIBLE);
|
||||
vb.imDownload.setSelected(false);
|
||||
return;
|
||||
}
|
||||
String id = downloads.get(downloads.size() - 1).request.id;
|
||||
@ -832,6 +867,10 @@ public class PlayActivity extends BaseActivity<ActivityPlayBinding> implements S
|
||||
vb.downloadPb.setVisibility(View.GONE);
|
||||
vb.imDownload.setVisibility(View.VISIBLE);
|
||||
vb.imDownload.setSelected(true);
|
||||
}else {
|
||||
vb.downloadPb.setVisibility(View.GONE);
|
||||
vb.imDownload.setVisibility(View.VISIBLE);
|
||||
vb.imDownload.setSelected(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -140,7 +140,7 @@ public class ResultListActivity extends BaseActivity<ActivityResultListBinding>
|
||||
switch (pageType) {
|
||||
case "MUSIC_PAGE_TYPE_ALBUM":
|
||||
//专辑
|
||||
CommonUtils.LogMsg("------------专辑-index=" + index + "--subTitle=" + subTitle);
|
||||
// CommonUtils.LogMsg("------------专辑-index=" + index + "--subTitle=" + subTitle);
|
||||
case "MUSIC_PAGE_TYPE_PLAYLIST":
|
||||
//精选
|
||||
Intent intent1 = new Intent(this, CategoryListActivity.class);
|
||||
|
||||
@ -63,7 +63,7 @@ public class VMPlay extends ViewModel {
|
||||
|
||||
@Override
|
||||
public void onFail(String errorMsg) {
|
||||
CommonUtils.LogMsg("-------------此次网络请求失败 playNow="+playNow +"--playListIndex="+playListIndex);
|
||||
// CommonUtils.LogMsg("-------------此次网络请求失败 playNow="+playNow +"--playListIndex="+playListIndex);
|
||||
_playUrlMutableLiveData.setValue(customerUrlInfo);
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,8 @@ import com.offline.music.playermp3.helper.CommonUtils;
|
||||
import com.offline.music.playermp3.helper.MyValue;
|
||||
import com.offline.music.playermp3.javabean.BoxDownloadSong;
|
||||
import com.offline.music.playermp3.javabean.BoxLikeSong;
|
||||
import com.offline.music.playermp3.max.MaxManager;
|
||||
import com.offline.music.playermp3.max.onAdAfterAction;
|
||||
import com.offline.music.playermp3.media3.MyDownloadService;
|
||||
import com.offline.music.playermp3.objectbox.ObjectBoxManager;
|
||||
import com.offline.music.playermp3.ui.activity.LikeSongActivity;
|
||||
@ -33,8 +35,6 @@ public class ProfileFragment extends BaseFragment<FragmentProfileBinding> implem
|
||||
private int likeSongCount = 0;
|
||||
private int downloadSongCount = 0;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected FragmentProfileBinding getFragmentVb() {
|
||||
return FragmentProfileBinding.inflate(getLayoutInflater());
|
||||
@ -125,15 +125,27 @@ public class ProfileFragment extends BaseFragment<FragmentProfileBinding> implem
|
||||
public void onClick(View v) {
|
||||
if (v.equals(Vb.relayoutLike)) {
|
||||
if (likeSongCount > 0) {
|
||||
Intent intent = new Intent(requireActivity(), LikeSongActivity.class);
|
||||
intent.putExtra(MyValue.KEY_ENTER_LIKE_ACTIVITY_TYPE, MyValue.KEY_ENTER_LIKE_ACTIVITY_TYPE_LIKE);
|
||||
startActivity(intent);
|
||||
MaxManager.startShowMaxAd(requireActivity(), new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
Intent intent = new Intent(requireActivity(), LikeSongActivity.class);
|
||||
intent.putExtra(MyValue.KEY_ENTER_LIKE_ACTIVITY_TYPE, MyValue.KEY_ENTER_LIKE_ACTIVITY_TYPE_LIKE);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
} else if (v.equals(Vb.relayoutDownload)) {
|
||||
if (downloadSongCount > 0) {
|
||||
Intent intent = new Intent(requireActivity(), LikeSongActivity.class);
|
||||
intent.putExtra(MyValue.KEY_ENTER_LIKE_ACTIVITY_TYPE, MyValue.KEY_ENTER_LIKE_ACTIVITY_TYPE_DOWNLOAD);
|
||||
startActivity(intent);
|
||||
MaxManager.startShowMaxAd(requireActivity(), new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
Intent intent = new Intent(requireActivity(), LikeSongActivity.class);
|
||||
intent.putExtra(MyValue.KEY_ENTER_LIKE_ACTIVITY_TYPE, MyValue.KEY_ENTER_LIKE_ACTIVITY_TYPE_DOWNLOAD);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,10 +7,15 @@ import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.applovin.mediation.MaxAd;
|
||||
import com.applovin.mediation.nativeAds.MaxNativeAdLoader;
|
||||
import com.offline.music.playermp3.MusicApplication;
|
||||
import com.offline.music.playermp3.R;
|
||||
import com.offline.music.playermp3.adapter.AdapterSearch;
|
||||
import com.offline.music.playermp3.adapter.AdapterSuggestion;
|
||||
import com.offline.music.playermp3.api.HomeItemClickListener;
|
||||
@ -20,6 +25,9 @@ import com.offline.music.playermp3.helper.MyValue;
|
||||
import com.offline.music.playermp3.javabean.response.ResponseSearch;
|
||||
import com.offline.music.playermp3.javabean.response.child.ResponseSearchChild;
|
||||
import com.offline.music.playermp3.javabean.response.child.ResponseSingle;
|
||||
import com.offline.music.playermp3.max.MaxManager;
|
||||
import com.offline.music.playermp3.max.NativeMaxListener;
|
||||
import com.offline.music.playermp3.max.onAdAfterAction;
|
||||
import com.offline.music.playermp3.ui.activity.CategoryListActivity;
|
||||
import com.offline.music.playermp3.ui.activity.PlayActivity;
|
||||
import com.offline.music.playermp3.ui.activity.ResultListActivity;
|
||||
@ -33,6 +41,9 @@ public class SearchFragment extends BaseFragment<FragmentSearchBinding> implemen
|
||||
|
||||
private VMSearch vmSearch;
|
||||
|
||||
private MaxAd nativeAd;
|
||||
private MaxNativeAdLoader nativeAdLoader;
|
||||
|
||||
@Override
|
||||
protected FragmentSearchBinding getFragmentVb() {
|
||||
return FragmentSearchBinding.inflate(getLayoutInflater());
|
||||
@ -91,7 +102,7 @@ public class SearchFragment extends BaseFragment<FragmentSearchBinding> implemen
|
||||
public void onChanged(List<String> strings) {
|
||||
if (strings != null) {
|
||||
adapterSuggestion.setData(strings);
|
||||
CommonUtils.LogMsg("------------更新=");
|
||||
// CommonUtils.LogMsg("------------更新=");
|
||||
}
|
||||
|
||||
}
|
||||
@ -111,9 +122,16 @@ public class SearchFragment extends BaseFragment<FragmentSearchBinding> implemen
|
||||
if(responseSearches == null){
|
||||
Vb.recyclerResult.setVisibility(View.GONE);
|
||||
Vb.layoutError.setVisibility(View.VISIBLE);
|
||||
CommonUtils.LogMsg("------------更新结果 null");
|
||||
// CommonUtils.LogMsg("------------更新结果 null");
|
||||
return;
|
||||
}
|
||||
MaxManager.onLoadNativeAd(Vb.adLayout, MaxManager.native_Ad1, new NativeMaxListener() {
|
||||
@Override
|
||||
public void onLoaded(MaxAd ad, MaxNativeAdLoader maxNativeAdLoader) {
|
||||
nativeAd = ad;
|
||||
nativeAdLoader = maxNativeAdLoader;
|
||||
}
|
||||
});
|
||||
Vb.recyclerResult.setVisibility(View.VISIBLE);
|
||||
Vb.layoutError.setVisibility(View.GONE);
|
||||
adapterSearch.setData(responseSearches);
|
||||
@ -121,11 +139,25 @@ public class SearchFragment extends BaseFragment<FragmentSearchBinding> implemen
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if(nativeAd!= null&&nativeAdLoader!= null){
|
||||
MaxManager.clearNativeAd(nativeAd,nativeAdLoader);
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void startQuery(String query){
|
||||
Vb.pbloading.setVisibility(View.VISIBLE);
|
||||
Vb.recyclerSuggestion.setVisibility(View.GONE);
|
||||
Vb.recyclerResult.setVisibility(View.VISIBLE);
|
||||
vmSearch.getSearchResult(query);
|
||||
MaxManager.startShowMaxAd(requireActivity(), new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
Vb.pbloading.setVisibility(View.VISIBLE);
|
||||
Vb.recyclerSuggestion.setVisibility(View.GONE);
|
||||
Vb.recyclerResult.setVisibility(View.VISIBLE);
|
||||
vmSearch.getSearchResult(query);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -156,7 +188,7 @@ public class SearchFragment extends BaseFragment<FragmentSearchBinding> implemen
|
||||
String pageType = responseSearch.getPageType();
|
||||
|
||||
if(beastVideoId!= null&&!beastVideoId.isEmpty()){
|
||||
CommonUtils.LogMsg("---------击搜索结果的play按钮--beastVideoId="+beastVideoId);
|
||||
// CommonUtils.LogMsg("---------击搜索结果的play按钮--beastVideoId="+beastVideoId);
|
||||
|
||||
ResponseSingle responseSingle = new ResponseSingle();
|
||||
responseSingle.setSongTitle(beastSongTitle);
|
||||
@ -167,7 +199,7 @@ public class SearchFragment extends BaseFragment<FragmentSearchBinding> implemen
|
||||
intent.putExtra(MyValue.KEY_PLAY_ACTIVITY_SINGER, responseSingle);
|
||||
startActivity(intent);
|
||||
}else if(beastBrowserId!= null&&!beastBrowserId.isEmpty()){
|
||||
CommonUtils.LogMsg("---------击搜索结果的play按钮--pageType="+pageType);
|
||||
// CommonUtils.LogMsg("---------击搜索结果的play按钮--pageType="+pageType);
|
||||
switch (pageType){
|
||||
case "MUSIC_PAGE_TYPE_PLAYLIST":
|
||||
case "MUSIC_PAGE_TYPE_ALBUM":
|
||||
@ -198,7 +230,7 @@ public class SearchFragment extends BaseFragment<FragmentSearchBinding> implemen
|
||||
|
||||
if(browserId!= null&&!browserId.isEmpty()){
|
||||
String pageType = responseSearchChild.getPageType();
|
||||
CommonUtils.LogMsg("---------点击搜索结果--pageType="+pageType);
|
||||
// CommonUtils.LogMsg("---------点击搜索结果--pageType="+pageType);
|
||||
switch (pageType){
|
||||
case "MUSIC_PAGE_TYPE_ARTIST":
|
||||
Intent intent = new Intent(requireActivity(), ResultListActivity.class);
|
||||
@ -215,7 +247,7 @@ public class SearchFragment extends BaseFragment<FragmentSearchBinding> implemen
|
||||
}
|
||||
|
||||
}else {
|
||||
CommonUtils.LogMsg("---------点击搜索结果--VideoId="+songVideoId);
|
||||
// CommonUtils.LogMsg("---------点击搜索结果--VideoId="+songVideoId);
|
||||
|
||||
ResponseSingle responseSingle = new ResponseSingle();
|
||||
responseSingle.setSongTitle(songTitle);
|
||||
|
||||
@ -19,12 +19,12 @@
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/text_like_song"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="17sp"
|
||||
android:id="@+id/tv_title"
|
||||
app:layout_constraintBottom_toBottomOf="@id/im_back"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
@ -43,15 +43,29 @@
|
||||
app:layout_constraintLeft_toLeftOf="@id/im_back"
|
||||
app:layout_constraintTop_toBottomOf="@id/im_back" />
|
||||
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/ad_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="120dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:layout_marginTop="5dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardCornerRadius="8dp"
|
||||
android:visibility="gone"
|
||||
app:cardBackgroundColor="@color/white_15_color"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_song_size" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="10dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_song_size" />
|
||||
app:layout_constraintTop_toBottomOf="@id/ad_layout" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -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"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@ -50,14 +51,27 @@
|
||||
android:layout_alignEnd="@id/layout_et" />
|
||||
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/ad_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="120dp"
|
||||
android:layout_below="@id/layout_et"
|
||||
android:layout_alignStart="@id/layout_et"
|
||||
android:layout_alignEnd="@id/layout_et"
|
||||
android:layout_marginTop="5dp"
|
||||
android:visibility="gone"
|
||||
app:cardBackgroundColor="@color/white_15_color"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="0dp" />
|
||||
|
||||
<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_below="@id/ad_layout"
|
||||
android:layout_alignStart="@id/layout_et"
|
||||
android:layout_alignEnd="@id/layout_et"
|
||||
android:visibility="gone" />
|
||||
android:visibility="visible" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/layout_error"
|
||||
@ -88,7 +102,7 @@
|
||||
android:layout_below="@id/layout_et"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="200dp"
|
||||
android:visibility="gone"
|
||||
android:indeterminateTint="@color/white" />
|
||||
android:indeterminateTint="@color/white"
|
||||
android:visibility="gone" />
|
||||
|
||||
</RelativeLayout>
|
||||
@ -50,6 +50,8 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
@ -58,6 +60,8 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:textColor="@color/white_60_color"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
<ImageView
|
||||
android:id="@+id/im_covert"
|
||||
android:layout_width="60dp"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_height="60dp" />
|
||||
|
||||
<LinearLayout
|
||||
@ -24,6 +25,8 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
@ -32,6 +35,8 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/white_60_color"
|
||||
android:textSize="12sp" />
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
id("com.android.application") version "8.1.3" apply false
|
||||
// id("org.jetbrains.kotlin.android") version "1.9.22" apply false
|
||||
id("org.jetbrains.kotlin.android") version "1.9.22" apply false
|
||||
|
||||
|
||||
id("com.google.gms.google-services") version "4.3.15" apply false
|
||||
@ -10,7 +10,12 @@ plugins {
|
||||
}
|
||||
|
||||
buildscript {
|
||||
|
||||
|
||||
dependencies {
|
||||
classpath("io.objectbox:objectbox-gradle-plugin:4.0.3")
|
||||
classpath ("com.applovin.quality:AppLovinQualityServiceGradlePlugin:+")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
|
||||
@ -3,6 +3,8 @@ pluginManagement {
|
||||
google()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
|
||||
maven { url = uri("https://artifacts.applovin.com/android") }
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
@ -10,6 +12,10 @@ dependencyResolutionManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
||||
maven { url = uri("https://cboost.jfrog.io/artifactory/chartboost-ads/") }
|
||||
maven { url = uri("https://android-sdk.is.com") }
|
||||
maven { url = uri("https://artifact.bytedance.com/repository/pangle") }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user