# HG changeset patch # User Da Risk # Date 1739985466 14400 # Node ID 599cbb8782df1280ecbb41ca743f672151f82007 # Parent 5de92f006da73490af0d5afc3f3968c338a51c05 geekdroid: remove deprecated ObjectCursorLoader diff -r 5de92f006da7 -r 599cbb8782df geekdroid/src/main/java/com/geekorum/geekdroid/loaders/ObjectCursorLoader.java --- a/geekdroid/src/main/java/com/geekorum/geekdroid/loaders/ObjectCursorLoader.java Wed Feb 19 13:17:30 2025 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* - * Geekdroid is a utility library for development on the Android - * Platform. - * - * Copyright (C) 2017-2025 by Frederic-Charles Barthelery. - * - * This file is part of Geekdroid. - * - * Geekdroid is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Geekdroid is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Geekdroid. If not, see . - */ -package com.geekorum.geekdroid.loaders; - -import android.content.Context; -import android.database.Cursor; -import android.net.Uri; -import androidx.loader.content.CursorLoader; - -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -/** - * A {@link CursorLoader} that can load data from a cursor and map it into an Object instance. - * @deprecated Use coroutines to load data asynchronously - */ -@Deprecated(forRemoval = true) -public class ObjectCursorLoader extends CursorLoader { - - private final CursorMapper cursorMapper; - private List items = Collections.emptyList(); - - public ObjectCursorLoader(Context context, CursorMapper cursorMapper) { - super(context); - this.cursorMapper = cursorMapper; - } - - public ObjectCursorLoader(Context context, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CursorMapper cursorMapper) { - super(context, uri, projection, selection, selectionArgs, sortOrder); - this.cursorMapper = cursorMapper; - } - - @Override - public Cursor loadInBackground() { - Cursor result; - result = super.loadInBackground(); - loadItems(result); - return result; - } - - private void loadItems(Cursor cursor) { - List newItems = new LinkedList<>(); - while (cursor.moveToNext()) { - newItems.add(cursorMapper.map(cursor)); - } - this.items = newItems; - } - - /** - * Get the loaded items - * @return the items - */ - public List getItems() { - return items; - } - - public interface CursorMapper { - T map(Cursor cursor); - } - -}