Search in sources :

Example 6 with TabFragment

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

the class TabManager method remove.

public void remove(TabFragment tabFragment) {
    Log.d(LOG_TAG, "remove: " + tabFragment);
    if (tabFragment == null)
        return;
    String tabTag = tabFragment.getTag();
    int tabIndex = existingFragments.indexOf(tabFragment);
    fragmentManager.beginTransaction().remove(tabFragment).commit();
    fragmentManager.executePendingTransactions();
    updateFragmentList();
    TabFragment parent = null;
    if (tabFragment.getParentTag() != null && !tabFragment.getParentTag().equals(""))
        parent = findTabByTag(tabFragment.getParentTag());
    if (parent == null) {
        if (existingFragments.size() >= 1) {
            if (existingFragments.size() <= activeIndex)
                activeIndex = existingFragments.size() - 1;
            activeTag = existingFragments.get(activeIndex).getTag();
        } else {
            activeIndex = 0;
            activeTag = "";
        }
    } else {
        Log.e(LOG_TAG, "Compare " + activeTag + " : " + tabTag);
        if (activeTag.equals(tabTag)) {
            activeTag = tabFragment.getParentTag();
            activeIndex = existingFragments.indexOf(parent);
        }
    }
    select(activeTag);
    tabListener.onChange();
    tabListener.onRemoveTab(tabFragment);
}
Also used : TabFragment(forpdateam.ru.forpda.ui.fragments.TabFragment)

Example 7 with TabFragment

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

the class TabManager method add.

public void add(Class<? extends TabFragment> tClass, Bundle args) {
    TabFragment.Builder builder = new TabFragment.Builder<>(tClass);
    if (args != null) {
        builder.setArgs(args);
    }
    TabFragment fragment = builder.build();
    add(fragment);
}
Also used : TabFragment(forpdateam.ru.forpda.ui.fragments.TabFragment)

Example 8 with TabFragment

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

the class BasePresenter method handleErrorRx.

private void handleErrorRx(Throwable throwable, View.OnClickListener listener) {
    new Handler(Looper.getMainLooper()).post(() -> {
        TabFragment tabFragment = TabManager.get().getActive();
        if (tabFragment == null) {
            throwable.printStackTrace();
            ACRA.getErrorReporter().handleException(throwable);
        } else {
            ErrorHandler.handle(tabFragment, throwable, listener);
        }
    });
}
Also used : Handler(android.os.Handler) ErrorHandler(forpdateam.ru.forpda.common.ErrorHandler) TabFragment(forpdateam.ru.forpda.ui.fragments.TabFragment)

Example 9 with TabFragment

use of forpdateam.ru.forpda.ui.fragments.TabFragment 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 10 with TabFragment

use of forpdateam.ru.forpda.ui.fragments.TabFragment 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)11 Intent (android.content.Intent)2 FavoritesFragment (forpdateam.ru.forpda.ui.fragments.favorites.FavoritesFragment)2 ThemeFragment (forpdateam.ru.forpda.ui.fragments.theme.ThemeFragment)2 SuppressLint (android.annotation.SuppressLint)1 PendingIntent (android.app.PendingIntent)1 Handler (android.os.Handler)1 DrawerLayout (android.support.v4.widget.DrawerLayout)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 View (android.view.View)1 AttachmentItem (forpdateam.ru.forpda.api.theme.editpost.models.AttachmentItem)1 ThemePage (forpdateam.ru.forpda.api.theme.models.ThemePage)1 ErrorHandler (forpdateam.ru.forpda.common.ErrorHandler)1 NetworkStateReceiver (forpdateam.ru.forpda.common.receivers.NetworkStateReceiver)1 SimpleUpdateChecker (forpdateam.ru.forpda.ui.activities.updatechecker.SimpleUpdateChecker)1 AuthFragment (forpdateam.ru.forpda.ui.fragments.auth.AuthFragment)1 TopicsFragment (forpdateam.ru.forpda.ui.fragments.topics.TopicsFragment)1 KeyboardUtil (forpdateam.ru.forpda.ui.views.KeyboardUtil)1 DrawerHeader (forpdateam.ru.forpda.ui.views.drawers.DrawerHeader)1 Drawers (forpdateam.ru.forpda.ui.views.drawers.Drawers)1