Merge branch 'issue-490' into 'master'

Fix Cursor initialization deprecation

Closes Issue #490, Avoids usage of `deprecated` constructors and suppresses deprecation warnings.

See merge request !242
This commit is contained in:
Daniel Martí 2016-04-14 13:58:10 +00:00
commit 44f39793be
9 changed files with 50 additions and 12 deletions

View File

@ -22,6 +22,7 @@ public abstract class AppListAdapter extends CursorAdapter {
private DisplayImageOptions displayImageOptions; private DisplayImageOptions displayImageOptions;
private String upgradeFromTo; private String upgradeFromTo;
@SuppressWarnings("deprecation")
public AppListAdapter(Context context, Cursor c) { public AppListAdapter(Context context, Cursor c) {
super(context, c); super(context, c);
init(context); init(context);

View File

@ -2,10 +2,19 @@ package org.fdroid.fdroid.views;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.os.Build;
public class AvailableAppListAdapter extends AppListAdapter { public class AvailableAppListAdapter extends AppListAdapter {
public AvailableAppListAdapter(Context context, Cursor c) { public static AvailableAppListAdapter create(Context context, Cursor cursor, int flags) {
if (Build.VERSION.SDK_INT >= 11) {
return new AvailableAppListAdapter(context, cursor, flags);
} else {
return new AvailableAppListAdapter(context, cursor);
}
}
private AvailableAppListAdapter(Context context, Cursor c) {
super(context, c); super(context, c);
} }
@ -13,7 +22,7 @@ public class AvailableAppListAdapter extends AppListAdapter {
super(context, c, autoRequery); super(context, c, autoRequery);
} }
public AvailableAppListAdapter(Context context, Cursor c, int flags) { private AvailableAppListAdapter(Context context, Cursor c, int flags) {
super(context, c, flags); super(context, c, flags);
} }

View File

@ -2,10 +2,19 @@ package org.fdroid.fdroid.views;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.os.Build;
public class CanUpdateAppListAdapter extends AppListAdapter { public class CanUpdateAppListAdapter extends AppListAdapter {
public CanUpdateAppListAdapter(Context context, Cursor c) { public static CanUpdateAppListAdapter create(Context context, Cursor cursor, int flags) {
if (Build.VERSION.SDK_INT >= 11) {
return new CanUpdateAppListAdapter(context, cursor, flags);
} else {
return new CanUpdateAppListAdapter(context, cursor);
}
}
private CanUpdateAppListAdapter(Context context, Cursor c) {
super(context, c); super(context, c);
} }
@ -13,7 +22,7 @@ public class CanUpdateAppListAdapter extends AppListAdapter {
super(context, c, autoRequery); super(context, c, autoRequery);
} }
public CanUpdateAppListAdapter(Context context, Cursor c, int flags) { private CanUpdateAppListAdapter(Context context, Cursor c, int flags) {
super(context, c, flags); super(context, c, flags);
} }

View File

@ -2,10 +2,19 @@ package org.fdroid.fdroid.views;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.os.Build;
public class InstalledAppListAdapter extends AppListAdapter { public class InstalledAppListAdapter extends AppListAdapter {
public InstalledAppListAdapter(Context context, Cursor c) { public static InstalledAppListAdapter create(Context context, Cursor cursor, int flags) {
if (Build.VERSION.SDK_INT >= 11) {
return new InstalledAppListAdapter(context, cursor, flags);
} else {
return new InstalledAppListAdapter(context, cursor);
}
}
private InstalledAppListAdapter(Context context, Cursor c) {
super(context, c); super(context, c);
} }
@ -13,7 +22,7 @@ public class InstalledAppListAdapter extends AppListAdapter {
super(context, c, autoRequery); super(context, c, autoRequery);
} }
public InstalledAppListAdapter(Context context, Cursor c, int flags) { private InstalledAppListAdapter(Context context, Cursor c, int flags) {
super(context, c, flags); super(context, c, flags);
} }

View File

@ -767,7 +767,7 @@ public class ManageReposActivity extends ActionBarActivity {
setRetainInstance(true); setRetainInstance(true);
setHasOptionsMenu(true); setHasOptionsMenu(true);
repoAdapter = new RepoAdapter(getActivity(), null); repoAdapter = RepoAdapter.create(getActivity(), null, 0);
repoAdapter.setEnabledListener(this); repoAdapter.setEnabledListener(this);
setListAdapter(repoAdapter); setListAdapter(repoAdapter);
} }

View File

@ -2,6 +2,7 @@ package org.fdroid.fdroid.views;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.os.Build;
import android.support.v4.widget.CursorAdapter; import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -22,7 +23,15 @@ public class RepoAdapter extends CursorAdapter {
private EnabledListener enabledListener; private EnabledListener enabledListener;
public RepoAdapter(Context context, Cursor c, int flags) { public static RepoAdapter create(Context context, Cursor cursor, int flags) {
if (Build.VERSION.SDK_INT >= 11) {
return new RepoAdapter(context, cursor, flags);
} else {
return new RepoAdapter(context, cursor);
}
}
private RepoAdapter(Context context, Cursor c, int flags) {
super(context, c, flags); super(context, c, flags);
inflater = LayoutInflater.from(context); inflater = LayoutInflater.from(context);
} }
@ -32,7 +41,8 @@ public class RepoAdapter extends CursorAdapter {
inflater = LayoutInflater.from(context); inflater = LayoutInflater.from(context);
} }
public RepoAdapter(Context context, Cursor c) { @SuppressWarnings("deprecation")
private RepoAdapter(Context context, Cursor c) {
super(context, c); super(context, c);
inflater = LayoutInflater.from(context); inflater = LayoutInflater.from(context);
} }

View File

@ -59,7 +59,7 @@ public class AvailableAppsFragment extends AppListFragment implements
@Override @Override
protected AppListAdapter getAppListAdapter() { protected AppListAdapter getAppListAdapter() {
if (adapter == null) { if (adapter == null) {
final AppListAdapter a = new AvailableAppListAdapter(getActivity(), null); final AppListAdapter a = AvailableAppListAdapter.create(getActivity(), null, 0);
Preferences.get().registerUpdateHistoryListener(new Preferences.ChangeListener() { Preferences.get().registerUpdateHistoryListener(new Preferences.ChangeListener() {
@Override @Override
public void onPreferenceChange() { public void onPreferenceChange() {

View File

@ -15,7 +15,7 @@ public class CanUpdateAppsFragment extends AppListFragment {
@Override @Override
protected AppListAdapter getAppListAdapter() { protected AppListAdapter getAppListAdapter() {
return new CanUpdateAppListAdapter(getActivity(), null); return CanUpdateAppListAdapter.create(getActivity(), null, 0);
} }
@Override @Override

View File

@ -15,7 +15,7 @@ public class InstalledAppsFragment extends AppListFragment {
@Override @Override
protected AppListAdapter getAppListAdapter() { protected AppListAdapter getAppListAdapter() {
return new InstalledAppListAdapter(getActivity(), null); return InstalledAppListAdapter.create(getActivity(), null, 0);
} }
@Override @Override