private class GetMsgsTask extends AsyncTask String String String priva

 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
private class GetMsgsTask extends AsyncTask<String, String, String> {
private ArrayList<User> x;
private ArrayList<Long> uids;
private HashMap<Integer, String> avatars = new HashMap<Integer, String>();
private ArrayList<com.perm.kate.api.Message> messages;
protected String doInBackground(String... urls) {
try {
messages = api.getMessagesHistory(0L, 28, 0L, 0L, 20);
uids = new ArrayList<Long>();
for (int i = messages.size() - 1; i >= 0; i--) {
final com.perm.kate.api.Message message = messages.get(i);
Log.e("Msgs ", message.body);
uids.add(message.uid);
}
x = api.getProfiles(uids, null, "photo, photo_50", "Nom", null, null);
for (User aX : x) {
avatars.put((int) aX.uid, aX.photo);
}
System.out.println(x);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String s) {
try {
runOnUiThread(new Runnable() {
@Override
public void run() {
for (int i = messages.size() - 1; i > 0 - 1; i--) {
com.perm.kate.api.Message message = messages.get(i);
String ava = avatars.get((int) message.uid);
refreshUpdates(2, message.uid, message.mid, message.body, "test", message.read_state, account.user_id != message.uid, 1, 1, 0L, ava);
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
super.onPostExecute(s);
}
}