aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2012-07-17 19:57:51 +0200
committerTobias Brunner <tobias@strongswan.org>2012-08-13 11:00:09 +0200
commitda9bb5044f9b1f5a1bcf759381ac8303db59d11e (patch)
tree2100ab44d6731d87103e4c167af19fa7c7ddaa35 /src
parentc6b736b9f5409371a69298aaab2a7f99d06b7ddd (diff)
downloadstrongswan-da9bb5044f9b1f5a1bcf759381ac8303db59d11e.tar.bz2
strongswan-da9bb5044f9b1f5a1bcf759381ac8303db59d11e.tar.xz
Make click events on the profile list available to the Activity
If the Activity this fragment is placed in implements the provided interface it is notified about clicks on any of the profiles.
Diffstat (limited to 'src')
-rw-r--r--src/frontends/android/src/org/strongswan/android/ui/VpnProfileListFragment.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/frontends/android/src/org/strongswan/android/ui/VpnProfileListFragment.java b/src/frontends/android/src/org/strongswan/android/ui/VpnProfileListFragment.java
index 252330b28..be0a9004e 100644
--- a/src/frontends/android/src/org/strongswan/android/ui/VpnProfileListFragment.java
+++ b/src/frontends/android/src/org/strongswan/android/ui/VpnProfileListFragment.java
@@ -53,6 +53,14 @@ public class VpnProfileListFragment extends Fragment
private VpnProfileDataSource mDataSource;
private VpnProfileAdapter mListAdapter;
private ListView mListView;
+ private OnVpnProfileSelectedListener mListener;
+
+ /**
+ * The activity containing this fragment should implement this interface
+ */
+ public interface OnVpnProfileSelectedListener {
+ public void onVpnProfileSelected(VpnProfile profile);
+ }
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -62,6 +70,7 @@ public class VpnProfileListFragment extends Fragment
mListView = (ListView)view.findViewById(R.id.profile_list);
mListView.setEmptyView(view.findViewById(R.id.profile_list_empty));
+ mListView.setOnItemClickListener(mVpnProfileClicked);
mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
mListView.setMultiChoiceModeListener(mVpnProfileSelected);
mListView.setAdapter(mListAdapter);
@@ -94,6 +103,17 @@ public class VpnProfileListFragment extends Fragment
}
@Override
+ public void onAttach(Activity activity)
+ {
+ super.onAttach(activity);
+
+ if (activity instanceof OnVpnProfileSelectedListener)
+ {
+ mListener = (OnVpnProfileSelectedListener)activity;
+ }
+ }
+
+ @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
{
inflater.inflate(R.menu.profile_list, menu);
@@ -138,6 +158,17 @@ public class VpnProfileListFragment extends Fragment
super.onActivityResult(requestCode, resultCode, data);
}
+ private final OnItemClickListener mVpnProfileClicked = new OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> a, View v, int position, long id)
+ {
+ if (mListener != null)
+ {
+ mListener.onVpnProfileSelected((VpnProfile)a.getItemAtPosition(position));
+ }
+ }
+ };
+
private final MultiChoiceModeListener mVpnProfileSelected = new MultiChoiceModeListener() {
private HashSet<Integer> mSelected;
private MenuItem mEditProfile;