mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Fix a crash
This commit is contained in:
parent
8103bf4a16
commit
96abece6da
4 changed files with 21 additions and 3 deletions
|
@ -96,7 +96,7 @@ public class FragmentMedia extends Fragment {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
canSwipe = (binding.mediaPicture.getScale() == 1);
|
canSwipe = (binding.mediaPicture.getScale() == 1);
|
||||||
if (!canSwipe && !requireActivity().isFinishing() && isAdded()) {
|
if (!canSwipe && isAdded() && !requireActivity().isFinishing()) {
|
||||||
if (!((MediaActivity) requireActivity()).getFullScreen()) {
|
if (!((MediaActivity) requireActivity()).getFullScreen()) {
|
||||||
((MediaActivity) requireActivity()).setFullscreen(true);
|
((MediaActivity) requireActivity()).setFullscreen(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class FragmentMediaProfile extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void federatedAccount(Account account) {
|
public void federatedAccount(Account account) {
|
||||||
if (account != null && !requireActivity().isFinishing() && isAdded()) {
|
if (account != null && isAdded() && !requireActivity().isFinishing()) {
|
||||||
accountId = account.id;
|
accountId = account.id;
|
||||||
accountsVM.getAccountStatuses(tempInstance, null, accountId, null, null, null, null, null, true, false, MastodonHelper.statusesPerCall(requireActivity()))
|
accountsVM.getAccountStatuses(tempInstance, null, accountId, null, null, null, null, null, true, false, MastodonHelper.statusesPerCall(requireActivity()))
|
||||||
.observe(getViewLifecycleOwner(), statuses -> initializeStatusesCommonView(statuses));
|
.observe(getViewLifecycleOwner(), statuses -> initializeStatusesCommonView(statuses));
|
||||||
|
|
|
@ -1067,7 +1067,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void federatedAccount(Account account) {
|
public void federatedAccount(Account account) {
|
||||||
if (account != null && !requireActivity().isFinishing() && isAdded()) {
|
if (account != null && isAdded() && !requireActivity().isFinishing()) {
|
||||||
accountIDInRemoteInstance = account.id;
|
accountIDInRemoteInstance = account.id;
|
||||||
accountsVM.getAccountStatuses(tempInstance, null, accountIDInRemoteInstance, null, null, null, null, null, false, true, MastodonHelper.statusesPerCall(requireActivity()))
|
accountsVM.getAccountStatuses(tempInstance, null, accountIDInRemoteInstance, null, null, null, null, null, false, true, MastodonHelper.statusesPerCall(requireActivity()))
|
||||||
.observe(getViewLifecycleOwner(), pinnedStatuses -> accountsVM.getAccountStatuses(tempInstance, null, accountIDInRemoteInstance, null, null, null, exclude_replies, exclude_reblogs, media_only, false, MastodonHelper.statusesPerCall(requireActivity()))
|
.observe(getViewLifecycleOwner(), pinnedStatuses -> accountsVM.getAccountStatuses(tempInstance, null, accountIDInRemoteInstance, null, null, null, exclude_replies, exclude_reblogs, media_only, false, MastodonHelper.statusesPerCall(requireActivity()))
|
||||||
|
|
|
@ -2,6 +2,7 @@ package de.timfreiheit.mathjax.android;
|
||||||
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
@ -90,6 +91,17 @@ public class MathJaxView extends FrameLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getProcessName(Context context) {
|
||||||
|
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
|
for (ActivityManager.RunningAppProcessInfo processInfo : manager.getRunningAppProcesses()) {
|
||||||
|
if (processInfo.pid == android.os.Process.myPid()) {
|
||||||
|
return processInfo.processName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
|
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
|
||||||
private void init(Context context, AttributeSet attrSet, MathJaxConfig config) {
|
private void init(Context context, AttributeSet attrSet, MathJaxConfig config) {
|
||||||
mWebView = new WebView(context);
|
mWebView = new WebView(context);
|
||||||
|
@ -155,6 +167,12 @@ public class MathJaxView extends FrameLayout {
|
||||||
mWebView.setHorizontalScrollBarEnabled(horizontalScrollbarsEnabled);
|
mWebView.setHorizontalScrollBarEnabled(horizontalScrollbarsEnabled);
|
||||||
mWebView.setBackgroundColor(0);
|
mWebView.setBackgroundColor(0);
|
||||||
mWebView.getSettings().setLoadWithOverviewMode(true);
|
mWebView.getSettings().setLoadWithOverviewMode(true);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
String process = getProcessName(context);
|
||||||
|
if (!context.getPackageName().equals(process))
|
||||||
|
WebView.setDataDirectorySuffix(process);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue