blob: b082c5c4e97dfe165b557142a0e6e30a034eecf4 (
plain)
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
|
package de.thedevstack.conversationsplus.ui.listeners;
import android.content.Context;
import android.view.View;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Contact;
import de.thedevstack.conversationsplus.ui.adapter.PresencesArrayAdapter;
import de.thedevstack.conversationsplus.ui.dialogs.AbstractAlertDialog;
/**
* This listener shows the dialog with the resources of a contact.
* The resources are shown with the color of their current online mode.
* This listener implements OnClickListener and OnLongClickListener.
*/
public class ShowResourcesListDialogListener extends AbstractAlertDialog implements View.OnClickListener, View.OnLongClickListener {
private Contact contact;
public ShowResourcesListDialogListener(Context context, Contact contact) {
super(context, getTitle(context, contact));
this.contact = contact;
this.init();
}
private static final String getTitle(Context context, Contact contact) {
if (null != contact && null != contact.getJid() && null != contact.getJid().toBareJid()) {
int presenceCount = null != contact.getPresences() ? contact.getPresences().size() : 0;
return context.getString(R.string.dlg_resources_title, contact.getJid().toBareJid().toString(), presenceCount);
}
return null != contact ? contact.toString() : "";
}
protected void init() {
this.builder.setAdapter(new PresencesArrayAdapter(getContext(), this.contact.getPresences()), null);
}
@Override
public void onClick(View v) {
this.show();
}
@Override
public boolean onLongClick(View view) {
this.show();
return true;
}
}
|