public static final void showFragment(Fragment newFragment, Integer intTransitionType) { if (intTransitionType == null) Multicards.getMainActivity() .getFragmentManager() .beginTransaction() .setCustomAnimations( R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right, R.anim.slide_out_left) .replace(R.id.fragment_flashcard_container, newFragment) .commit(); else if (intTransitionType == Constants.ANIMATION_FLIP) Multicards.getMainActivity() .getFragmentManager() .beginTransaction() .setCustomAnimations( R.anim.flip_right_in, R.anim.flip_right_out, R.anim.flip_left_in, R.anim.flip_left_out) .replace(R.id.fragment_flashcard_container, newFragment) .commit(); currentFragment = newFragment; if (newFragment instanceof FlashCardFragment) currentFlashCardFragment = (FlashCardFragment) newFragment; }
public static final void showPlayersInfo(Boolean boolConfigurationChange) { if ((playersInfoFragment == null) || boolConfigurationChange) playersInfoFragment = new PlayersInfoFragment(); if (!playersInfoFragment.isAdded()) { Multicards.getMainActivity() .getFragmentManager() .beginTransaction() .add(R.id.fragment_players_info_container, playersInfoFragment) .commit(); Multicards.getMainActivity().getFragmentManager().executePendingTransactions(); } }
public static final void returnToMainMenu(Boolean boolConfigurationChange) { showMainMenu(boolConfigurationChange); hidePlayersInfo(); hideCurrentFlashcardFragment(); hideUserProfileFragment(); hideGameOverFragment(); Multicards.getMainActivity().linearLayoutEmoticons.setVisibility(View.GONE); Multicards.getMainActivity().linearLayoutBottomBar.setVisibility(View.INVISIBLE); intUIState = Constants.UI_STATE_MAIN_MENU; setUIStates.remove(Constants.UI_STATE_MULTIPLAYER_MODE); setUIStates.remove(Constants.UI_STATE_TRAIN_MODE); setUIStates.remove(Constants.UI_STATE_GAME_OVER); }
public static final void hideUserProfileFragment() { if ((userProfileFragment != null) && (userProfileFragment.isAdded())) Multicards.getMainActivity() .getFragmentManager() .beginTransaction() .remove(userProfileFragment) .commit(); }
public static final void hideMainMenu() { if ((mainMenuFragment != null) && (mainMenuFragment.isAdded())) Multicards.getMainActivity() .getFragmentManager() .beginTransaction() .remove(mainMenuFragment) .commit(); }
public static final void hidePlayersInfo() { if ((playersInfoFragment != null) && (playersInfoFragment.isAdded())) Multicards.getMainActivity() .getFragmentManager() .beginTransaction() .remove(playersInfoFragment) .commit(); }
public static final void hideCurrentFlashcardFragment() { if ((currentFlashCardFragment != null) && (currentFlashCardFragment.isAdded())) { Multicards.getMainActivity() .getFragmentManager() .beginTransaction() .remove(currentFlashCardFragment) .commit(); currentFlashCardFragment = null; } }
public static final void showGamePlayFragments(Boolean boolConfigurationChange, int state) { hideMainMenu(); intUIState = state; setUIStates.add(state); showPlayersInfo(boolConfigurationChange); if (boolConfigurationChange) showFragment(FlashCardFragment.cloneFragment(currentFlashCardFragment), null); Multicards.getMainActivity().linearLayoutEmoticons.setVisibility(View.INVISIBLE); // Multicards.getMainActivity().linearLayoutBottomBar.setVisibility(View.VISIBLE); }
public static final void showMainMenu(Boolean boolConfigurationChange) { if ((mainMenuFragment == null) || boolConfigurationChange) mainMenuFragment = new MainMenuFragment(); if (!mainMenuFragment.isAdded()) Multicards.getMainActivity() .getFragmentManager() .beginTransaction() .add(R.id.fragment_flashcard_container, mainMenuFragment) .commit(); }
public static final void showGameOverFragment( String strCardsetID, GameOverMessage gameOverMessage, Boolean boolConfigurationChange) { hidePlayersInfo(); hideCurrentFlashcardFragment(); Intent intent = new Intent(Multicards.getMainActivity(), GameOverActivity.class); intent.putExtra(Constants.INTENT_META_SET_ID, strCardsetID); if (intUIState == Constants.UI_STATE_MULTIPLAYER_MODE) intent.putExtra(Constants.INTENT_META_GAME_TYPE, GameOverActivity.INT_GAME_TYPE_MULTIPLAYER); else if (intUIState == Constants.UI_STATE_TRAIN_MODE) intent.putExtra(Constants.INTENT_META_GAME_TYPE, GameOverActivity.INT_GAME_TYPE_SINGLEPLAYER); if (gameOverMessage != null) intent.putExtra(Constants.INTENT_META_GAMEOVER_MESSAGE, gson.toJson(gameOverMessage)); hideGameOverFragment(); Multicards.getMainActivity().startActivity(intent); intUIState = Constants.UI_STATE_GAME_OVER; setUIStates.add(Constants.UI_STATE_GAME_OVER); }
public static final void showUserProfileFragment(Boolean boolConfigurationChange) { hidePlayersInfo(); hideCurrentFlashcardFragment(); hideMainMenu(); if ((userProfileFragment == null) || boolConfigurationChange) { userProfileFragment = new UserProfileFragment(); } if (!userProfileFragment.isAdded()) Multicards.getMainActivity() .getFragmentManager() .beginTransaction() .add(R.id.fragment_flashcard_container, userProfileFragment) .commit(); intUIState = Constants.UI_STATE_SETTINGS; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cardset_picker); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.container); mViewPager.setAdapter(mSectionsPagerAdapter); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null) .show(); } }); mViewPager.addOnPageChangeListener( new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels) {} @Override public void onPageSelected(int position) { tabLayout.getTabAt(position).select(); } @Override public void onPageScrollStateChanged(int state) {} }); tabLayout = (TabLayout) findViewById(R.id.tabLayoutCardsetPicker); String[] mTabItems = getResources().getStringArray(R.array.tab_items_cardsetpicker); tabLayout.addTab(tabLayout.newTab().setText(mTabItems[0])); tabLayout.addTab(tabLayout.newTab().setText(mTabItems[1])); tabLayout.setOnTabSelectedListener( new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { mViewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(TabLayout.Tab tab) {} @Override public void onTabReselected(TabLayout.Tab tab) {} }); cardsetPickerFragment = new SearchCardsetFragment(); cardsetRecentsFragment = new RecentCardsetsFragment(); memorizer.freecoders.com.flashcards.FragmentManager.intUIState = Constants.UI_STATE_CARD_PICK; Multicards.setCardsetPickerActivity(this); }
public static final void initEmoticons() { if ((Multicards.getMultiplayerInterface().currentGame == null) || (Multicards.getMultiplayerInterface().currentGame.game == null) || (Multicards.getMultiplayerInterface().currentGame.game.profiles == null)) return; final String strOpponentSocketID = Utils.extractOpponentSocketID( Multicards.getMultiplayerInterface().currentGame.game.profiles); Multicards.getMainActivity() .imageViewEmoticon1 .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { SocketInterface.emitSendEmoticon(strOpponentSocketID, 1); playersInfoFragment.showEmoticon(false, 1); } }); Multicards.getMainActivity() .imageViewEmoticon2 .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { SocketInterface.emitSendEmoticon(strOpponentSocketID, 2); playersInfoFragment.showEmoticon(false, 2); } }); Multicards.getMainActivity() .imageViewEmoticon3 .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { SocketInterface.emitSendEmoticon(strOpponentSocketID, 3); playersInfoFragment.showEmoticon(false, 3); } }); Multicards.getMainActivity() .imageViewEmoticon4 .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { SocketInterface.emitSendEmoticon(strOpponentSocketID, 4); playersInfoFragment.showEmoticon(false, 4); } }); Multicards.getMainActivity() .imageViewEmoticon5 .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { SocketInterface.emitSendEmoticon(strOpponentSocketID, 5); playersInfoFragment.showEmoticon(false, 5); } }); Multicards.getMainActivity() .imageViewEmoticon6 .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { SocketInterface.emitSendEmoticon(strOpponentSocketID, 6); playersInfoFragment.showEmoticon(false, 6); } }); }
public static final void hideCardsetPickerActivity() { if (Multicards.getCardsetPickerActivity() != null) Multicards.getCardsetPickerActivity().finish(); }
public static final void hideGameOverFragment() { if (Multicards.getGameOverActivity() != null) Multicards.getGameOverActivity().finish(); }