2 * Copyright (C) 2013 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 package org.strongswan.android.ui;
18 import org.strongswan.android.R;
19 import org.strongswan.android.logic.imc.RemediationInstruction;
21 import android.app.ListFragment;
22 import android.os.Bundle;
23 import android.view.LayoutInflater;
24 import android.view.View;
25 import android.view.ViewGroup;
26 import android.widget.ArrayAdapter;
27 import android.widget.TextView;
29 public class RemediationInstructionFragment extends ListFragment
31 public static final String ARG_REMEDIATION_INSTRUCTION = "instruction";
32 private RemediationInstruction mInstruction = null;
33 private TextView mTitle;
34 private TextView mDescription;
35 private TextView mHeader;
38 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
40 return inflater.inflate(R.layout.remediation_instruction, container, false);
44 public void onActivityCreated(Bundle savedInstanceState)
46 super.onActivityCreated(savedInstanceState);
48 if (savedInstanceState != null)
50 mInstruction = savedInstanceState.getParcelable(ARG_REMEDIATION_INSTRUCTION);
52 /* show dividers only between list items */
53 getListView().setHeaderDividersEnabled(false);
54 getListView().setFooterDividersEnabled(false);
55 /* don't show loader while adapter is not set */
57 mTitle = (TextView)getView().findViewById(R.id.title);
58 mDescription = (TextView)getView().findViewById(R.id.description);
59 mHeader = (TextView)getView().findViewById(R.id.list_header);
63 public void onSaveInstanceState(Bundle outState)
65 super.onSaveInstanceState(outState);
66 outState.putParcelable(ARG_REMEDIATION_INSTRUCTION, mInstruction);
74 Bundle args = getArguments();
77 mInstruction = args.getParcelable(ARG_REMEDIATION_INSTRUCTION);
79 updateView(mInstruction);
82 public void updateView(RemediationInstruction instruction)
84 mInstruction = instruction;
85 if (mInstruction != null)
87 mTitle.setText(mInstruction.getTitle());
88 mDescription.setText(mInstruction.getDescription());
89 if (mInstruction.getHeader() != null)
91 mHeader.setText(mInstruction.getHeader());
92 setListAdapter(new ArrayAdapter<String>(getActivity(),
93 android.R.layout.simple_list_item_1, mInstruction.getItems()));
104 mDescription.setText("");
106 setListAdapter(null);