Search in sources :

Example 1 with ForumItemFlatBd

use of forpdateam.ru.forpda.data.realm.forum.ForumItemFlatBd in project ForPDA by RadiationX.

the class ForumFragment method transformToList.

public void transformToList(List<ForumItemFlatBd> list, ForumItemTree rootForum) {
    if (rootForum.getForums() == null)
        return;
    for (ForumItemTree item : rootForum.getForums()) {
        list.add(new ForumItemFlatBd(item));
        transformToList(list, item);
    }
}
Also used : ForumItemTree(forpdateam.ru.forpda.api.forum.models.ForumItemTree) ForumItemFlatBd(forpdateam.ru.forpda.data.realm.forum.ForumItemFlatBd)

Example 2 with ForumItemFlatBd

use of forpdateam.ru.forpda.data.realm.forum.ForumItemFlatBd in project ForPDA by RadiationX.

the class ForumFragment method onLoadThemes.

private void onLoadThemes(ForumItemTree forumRoot) {
    updateDialog.setMessage(getString(R.string.update_data_base));
    if (forumRoot.getForums() == null) {
        updateDialog.setMessage(getString(R.string.error_occurred));
        new Handler().postDelayed(() -> {
            if (updateDialog != null)
                updateDialog.cancel();
        }, 500);
        return;
    }
    if (realm.isClosed())
        return;
    realm.executeTransactionAsync(r -> {
        r.delete(ForumItemFlatBd.class);
        List<ForumItemFlatBd> items = new ArrayList<>();
        transformToList(items, forumRoot);
        r.copyToRealmOrUpdate(items);
        items.clear();
    }, this::loadCacheData);
// setSubtitle(data.getAll() <= 1 ? null : "" + data.getCurrent() + "/" + data.getAll());
}
Also used : ForumItemFlatBd(forpdateam.ru.forpda.data.realm.forum.ForumItemFlatBd) ArrayList(java.util.ArrayList) Handler(android.os.Handler)

Aggregations

ForumItemFlatBd (forpdateam.ru.forpda.data.realm.forum.ForumItemFlatBd)2 Handler (android.os.Handler)1 ForumItemTree (forpdateam.ru.forpda.api.forum.models.ForumItemTree)1 ArrayList (java.util.ArrayList)1