use of forpdateam.ru.forpda.ui.fragments.TabFragment in project ForPDA by RadiationX.
the class ThemeFragment method updateFavorites.
protected void updateFavorites(ThemePage themePage) {
if (!ClientHelper.getAuthState() || themePage.getPagination().getCurrent() < themePage.getPagination().getAll())
return;
int topicId = themePage.getId();
TabFragment parentTab = TabManager.get().get(getParentTag());
if (parentTab == null) {
parentTab = TabManager.get().getByClass(FavoritesFragment.class);
}
if (parentTab == null)
return;
if (parentTab instanceof FavoritesFragment) {
((FavoritesFragment) parentTab).markRead(topicId);
} else if (parentTab instanceof TopicsFragment) {
((TopicsFragment) parentTab).markRead(topicId);
}
}
use of forpdateam.ru.forpda.ui.fragments.TabFragment in project ForPDA by RadiationX.
the class Drawers method closeAllTabs.
public void closeAllTabs() {
new AlertDialog.Builder(activity).setMessage(R.string.ask_close_other_tabs).setPositiveButton(R.string.ok, (dialog, which) -> {
closeTabs();
List<TabFragment> fragmentList = new ArrayList<>();
for (TabFragment fragment : TabManager.get().getFragments()) {
if (!fragment.getTag().equals(TabManager.getActiveTag())) {
fragmentList.add(fragment);
}
}
for (TabFragment fragment : fragmentList) {
TabManager.get().remove(fragment);
}
}).setNegativeButton(R.string.no, null).show();
}
use of forpdateam.ru.forpda.ui.fragments.TabFragment in project ForPDA by RadiationX.
the class Drawers method firstSelect.
public void firstSelect() {
if (isFirstSelected)
return;
isFirstSelected = true;
String className = ClientHelper.getAuthState() == ClientHelper.AUTH_STATE_LOGIN ? FavoritesFragment.class.getSimpleName() : AuthFragment.class.getSimpleName();
String last = App.get().getPreferences().getString("menu_drawer_last", className);
last = ClientHelper.getAuthState() == ClientHelper.AUTH_STATE_LOGIN && last.equals(AuthFragment.class.getSimpleName()) ? FavoritesFragment.class.getSimpleName() : last;
Log.d(LOG_TAG, "Last item " + last);
MenuItems.MenuItem item = null;
if (this.savedInstanceState != null) {
TabFragment tabFragment = TabManager.get().get(TabManager.getActiveTag());
if (tabFragment != null) {
item = findMenuItem(tabFragment.getClass());
}
Log.d(LOG_TAG, "AAAA " + tabFragment + " : " + item);
if (item != null) {
item.setAttachedTabTag(tabFragment.getTag());
item.setActive(true);
lastActive = item;
} else {
item = findMenuItem(last);
}
} else {
item = findMenuItem(last);
}
Log.d(LOG_TAG, "Final item " + item);
if (item == null) {
item = menuItems.get(0);
}
Log.d(LOG_TAG, "FinalFinal item " + item);
selectMenuItem(item);
/*if (savedInstanceState == null) {
select(findByClassName(last));
} else {
setActive(last);
}*/
}
use of forpdateam.ru.forpda.ui.fragments.TabFragment in project ForPDA by RadiationX.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (EmptyActivity.empty(App.get().getPreferences().getString("auth.user.nick", ""))) {
startActivity(new Intent(this, EmptyActivity.class));
finish();
return;
}
Intent intent = getIntent();
if (intent != null) {
checkWebView = intent.getBooleanExtra(CHECK_WEBVIEW, checkWebView);
}
if (checkWebView) {
Observable.fromCallable(() -> App.get().isWebViewFound(this)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(aBoolean -> {
if (!aBoolean) {
startActivity(new Intent(App.getContext(), WebVewNotFoundActivity.class));
finish();
}
});
}
currentThemeIsDark = App.get().isDarkTheme();
setTheme(currentThemeIsDark ? R.style.DarkAppTheme_NoActionBar : R.style.LightAppTheme_NoActionBar);
setContentView(R.layout.activity_main);
DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawerLayout.addDrawerListener(toggle);
toggle.syncState();
/*
* Т.к. 2 вьюхи, делаю цвет в 2 раза прозрачнее, чтобы компенсировать это.
* P.S. Чем больше вьюх в DrawerLayout находятся до NavigationView, тем сильнее будет затенение
* P.S.S. Первая вьюха - контейнер фрагментов, вторая - view_for_measure
* */
drawerLayout.setScrimColor(0x4C000000);
drawers = new Drawers(this, drawerLayout);
drawers.init(savedInstanceState);
drawerHeader = new DrawerHeader(this, drawerLayout);
drawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
}
@Override
public void onDrawerOpened(View drawerView) {
if (drawerView.getId() == R.id.menu_drawer) {
if (App.get().getPreferences().getBoolean("drawers.tooltip.link_open", true)) {
SimpleTooltip tooltip = new SimpleTooltip.Builder(MainActivity.this).anchorView(drawerView.findViewById(R.id.drawer_header_open_link)).text(R.string.tooltip_link).gravity(Gravity.BOTTOM).animated(false).modal(true).transparentOverlay(false).backgroundColor(Color.BLACK).textColor(Color.WHITE).padding((float) App.px16).onDismissListener(simpleTooltip -> tooltips.remove(simpleTooltip)).build();
tooltip.show();
tooltips.add(tooltip);
App.get().getPreferences().edit().putBoolean("drawers.tooltip.link_open", false).apply();
}
}
}
@Override
public void onDrawerClosed(View drawerView) {
if (drawerView.getId() == R.id.menu_drawer) {
if (App.get().getPreferences().getBoolean("drawers.tooltip.tabs_drawer", true)) {
SimpleTooltip tooltip = new SimpleTooltip.Builder(MainActivity.this).anchorView(drawers.getTabDrawer()).text(R.string.tooltip_tabs).gravity(Gravity.START).animated(false).modal(true).transparentOverlay(false).backgroundColor(Color.BLACK).textColor(Color.WHITE).padding((float) App.px16).onDismissListener(simpleTooltip -> tooltips.remove(simpleTooltip)).build();
tooltip.show();
tooltips.add(tooltip);
App.get().getPreferences().edit().putBoolean("drawers.tooltip.tabs_drawer", false).apply();
}
}
}
@Override
public void onDrawerStateChanged(int newState) {
if (newState == DrawerLayout.STATE_DRAGGING) {
TabFragment fragment = TabManager.get().getActive();
if (fragment != null) {
fragment.hidePopupWindows();
}
}
}
});
receiver = new NetworkStateReceiver();
receiver.registerReceiver();
KeyboardUtil keyboardUtil = new KeyboardUtil(this, findViewById(R.id.fragments_container));
keyboardUtil.enable();
final View viewDiff = findViewById(R.id.view_for_measure);
viewDiff.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> measureView(v));
if (Preferences.Notifications.Update.isEnabled(getApplicationContext())) {
new SimpleUpdateChecker().checkFromGitHub(this);
}
checkIntent(getIntent());
}
use of forpdateam.ru.forpda.ui.fragments.TabFragment in project ForPDA by RadiationX.
the class MainActivity method backHandler.
public void backHandler(boolean fromToolbar) {
/*if (TabManager.get().getSize() <= 1) {
super.onBackPressed();
} else {
if (fromToolbar || !TabManager.get().getActive().onBackPressed()) {
hideKeyboard();
TabManager.get().remove(TabManager.get().getActive());
}
}*/
TabFragment active = TabManager.get().getActive();
if (active == null) {
finish();
return;
}
if (fromToolbar || !active.onBackPressed()) {
hideKeyboard();
TabManager.get().remove(active);
if (TabManager.get().getSize() < 1) {
finish();
}
}
}
Aggregations