]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/frontends/android/app/src/main/java/org/strongswan/android/ui/adapter/TrustedCertificateAdapter.java
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / frontends / android / app / src / main / java / org / strongswan / android / ui / adapter / TrustedCertificateAdapter.java
1 /*
2 * Copyright (C) 2012 Tobias Brunner
3 *
4 * Copyright (C) secunet Security Networks AG
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 package org.strongswan.android.ui.adapter;
18
19 import java.util.List;
20
21 import org.strongswan.android.R;
22 import org.strongswan.android.security.TrustedCertificateEntry;
23
24 import android.content.Context;
25 import android.view.LayoutInflater;
26 import android.view.View;
27 import android.view.ViewGroup;
28 import android.widget.ArrayAdapter;
29 import android.widget.TextView;
30
31 public class TrustedCertificateAdapter extends ArrayAdapter<TrustedCertificateEntry>
32 {
33 public TrustedCertificateAdapter(Context context)
34 {
35 super(context, R.layout.trusted_certificates_item);
36 }
37
38 /**
39 * Set new data for this adapter.
40 *
41 * @param data the new data (null to clear)
42 */
43 public void setData(List<TrustedCertificateEntry> data)
44 {
45 clear();
46 if (data != null)
47 {
48 addAll(data);
49 }
50 }
51
52 @Override
53 public View getView(int position, View convertView, ViewGroup parent)
54 {
55 View view;
56 if (convertView != null)
57 {
58 view = convertView;
59 }
60 else
61 {
62 LayoutInflater inflater = LayoutInflater.from(getContext());
63 view = inflater.inflate(R.layout.trusted_certificates_item, parent, false);
64 }
65 TrustedCertificateEntry item = getItem(position);
66 TextView text = (TextView)view.findViewById(R.id.subject_primary);
67 text.setText(item.getSubjectPrimary());
68 text = (TextView)view.findViewById(R.id.subject_secondary);
69 text.setText(item.getSubjectSecondary());
70 return view;
71 }
72 }