List fragment for trusted certificates can notify listeners about clicks
This commit is contained in:
+31
@@ -27,18 +27,29 @@ import org.strongswan.android.data.TrustedCertificateEntry;
|
|||||||
import org.strongswan.android.logic.TrustedCertificateManager;
|
import org.strongswan.android.logic.TrustedCertificateManager;
|
||||||
import org.strongswan.android.ui.adapter.TrustedCertificateAdapter;
|
import org.strongswan.android.ui.adapter.TrustedCertificateAdapter;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.ListFragment;
|
import android.app.ListFragment;
|
||||||
import android.app.LoaderManager.LoaderCallbacks;
|
import android.app.LoaderManager.LoaderCallbacks;
|
||||||
import android.content.AsyncTaskLoader;
|
import android.content.AsyncTaskLoader;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Loader;
|
import android.content.Loader;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ListView;
|
||||||
|
|
||||||
public class TrustedCertificateListFragment extends ListFragment implements LoaderCallbacks<List<TrustedCertificateEntry>>
|
public class TrustedCertificateListFragment extends ListFragment implements LoaderCallbacks<List<TrustedCertificateEntry>>
|
||||||
{
|
{
|
||||||
|
private OnTrustedCertificateSelectedListener mListener;
|
||||||
private TrustedCertificateAdapter mAdapter;
|
private TrustedCertificateAdapter mAdapter;
|
||||||
private boolean mUser;
|
private boolean mUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The activity containing this fragment should implement this interface
|
||||||
|
*/
|
||||||
|
public interface OnTrustedCertificateSelectedListener {
|
||||||
|
public void onTrustedCertificateSelected(TrustedCertificateEntry selected);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState)
|
public void onActivityCreated(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
@@ -63,6 +74,17 @@ public class TrustedCertificateListFragment extends ListFragment implements Load
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Activity activity)
|
||||||
|
{
|
||||||
|
super.onAttach(activity);
|
||||||
|
|
||||||
|
if (activity instanceof OnTrustedCertificateSelectedListener)
|
||||||
|
{
|
||||||
|
mListener = (OnTrustedCertificateSelectedListener)activity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Loader<List<TrustedCertificateEntry>> onCreateLoader(int id, Bundle args)
|
public Loader<List<TrustedCertificateEntry>> onCreateLoader(int id, Bundle args)
|
||||||
{ /* we don't need the id as we have only one loader */
|
{ /* we don't need the id as we have only one loader */
|
||||||
@@ -90,6 +112,15 @@ public class TrustedCertificateListFragment extends ListFragment implements Load
|
|||||||
mAdapter.setData(null);
|
mAdapter.setData(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onListItemClick(ListView l, View v, int position, long id)
|
||||||
|
{
|
||||||
|
if (mListener != null)
|
||||||
|
{
|
||||||
|
mListener.onTrustedCertificateSelected(mAdapter.getItem(position));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class CertificateListLoader extends AsyncTaskLoader<List<TrustedCertificateEntry>>
|
public static class CertificateListLoader extends AsyncTaskLoader<List<TrustedCertificateEntry>>
|
||||||
{
|
{
|
||||||
private List<TrustedCertificateEntry> mData;
|
private List<TrustedCertificateEntry> mData;
|
||||||
|
|||||||
Reference in New Issue
Block a user