Example #1
0
  /** Set Design of ActionBar */
  @Override
  protected void onStart() {
    super.onStart();
    ActionBar actionBar = this.getSupportActionBar();
    actionBar.setSubtitle(R.string.app_subtitle);

    // add WebserverFragment when enabled in preferences
    if (PreferenceHelper.getWebserverEnabled(this)) {
      FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();

      mWebserverFragment = new WebserverFragment();
      // replace container in view with fragment
      fragmentTransaction.replace(R.id.base_activity_webserver_container, mWebserverFragment);
      fragmentTransaction.commit();
    } else {
      // when disabled in preferences remove fragment if existing
      if (mWebserverFragment != null) {
        FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();

        fragmentTransaction.remove(mWebserverFragment);
        fragmentTransaction.commit();

        mWebserverFragment = null;
      }
    }
  }
Example #2
0
 private void loadSelection(int i) {
   switch (i) {
     case 0:
       CostOverviewFragment overviewFragment = new CostOverviewFragment();
       toolbar.setTitle("Cost Overview");
       FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
       Bundle bundle = new Bundle();
       bundle.putParcelable("house", house);
       bundle.putParcelable("account", current);
       bundle.putInt("cost", getIntent().getBundleExtra("extra").getInt("cost"));
       getIntent().putExtra("extra", bundle);
       fragmentTransaction.replace(R.id.detailsFragmentHolder, overviewFragment);
       fragmentTransaction.addToBackStack(overviewFragment.getTag());
       fragmentTransaction.commit();
       break;
     case 1:
       PersonalCostOverview personalCostOverview = new PersonalCostOverview();
       toolbar.setTitle(cost.getSplit().get(selectedUser).getName() + "'s payments");
       fragmentTransaction = fragmentManager.beginTransaction();
       bundle = new Bundle();
       bundle.putParcelable("house", house);
       bundle.putParcelable("account", current);
       bundle.putInt("cost", getIntent().getBundleExtra("extra").getInt("cost"));
       bundle.putInt("selected", selectedUser);
       getIntent().putExtra("extra", bundle);
       fragmentTransaction.replace(R.id.detailsFragmentHolder, personalCostOverview);
       fragmentTransaction.addToBackStack(personalCostOverview.getTag());
       fragmentTransaction.commit();
       break;
   }
 }
Example #3
0
  @Override
  public void onNavigationDrawerItemSelected(int position) {
    super.onNavigationDrawerItemSelected(position);
    FragmentManager fm;
    FragmentTransaction transaction;

    switch (position) {
      case 0:
        fm = getSupportFragmentManager();
        transaction = fm.beginTransaction();
        transaction.replace(R.id.main_content, getColumbiaFragment());
        transaction.commit();

        getSupportActionBar().setSubtitle("Columbia");
        break;
      case 1:
        fm = getSupportFragmentManager();
        transaction = fm.beginTransaction();
        transaction.replace(R.id.main_content, getCroftonFragment());
        transaction.commit();

        getSupportActionBar().setSubtitle("Crofton");
        break;
      case 2:
        // Show the default location selection dialog
        DefaultLocationDialog f = DefaultLocationDialog.newInstance();
        f.show(getSupportFragmentManager(), TAG);

        break;
      default:
        FriscoUtil.toast(this, "Pressed: " + position);
    }
  }
Example #4
0
  public void removeCurrent() {
    if (currentFragment != null) {
      currentFragment.setPrimaryFragment(false);
    }
    Fragment oldFrag = currentFragment;

    currentFragment = backStack.remove(backStack.size() - 1);
    currentFragment.setPrimaryFragment(true, false);
    supportInvalidateOptionsMenu();

    if (secondaryContainer == null) {
      FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
      trans.setCustomAnimations(
          R.anim.enter_from_left,
          R.anim.exit_to_right,
          R.anim.enter_from_right,
          R.anim.exit_to_left);
      trans.remove(oldFrag);
      trans.show(currentFragment);
      trans.commit();
    } else {
      FragmentTransaction trans = getSupportFragmentManager().beginTransaction();

      // Remove old right fragment
      trans.setCustomAnimations(
          R.anim.enter_from_left,
          R.anim.exit_to_right,
          R.anim.enter_from_right,
          R.anim.exit_to_left);
      trans.remove(oldFrag);

      // Only switch places if there is a backstack, otherwise primary container is correct
      if (backStack.size() > 0) {
        trans.setCustomAnimations(0, 0, 0, 0);
        // Add current left fragment to right side
        trans.remove(currentFragment);

        // Make sure remove is finished before adding
        trans.commit();
        getSupportFragmentManager().executePendingTransactions();

        trans = getSupportFragmentManager().beginTransaction();
        // trans.setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right,
        // R.anim.enter_from_right, R.anim.exit_to_left);
        trans.add(
            R.id.fragment_second_container, currentFragment, currentFragment.getSupportTag() + "");

        SubsonicFragment newLeftFragment = backStack.get(backStack.size() - 1);
        newLeftFragment.setSecondaryFragment(true);
        trans.show(newLeftFragment);
      } else {
        secondaryContainer.startAnimation(AnimationUtils.loadAnimation(this, R.anim.exit_to_right));
        secondaryContainer.setVisibility(View.GONE);
      }

      trans.commit();
    }
    recreateSpinner();
  }
Example #5
0
  @Override
  public void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    int size = savedInstanceState.getInt(Constants.MAIN_BACK_STACK_SIZE);
    String[] ids = savedInstanceState.getStringArray(Constants.MAIN_BACK_STACK);
    FragmentManager fm = getSupportFragmentManager();
    currentFragment = (SubsonicFragment) fm.findFragmentByTag(ids[0]);
    currentFragment.setPrimaryFragment(true);
    currentFragment.setSupportTag(ids[0]);
    supportInvalidateOptionsMenu();
    FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
    for (int i = 1; i < size; i++) {
      SubsonicFragment frag = (SubsonicFragment) fm.findFragmentByTag(ids[i]);
      frag.setSupportTag(ids[i]);
      if (secondaryContainer != null) {
        frag.setPrimaryFragment(false, true);
      }
      trans.hide(frag);
      backStack.add(frag);
    }
    trans.commit();

    // Current fragment is hidden in secondaryContainer
    if (secondaryContainer == null && !currentFragment.isVisible()) {
      trans = getSupportFragmentManager().beginTransaction();
      trans.remove(currentFragment);
      trans.commit();
      getSupportFragmentManager().executePendingTransactions();

      trans = getSupportFragmentManager().beginTransaction();
      trans.add(R.id.fragment_container, currentFragment, ids[0]);
      trans.commit();
    }
    // Current fragment needs to be moved over to secondaryContainer
    else if (secondaryContainer != null
        && secondaryContainer.findViewById(currentFragment.getRootId()) == null
        && backStack.size() > 0) {
      trans = getSupportFragmentManager().beginTransaction();
      trans.remove(currentFragment);
      trans.show(backStack.get(backStack.size() - 1));
      trans.commit();
      getSupportFragmentManager().executePendingTransactions();

      trans = getSupportFragmentManager().beginTransaction();
      trans.add(R.id.fragment_second_container, currentFragment, ids[0]);
      trans.commit();

      secondaryContainer.setVisibility(View.VISIBLE);
    }

    lastSelectedPosition = savedInstanceState.getInt(Constants.FRAGMENT_POSITION);
    if (lastSelectedPosition != 0) {
      MenuItem item = drawerList.getMenu().findItem(lastSelectedPosition);
      if (item != null) {
        item.setChecked(true);
      }
    }
    recreateSpinner();
  }
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();
    fab.setVisibility(View.VISIBLE);
    if (id == R.id.nav_camera) {
      // set the fragment initially
      MainFragment fragment = new MainFragment();
      android.support.v4.app.FragmentTransaction fragmentTransaction =
          getSupportFragmentManager().beginTransaction();
      fragmentTransaction.replace(R.id.fragment_container, fragment);
      fragmentTransaction.commit();
      // handle the camera action
    } else if (id == R.id.nav_gallery) {
      Zakkaartjes fragment = new Zakkaartjes();
      android.support.v4.app.FragmentTransaction fragmentTransaction =
          getSupportFragmentManager().beginTransaction();
      fragmentTransaction.replace(R.id.fragment_container, fragment);
      fragmentTransaction.commit();

    } else if (id == R.id.nav_slideshow) {
      Rekenen fragment = new Rekenen();
      android.support.v4.app.FragmentTransaction fragmentTransaction =
          getSupportFragmentManager().beginTransaction();
      fragmentTransaction.replace(R.id.fragment_container, fragment);
      fragmentTransaction.commit();

    } else if (id == R.id.nav_manage) {
      //            Intent intent = new Intent(this, Notities.class);
      //            startActivity(intent);
      //            finish();
      fab.setVisibility(View.GONE);
      NotitiesFragment fragment = new NotitiesFragment();
      android.support.v4.app.FragmentTransaction fragmentTransaction =
          getSupportFragmentManager().beginTransaction();
      fragmentTransaction.replace(R.id.fragment_container, fragment);
      fragmentTransaction.commit();

    } else if (id == R.id.nav_share) {
      Handelingen fragment = new Handelingen();
      android.support.v4.app.FragmentTransaction fragmentTransaction =
          getSupportFragmentManager().beginTransaction();
      fragmentTransaction.replace(R.id.fragment_container, fragment);
      fragmentTransaction.commit();

    } else if (id == R.id.nav_send) {
      Intent emailIntent =
          new Intent(
              Intent.ACTION_SENDTO, Uri.fromParts("mailto", "*****@*****.**", null));
      emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Email van verpleegkundig zakboek app");
      startActivity(Intent.createChooser(emailIntent, "Verzend e-mail"));
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    if (item.getItemId() == R.id.map_view) {
      category =
          (getArguments() != null) ? getArguments().getString(SearchFragment.ARG_CATEGORY) : null;
      if (category != null) {
        MapManager.switchToMapView(category, HomeFragment.ARG_POI_CATEGORY, this);
      } else {
        ArrayList<BaseDTObject> target = new ArrayList<BaseDTObject>();
        for (int i = 0; i < list.getAdapter().getCount(); i++) {
          BaseDTObject o = (BaseDTObject) list.getAdapter().getItem(i);
          target.add(o);
        }
        MapManager.switchToMapView(target, this);
      }
      return true;
    } else if (item.getItemId() == R.id.menu_item_addpoi) {
      {
        FragmentTransaction fragmentTransaction =
            getSherlockActivity().getSupportFragmentManager().beginTransaction();
        Fragment fragment = new CreatePoiFragment();
        Bundle args = new Bundle();
        args.putString(SearchFragment.ARG_CATEGORY, category);
        fragment.setArguments(args);
        fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        // fragmentTransaction.detach(this);
        fragmentTransaction.replace(R.id.fragment_container, fragment, "pois");
        fragmentTransaction.addToBackStack(fragment.getTag());
        fragmentTransaction.commit();
        reload = true;
        return true;
      }
    } else if (item.getItemId() == R.id.submenu_search) {
      FragmentTransaction fragmentTransaction;
      Fragment fragment;
      fragmentTransaction = getSherlockActivity().getSupportFragmentManager().beginTransaction();
      fragment = new SearchFragment();
      Bundle args = new Bundle();
      args.putString(SearchFragment.ARG_CATEGORY, category);
      args.putString(CategoryHelper.CATEGORY_TYPE_POIS, CategoryHelper.CATEGORY_TYPE_POIS);
      if (getArguments() != null
          && getArguments().containsKey(SearchFragment.ARG_MY)
          && getArguments().getBoolean(SearchFragment.ARG_MY))
        args.putBoolean(SearchFragment.ARG_MY, getArguments().getBoolean(SearchFragment.ARG_MY));
      fragment.setArguments(args);
      fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
      fragmentTransaction.replace(R.id.fragment_container, fragment, "pois");
      fragmentTransaction.addToBackStack(fragment.getTag());
      fragmentTransaction.commit();
      /* add category to bundle */
      return true;

    } else {
      return super.onOptionsItemSelected(item);
    }
  }
Example #8
0
  @Override
  public void onClick(View arg0) {
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    for (int i = 0; i < mFragments.length; i++) {
      if (mFragments[i] != null) {
        fragmentTransaction.hide(mFragments[i]);
      }
    }
    switch (arg0.getId()) {
      case R.id.home:
        if (mFragments[0] != null) {
          fragmentTransaction.show(mFragments[0]);
        } else {
          fragmentTransaction.add(R.id.zhuye_content, fghome).show(fghome);
          mFragments[0] = fghome;
        }
        fragmentTransaction.commit();

        break;

      case R.id.session:
        if (mFragments[1] != null) {
          fragmentTransaction.show(mFragments[1]);
        } else {
          fragmentTransaction.add(R.id.zhuye_content, fsession).show(fsession);
          mFragments[1] = fsession;
        }
        fragmentTransaction.commit();
        break;

      case R.id.person:
        if (mFragments[2] != null) {
          fragmentTransaction.show(mFragments[2]);
        } else {
          fragmentTransaction.add(R.id.zhuye_content, fperson).show(fperson);
          mFragments[2] = fperson;
        }
        fragmentTransaction.commit();
        break;
      case R.id.nearby:
        if (mFragments[3] != null) {
          fragmentTransaction.show(mFragments[3]);
        } else {
          fragmentTransaction.add(R.id.zhuye_content, fNearby).show(fNearby);
          mFragments[3] = fNearby;
        }
        fragmentTransaction.commit();
        break;

      default:
        break;
    }
  }
  @Override
  public void onEmotionCategorySelected(int category) {
    final FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    final Fragment categoryFragment =
        getSupportFragmentManager().findFragmentByTag(EMOTION_CATEGORY_TAG);
    if (categoryFragment != null) ft.remove(categoryFragment);
    ft.commit();

    ft = fm.beginTransaction();
    final Fragment prev = getSupportFragmentManager().findFragmentByTag(EMOTION_TAG);
    if (prev != null) {
      ft.remove(prev);
    }

    DialogFragment newFragment = null;
    switch (category) {
      case CATEGORY_BASIC:
        newFragment = new EmotionDialogFragment();
        break;
      case CATEGORY_BAOZOU:
      case CATEGORY_XIONGMAO:
      case CATEGORY_TAIJUN:
      case CATEGORY_ALI:
      case CATEGORY_DAYANMAO:
      case CATEGORY_LUOXIAOHEI:
      case CATEGORY_MAJIANGLIAN:
      case CATEGORY_ZHAIYIN:
      case CATEGORY_YANGCONGTOU:
      case CATEGORY_ACNIANG:
      case CATEGORY_BIERDE:
      case CATEGORY_LINDABI:
      case CATEGORY_QUNIANG:
      case CATEGORY_NIWEIHEZHEMEDIAO:
      case CATEGORY_PST:
      case CATEGORY_DT:
        Bundle args = new Bundle();
        args.putInt("index", category - 1);
        newFragment = new ExtensionEmotionFragment();
        newFragment.setArguments(args);
        break;
      default:
    }
    // ft.commit();
    // ft.addToBackStack(null);

    if (newFragment != null) {
      ft.commit();
      newFragment.show(fm, EMOTION_TAG);
    }
  }
 /**
  * @param position
  * @return This method is used to replace fragment as per category list item selected.
  */
 public Fragment getIndexOfFragment(int position) {
   if (position == FragmentOne) {
     changePagerPage(0);
     FragmentOne fragmentOne = new FragmentOne();
     FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
     fragmentTransaction.replace(R.id.details_datafragment, fragmentOne);
     setCategoryListTitle("FragmentOne");
     fragmentTransaction.commit();
     setCategoryListItemBackground(FragmentOne);
     return fragmentOne;
   } else if (position == FragmentTwo) {
     changePagerPage(0);
     FragmentTwo fragmentTwo = new FragmentTwo();
     FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
     fragmentTransaction.replace(R.id.details_datafragment, fragmentTwo);
     setCategoryListTitle("FragmentTwo");
     fragmentTransaction.commit();
     setCategoryListItemBackground(FragmentTwo);
     return fragmentTwo;
   } else if (position == FragmentThree) {
     changePagerPage(0);
     FragmentThree fragmentThree = new FragmentThree();
     FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
     fragmentTransaction.replace(R.id.details_datafragment, fragmentThree);
     setCategoryListTitle("FragmentThree");
     fragmentTransaction.commit();
     setCategoryListItemBackground(FragmentThree);
     return fragmentThree;
   } else if (position == FragmentFour) {
     changePagerPage(0);
     FragmentFour fragmentFour = new FragmentFour();
     FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
     fragmentTransaction.replace(R.id.details_datafragment, fragmentFour);
     setCategoryListTitle("FragmentFour");
     fragmentTransaction.commit();
     setCategoryListItemBackground(FragmentFour);
     return fragmentFour;
   } else if (position == FragmentFive) {
     changePagerPage(0);
     FragmentFive fragmentFive = new FragmentFive();
     FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
     fragmentTransaction.replace(R.id.details_datafragment, fragmentFive);
     setCategoryListTitle("FragmentFive");
     fragmentTransaction.commit();
     setCategoryListItemBackground(FragmentFive);
     return fragmentFive;
   }
   return null;
 }
Example #11
0
  void showDetails(int index) {
    mCurCheckPosition = index;

    Log.d("HabrQA", "TitleFragment requests qestion with ID: " + questionsList.get(index).getId());

    if (mDualPane) {
      getListView().setItemChecked(index, true);

      DetailsFragment details =
          (DetailsFragment) getFragmentManager().findFragmentById(R.id.details);
      if (details == null /*|| details.getShownIndex() != index*/) {
        details =
            DetailsFragment.newInstance(
                questionsList.get(index).getId(),
                questionsList.get(index).getTitle(),
                questionsList.get(index).getDescription(),
                questionsList.get(index).getUrl().toString());

        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.replace(R.id.details, details);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.commit();
      }

    } else {
      Intent intent = new Intent();
      intent.setClass(getActivity(), DetailsActivity.class);
      //			intent.putExtra("index", index);
      intent.putExtra("id", questionsList.get(index).getId());
      intent.putExtra("title", questionsList.get(index).getTitle());
      intent.putExtra("data", questionsList.get(index).getDescription());
      intent.putExtra("link", questionsList.get(index).getUrl().toString());
      startActivity(intent);
    }
  }
Example #12
0
 public void commit(FragmentTransaction ft) {
   if (FRAG_ALLOW_LOSS_STATE == (FRAG_ALLOW_LOSS_STATE & mFlag)) {
     ft.commitAllowingStateLoss();
   } else {
     ft.commit();
   }
 }
 public void onKeyboardShow() {
   Log.i("KeyboardFragment", "Showing keyboard");
   FragmentManager fm = getFragmentManager();
   FragmentTransaction ft = fm.beginTransaction();
   ft.show(this);
   ft.commit();
 }
  private void displayView(int position) {

    String title = getString(R.string.app_name);
    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    switch (position) {
      case 0:
        fragment = new HomeFragment();
        title = getString(R.string.title_home);
        fragmentTransaction.replace(R.id.content_frame, fragment);
        break;
      case 1:
        //                fragment = new FriendsFragment();
        //                title = getString(R.string.title_friends);
        fragmentTransaction.remove(fragment);
        break;
      case 2:
        //                fragment = new MessagesFragment();
        //                title = getString(R.string.title_messages);
        break;
      default:
        break;
    }

    if (fragment != null) {

      fragmentTransaction.commit();

      // set the toolbar title
      getSupportActionBar().setTitle(title);
    }
  }
Example #15
0
 // changing manually to skip adding to back stack
 @Override
 public void paypalNetworkUnavailable() {
   FragmentTransaction ft = fm.beginTransaction();
   Fragment mFragement = SherlockFragment.instantiate(this, OrderSummary.class.getName(), null);
   ft.replace(R.id.layout_container, mFragement);
   ft.commit();
 }
Example #16
0
 public void switchTo(Class className, Bundle bundle, String tag) {
   FragmentTransaction ft = fm.beginTransaction();
   Fragment mFragement = SherlockFragment.instantiate(this, className.getName(), bundle);
   ft.replace(R.id.layout_container, mFragement, tag);
   ft.addToBackStack(null);
   ft.commit();
 }
Example #17
0
 // changing manually to skip adding to back stack
 @Override
 public void paymentSuccessful() {
   FragmentTransaction ft = fm.beginTransaction();
   Fragment mFragement = SherlockFragment.instantiate(this, ServerUpload.class.getName(), null);
   ft.replace(R.id.layout_container, mFragement, "SERVER_UPLOAD");
   ft.commit();
 }
Example #18
0
 private void loadFragments(String mensaje, int id) {
   FragmentManager gestorFragmentos = getSupportFragmentManager();
   gestorFragmentos.beginTransaction();
   FragmentTransaction transaccion = gestorFragmentos.beginTransaction();
   transaccion.replace(id, UnoFragment.newInstance(mensaje));
   transaccion.commit();
 }
  /** {@inheritDoc} */
  @Override
  public void openActivityOrFragment(final Intent intent) {
    final PackageManager pm = getPackageManager();
    List<ResolveInfo> resolveInfoList =
        pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
    for (ResolveInfo resolveInfo : resolveInfoList) {
      final FragmentReplaceInfo fri =
          onSubstituteFragmentForActivityLaunch(resolveInfo.activityInfo.name);
      if (fri != null) {
        final Bundle arguments = intentToFragmentArguments(intent);
        final FragmentManager fm = getSupportFragmentManager();

        try {
          Fragment fragment = (Fragment) fri.getFragmentClass().newInstance();
          fragment.setArguments(arguments);

          FragmentTransaction ft = fm.beginTransaction();
          ft.replace(fri.getContainerId(), fragment, fri.getFragmentTag());
          onBeforeCommitReplaceFragment(fm, ft, fragment);
          ft.commit();
        } catch (InstantiationException e) {
          throw new IllegalStateException("Error creating new fragment.", e);
        } catch (IllegalAccessException e) {
          throw new IllegalStateException("Error creating new fragment.", e);
        }
        return;
      }
    }
    super.openActivityOrFragment(intent);
  }
  protected void initView() {
    setContentViewSrc(R.layout.activity_web_layout);
    webView = new WebActivityFragment();
    pb_bar = (ProgressBar) findViewById(R.id.pb_bar);
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.add(R.id.fl_content, webView);
    ft.commit();

    refresh = new ImageView(this);
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(CommonUtils.dp2px(30), CommonUtils.dp2px(30));
    params.setMargins(0, 0, CommonUtils.dp2px(10), 0);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    refresh.setLayoutParams(params);
    if (!isUseToolbar()) addOptionsMenu(refresh);
    refresh.setBackgroundResource(R.mipmap.ic_refresh);
    refresh.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (isLoading) webView.stopLoading();
            else webView.refresh();
          }
        });
  }
Example #21
0
 private void replaceFragment(Fragment fragment) {
   final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
   ft.setCustomAnimations(R.anim.fragment_fade_enter, R.anim.fragment_fade_exit);
   ft.replace(R.id.content_view, fragment, fragment.getClass().getSimpleName());
   ft.addToBackStack(null);
   ft.commit();
 }
  public void initFragment(FragmentManager fragmentManager) {
    FragmentTransaction transaction;
    // 开启一个Fragment事务
    transaction = fragmentManager.beginTransaction();

    mainPageFragment = new MainPageFragment();
    transaction.add(R.id.content, mainPageFragment, Constant.FRAGMENTTAG[0]);

    scheduleFragment = new ScheduleFragment();
    transaction.add(R.id.content, scheduleFragment, Constant.FRAGMENTTAG[1]);

    gradesFragment = new GradesFragment();
    transaction.add(R.id.content, gradesFragment, Constant.FRAGMENTTAG[2]);

    cardfragment = new EcardFragmentImp();
    transaction.add(R.id.content, cardfragment, Constant.FRAGMENTTAG[3]);

    studyMaterialsFragment = new StudyMaterialsFragment();
    transaction.add(R.id.content, studyMaterialsFragment, Constant.FRAGMENTTAG[3]);

    findLostFragment = new FindLostFragment();
    transaction.add(R.id.content, findLostFragment, Constant.FRAGMENTTAG[4]);

    chargeFragment = new ChargeFragment();
    transaction.add(R.id.content, chargeFragment, Constant.FRAGMENTTAG[5]);

    libraryFragment = new LibFragment();
    transaction.add(R.id.content, libraryFragment, Constant.FRAGMENTTAG[6]);
    transaction.commit();
    hideFragments(transaction);
  }
Example #23
0
 @Override
 public void onCheckedChanged(RadioGroup group, int checkedId) {
   TabInfo newTab = mTabs.get("" + checkedId);
   if (mLastTab != newTab) {
     FragmentTransaction ft = mFragmentManager.beginTransaction();
     if (mLastTab != null) {
       if (mLastTab.fragment != null) {
         ft.detach(mLastTab.fragment);
       }
     }
     if (newTab != null) {
       if (newTab.fragment == null) {
         newTab.fragment =
             (BaseFragment)
                 Fragment.instantiate(group.getContext(), newTab.clss.getName(), newTab.args);
         ft.add(mContainerId, newTab.fragment, newTab.tag);
       } else {
         ft.attach(newTab.fragment);
       }
     }
     mLastTab = newTab;
     ft.commit();
     mFragmentManager.executePendingTransactions();
   }
 }
Example #24
0
 private void initFragment() {
   FragmentManager fm = getSupportFragmentManager();
   FragmentTransaction transaction = fm.beginTransaction();
   Fragment topicFragment = new TopicFragment();
   transaction.replace(R.id.main_content, topicFragment);
   transaction.commit();
 }
 public void onKeyboardHide() {
   Log.i("KeyboardFragment", "Hiding keyboard");
   FragmentManager fm = getFragmentManager();
   FragmentTransaction ft = fm.beginTransaction();
   ft.hide(this);
   ft.commit();
 }
Example #26
0
  public void jumpToFragment(int index) {

    FragmentManager fragmentManager = this.getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    if (index == 0) {
      FragmentMain fragmentMain = new FragmentMain();
      fragmentTransaction.replace(R.id.fragmentContainer, fragmentMain);
    } else if (index == 1) {
      FragmentOne fragmentOne = new FragmentOne();
      fragmentTransaction.replace(R.id.fragmentContainer, fragmentOne);
    } else if (index == 2) {
      FragmentTwo fragmentTwo = new FragmentTwo();
      fragmentTransaction.replace(R.id.fragmentContainer, fragmentTwo);
    } else if (index == 3) {
      FragmentThree fragmentThree = new FragmentThree();
      fragmentTransaction.replace(R.id.fragmentContainer, fragmentThree);
    } else if (index == 4) {
      FragmentFour fragmentFour = new FragmentFour();
      fragmentTransaction.replace(R.id.fragmentContainer, fragmentFour);
    } else if (index == 5) {
      FragmentAbout fragmentAbout = new FragmentAbout();
      fragmentTransaction.replace(R.id.fragmentContainer, fragmentAbout);
    } else if (index == 6) {
      android.os.Process.killProcess(android.os.Process.myPid()); // 获取PID
      System.exit(0);
    }
    fragmentTransaction.commit();
  }
  /* (non-Javadoc)
   * @see uk.ac.swan.digitaltrails.fragments.SearchListFragment.OnWalkSelectedListener#onWalkSelected(uk.ac.swan.digitaltrails.components.Walk)
   */
  @Override
  public void onWalkSelected(Walk walk) {
    Log.d(TAG, "Trying to choose a walk");
    SearchDetailsFragment detailsFrag =
        (SearchDetailsFragment)
            getSupportFragmentManager().findFragmentById(R.id.search_details_fragment);
    mWalk = walk;
    if (detailsFrag != null) {
      Log.d(TAG, "In 2 pane view");
      // if available and we are in 2-pane view.
      detailsFrag.updateDetailsView(walk);
    } else {
      Log.d(TAG, "In 1 pane view");
      // if in 1 pane view
      SearchDetailsFragment newDetailsFragment = new SearchDetailsFragment();
      Bundle args = new Bundle();
      args.putParcelable(SearchDetailsFragment.ARG_POSITION, walk);
      newDetailsFragment.setArguments(args);

      FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

      transaction.replace(R.id.fragment_container, newDetailsFragment);
      transaction.addToBackStack(null);

      transaction.commit();
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    HistoryFragment fragment = new HistoryFragment();
    android.support.v4.app.FragmentTransaction fragmentTransaction =
        getSupportFragmentManager().beginTransaction();
    fragmentTransaction.replace(R.id.fragment_container, fragment);
    fragmentTransaction.commit();

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawer,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
  }
  private void addFragment(Fragment f, int index) {
    if (f == null) return;

    Log.e("ASDF", f + ": " + index);

    clearFragments(index + 1);

    int type = 0;
    boolean focused = false;

    PaneSizer paneSizer = mPaneSizer;
    if (paneSizer != null) {
      type = paneSizer.getType(f);
      focused = paneSizer.getFocused(f);
    }

    PaneView p = panesLayout.getPane(index);
    if (p != null && p.type == type) {
    } else {
      clearFragments(index);
      p = panesLayout.addPane(type, focused);
      if (p.index != index) throw new IllegalStateException("Added pane has wrong index");
    }

    panesLayout.setIndex(index);

    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.replace(p.getInnerId(), f);
    ft.commit();

    fragmentStack.add(index, f);
    updateFragment(f);
  }
Example #30
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(R.string.backpack_title);
    setContentView(R.layout.activity_script);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    currentFragmentPosition = FRAGMENT_BACKPACK_SCRIPTS;

    if (savedInstanceState == null) {
      Bundle bundle = this.getIntent().getExtras();

      if (bundle != null) {
        currentFragmentPosition = bundle.getInt(EXTRA_FRAGMENT_POSITION, FRAGMENT_BACKPACK_SCRIPTS);
        backpackItem = bundle.getBoolean(BACKPACK_ITEM);
      }
    }

    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    setCurrentFragment(currentFragmentPosition);
    fragmentTransaction.commit();
    fragmentTransaction.add(R.id.script_fragment_container, currentFragment, currentFragmentTag);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
  }