use of com.hannesdorfmann.mosby3.sample.mail.model.mail.Mail in project mosby by sockeqwe.
the class MailsAdapter method findMail.
/**
* Searches for an equal mail (compares mail id) in the adapter.
*
* @return A {@link MailInAdapterResult} containing the information if the adapter contains that
* mail and at which index position. If the adapter doesn't contain this mail, then the result
* will contain the index position where the mail would be.
*/
public MailInAdapterResult findMail(Mail mail) {
int indexPosition = Collections.binarySearch(items, mail, MailComparator.INSTANCE);
boolean containsMail = false;
Mail found = null;
if (indexPosition < 0) {
indexPosition = ~indexPosition;
} else {
found = items.get(indexPosition);
if (found.getId() == mail.getId()) {
containsMail = true;
} else {
containsMail = false;
found = null;
}
}
return new MailInAdapterResult(containsMail, found, indexPosition);
}
use of com.hannesdorfmann.mosby3.sample.mail.model.mail.Mail in project mosby by sockeqwe.
the class DetailsPresenter method markAsRead.
private void markAsRead(final Mail mail) {
// We assume that this call could never fail
eventBus.post(new MailReadEvent(mail, true));
mailProvider.markAsRead(mail, true).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe();
}
use of com.hannesdorfmann.mosby3.sample.mail.model.mail.Mail in project mosby by sockeqwe.
the class LabelLayout method init.
private void init() {
View.inflate(getContext(), R.layout.view_label_layout, this);
LayoutTransition transition = new LayoutTransition();
transition.enableTransitionType(LayoutTransition.CHANGING);
this.setLayoutTransition(transition);
adapter = new LabelAdapter(getContext());
popUpWindow = new ListPopupWindow(getContext());
popUpWindow.setAnchorView(this);
popUpWindow.setAdapter(adapter);
popUpWindow.setWidth(DimensUtils.dpToPx(getContext(), 140));
popUpWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
showLabel();
}
});
popUpWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Label label = (Label) adapter.getItem(position);
if (!label.getName().equals(mail.getLabel())) {
presenter.setLabel(mail, label.getName());
popUpWindow.dismiss();
}
}
});
setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
loadData(false);
}
});
}
use of com.hannesdorfmann.mosby3.sample.mail.model.mail.Mail in project mosby by sockeqwe.
the class WriteActivity method onSendClicked.
@OnClick(R.id.send)
public void onSendClicked() {
String email = receiver.getText().toString();
if (TextUtils.isEmpty(email) || !emailPattern.matcher(email).matches()) {
Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
receiver.startAnimation(shake);
return;
}
String sub = subject.getText().toString();
if (TextUtils.isEmpty(sub)) {
Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
subject.startAnimation(shake);
return;
}
Person receiver = null;
if (email.equals(Person.BARNEY.getEmail())) {
receiver = Person.BARNEY;
} else if (email.equals(Person.LILY.getEmail())) {
receiver = Person.LILY;
} else if (email.equals(Person.MARSHALL.getEmail())) {
receiver = Person.MARSHALL;
} else if (email.equals(Person.ROBIN.getEmail())) {
receiver = Person.ROBIN;
} else {
String name = email.split("@")[0];
receiver = new Person(23, name, email, R.drawable.unknown, null, 0);
}
String text = message.getText().toString();
Mail mail = new Mail().date(new Date()).label(Label.SENT).sender(Person.TED).receiver(receiver).subject(sub).text(text);
presenter.writeMail(getApplicationContext(), mail);
}
use of com.hannesdorfmann.mosby3.sample.mail.model.mail.Mail in project mosby by sockeqwe.
the class MailReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(ACTION_RECEIVE)) {
Mail mail = intent.getParcelableExtra(EXTRA_MAIL);
Intent gcmIntent = new Intent(context, GcmFakeIntentService.class);
gcmIntent.putExtra(GcmFakeIntentService.KEY_MAIL, mail);
context.startService(gcmIntent);
}
}
Aggregations