use of net.iGap.fragments.BottomNavigationFragment in project iGap-Android by KianIranian-STDG.
the class ActivityMain method onBackPressed.
@Override
public void onBackPressed() {
Log.wtf(this.getClass().getName(), "onBackPressed");
if (G.ISRealmOK) {
if (G.onBackPressedWebView != null) {
Log.wtf(this.getClass().getName(), "onBackPressedWebView");
if (G.onBackPressedWebView.onBack()) {
return;
}
}
if (G.onBackPressedChat != null) {
Log.wtf(this.getClass().getName(), "onBackPressedChat");
if (G.onBackPressedChat.onBack()) {
return;
}
}
if (onBackPressedListener != null) {
Log.wtf(this.getClass().getName(), "onBackPressedChat");
onBackPressedListener.doBack();
}
if (G.twoPaneMode) {
Log.wtf(this.getClass().getName(), "twoPaneMode");
if (findViewById(R.id.fullScreenFrame).getVisibility() == View.VISIBLE) {
// handle back in fragment show like dialog
Log.wtf(this.getClass().getName(), "fullScreenFrame VISIBLE");
Fragment frag = getSupportFragmentManager().findFragmentById(R.id.fullScreenFrame);
if (frag == null) {
Log.wtf(this.getClass().getName(), "pop from: detailFrame");
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.detailFrame);
if (fragment != null) {
getSupportFragmentManager().popBackStackImmediate();
}
Fragment fragmentShowed = getSupportFragmentManager().findFragmentById(R.id.detailFrame);
if (fragmentShowed == null) {
findViewById(R.id.fullScreenFrame).setVisibility(View.GONE);
}
} else {
Log.wtf(this.getClass().getName(), "pop from: fullScreenFrame");
getSupportFragmentManager().popBackStackImmediate();
findViewById(R.id.fullScreenFrame).setVisibility(View.GONE);
}
} else {
Log.wtf(this.getClass().getName(), "fullScreenFrame not VISIBLE");
if (getSupportFragmentManager().getBackStackEntryCount() > 2) {
Log.wtf(this.getClass().getName(), "pop from: backStack");
if (getSupportFragmentManager().getBackStackEntryAt(2).getName().equals(FragmentChat.class.getName())) {
if (G.isLandscape) {
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.roomListFrame);
if (fragment instanceof BottomNavigationFragment) {
if (((BottomNavigationFragment) fragment).isAllowToBackPressed()) {
getSupportFragmentManager().popBackStackImmediate();
}
} else {
getSupportFragmentManager().popBackStackImmediate();
}
} else {
getSupportFragmentManager().popBackStackImmediate();
findViewById(R.id.mainFrame).setVisibility(View.GONE);
findViewById(R.id.roomListFrame).setVisibility(View.VISIBLE);
}
} else {
getSupportFragmentManager().popBackStackImmediate();
}
} else {
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.roomListFrame);
if (fragment instanceof BottomNavigationFragment) {
if (((BottomNavigationFragment) fragment).isAllowToBackPressed()) {
if (((BottomNavigationFragment) fragment).isFirstTabItem()) {
Log.wtf(this.getClass().getName(), "pop from: finish");
finish();
}
}
}
}
}
} else {
if (getSupportFragmentManager().getBackStackEntryCount() > 1) {
// List fragmentList = getSupportFragmentManager().getFragments();
boolean handled = false;
try {
// because some of our fragments are NOT extended from BaseFragment
if (getSupportFragmentManager().findFragmentById(R.id.chatContainer) instanceof SearchFragment) {
SearchFragment searchFragment = (SearchFragment) getSupportFragmentManager().findFragmentById(R.id.chatContainer);
if (searchFragment != null && searchFragment.isVisible()) {
searchFragment.onSearchCollapsed();
}
}
Fragment frag = getSupportFragmentManager().findFragmentByTag(getSupportFragmentManager().getBackStackEntryAt(getSupportFragmentManager().getBackStackEntryCount() - 1).getName());
handled = ((BaseFragment) frag).onBackPressed();
} catch (Exception e) {
e.printStackTrace();
}
if (!handled) {
super.onBackPressed();
}
} else {
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.mainFrame);
if (fragment instanceof BottomNavigationFragment) {
if (((BottomNavigationFragment) fragment).isAllowToBackPressed()) {
if (((BottomNavigationFragment) fragment).isFirstTabItem()) {
finish();
}
}
}
}
}
} else {
super.onBackPressed();
}
}
use of net.iGap.fragments.BottomNavigationFragment in project iGap-Android by KianIranian-STDG.
the class ActivityMain method checkIntent.
private void checkIntent(Intent intent) {
if (G.isRestartActivity) {
return;
}
if (intent.getAction() != null && intent.getAction().equals("net.iGap.payment")) {
FragmentManager fragmentManager = getSupportFragmentManager();
Fragment fragment = fragmentManager.findFragmentByTag(PaymentFragment.class.getName());
if (fragment instanceof PaymentFragment) {
((PaymentFragment) fragment).setPaymentResult(new Payment(intent.getStringExtra("status"), intent.getStringExtra("message"), intent.getStringExtra("order_id"), intent.getStringExtra("tax"), intent.getStringExtra("discount")));
}
}
new HelperGetDataFromOtherApp(this, intent);
// check has shared data if true setup main fragment (room list) ui
Fragment fragmentBottomNav = getSupportFragmentManager().findFragmentByTag(BottomNavigationFragment.class.getName());
if (fragmentBottomNav instanceof BottomNavigationFragment) {
// set true just for checking state
((BottomNavigationFragment) fragmentBottomNav).checkHasSharedData(true);
((BottomNavigationFragment) fragmentBottomNav).isFirstTabItem();
}
if (intent.getAction() != null && intent.getAction().equals("net.iGap.activities.OPEN_ACCOUNT")) {
new HelperFragment(getSupportFragmentManager(), new FragmentSetting()).load();
}
Bundle extras = intent.getExtras();
if (extras != null) {
long roomId = extras.getLong(ActivityMain.openChat);
if (!FragmentLanguage.languageChanged && roomId > 0) {
// if language changed not need check enter to chat
// GoToChatActivity goToChatActivity = new GoToChatActivity(roomId);
// TODO this change is duo to room null bug. if it works server must change routine.
long peerId = extras.getLong("PeerID");
long userId = extras.getLong(ActivityMain.userId);
if (AccountManager.getInstance().getCurrentUser().getId() != userId) {
new AccountHelper().changeAccount(userId);
updateUiForChangeAccount();
}
HelperUrl.goToActivityFromFCM(this, roomId, peerId);
}
FragmentLanguage.languageChanged = false;
boolean openMediaPlayer = extras.getBoolean(ActivityMain.openMediaPlayer);
if (openMediaPlayer) {
if (getSupportFragmentManager().findFragmentByTag(FragmentMediaPlayer.class.getName()) == null) {
FragmentMediaPlayer fragment = new FragmentMediaPlayer();
new HelperFragment(getSupportFragmentManager(), fragment).setReplace(false).load();
}
}
}
}
use of net.iGap.fragments.BottomNavigationFragment in project iGap-Android by KianIranian-STDG.
the class ActivityMain method initTabStrip.
// ******************************************************************************************************************************
private void initTabStrip(Intent intent) {
if (G.twoPaneMode) {
new HelperFragment(getSupportFragmentManager(), new TabletEmptyChatFragment()).load(true);
}
Log.wtf(this.getClass().getName(), "initTabStrip");
BottomNavigationFragment bottomNavigationFragment = new BottomNavigationFragment();
if (intent.getExtras() != null && intent.getExtras().getString(DEEP_LINK) != null) {
bottomNavigationFragment.setCrawlerMap(intent.getExtras().getString(DEEP_LINK, DEEP_LINK_CALL));
}
new HelperFragment(getSupportFragmentManager(), bottomNavigationFragment).load();
}
use of net.iGap.fragments.BottomNavigationFragment in project iGap-Android by KianIranian-STDG.
the class ActivityMain method setForwardMessage.
public void setForwardMessage(boolean enable) {
Fragment fragment = getSupportFragmentManager().findFragmentByTag(BottomNavigationFragment.class.getName());
if (fragment instanceof BottomNavigationFragment) {
((BottomNavigationFragment) fragment).setForwardMessage(enable);
((BottomNavigationFragment) fragment).isFirstTabItem();
}
}
use of net.iGap.fragments.BottomNavigationFragment in project iGap-Android by KianIranian-STDG.
the class DiscoveryFragment method discoveryCrawler.
public void discoveryCrawler(FragmentActivity activity) {
BottomNavigationFragment bottomNavigationFragment = (BottomNavigationFragment) activity.getSupportFragmentManager().findFragmentByTag(BottomNavigationFragment.class.getName());
try {
if (bottomNavigationFragment != null) {
for (int i = 0; i < discoveryArrayList.size(); i++) {
ArrayList<DiscoveryItemField> discoveryFields = discoveryArrayList.get(i).discoveryFields;
for (int j = 0; j < discoveryFields.size(); j++) {
if (discoveryFields.get(j).id == bottomNavigationFragment.getCrawlerStruct().getPages().get(bottomNavigationFragment.getCrawlerStruct().getCurrentPage())) {
if (bottomNavigationFragment.getCrawlerStruct().getPageSum() > 0) {
int currentPage = bottomNavigationFragment.getCrawlerStruct().getCurrentPage();
currentPage++;
bottomNavigationFragment.getCrawlerStruct().setCurrentPage(currentPage);
bottomNavigationFragment.getCrawlerStruct().setCurrentPageId(discoveryFields.get(j).id);
BaseViewHolder.handleDiscoveryFieldsClickStatic(discoveryFields.get(j), getActivity(), bottomNavigationFragment.getCrawlerStruct().getHaveNext());
} else
BaseViewHolder.handleDiscoveryFieldsClickStatic(discoveryFields.get(j), getActivity(), false);
needToCrawl = false;
return;
}
}
}
}
} catch (Exception e) {
HelperError.showSnackMessage(getResources().getString(R.string.link_not_valid), false);
}
}
Aggregations