1 package com
.owncloud
.android
.ui
.activity
;
3 import java
.util
.ArrayList
;
5 import android
.content
.Context
;
6 import android
.content
.Intent
;
7 import android
.os
.Bundle
;
8 import android
.view
.View
;
9 import android
.view
.ViewGroup
;
10 import android
.widget
.ArrayAdapter
;
11 import android
.widget
.ListAdapter
;
12 import android
.widget
.ListView
;
13 import android
.widget
.TextView
;
15 import com
.actionbarsherlock
.app
.SherlockFragmentActivity
;
16 import com
.owncloud
.android
.R
;
19 * Activity showing a text message and, optionally, a couple of scrollable lists of texts.
21 * Added to show explanations for notifications when the user clicks on them, and there no place
22 * better to show them.
24 * @author David A. Velasco
26 public class ExplanationActivity
extends SherlockFragmentActivity
{
28 public static final String EXTRA_LIST
= ExplanationActivity
.class.getCanonicalName() + ".EXTRA_LIST";
29 public static final String EXTRA_LIST_2
= ExplanationActivity
.class.getCanonicalName() + ".EXTRA_LIST_2";
30 public static final String MESSAGE
= ExplanationActivity
.class.getCanonicalName() + ".MESSAGE";
34 protected void onCreate(Bundle savedInstanceState
) {
35 super.onCreate(savedInstanceState
);
37 Intent intent
= getIntent();
38 String message
= intent
.getStringExtra(MESSAGE
);
39 ArrayList
<String
> list
= intent
.getStringArrayListExtra(EXTRA_LIST
);
40 ArrayList
<String
> list2
= intent
.getStringArrayListExtra(EXTRA_LIST_2
);
42 setContentView(R
.layout
.explanation
);
44 if (message
!= null
) {
45 TextView textView
= (TextView
) findViewById(R
.id
.message
);
46 textView
.setText(message
);
49 ListView listView
= (ListView
) findViewById(R
.id
.list
);
50 if (list
!= null
&& list
.size() > 0) {
51 //ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
52 ListAdapter adapter
= new ExplanationListAdapterView(this, list
, list2
);
53 listView
.setAdapter(adapter
);
55 listView
.setVisibility(View
.GONE
);
59 public class ExplanationListAdapterView
extends ArrayAdapter
<String
> {
61 ArrayList
<String
> mList
;
62 ArrayList
<String
> mList2
;
64 ExplanationListAdapterView(Context context
, ArrayList
<String
> list
, ArrayList
<String
> list2
) {
65 //super(context, android.R.layout.two_line_list_item, android.R.id.text1, list);
66 super(context
, android
.R
.layout
.two_line_list_item
, android
.R
.id
.text1
, list
);
72 public boolean isEnabled(int position
) {
80 public View
getView (int position
, View convertView
, ViewGroup parent
) {
81 View view
= super.getView(position
, convertView
, parent
);
83 if (mList2
!= null
&& mList2
.size() > 0 && position
>= 0 && position
< mList2
.size()) {
84 TextView text2
= (TextView
) view
.findViewById(android
.R
.id
.text2
);
86 text2
.setText(mList2
.get(position
));