forked from pu20720/2019
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAction.java
205 lines (161 loc) · 5.38 KB
/
Action.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
package andbas.Ch11TabHost2;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.StringTokenizer;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import com.xml.LoginXMLHandler;
import com.xml.LoginXMLStruct;
import com.xml.MessageHandler;
import com.xml.MessageStruct;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import android.os.StrictMode;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
public class Action extends Activity
{
static public Action myaction;
ListView listaction;
Intent intent;
int index = 0;
String IPAddress="";
private ArrayList<MessageStruct> query_data= new ArrayList<MessageStruct>();
private ArrayList<MessageStruct> query_data2= new ArrayList<MessageStruct>();
int type;
String msg;
String user;
LoginXMLStruct data;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dynamic);
myaction = this;
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
user = telephonyManager.getDeviceId();
IPAddress = (String) this.getResources().getText(R.string.url);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
listaction =(ListView)findViewById(R.id.list_action);
index = 0;
buildViews();
}
private void buildViews()
{
reload();
listaction.setOnItemClickListener(lstPreferListener);
}
private ListView.OnItemClickListener lstPreferListener=
new ListView.OnItemClickListener(){
public void onItemClick(AdapterView<?> parent, View v,
int position, long id)
{
Intent app = new Intent(Action.this, DiscussList.class);
Bundle rdata = new Bundle();
rdata.putString("title", query_data2.get(position).title);
rdata.putString("pnum", query_data2.get(position).pnum);
rdata.putString("article_id", query_data2.get(position).id);
app.putExtras(rdata);
startActivity(app);
}
};
void reload()
{
gettype();
String address="";
StringTokenizer stoken = null;
ArrayList<HashMap<String, String>> listitem = new ArrayList<HashMap<String, String>>();
query_data2.clear();
for (int i=0; i<query_data.size(); i++)
{
HashMap<String, String> map = new HashMap<String, String>();
if (query_data.get(i).id == null) continue;
map.put("id", query_data.get(i).id);
map.put("name", query_data.get(i).title);
query_data2.add(query_data.get(i));
listitem.add(map);
}
listaction.setAdapter(new MyAdapter(this, listitem));
}
void gettype()
{
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
String uriAPI ="";
try
{
//String s = URLEncoder.encode(k, "utf-8");
uriAPI = IPAddress + "getusergrouplist.php?user=" + user;
Log.i("TAG", uriAPI);
}
catch (Exception e)
{
e.printStackTrace();
}
Log.i("TAG", uriAPI);
URL url = null;
try{
url = new URL(uriAPI);
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
//Using login handler for xml
MessageHandler myHandler = new MessageHandler();
xr.setContentHandler(myHandler);
//open connection
xr.parse(new InputSource(url.openStream()));
//verify OK
query_data = myHandler.getContainer().getListItems();
}
catch (Exception e)
{
e.printStackTrace();
}
}
void DeleteData(String article_id)
{
try
{
String uriAPI = IPAddress + "deleteattendgroup.php?aid=" + article_id + "&user=" + user;
Log.i("TAG", uriAPI);
URL url = null;
try{
url = new URL(uriAPI);
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
//Using login handler for xml
LoginXMLHandler myHandler = new LoginXMLHandler();
xr.setContentHandler(myHandler);
//open connection
xr.parse(new InputSource(url.openStream()));
//verify OK
data = myHandler.getParsedData();
}
catch(Exception e){
e.printStackTrace();
return;
}
}
catch (Exception e)
{
e.printStackTrace();
}
reload();
}
}