Fix a crash

This commit is contained in:
Thomas 2023-12-17 17:41:17 +01:00
parent 3148d5f9b2
commit 5b805ca9a9
13 changed files with 64 additions and 17 deletions

View file

@ -193,7 +193,11 @@ public abstract class PeertubeBaseMainActivity extends BaseActivity implements C
super.onDestroy(); super.onDestroy();
ChromeCasts.unregisterListener(this); ChromeCasts.unregisterListener(this);
if (manage_chromecast != null) { if (manage_chromecast != null) {
unregisterReceiver(manage_chromecast); try {
unregisterReceiver(manage_chromecast);
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
new Thread(() -> { new Thread(() -> {
if (chromeCasts != null && chromeCasts.size() > 0) { if (chromeCasts != null && chromeCasts.size() > 0) {
for (ChromeCast cast : chromeCasts) { for (ChromeCast cast : chromeCasts) {

View file

@ -1859,9 +1859,12 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
@Override @Override
protected void onDestroy() { protected void onDestroy() {
unregisterReceiver(broadcast_data); try {
unregisterReceiver(broadcast_error_message); unregisterReceiver(broadcast_data);
unregisterReceiver(broadcast_error_message);
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
if (networkStateReceiver != null) { if (networkStateReceiver != null) {
try { try {
unregisterReceiver(networkStateReceiver); unregisterReceiver(networkStateReceiver);

View file

@ -195,8 +195,11 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
if (timer != null) { if (timer != null) {
timer.cancel(); timer.cancel();
} }
unregisterReceiver(imageReceiver); try {
unregisterReceiver(imageReceiver);
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
} }

View file

@ -367,7 +367,11 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
@Override @Override
public void onDestroy() { public void onDestroy() {
unregisterReceiver(onDownloadComplete); try {
unregisterReceiver(onDownloadComplete);
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
super.onDestroy(); super.onDestroy();
} }

View file

@ -1260,7 +1260,11 @@ public class ProfileActivity extends BaseActivity {
scheduledExecutorService.shutdownNow(); scheduledExecutorService.shutdownNow();
scheduledExecutorService = null; scheduledExecutorService = null;
} }
unregisterReceiver(broadcast_data); try {
unregisterReceiver(broadcast_data);
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
super.onDestroy(); super.onDestroy();
} }

View file

@ -340,7 +340,11 @@ public class AdminActionActivity extends BaseBarActivity {
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
if (mReceiver != null) { if (mReceiver != null) {
unregisterReceiver(mReceiver); try {
unregisterReceiver(mReceiver);
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
} }
} }

View file

@ -295,7 +295,11 @@ public class FragmentMastodonContext extends Fragment {
@Override @Override
public void onDestroyView() { public void onDestroyView() {
requireActivity().unregisterReceiver(receive_action); try {
requireActivity().unregisterReceiver(receive_action);
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
super.onDestroyView(); super.onDestroyView();
} }

View file

@ -272,7 +272,11 @@ public class FragmentMastodonDirectMessage extends Fragment {
@Override @Override
public void onDestroyView() { public void onDestroyView() {
requireActivity().unregisterReceiver(broadcast_data); try {
requireActivity().unregisterReceiver(broadcast_data);
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
super.onDestroyView(); super.onDestroyView();
} }

View file

@ -675,8 +675,13 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
@Override @Override
public void onDestroyView() { public void onDestroyView() {
requireActivity().unregisterReceiver(receive_action);
requireActivity().unregisterReceiver(receive_refresh); try {
requireActivity().unregisterReceiver(receive_action);
requireActivity().unregisterReceiver(receive_refresh);
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
if (isAdded()) { if (isAdded()) {
storeMarker(); storeMarker();
} }

View file

@ -1596,7 +1596,11 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
private void unregisterReceiver() { private void unregisterReceiver() {
if (mPowerKeyReceiver != null) { if (mPowerKeyReceiver != null) {
unregisterReceiver(mPowerKeyReceiver); try {
unregisterReceiver(mPowerKeyReceiver);
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
mPowerKeyReceiver = null; mPowerKeyReceiver = null;
} }
} }

View file

@ -153,7 +153,11 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity {
if (!keepRemote) { if (!keepRemote) {
typeOfConnection = TypeOfConnection.NORMAL; typeOfConnection = TypeOfConnection.NORMAL;
} }
unregisterReceiver(broadcast_data); try {
unregisterReceiver(broadcast_data);
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
} }
@SuppressLint("ApplySharedPref") @SuppressLint("ApplySharedPref")

View file

@ -125,7 +125,11 @@ public class RetrieveInfoService extends Service implements NetworkStateReceiver
super.onDestroy(); super.onDestroy();
if (networkStateReceiver != null) { if (networkStateReceiver != null) {
networkStateReceiver.removeListener(this); networkStateReceiver.removeListener(this);
unregisterReceiver(networkStateReceiver); try {
unregisterReceiver(networkStateReceiver);
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
} }
} }

View file

@ -1,7 +1,7 @@
Added: Added:
- Android 14 support - Android 14 support
- Automatically split long messages in threads (default: ASK) - Automatically split long messages in threads (default: ASK)
- Links and media are clickable when composing - Links and media are clicka ble when composing
Fixed: Fixed:
- Avoid error 429 with NTFY - Avoid error 429 with NTFY