android: Switch to Loaders from the support library

They are officially deprecated as of API 28 (recommended replacement is
a combination of ViewModels and LiveData, maybe something to look into
later).
This commit is contained in:
Tobias Brunner
2019-08-26 11:20:48 +02:00
parent ef57913d37
commit d59158df7b
3 changed files with 10 additions and 9 deletions
@@ -74,7 +74,7 @@ public class SelectedApplicationsListFragment extends ListFragment implements Lo
}
mSelection = new TreeSet<>(selection);
getLoaderManager().initLoader(0, null, this);
LoaderManager.getInstance(this).initLoader(0, null, this);
}
@Override
@@ -18,6 +18,7 @@ package org.strongswan.android.ui;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.AsyncTaskLoader;
import android.support.v4.content.Loader;
@@ -79,7 +80,7 @@ public class TrustedCertificateListFragment extends ListFragment implements Load
mSource = (TrustedCertificateSource)arguments.getSerializable(EXTRA_CERTIFICATE_SOURCE);
}
getLoaderManager().initLoader(0, null, this);
LoaderManager.getInstance(this).initLoader(0, null, this);
}
@Override
@@ -16,19 +16,19 @@
package org.strongswan.android.ui;
import android.app.Activity;
import android.app.LoaderManager;
import android.content.ActivityNotFoundException;
import android.content.AsyncTaskLoader;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.Loader;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.security.KeyChain;
import android.security.KeyChainAliasCallback;
import android.security.KeyChainException;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.AsyncTaskLoader;
import android.support.v4.content.Loader;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
@@ -229,7 +229,7 @@ public class VpnProfileImportActivity extends AppCompatActivity
mUserCertLoading = savedInstanceState.getString(VpnProfileDataSource.KEY_USER_CERTIFICATE);
if (mUserCertLoading != null)
{
getLoaderManager().initLoader(USER_CERT_LOADER, null, mUserCertificateLoaderCallbacks);
LoaderManager.getInstance(this).initLoader(USER_CERT_LOADER, null, mUserCertificateLoaderCallbacks);
}
mImportUserCert.setEnabled(!savedInstanceState.getBoolean(PKCS12_INSTALLED));
}
@@ -312,7 +312,7 @@ public class VpnProfileImportActivity extends AppCompatActivity
Bundle args = new Bundle();
args.putParcelable(PROFILE_URI, uri);
getLoaderManager().initLoader(PROFILE_LOADER, args, mProfileLoaderCallbacks);
LoaderManager.getInstance(this).initLoader(PROFILE_LOADER, args, mProfileLoaderCallbacks);
}
public void handleProfile(ProfileLoadResult data)
@@ -400,7 +400,7 @@ public class VpnProfileImportActivity extends AppCompatActivity
if (mUserCertLoading == null)
{
mUserCertLoading = getString(R.string.profile_cert_alias, mProfile.getName());
getLoaderManager().initLoader(USER_CERT_LOADER, null, mUserCertificateLoaderCallbacks);
LoaderManager.getInstance(this).initLoader(USER_CERT_LOADER, null, mUserCertificateLoaderCallbacks);
}
updateUserCertView();
}
@@ -902,7 +902,7 @@ public class VpnProfileImportActivity extends AppCompatActivity
updateUserCertView();
if (alias != null)
{ /* otherwise the dialog was canceled, the request denied */
getLoaderManager().restartLoader(USER_CERT_LOADER, null, mUserCertificateLoaderCallbacks);
LoaderManager.getInstance(VpnProfileImportActivity.this).restartLoader(USER_CERT_LOADER, null, mUserCertificateLoaderCallbacks);
}
}
});