|
|
|
|
@ -1,9 +1,7 @@ |
|
|
|
|
package com.fongmi.android.tv.ui.base; |
|
|
|
|
|
|
|
|
|
import android.app.Activity; |
|
|
|
|
import android.content.res.Configuration; |
|
|
|
|
import android.graphics.Color; |
|
|
|
|
import android.graphics.drawable.Drawable; |
|
|
|
|
import android.os.Build; |
|
|
|
|
import android.os.Bundle; |
|
|
|
|
import android.view.DisplayCutout; |
|
|
|
|
@ -12,22 +10,15 @@ import android.view.ViewGroup; |
|
|
|
|
import android.view.WindowManager; |
|
|
|
|
|
|
|
|
|
import androidx.activity.OnBackPressedCallback; |
|
|
|
|
import androidx.annotation.NonNull; |
|
|
|
|
import androidx.annotation.Nullable; |
|
|
|
|
import androidx.appcompat.app.AppCompatActivity; |
|
|
|
|
import androidx.viewbinding.ViewBinding; |
|
|
|
|
|
|
|
|
|
import com.bumptech.glide.Glide; |
|
|
|
|
import com.bumptech.glide.request.target.CustomTarget; |
|
|
|
|
import com.bumptech.glide.request.transition.Transition; |
|
|
|
|
import com.bumptech.glide.signature.ObjectKey; |
|
|
|
|
import com.fongmi.android.tv.App; |
|
|
|
|
import com.fongmi.android.tv.R; |
|
|
|
|
import com.fongmi.android.tv.Setting; |
|
|
|
|
import com.fongmi.android.tv.api.config.WallConfig; |
|
|
|
|
import com.fongmi.android.tv.event.RefreshEvent; |
|
|
|
|
import com.fongmi.android.tv.utils.FileUtil; |
|
|
|
|
import com.fongmi.android.tv.utils.ResUtil; |
|
|
|
|
import com.github.catvod.utils.Util; |
|
|
|
|
|
|
|
|
|
import org.greenrobot.eventbus.EventBus; |
|
|
|
|
import org.greenrobot.eventbus.Subscribe; |
|
|
|
|
@ -129,40 +120,18 @@ public abstract class BaseActivity extends AppCompatActivity { |
|
|
|
|
try { |
|
|
|
|
if (!customWall()) return; |
|
|
|
|
File file = FileUtil.getWall(Setting.getWall()); |
|
|
|
|
if (file.exists() && file.length() > 0) loadWall(file); |
|
|
|
|
if (file.exists() && file.length() > 0) getWindow().setBackgroundDrawable(WallConfig.drawable(file)); |
|
|
|
|
else getWindow().setBackgroundDrawableResource(ResUtil.getDrawable(file.getName())); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
getWindow().setBackgroundDrawableResource(R.drawable.wallpaper_1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void loadWall(File file) { |
|
|
|
|
Glide.with(App.get()).load(file).centerCrop().override(ResUtil.getScreenWidth(), ResUtil.getScreenHeight()).signature(new ObjectKey(Util.md5(file))).into(new CustomTarget<Drawable>() { |
|
|
|
|
@Override |
|
|
|
|
public void onResourceReady(@NonNull Drawable drawable, @Nullable Transition<? super Drawable> transition) { |
|
|
|
|
getWindow().setBackgroundDrawable(drawable); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onLoadFailed(@Nullable Drawable error) { |
|
|
|
|
getWindow().setBackgroundDrawableResource(R.drawable.wallpaper_1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onLoadCleared(@Nullable Drawable drawable) { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onConfigurationChanged(@NonNull Configuration newConfig) { |
|
|
|
|
if (getRequestedOrientation() != newConfig.orientation) refreshWall(); |
|
|
|
|
super.onConfigurationChanged(newConfig); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN) |
|
|
|
|
public void onRefreshEvent(RefreshEvent event) { |
|
|
|
|
if (event.getType() == RefreshEvent.Type.WALL) refreshWall(); |
|
|
|
|
if (event.getType() != RefreshEvent.Type.WALL) return; |
|
|
|
|
WallConfig.get().setDrawable(null); |
|
|
|
|
refreshWall(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|