Search in sources :

Example 1 with Label

use of com.hannesdorfmann.mosby3.sample.mail.model.mail.Label in project mosby by sockeqwe.

the class MenuAdapter method bindViewHolder.

@Override
public void bindViewHolder(MenuAdapterHolders.MenuItemViewHolder vh, int position) {
    final Label label = items.get(position);
    vh.icon.setImageResource(label.getIconRes());
    vh.name.setText(label.getName());
    if (label.getUnreadCount() > 0) {
        vh.unread.setVisibility(View.VISIBLE);
        vh.unread.setText("" + label.getUnreadCount());
    } else {
        vh.unread.setVisibility(View.INVISIBLE);
    }
    vh.itemView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            listener.onLabelClicked(label);
        }
    });
}
Also used : Label(com.hannesdorfmann.mosby3.sample.mail.model.mail.Label) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View)

Example 2 with Label

use of com.hannesdorfmann.mosby3.sample.mail.model.mail.Label in project mosby by sockeqwe.

the class RandomMailGenerator method generateMails.

@Override
public List<Mail> generateMails() {
    int id = 0;
    int mailSize = 50;
    List<Mail> mails = new ArrayList<>(mailSize);
    long day = 24 * 60 * 60 * 1000;
    long timestamp = System.currentTimeMillis();
    for (int i = 0; i < mailSize; i++, timestamp -= day) {
        String[] quotes = barneyQuotes;
        Person sender = Person.BARNEY;
        switch(i % 5) {
            case 1:
                sender = Person.LILY;
                quotes = lilyQuotes;
                break;
            case 3:
                sender = Person.MARSHALL;
                quotes = marshallQuotes;
                break;
            case 4:
                sender = Person.ROBIN;
                quotes = robinQuotes;
                break;
            default:
                // 0 and 2 is barney
                break;
        }
        String label;
        if (i < 40) {
            label = Label.INBOX;
        } else if (i < 45) {
            label = Label.SPAM;
        } else {
            label = Label.TRASH;
        }
        mails.add(new Mail().id(id++).date(new Date(timestamp)).label(label).read((i % 6) != random.nextInt(6)).receiver(Person.TED).sender(sender).subject(randomString(subjects)).text(generateMsg(quotes)));
    }
    /*
    // SENT
    Person[] receiver = { barney, marshall, lily, robin };
    for (int i = 0; i < 10; i++, timestamp -= day) {
      mails.add(new Mail().id(id++)
          .date(new Date(timestamp))
          .label(Label.SENT)
          .read(true)
          .receiver(receiver[randomIndex(receiver)])
          .sender(ted)
          .subject("RE: " + randomString(subjects))
          .text(generateMsg(tedQuotes)));
    }
    */
    return mails;
}
Also used : ArrayList(java.util.ArrayList) Person(com.hannesdorfmann.mosby3.sample.mail.model.contact.Person) Date(java.util.Date)

Example 3 with Label

use of com.hannesdorfmann.mosby3.sample.mail.model.mail.Label in project mosby by sockeqwe.

the class MainActivity method onNewIntent.

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);
    String showAction = intent.getStringExtra(KEY_SHOW_ACTION);
    if (KEY_SHOW_ACTION_MAIL_DETAILS.equals(showAction)) {
        Mail mail = intent.getParcelableExtra(KEY_DATA_MAIL_DETAILS);
        showMail(mail);
    } else if (KEY_SHOW_ACTION_MAILS_OF_LABEL.equals(showAction)) {
        Label label = intent.getParcelableExtra(KEY_DATA_MAILS_OF_LABEL);
        showMails(label, true);
    }
}
Also used : Mail(com.hannesdorfmann.mosby3.sample.mail.model.mail.Mail) Label(com.hannesdorfmann.mosby3.sample.mail.model.mail.Label)

Example 4 with Label

use of com.hannesdorfmann.mosby3.sample.mail.model.mail.Label in project mosby by sockeqwe.

the class LabelAdapter method bindView.

@Override
public void bindView(int position, int type, View view) {
    ViewHolder vh = (ViewHolder) view.getTag();
    Label label = items.get(position);
    vh.text.setText(label.getName());
    vh.icon.setImageResource(label.getIconRes());
}
Also used : Label(com.hannesdorfmann.mosby3.sample.mail.model.mail.Label)

Example 5 with Label

use of com.hannesdorfmann.mosby3.sample.mail.model.mail.Label 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);
        }
    });
}
Also used : PopupWindow(android.widget.PopupWindow) ListPopupWindow(android.support.v7.widget.ListPopupWindow) Label(com.hannesdorfmann.mosby3.sample.mail.model.mail.Label) LayoutTransition(android.animation.LayoutTransition) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListPopupWindow(android.support.v7.widget.ListPopupWindow) AdapterView(android.widget.AdapterView)

Aggregations

Label (com.hannesdorfmann.mosby3.sample.mail.model.mail.Label)5 View (android.view.View)2 TextView (android.widget.TextView)2 Person (com.hannesdorfmann.mosby3.sample.mail.model.contact.Person)2 Mail (com.hannesdorfmann.mosby3.sample.mail.model.mail.Mail)2 Date (java.util.Date)2 LayoutTransition (android.animation.LayoutTransition)1 ListPopupWindow (android.support.v7.widget.ListPopupWindow)1 Animation (android.view.animation.Animation)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 PopupWindow (android.widget.PopupWindow)1 BindView (butterknife.BindView)1 OnClick (butterknife.OnClick)1 MailsFragmentBuilder (com.hannesdorfmann.mosby3.sample.mail.mails.MailsFragmentBuilder)1 ArrayList (java.util.ArrayList)1