aboutsummaryrefslogtreecommitdiffstats
path: root/src/frontends
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2012-08-14 10:43:03 +0200
committerTobias Brunner <tobias@strongswan.org>2012-08-14 12:01:41 +0200
commit7546735fecaa5815c9c4007db5e069e0f10ad278 (patch)
treeea87ab3ed48fcc100b5a88ae1439a1f09ee69f09 /src/frontends
parentb0b0eac6eb0701ae38b769e0283ad26d1299e46b (diff)
downloadstrongswan-7546735fecaa5815c9c4007db5e069e0f10ad278.tar.bz2
strongswan-7546735fecaa5815c9c4007db5e069e0f10ad278.tar.xz
List fragment for trusted certificates can notify listeners about clicks
Diffstat (limited to 'src/frontends')
-rw-r--r--src/frontends/android/src/org/strongswan/android/ui/TrustedCertificateListFragment.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificateListFragment.java b/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificateListFragment.java
index a64a92755..f5cc57ab5 100644
--- a/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificateListFragment.java
+++ b/src/frontends/android/src/org/strongswan/android/ui/TrustedCertificateListFragment.java
@@ -27,18 +27,29 @@ import org.strongswan.android.data.TrustedCertificateEntry;
import org.strongswan.android.logic.TrustedCertificateManager;
import org.strongswan.android.ui.adapter.TrustedCertificateAdapter;
+import android.app.Activity;
import android.app.ListFragment;
import android.app.LoaderManager.LoaderCallbacks;
import android.content.AsyncTaskLoader;
import android.content.Context;
import android.content.Loader;
import android.os.Bundle;
+import android.view.View;
+import android.widget.ListView;
public class TrustedCertificateListFragment extends ListFragment implements LoaderCallbacks<List<TrustedCertificateEntry>>
{
+ private OnTrustedCertificateSelectedListener mListener;
private TrustedCertificateAdapter mAdapter;
private boolean mUser;
+ /**
+ * The activity containing this fragment should implement this interface
+ */
+ public interface OnTrustedCertificateSelectedListener {
+ public void onTrustedCertificateSelected(TrustedCertificateEntry selected);
+ }
+
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
@@ -64,6 +75,17 @@ public class TrustedCertificateListFragment extends ListFragment implements Load
}
@Override
+ public void onAttach(Activity activity)
+ {
+ super.onAttach(activity);
+
+ if (activity instanceof OnTrustedCertificateSelectedListener)
+ {
+ mListener = (OnTrustedCertificateSelectedListener)activity;
+ }
+ }
+
+ @Override
public Loader<List<TrustedCertificateEntry>> onCreateLoader(int id, Bundle args)
{ /* we don't need the id as we have only one loader */
return new CertificateListLoader(getActivity(), mUser);
@@ -90,6 +112,15 @@ public class TrustedCertificateListFragment extends ListFragment implements Load
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>>
{
private List<TrustedCertificateEntry> mData;