code cleanup
This commit is contained in:
@@ -149,8 +149,8 @@ public class FoafBase {
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LifecycleUtils.getCurrentActivity().runOnUiThread(() -> makeText(getGlobalContext(), context.getString(R.string.foaferr), LENGTH_SHORT).show());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,11 +59,6 @@ public class CryptImHook {
|
||||
IMProcessor finalEnabled = enabled;
|
||||
Activity ctx = getCurrentActivity();
|
||||
|
||||
if (ctx == null) {
|
||||
sendToast(AndroidUtils.getString(R.string.app_activities_error));
|
||||
return;
|
||||
}
|
||||
|
||||
new VkAlertDialog.Builder(ctx)
|
||||
.setTitle(AndroidUtils.getString(R.string.encryption_sett))
|
||||
.setSingleChoiceItems(titles, enabledPosition, (dialog, which) -> {
|
||||
@@ -111,11 +106,6 @@ public class CryptImHook {
|
||||
|
||||
Context ctx = getCurrentActivity();
|
||||
|
||||
if (ctx == null) {
|
||||
sendToast(ctx.getString(R.string.app_activities_error));
|
||||
return;
|
||||
}
|
||||
|
||||
LinearLayout linearLayout = new LinearLayout(ctx);
|
||||
|
||||
final EditText editText = new EditText(ctx);
|
||||
|
||||
@@ -94,7 +94,7 @@ public class ServerDialog {
|
||||
showAlert = true;
|
||||
|
||||
var activity = LifecycleUtils.getCurrentActivity();
|
||||
if (activity != null && getBoolValue(key, true) && showForNotVerified() && showAlert) {
|
||||
if (getBoolValue(key, true) && showForNotVerified() && showAlert) {
|
||||
activity.runOnUiThread(() -> {
|
||||
new VkAlertDialog.Builder(activity)
|
||||
.setTitle(title)
|
||||
|
||||
@@ -60,7 +60,7 @@ public class AndroidUtils {
|
||||
} catch (Exception e) {
|
||||
Log.d("GlobalContext", "Error while fetching context via refl");
|
||||
}
|
||||
return Objects.requireNonNull(LifecycleUtils.getCurrentActivity());
|
||||
return LifecycleUtils.getCurrentActivity();
|
||||
} // Getting the global context through reflection to use context on application initialization
|
||||
|
||||
public static Resources getResources() {
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.os.Handler;
|
||||
|
||||
import com.vk.core.fragments.FragmentImpl;
|
||||
import com.vk.navigation.Navigator;
|
||||
import com.vtosters.lite.MainActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -54,7 +55,7 @@ public class LifecycleUtils {
|
||||
}
|
||||
|
||||
public static Activity getCurrentActivity() {
|
||||
return activities.size() > 0 ? activities.get(activities.size() - 1) : null;
|
||||
return activities.size() > 0 ? activities.get(activities.size() - 1) : new MainActivity();
|
||||
}
|
||||
|
||||
public static void restartApplication() {
|
||||
@@ -72,12 +73,4 @@ public class LifecycleUtils {
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(LifecycleUtils::restartApplication, 500);
|
||||
}
|
||||
|
||||
public static void restartApplicationInto(Class< ? extends FragmentImpl> clz) {
|
||||
Context ctx = AndroidUtils.getGlobalContext();
|
||||
|
||||
NavigatorUtils.switchFragment(AndroidUtils.getGlobalContext(), clz);
|
||||
|
||||
Runtime.getRuntime().exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,15 +39,10 @@ import static ru.vtosters.lite.utils.Preferences.*;
|
||||
|
||||
public class ThemesUtils {
|
||||
public static void applyTheme(VKTheme theme) {
|
||||
var currentActivity = LifecycleUtils.getCurrentActivity();
|
||||
if (currentActivity != null) {
|
||||
try {
|
||||
VKThemeHelper.theme(theme, currentActivity, getCenterScreenCoords());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Log.d("ThemesUtils", "Null activity lol");
|
||||
try {
|
||||
VKThemeHelper.theme(theme, LifecycleUtils.getCurrentActivity(), getCenterScreenCoords());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} // Apply VKTheme and ImTheme (hard applying without dynamic theme changing)
|
||||
|
||||
@@ -66,8 +61,6 @@ public class ThemesUtils {
|
||||
public static void setTheme(VKTheme theme, Activity activity) {
|
||||
if (activity == null) {
|
||||
activity = LifecycleUtils.getCurrentActivity();
|
||||
|
||||
if (activity == null) return;
|
||||
}
|
||||
VKThemeHelper.theme(theme, activity, getCenterScreenCoords());
|
||||
ThemeTracker.a();
|
||||
@@ -79,8 +72,6 @@ public class ThemesUtils {
|
||||
public static void setThemeFL(VKTheme theme, Activity activity, float[] fl) {
|
||||
if (activity == null) {
|
||||
activity = LifecycleUtils.getCurrentActivity();
|
||||
|
||||
if (activity == null) return;
|
||||
}
|
||||
VKThemeHelper.theme(theme, activity, fl);
|
||||
ThemeTracker.a();
|
||||
|
||||
Reference in New Issue
Block a user