1 | package ve.gob.cenditel.tibisaymovil; |
---|
2 | |
---|
3 | import java.util.ArrayList; |
---|
4 | import java.util.List; |
---|
5 | |
---|
6 | import android.app.Activity; |
---|
7 | import android.content.Intent; |
---|
8 | import android.os.Bundle; |
---|
9 | import android.util.SparseBooleanArray; |
---|
10 | import android.view.View; |
---|
11 | import android.view.Window; |
---|
12 | import android.view.View.OnClickListener; |
---|
13 | import android.widget.AdapterView; |
---|
14 | import android.widget.AdapterView.OnItemClickListener; |
---|
15 | import android.widget.ArrayAdapter; |
---|
16 | import android.widget.Button; |
---|
17 | import android.widget.LinearLayout; |
---|
18 | import android.widget.ListView; |
---|
19 | |
---|
20 | public class FilesToPKCS7SignConfirmationActivity extends Activity implements OnClickListener, OnItemClickListener { |
---|
21 | |
---|
22 | private List<String> uris; |
---|
23 | private ListView listView; |
---|
24 | private LinearLayout next; |
---|
25 | private LinearLayout back; |
---|
26 | private ArrayAdapter<String> listAdapter; |
---|
27 | |
---|
28 | public void onCreate(Bundle savedInstanceState) { |
---|
29 | super.onCreate(savedInstanceState); |
---|
30 | |
---|
31 | final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); |
---|
32 | this.setContentView(R.layout.confirmationlist); |
---|
33 | if(customTitleSupported) |
---|
34 | getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar); |
---|
35 | |
---|
36 | |
---|
37 | this.next = (LinearLayout) this.findViewById(R.id.button_next_zone); |
---|
38 | this.next.setOnClickListener(this); |
---|
39 | |
---|
40 | this.back = (LinearLayout) this.findViewById(R.id.button_back_zone); |
---|
41 | this.back.setOnClickListener(this); |
---|
42 | |
---|
43 | |
---|
44 | this.uris = getIntent().getStringArrayListExtra(IntentExtraField.FILES); |
---|
45 | this.listAdapter = new ArrayAdapter<String>(this,R.layout.confirmation_item, this.uris); |
---|
46 | |
---|
47 | |
---|
48 | this.listView = (ListView) this.findViewById(R.id.confirmation_list); |
---|
49 | this.listView.setAdapter(this.listAdapter); |
---|
50 | this.listView.setOnItemClickListener(this); |
---|
51 | |
---|
52 | this.listAdapter.notifyDataSetChanged(); |
---|
53 | |
---|
54 | //Estilando Barra de titulo |
---|
55 | if(customTitleSupported) |
---|
56 | getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar); |
---|
57 | |
---|
58 | |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | @Override |
---|
63 | public void onStart(){ |
---|
64 | super.onStart(); |
---|
65 | |
---|
66 | for (int i=0;i<this.listView.getCount();i++) |
---|
67 | this.listView.setItemChecked(i, true); |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | @Override |
---|
72 | public void onClick(View v) { |
---|
73 | switch (v.getId()) |
---|
74 | { |
---|
75 | case R.id.button_back_zone: |
---|
76 | finish(); |
---|
77 | break; |
---|
78 | case R.id.button_next_zone: |
---|
79 | |
---|
80 | Intent intent = new Intent(); |
---|
81 | SparseBooleanArray sparse = this.listView.getCheckedItemPositions(); |
---|
82 | ArrayList<String> sublist = new ArrayList<String>(); |
---|
83 | |
---|
84 | for (int i = 0; i < sparse.size(); i++) { |
---|
85 | if( sparse.valueAt(i)== true){ |
---|
86 | sublist.add((String)this.listAdapter.getItem(sparse.keyAt(i))); |
---|
87 | } |
---|
88 | } |
---|
89 | |
---|
90 | if (sublist.size()>0){ |
---|
91 | intent.putStringArrayListExtra(IntentExtraField.FILES, sublist); |
---|
92 | this.setResult(RESULT_OK, intent); |
---|
93 | finish(); |
---|
94 | }else{} |
---|
95 | |
---|
96 | break; |
---|
97 | |
---|
98 | |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | |
---|
104 | } |
---|
105 | |
---|
106 | |
---|
107 | @Override |
---|
108 | public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { |
---|
109 | |
---|
110 | |
---|
111 | SparseBooleanArray checked = this.listView.getCheckedItemPositions(); |
---|
112 | boolean found=false; |
---|
113 | |
---|
114 | for (int i=0; i<checked.size() && found == false; i++) { |
---|
115 | if (checked.valueAt(i)) |
---|
116 | found=true; |
---|
117 | |
---|
118 | } |
---|
119 | |
---|
120 | |
---|
121 | if (found==false) |
---|
122 | this.next.setEnabled(false); |
---|
123 | else |
---|
124 | this.next.setEnabled(true); |
---|
125 | |
---|
126 | } |
---|
127 | |
---|
128 | |
---|
129 | |
---|
130 | |
---|
131 | |
---|
132 | |
---|
133 | |
---|
134 | } |
---|
135 | |
---|