Search in sources :

Example 1 with ThemeFragment

use of forpdateam.ru.forpda.ui.fragments.theme.ThemeFragment in project ForPDA by RadiationX.

the class EditPostFragment method sendMessage.

private void sendMessage() {
    messagePanel.setProgressState(true);
    postForm.setMessage(messagePanel.getMessage());
    List<AttachmentItem> attachments = messagePanel.getAttachments();
    postForm.getAttachments().clear();
    for (AttachmentItem item : attachments) {
        postForm.addAttachment(item);
    }
    subscribe(RxApi.EditPost().sendPost(postForm), s -> {
        messagePanel.setProgressState(false);
        if (s.getId() != 0) {
            TabFragment fragment = TabManager.get().get(getParentTag());
            if (fragment != null) {
                if (fragment instanceof ThemeFragment) {
                    ThemeFragment themeFragment = (ThemeFragment) fragment;
                    if (postForm.getType() == TYPE_EDIT_POST) {
                        themeFragment.onEditPostCompleted(s);
                    } else {
                        themeFragment.onSendPostCompleted(s);
                    }
                }
            }
            TabManager.get().remove(EditPostFragment.this);
        }
    }, new ThemePage(), v -> loadData());
}
Also used : ThemePage(forpdateam.ru.forpda.api.theme.models.ThemePage) TabFragment(forpdateam.ru.forpda.ui.fragments.TabFragment) AttachmentItem(forpdateam.ru.forpda.api.theme.editpost.models.AttachmentItem) ThemeFragment(forpdateam.ru.forpda.ui.fragments.theme.ThemeFragment)

Example 2 with ThemeFragment

use of forpdateam.ru.forpda.ui.fragments.theme.ThemeFragment in project ForPDA by RadiationX.

the class EditPostFragment method onBackPressed.

@Override
public boolean onBackPressed() {
    super.onBackPressed();
    if (messagePanel.onBackPressed())
        return true;
    if (showExitDialog()) {
        return true;
    }
    // Синхронизация с полем в фрагменте темы
    TabFragment fragment = TabManager.get().get(getParentTag());
    if (fragment != null && fragment instanceof ThemeFragment) {
        ThemeFragment themeFragment = (ThemeFragment) fragment;
        showSyncDialog(themeFragment);
        return true;
    }
    return false;
}
Also used : TabFragment(forpdateam.ru.forpda.ui.fragments.TabFragment) ThemeFragment(forpdateam.ru.forpda.ui.fragments.theme.ThemeFragment)

Aggregations

TabFragment (forpdateam.ru.forpda.ui.fragments.TabFragment)2 ThemeFragment (forpdateam.ru.forpda.ui.fragments.theme.ThemeFragment)2 AttachmentItem (forpdateam.ru.forpda.api.theme.editpost.models.AttachmentItem)1 ThemePage (forpdateam.ru.forpda.api.theme.models.ThemePage)1