Search in sources :

Example 6 with QmsContact

use of forpdateam.ru.forpda.api.qms.models.QmsContact in project ForPDA by RadiationX.

the class QmsContactsFragment method bindView.

private void bindView() {
    if (realm.isClosed())
        return;
    results = realm.where(QmsContactBd.class).findAll();
    if (results.isEmpty()) {
        if (!contentController.contains(ContentController.TAG_NO_DATA)) {
            FunnyContent funnyContent = new FunnyContent(getContext()).setImage(R.drawable.ic_contacts).setTitle(R.string.funny_contacts_nodata_title);
            contentController.addContent(funnyContent, ContentController.TAG_NO_DATA);
        }
        contentController.showContent(ContentController.TAG_NO_DATA);
    } else {
        contentController.hideContent(ContentController.TAG_NO_DATA);
    }
    ArrayList<QmsContact> currentItems = new ArrayList<>();
    for (QmsContactBd qmsContactBd : results) {
        QmsContact contact = new QmsContact(qmsContactBd);
        currentItems.add(contact);
    }
    int count = 0;
    for (QmsContact contact : currentItems) {
        if (contact.getCount() > 0) {
            count += contact.getCount();
        }
    }
    ClientHelper.setQmsCount(count);
    ClientHelper.get().notifyCountsChanged();
    adapter.addAll(currentItems);
}
Also used : FunnyContent(forpdateam.ru.forpda.ui.views.FunnyContent) ArrayList(java.util.ArrayList) IQmsContact(forpdateam.ru.forpda.api.qms.interfaces.IQmsContact) QmsContact(forpdateam.ru.forpda.api.qms.models.QmsContact) QmsContactBd(forpdateam.ru.forpda.data.realm.qms.QmsContactBd)

Aggregations

QmsContact (forpdateam.ru.forpda.api.qms.models.QmsContact)6 ArrayList (java.util.ArrayList)6 IQmsContact (forpdateam.ru.forpda.api.qms.interfaces.IQmsContact)3 QmsContactBd (forpdateam.ru.forpda.data.realm.qms.QmsContactBd)3 Matcher (java.util.regex.Matcher)2 SparseIntArray (android.util.SparseIntArray)1 NetworkRequest (forpdateam.ru.forpda.api.NetworkRequest)1 NetworkResponse (forpdateam.ru.forpda.api.NetworkResponse)1 NotificationEvent (forpdateam.ru.forpda.api.events.models.NotificationEvent)1 ForumUser (forpdateam.ru.forpda.api.others.user.ForumUser)1 FunnyContent (forpdateam.ru.forpda.ui.views.FunnyContent)1