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);
}
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);
}
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);
}
});
}
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());
}
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;
}
Aggregations