some null checks
This commit is contained in:
@@ -7,6 +7,7 @@ import static ru.vtosters.lite.utils.LifecycleUtils.getCurrentActivity;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getAlertStyle;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getSTextAttr;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.text.Editable;
|
||||
@@ -57,7 +58,14 @@ public class CryptImHook{
|
||||
}
|
||||
|
||||
IMProcessor finalEnabled = enabled;
|
||||
new VkAlertDialog.Builder(getCurrentActivity())
|
||||
Activity ctx = getCurrentActivity();
|
||||
|
||||
if (ctx == null) {
|
||||
sendToast("Ошибка в работе приложения. Перезапустите приложение");
|
||||
return;
|
||||
}
|
||||
|
||||
new VkAlertDialog.Builder(ctx)
|
||||
.setTitle(getString("encryption_sett"))
|
||||
.setSingleChoiceItems(titles, enabledPosition, (dialog, which) -> {
|
||||
if (which == 0) {
|
||||
@@ -103,6 +111,11 @@ public class CryptImHook{
|
||||
|
||||
Context ctx = getCurrentActivity();
|
||||
|
||||
if (ctx == null) {
|
||||
sendToast("Ошибка в работе приложения. Перезапустите приложение");
|
||||
return;
|
||||
}
|
||||
|
||||
LinearLayout linearLayout = new LinearLayout(ctx);
|
||||
|
||||
final EditText editText = new EditText(ctx);
|
||||
|
||||
@@ -225,7 +225,7 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
alert.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(getAccentColor());;
|
||||
}
|
||||
|
||||
public static void deleteVideoHistory() {
|
||||
public void deleteVideoHistory() {
|
||||
Thread thread = new Thread(() -> {
|
||||
try {
|
||||
var request = new Request.a()
|
||||
@@ -237,9 +237,9 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
var response = new JSONObject(new OkHttpClient().a(request).execute().a().g());
|
||||
|
||||
if (response.optInt("response") == 1){
|
||||
LifecycleUtils.getCurrentActivity().runOnUiThread(() -> sendToast(AndroidUtils.getString("video_history_cleaned")));
|
||||
requireActivity().runOnUiThread(() -> sendToast(AndroidUtils.getString("video_history_cleaned")));
|
||||
} else {
|
||||
LifecycleUtils.getCurrentActivity().runOnUiThread(() -> sendToast(AndroidUtils.getString("delete_video_history_error")));
|
||||
requireActivity().runOnUiThread(() -> sendToast(AndroidUtils.getString("delete_video_history_error")));
|
||||
}
|
||||
|
||||
Log.d("VideoHistory", response.toString());
|
||||
|
||||
@@ -8,6 +8,7 @@ import static ru.vtosters.lite.utils.AndroidUtils.getString;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.SyncResult;
|
||||
@@ -45,11 +46,11 @@ public class ContactsUtils{
|
||||
});
|
||||
}
|
||||
|
||||
public static void uploadContacts(Context ctx){
|
||||
public static void uploadContacts(Activity ctx){
|
||||
try {
|
||||
if (ContextCompat.checkSelfPermission(ctx, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
|
||||
sendToast(getString("contact_permission_toast"));
|
||||
requestPermissions(LifecycleUtils.getCurrentActivity(), new String[] {Manifest.permission.READ_CONTACTS}, 11111);
|
||||
requestPermissions(ctx, new String[] {Manifest.permission.READ_CONTACTS}, 11111);
|
||||
} else {
|
||||
var account = VKAuthUtils.a.a(VKAccountManager.d().Z());
|
||||
ContactsSyncAdapterService.c(ctx, account, new Bundle(), new SyncResult());
|
||||
|
||||
@@ -7,6 +7,7 @@ import static ru.vtosters.lite.utils.AndroidUtils.getCenterScreenCoords;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getResources;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.*;
|
||||
import static ru.vtosters.lite.utils.Preferences.color_grishka;
|
||||
import static ru.vtosters.lite.utils.Preferences.dockbar_accent;
|
||||
import static ru.vtosters.lite.utils.Preferences.milkshake;
|
||||
@@ -46,11 +47,19 @@ public class ThemesUtils {
|
||||
);
|
||||
|
||||
public static void applyTheme(VKTheme theme) {
|
||||
VKThemeHelper.theme(theme, LifecycleUtils.getCurrentActivity(), getCenterScreenCoords());
|
||||
var activity = getCurrentActivity();
|
||||
|
||||
if (activity == null) return;
|
||||
|
||||
VKThemeHelper.theme(theme, activity, getCenterScreenCoords());
|
||||
} // Apply VKTheme and ImTheme (hard applying without dynamic theme changing)
|
||||
|
||||
public static void setTheme(VKTheme theme, Activity activity) {
|
||||
if (activity == null) activity = LifecycleUtils.getCurrentActivity();
|
||||
if (activity == null) {
|
||||
activity = getCurrentActivity();
|
||||
|
||||
if (activity == null) return;
|
||||
}
|
||||
VKThemeHelper.theme(theme, activity, getCenterScreenCoords());
|
||||
ThemeTracker.a();
|
||||
isLoaded = false;
|
||||
@@ -59,7 +68,11 @@ public class ThemesUtils {
|
||||
} // apply changed theme
|
||||
|
||||
public static void setThemeFL(VKTheme theme, Activity activity, float[] fl) {
|
||||
if (activity == null) activity = LifecycleUtils.getCurrentActivity();
|
||||
if (activity == null) {
|
||||
activity = getCurrentActivity();
|
||||
|
||||
if (activity == null) return;
|
||||
}
|
||||
VKThemeHelper.theme(theme, activity, fl);
|
||||
ThemeTracker.a();
|
||||
isLoaded = false;
|
||||
|
||||
Reference in New Issue
Block a user