Search in sources :

Example 1 with BottomNavigationFragment

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();
    }
}
Also used : BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment) SearchFragment(net.iGap.fragments.SearchFragment) FragmentChat(net.iGap.fragments.FragmentChat) PaymentFragment(net.iGap.fragments.PaymentFragment) Fragment(androidx.fragment.app.Fragment) HelperFragment(net.iGap.helper.HelperFragment) OpenFragment(net.iGap.observers.interfaces.OpenFragment) TabletEmptyChatFragment(net.iGap.fragments.TabletEmptyChatFragment) BaseFragment(net.iGap.fragments.BaseFragment) CameraStoryFragment(net.iGap.story.CameraStoryFragment) CallSelectFragment(net.iGap.fragments.CallSelectFragment) SearchFragment(net.iGap.fragments.SearchFragment) DiscoveryFragment(net.iGap.fragments.discovery.DiscoveryFragment) BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment) RemoteException(android.os.RemoteException) IOException(java.io.IOException) ActivityNotFoundException(android.content.ActivityNotFoundException)

Example 2 with BottomNavigationFragment

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();
            }
        }
    }
}
Also used : HelperGetDataFromOtherApp(net.iGap.helper.HelperGetDataFromOtherApp) AccountHelper(net.iGap.module.accountManager.AccountHelper) PaymentFragment(net.iGap.fragments.PaymentFragment) FragmentSetting(net.iGap.fragments.FragmentSetting) Bundle(android.os.Bundle) PaymentFragment(net.iGap.fragments.PaymentFragment) Fragment(androidx.fragment.app.Fragment) HelperFragment(net.iGap.helper.HelperFragment) OpenFragment(net.iGap.observers.interfaces.OpenFragment) TabletEmptyChatFragment(net.iGap.fragments.TabletEmptyChatFragment) BaseFragment(net.iGap.fragments.BaseFragment) CameraStoryFragment(net.iGap.story.CameraStoryFragment) CallSelectFragment(net.iGap.fragments.CallSelectFragment) SearchFragment(net.iGap.fragments.SearchFragment) DiscoveryFragment(net.iGap.fragments.discovery.DiscoveryFragment) BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment) FragmentManager(androidx.fragment.app.FragmentManager) OnPayment(net.iGap.observers.interfaces.OnPayment) Payment(net.iGap.model.payment.Payment) BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment) FragmentMediaPlayer(net.iGap.fragments.FragmentMediaPlayer) HelperFragment(net.iGap.helper.HelperFragment)

Example 3 with BottomNavigationFragment

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();
}
Also used : BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment) TabletEmptyChatFragment(net.iGap.fragments.TabletEmptyChatFragment) HelperFragment(net.iGap.helper.HelperFragment)

Example 4 with BottomNavigationFragment

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();
    }
}
Also used : BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment) PaymentFragment(net.iGap.fragments.PaymentFragment) Fragment(androidx.fragment.app.Fragment) HelperFragment(net.iGap.helper.HelperFragment) OpenFragment(net.iGap.observers.interfaces.OpenFragment) TabletEmptyChatFragment(net.iGap.fragments.TabletEmptyChatFragment) BaseFragment(net.iGap.fragments.BaseFragment) CameraStoryFragment(net.iGap.story.CameraStoryFragment) CallSelectFragment(net.iGap.fragments.CallSelectFragment) SearchFragment(net.iGap.fragments.SearchFragment) DiscoveryFragment(net.iGap.fragments.discovery.DiscoveryFragment) BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment)

Example 5 with BottomNavigationFragment

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);
    }
}
Also used : BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment) DiscoveryItemField(net.iGap.adapter.items.discovery.DiscoveryItemField)

Aggregations

BottomNavigationFragment (net.iGap.fragments.BottomNavigationFragment)9 DiscoveryFragment (net.iGap.fragments.discovery.DiscoveryFragment)6 TabletEmptyChatFragment (net.iGap.fragments.TabletEmptyChatFragment)5 HelperFragment (net.iGap.helper.HelperFragment)5 Fragment (androidx.fragment.app.Fragment)4 BaseFragment (net.iGap.fragments.BaseFragment)4 CallSelectFragment (net.iGap.fragments.CallSelectFragment)4 PaymentFragment (net.iGap.fragments.PaymentFragment)4 SearchFragment (net.iGap.fragments.SearchFragment)4 OpenFragment (net.iGap.observers.interfaces.OpenFragment)4 CameraStoryFragment (net.iGap.story.CameraStoryFragment)4 FragmentManager (androidx.fragment.app.FragmentManager)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1 SharedPreferences (android.content.SharedPreferences)1 Bundle (android.os.Bundle)1 RemoteException (android.os.RemoteException)1 TextPaint (android.text.TextPaint)1 ClickableSpan (android.text.style.ClickableSpan)1 View (android.view.View)1 IOException (java.io.IOException)1