Utilize BundleCompat and IntentCompat methods

This commit is contained in:
TacoTheDank 2023-10-31 16:35:56 -04:00 committed by Stypox
parent f3b458c803
commit 76f1e588f7
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
4 changed files with 9 additions and 4 deletions

View File

@ -17,6 +17,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.IntentCompat;
import com.grack.nanojson.JsonWriter; import com.grack.nanojson.JsonWriter;
@ -105,7 +106,7 @@ public class ErrorActivity extends AppCompatActivity {
actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowTitleEnabled(true);
} }
errorInfo = intent.getParcelableExtra(ERROR_INFO); errorInfo = IntentCompat.getParcelableExtra(intent, ERROR_INFO, ErrorInfo.class);
// important add guru meditation // important add guru meditation
addGuruMeditation(); addGuruMeditation();

View File

@ -25,6 +25,7 @@ import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.util.Log; import android.util.Log;
import androidx.core.content.IntentCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.reactivestreams.Subscriber; import org.reactivestreams.Subscriber;
@ -65,7 +66,7 @@ public class SubscriptionsExportService extends BaseImportExportService {
return START_NOT_STICKY; return START_NOT_STICKY;
} }
final Uri path = intent.getParcelableExtra(KEY_FILE_PATH); final Uri path = IntentCompat.getParcelableExtra(intent, KEY_FILE_PATH, Uri.class);
if (path == null) { if (path == null) {
stopAndReportError(new IllegalStateException( stopAndReportError(new IllegalStateException(
"Exporting to a file, but the path is null"), "Exporting to a file, but the path is null"),

View File

@ -30,6 +30,7 @@ import android.util.Pair;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.content.IntentCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.reactivestreams.Subscriber; import org.reactivestreams.Subscriber;
@ -108,7 +109,7 @@ public class SubscriptionsImportService extends BaseImportExportService {
if (currentMode == CHANNEL_URL_MODE) { if (currentMode == CHANNEL_URL_MODE) {
channelUrl = intent.getStringExtra(KEY_VALUE); channelUrl = intent.getStringExtra(KEY_VALUE);
} else { } else {
final Uri uri = intent.getParcelableExtra(KEY_VALUE); final Uri uri = IntentCompat.getParcelableExtra(intent, KEY_VALUE, Uri.class);
if (uri == null) { if (uri == null) {
stopAndReportError(new IllegalStateException( stopAndReportError(new IllegalStateException(
"Importing from input stream, but file path is null"), "Importing from input stream, but file path is null"),

View File

@ -27,6 +27,7 @@ import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.os.BundleCompat;
import org.schabi.newpipe.BuildConfig; import org.schabi.newpipe.BuildConfig;
import org.schabi.newpipe.MainActivity; import org.schabi.newpipe.MainActivity;
@ -82,7 +83,8 @@ public final class StateSaver {
return null; return null;
} }
final SavedState savedState = outState.getParcelable(KEY_SAVED_STATE); final SavedState savedState = BundleCompat.getParcelable(
outState, KEY_SAVED_STATE, SavedState.class);
if (savedState == null) { if (savedState == null) {
return null; return null;
} }