[android] Fix ClassNotFoundException .bookmarks.data.BookmarkCategory

Regression by 4cadc09

Related to #143 and #3757
Closes #6629

Signed-off-by: Roman Tsisyk <roman@tsisyk.com>
This commit is contained in:
Roman Tsisyk 2023-11-22 07:54:20 +02:00
parent fa854b34e3
commit 9696a83ec3
7 changed files with 20 additions and 17 deletions

View file

@ -12,12 +12,12 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.os.BundleCompat;
import app.organicmaps.R;
import app.organicmaps.base.BaseMwmToolbarFragment;
import app.organicmaps.bookmarks.data.BookmarkCategory;
import app.organicmaps.bookmarks.data.BookmarkManager;
import app.organicmaps.util.Utils;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.textfield.TextInputEditText;
@ -45,7 +45,7 @@ public class BookmarkCategorySettingsFragment extends BaseMwmToolbarFragment
{
super.onCreate(savedInstanceState);
final Bundle args = requireArguments();
mCategory = Objects.requireNonNull(BundleCompat.getParcelable(args,
mCategory = Objects.requireNonNull(Utils.getParcelable(args,
BookmarkCategorySettingsActivity.EXTRA_BOOKMARK_CATEGORY, BookmarkCategory.class));
}

View file

@ -1,7 +1,5 @@
package app.organicmaps.bookmarks;
import static app.organicmaps.bookmarks.BookmarksListFragment.EXTRA_BUNDLE;
import android.content.Intent;
import android.os.Bundle;
@ -62,9 +60,8 @@ public class BookmarkListActivity extends BaseToolbarActivity
static void startForResult(@NonNull Fragment fragment, @NonNull BookmarkCategory category)
{
Bundle args = new Bundle();
args.putParcelable(BookmarksListFragment.EXTRA_CATEGORY, category);
Intent intent = new Intent(fragment.requireActivity(), BookmarkListActivity.class);
intent.putExtra(EXTRA_BUNDLE, args);
intent.putExtra(BookmarksListFragment.EXTRA_CATEGORY, category);
fragment.startActivityForResult(intent, BookmarkCategoriesFragment.REQ_CODE_DELETE_CATEGORY);
}
}

View file

@ -16,7 +16,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.os.BundleCompat;
import androidx.recyclerview.widget.ConcatAdapter;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;
@ -36,6 +35,7 @@ import app.organicmaps.intent.Factory;
import app.organicmaps.location.LocationHelper;
import app.organicmaps.search.NativeBookmarkSearchListener;
import app.organicmaps.search.SearchEngine;
import app.organicmaps.util.Utils;
import app.organicmaps.widget.SearchToolbarController;
import app.organicmaps.widget.placepage.EditBookmarkFragment;
import app.organicmaps.widget.recycler.DividerItemDecorationWithPadding;
@ -58,7 +58,6 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<ConcatAdapter
{
public static final String TAG = BookmarksListFragment.class.getSimpleName();
public static final String EXTRA_CATEGORY = "bookmark_category";
public static final String EXTRA_BUNDLE = "bookmark_bundle";
private static final int INDEX_BOOKMARKS_COLLECTION_ADAPTER = 0;
private static final int INDEX_BOOKMARKS_LIST_ADAPTER = 1;
private static final String BOOKMARKS_MENU_ID = "BOOKMARKS_MENU_BOTTOM_SHEET";
@ -109,8 +108,7 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<ConcatAdapter
private BookmarkCategory getCategoryOrThrow()
{
final Bundle args = requireArguments();
final Bundle extra = Objects.requireNonNull(args.getBundle(EXTRA_BUNDLE));
return Objects.requireNonNull(BundleCompat.getParcelable(extra, EXTRA_CATEGORY, BookmarkCategory.class));
return Objects.requireNonNull(Utils.getParcelable(args, EXTRA_CATEGORY, BookmarkCategory.class));
}
@NonNull

View file

@ -8,7 +8,6 @@ import android.view.ViewGroup;
import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.os.BundleCompat;
import app.organicmaps.R;
import app.organicmaps.base.BaseMwmRecyclerFragment;
@ -45,7 +44,7 @@ public class FeatureCategoryFragment extends BaseMwmRecyclerFragment<FeatureCate
final Bundle args = getArguments();
if (args != null)
{
mSelectedCategory = BundleCompat.getParcelable(args, FeatureCategoryActivity.EXTRA_FEATURE_CATEGORY,
mSelectedCategory = Utils.getParcelable(args, FeatureCategoryActivity.EXTRA_FEATURE_CATEGORY,
FeatureCategory.class);
}
mToolbarController = new SearchToolbarController(view, requireActivity())

View file

@ -17,7 +17,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.StyleRes;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.os.BundleCompat;
import androidx.fragment.app.FragmentManager;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
@ -27,6 +26,7 @@ import app.organicmaps.base.BaseMwmDialogFragment;
import app.organicmaps.editor.data.HoursMinutes;
import app.organicmaps.util.DateUtils;
import app.organicmaps.util.ThemeUtils;
import app.organicmaps.util.Utils;
public class HoursMinutesPickerFragment extends BaseMwmDialogFragment
{
@ -115,8 +115,8 @@ public class HoursMinutesPickerFragment extends BaseMwmDialogFragment
final Bundle args = getArguments();
if (args == null)
throw new IllegalArgumentException("Args must not be null");
mFrom = BundleCompat.getParcelable(args, EXTRA_FROM, HoursMinutes.class);
mTo = BundleCompat.getParcelable(args, EXTRA_TO, HoursMinutes.class);
mFrom = Utils.getParcelable(args, EXTRA_FROM, HoursMinutes.class);
mTo = Utils.getParcelable(args, EXTRA_TO, HoursMinutes.class);
mSelectedTab = args.getInt(EXTRA_SELECT_FIRST);
mId = args.getInt(EXTRA_ID);
}

View file

@ -13,6 +13,7 @@ import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
@ -33,6 +34,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.core.app.NavUtils;
import androidx.core.os.BundleCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
@ -722,6 +724,13 @@ public class Utils
}
}
public static <T> T getParcelable(@NonNull Bundle in, @Nullable String key,
@NonNull Class<T> clazz)
{
in.setClassLoader(clazz.getClassLoader());
return BundleCompat.getParcelable(in, key, clazz);
}
@SuppressWarnings("deprecation")
private static Spanned fromHtmlOld(@NonNull String htmlDescription)
{

View file

@ -10,7 +10,6 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.os.BundleCompat;
import app.organicmaps.Framework;
import app.organicmaps.R;
@ -21,6 +20,7 @@ import app.organicmaps.location.LocationHelper;
import app.organicmaps.location.LocationListener;
import app.organicmaps.location.SensorHelper;
import app.organicmaps.location.SensorListener;
import app.organicmaps.util.Utils;
import app.organicmaps.widget.ArrowView;
import app.organicmaps.util.UiUtils;
@ -52,7 +52,7 @@ public class DirectionFragment extends BaseMwmDialogFragment
});
initViews(root);
if (savedInstanceState != null)
setMapObject(BundleCompat.getParcelable(savedInstanceState, EXTRA_MAP_OBJECT, MapObject.class));
setMapObject(Utils.getParcelable(savedInstanceState, EXTRA_MAP_OBJECT, MapObject.class));
return root;
}