|
|
|
@ -3,25 +3,19 @@ package com.fongmi.android.tv.ui.base; |
|
|
|
import android.app.Activity; |
|
|
|
import android.app.Activity; |
|
|
|
import android.content.res.Configuration; |
|
|
|
import android.content.res.Configuration; |
|
|
|
import android.content.res.Resources; |
|
|
|
import android.content.res.Resources; |
|
|
|
import android.graphics.drawable.Drawable; |
|
|
|
|
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.view.View; |
|
|
|
import android.view.View; |
|
|
|
|
|
|
|
|
|
|
|
import androidx.activity.OnBackPressedCallback; |
|
|
|
import androidx.activity.OnBackPressedCallback; |
|
|
|
import androidx.annotation.NonNull; |
|
|
|
import androidx.annotation.NonNull; |
|
|
|
import androidx.annotation.Nullable; |
|
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity; |
|
|
|
import androidx.appcompat.app.AppCompatActivity; |
|
|
|
import androidx.leanback.widget.ArrayObjectAdapter; |
|
|
|
import androidx.leanback.widget.ArrayObjectAdapter; |
|
|
|
import androidx.recyclerview.widget.RecyclerView; |
|
|
|
import androidx.recyclerview.widget.RecyclerView; |
|
|
|
import androidx.viewbinding.ViewBinding; |
|
|
|
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.R; |
|
|
|
import com.fongmi.android.tv.Setting; |
|
|
|
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.event.RefreshEvent; |
|
|
|
import com.fongmi.android.tv.utils.FileUtil; |
|
|
|
import com.fongmi.android.tv.utils.FileUtil; |
|
|
|
import com.fongmi.android.tv.utils.ResUtil; |
|
|
|
import com.fongmi.android.tv.utils.ResUtil; |
|
|
|
@ -102,31 +96,13 @@ public abstract class BaseActivity extends AppCompatActivity { |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (!customWall()) return; |
|
|
|
if (!customWall()) return; |
|
|
|
File file = FileUtil.getWall(Setting.getWall()); |
|
|
|
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())); |
|
|
|
else getWindow().setBackgroundDrawableResource(ResUtil.getDrawable(file.getName())); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
getWindow().setBackgroundDrawableResource(R.drawable.wallpaper_1); |
|
|
|
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(com.github.catvod.utils.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) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Resources hackResources(Resources resources) { |
|
|
|
private Resources hackResources(Resources resources) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
AutoSizeCompat.autoConvertDensityOfGlobal(resources); |
|
|
|
AutoSizeCompat.autoConvertDensityOfGlobal(resources); |
|
|
|
@ -138,7 +114,9 @@ public abstract class BaseActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN) |
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN) |
|
|
|
public void onRefreshEvent(RefreshEvent event) { |
|
|
|
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 |
|
|
|
@Override |
|
|
|
|