use of eu.siacs.conversations.entities.PresenceTemplate in project Conversations by siacs.
the class SetPresenceActivity method onClick.
@Override
public void onClick(View v) {
PresenceTemplate template = (PresenceTemplate) v.getTag();
if (template == null) {
return;
}
if (v.getId() == R.id.presence_template) {
setStatusInSpinner(template.getStatus());
mStatusMessage.getEditableText().clear();
mStatusMessage.getEditableText().append(template.getStatusMessage());
new Handler().post(new Runnable() {
@Override
public void run() {
mScrollView.smoothScrollTo(0, 0);
}
});
} else if (v.getId() == R.id.delete_button) {
xmppConnectionService.databaseBackend.deletePresenceTemplate(template);
mTemplates.remove(template);
redrawTemplates();
}
}
use of eu.siacs.conversations.entities.PresenceTemplate in project Conversations by siacs.
the class DatabaseBackend method getPresenceTemplates.
public List<PresenceTemplate> getPresenceTemplates() {
ArrayList<PresenceTemplate> templates = new ArrayList<>();
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(PresenceTemplate.TABELNAME, null, null, null, null, null, PresenceTemplate.LAST_USED + " desc");
while (cursor.moveToNext()) {
templates.add(PresenceTemplate.fromCursor(cursor));
}
cursor.close();
return templates;
}
use of eu.siacs.conversations.entities.PresenceTemplate in project Conversations by siacs.
the class SetPresenceActivity method redrawTemplates.
private void redrawTemplates() {
if (mTemplates == null || mTemplates.size() == 0) {
mTemplatesView.setVisibility(View.GONE);
} else {
mTemplatesView.removeAllViews();
mTemplatesView.setVisibility(View.VISIBLE);
LayoutInflater inflater = getLayoutInflater();
for (PresenceTemplate template : mTemplates) {
View templateLayout = inflater.inflate(R.layout.presence_template, mTemplatesView, false);
templateLayout.setTag(template);
setListItemBackgroundOnView(templateLayout);
templateLayout.setOnClickListener(this);
TextView message = (TextView) templateLayout.findViewById(R.id.presence_status_message);
TextView status = (TextView) templateLayout.findViewById(R.id.status);
ImageButton button = (ImageButton) templateLayout.findViewById(R.id.delete_button);
button.setTag(template);
button.setOnClickListener(this);
ListItem.Tag tag = UIHelper.getTagForStatus(this, template.getStatus());
status.setText(tag.getName());
status.setBackgroundColor(tag.getColor());
message.setText(template.getStatusMessage());
mTemplatesView.addView(templateLayout);
}
}
}
Aggregations