|
|
|
|
@ -1,10 +1,12 @@ |
|
|
|
|
package com.fongmi.android.tv.ui.activity; |
|
|
|
|
|
|
|
|
|
import android.app.Activity; |
|
|
|
|
import android.content.res.Configuration; |
|
|
|
|
import android.content.res.Resources; |
|
|
|
|
import android.graphics.drawable.Drawable; |
|
|
|
|
import android.os.Bundle; |
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
|
|
import androidx.appcompat.app.AppCompatActivity; |
|
|
|
|
import androidx.viewbinding.ViewBinding; |
|
|
|
|
|
|
|
|
|
@ -22,12 +24,18 @@ import org.greenrobot.eventbus.ThreadMode; |
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
|
|
public abstract class BaseActivity extends AppCompatActivity { |
|
|
|
|
import me.jessyan.autosize.AutoSizeCompat; |
|
|
|
|
import me.jessyan.autosize.internal.CustomAdapt; |
|
|
|
|
|
|
|
|
|
public abstract class BaseActivity extends AppCompatActivity implements CustomAdapt { |
|
|
|
|
|
|
|
|
|
protected abstract ViewBinding getBinding(); |
|
|
|
|
|
|
|
|
|
private boolean land; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
|
|
land = ResUtil.isLand(this); |
|
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
|
setContentView(getBinding().getRoot()); |
|
|
|
|
EventBus.getDefault().register(this); |
|
|
|
|
@ -56,6 +64,15 @@ public abstract class BaseActivity extends AppCompatActivity { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Resources hackResources(Resources resources) { |
|
|
|
|
try { |
|
|
|
|
AutoSizeCompat.autoConvertDensityOfCustomAdapt(resources, this); |
|
|
|
|
return resources; |
|
|
|
|
} catch (Exception ignored) { |
|
|
|
|
return resources; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN) |
|
|
|
|
public void onRefreshEvent(RefreshEvent event) { |
|
|
|
|
if (event.getType() != RefreshEvent.Type.WALL) return; |
|
|
|
|
@ -65,7 +82,7 @@ public abstract class BaseActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Resources getResources() { |
|
|
|
|
return Product.hackResources(super.getResources()); |
|
|
|
|
return hackResources(super.getResources()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@ -73,4 +90,20 @@ public abstract class BaseActivity extends AppCompatActivity { |
|
|
|
|
super.onDestroy(); |
|
|
|
|
EventBus.getDefault().unregister(this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onConfigurationChanged(@NonNull Configuration newConfig) { |
|
|
|
|
super.onConfigurationChanged(newConfig); |
|
|
|
|
land = ResUtil.isLand(this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean isBaseOnWidth() { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public float getSizeInDp() { |
|
|
|
|
return Product.getSizeInDp(land); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|