예제 #1
1
  private void showFragment(Class<?> paramClass, String paramString, boolean addToBackStack) {
    Log.d(TAG, "showFragment for " + paramClass);

    FragmentManager localFragmentManager = getSupportFragmentManager();

    Fragment localFragment = localFragmentManager.findFragmentById(R.id.fragment_container);

    if ((localFragment == null) || (!paramClass.isInstance(localFragment))) {
      try {
        Log.d(TAG, "replacing fragments");

        if (addToBackStack) {

          localFragment = (Fragment) paramClass.newInstance();
          localFragmentManager
              .beginTransaction()
              .add(R.id.fragment_container, localFragment)
              .addToBackStack("growth_stack")
              .commit();

        } else {
          localFragment = (Fragment) paramClass.newInstance();
          localFragmentManager
              .beginTransaction()
              .replace(R.id.fragment_container, localFragment)
              .commitAllowingStateLoss();
        }

      } catch (InstantiationException e) {
        e.printStackTrace();
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      }
    }
  }
예제 #2
0
  private void navigateFragment(int fNum) {
    android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
    switch (fNum) {
      case 0:
        { // Home
          fragmentManager.beginTransaction().replace(R.id.container, mainFragment).commit();
          break;
        }
      case 1:
        { // Settings
          SettingsFragment fragment = new SettingsFragment();
          fragmentManager.beginTransaction().replace(R.id.container, fragment).commit();
          break;
        }
      case 2:
        { // About
          AboutFragment fragment = new AboutFragment();
          fragmentManager.beginTransaction().replace(R.id.container, fragment).commit();
          break;
        }
      default:
        Log.e(APP_TAG, "Cannot navigate to fragment number: " + fNum);
        throw new ArrayIndexOutOfBoundsException(
            "Invalid position passed to navigate to. This should never happen.");
    }

    // Close the drawer
    drawerLayout.closeDrawer(Gravity.LEFT);
  }
예제 #3
0
  @Override
  public void onNavigationDrawerItemSelected(int position) {

    FragmentManager fragmentManager = getFragmentManager();
    android.support.v4.app.FragmentManager supportFragmentManager = getSupportFragmentManager();
    if (position == 1) {

      if (bluetoothChatFragment != null) {
        supportFragmentManager.beginTransaction().remove(bluetoothChatFragment).commit();
      }
      if (conversationFragment == null) {
        conversationFragment = new ConversationFragment();
      }
      fragmentManager.beginTransaction().replace(R.id.container, conversationFragment).commit();
    } else if (position == 2) {
      Intent myIntent = new Intent(MainActivity.this, DeviceListActivity.class);
      startActivity(myIntent);
    } else if (position == 3) {

      if (conversationFragment != null) {
        fragmentManager.beginTransaction().remove(conversationFragment).commit();
      }
      if (bluetoothChatFragment == null) {
        bluetoothChatFragment = new BluetoothChatFragment();
      }
      supportFragmentManager
          .beginTransaction()
          .replace(R.id.container, bluetoothChatFragment)
          .commit();
    } else {
      fragmentManager.beginTransaction().replace(R.id.container, new MainFragment()).commit();
    }
  }
예제 #4
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);
    }
  }
  private void showFragmentWithWaveForm() {

    android.support.v4.app.FragmentManager fm = this.getSupportFragmentManager();
    CustomWaveformFragment customWaveformFragment =
        (CustomWaveformFragment) fm.findFragmentByTag(GlobParam.WAVEFORM_VIEW_TAG);

    if (customWaveformFragment == null) {
      customWaveformFragment = new CustomWaveformFragment();
    }

    if (!customWaveformFragment.isAdded()) {
      fm.beginTransaction()
          .add(R.id.container, customWaveformFragment, GlobParam.WAVEFORM_VIEW_TAG)
          .commit();
    } else {
      // Here I will try to remove and then add a fragment in order to change the song
      if (!this.songsPath.equalsIgnoreCase(customWaveformFragment.getFileName())) {
        customWaveformFragment = new CustomWaveformFragment();
        fm.beginTransaction()
            .remove(customWaveformFragment)
            .add(R.id.container, customWaveformFragment, GlobParam.WAVEFORM_VIEW_TAG)
            .commit();
      }
    }
  }
예제 #6
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;
   }
 }
예제 #7
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.new_two_find:
        if (current == 0) {
          return;
        }
        current = 0;
        fm.beginTransaction().replace(R.id.new_two_frameLayout, list.get(current)).commit();
        tv_find.setBackgroundResource(R.drawable.corners_left_bg_red);
        tv_find.setTextColor(Color.WHITE);
        tv_ranking.setBackgroundResource(R.drawable.corners_right_bg_white);
        tv_ranking.setTextColor(Color.BLACK);
        break;
      case R.id.new_two_ranking:
        if (current == 1) {
          return;
        }
        current = 1;
        fm.beginTransaction().replace(R.id.new_two_frameLayout, list.get(current)).commit();
        tv_find.setBackgroundResource(R.drawable.corners_left_bg_white);
        tv_find.setTextColor(Color.BLACK);
        tv_ranking.setBackgroundResource(R.drawable.corners_right_bg_red);
        tv_ranking.setTextColor(Color.WHITE);
        break;
      case R.id.new_tow_back:
        ((NewMainActivity) getActivity()).switchFragment(0);
        break;

      default:
        break;
    }
  }
예제 #8
0
  private void initData(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
      mCurrSelectedTabId = savedInstanceState.getInt(KEY_CURR_SELECTED_TAB_ID);
    } else {
      mCurrSelectedTabId = R.id.stock_button;
    }

    mFragmentManager = getSupportFragmentManager();

    mStockFragment = mFragmentManager.findFragmentByTag(TAG_STOCK_FRAGMENT);
    if (mStockFragment == null) {
      mStockFragment = new StockFragment();
      Bundle args = new Bundle();
      mStockFragment.setArguments(args);

      FragmentTransaction trans = mFragmentManager.beginTransaction();
      trans.add(R.id.fragment_container, mStockFragment, TAG_STOCK_FRAGMENT);
      trans.commitAllowingStateLoss();
    }

    mNoteFragment = mFragmentManager.findFragmentByTag(TAG_NOTE_FRAGMENT);
    if (mNoteFragment == null) {
      mNoteFragment = new NoteFragment();

      FragmentTransaction trans = mFragmentManager.beginTransaction();
      trans.add(R.id.fragment_container, mNoteFragment, TAG_NOTE_FRAGMENT);
      trans.commitAllowingStateLoss();
    }
  }
예제 #9
0
  @Override
  public void onNavigationDrawerItemSelected(int position) {
    // update the main content by replacing fragments

    Fragment objFragment = null;
    FragmentManager fragmentManager1 = getSupportFragmentManager();
    switch (position) {
      case 0:
        objFragment = new DashboardFragment();
        fragmentManager1.beginTransaction().replace(R.id.container, objFragment).commit();
        break;
      case 1:
        Intent intent = new Intent(this, DayViewActivity.class);
        startActivity(intent);
        break;
      case 2:
        objFragment = new TasksFragment();
        fragmentManager1.beginTransaction().replace(R.id.container, objFragment).commit();
        break;
      case 3:
        objFragment = new BlockFragment();
        fragmentManager1.beginTransaction().replace(R.id.container, objFragment).commit();
        break;
    }
  }
예제 #10
0
  private void drawerSelectItem(int position) {
    // Toast.makeText(ActivityMain.this, mDrawerItems[position],
    // Toast.LENGTH_SHORT).show();
    switch (position) {
      case 0: // My Profile
        getSupportActionBar().setTitle("My Profile");
        mFragmentManager
            .beginTransaction()
            .replace(R.id.main_fragment_container, new FragmentMyProfile())
            .commit();
        break;

      case 1: // Find a ride
        getSupportActionBar().setTitle("Find A Ride");
        mFragmentManager
            .beginTransaction()
            .replace(R.id.main_fragment_container, new FragmentFindARide())
            .commit();
        break;

      case 3: // Sign out
    }

    mDrawerLayout.closeDrawer(mDrawerList);
  }
예제 #11
0
  public void push(String name) {
    Page p = PageFactory.CreatePage(name);
    PageService.getInstance().pushPage(p);
    NormalPagFragement fragements;
    try {
      fragements = new NormalPagFragement(p);

      RelativeLayout mParent = (RelativeLayout) findViewById(0x1237156);
      // mParent.removeAllViews();
      // fragmentManger
      Page ps = PageService.getInstance().getSecontPage();
      if (ps != null) {
        // fragmentManger.beginTransaction().addToBackStack(ps.getPageName()).commit();
        fragmentManger
            .beginTransaction()
            .hide(fragmentManger.findFragmentByTag(ps.getPageName()))
            .commit();
      }

      fragmentManger
          .beginTransaction()
          .setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right)
          .add(0x1237156, fragements, name)
          .addToBackStack(null)
          .commitAllowingStateLoss();

    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      RuntimeContext.showLuaError(e.getMessage());
    }
  }
예제 #12
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_settings) {
      FragmentManager fm = getSupportFragmentManager();
      fm.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
      tag = WELCOME;
      TextView title = (TextView) findViewById(R.id.nav_bar_title);
      title.setText(tag);
      fm.beginTransaction().replace(R.id.container, new Fragment_Welcome(), tag).commit();
      return true;
    }
    if (id == R.id.profile_icon) {
      tag = PROFILE;
      submenu_bar.setVisibility(View.VISIBLE);

      TextView title = (TextView) findViewById(R.id.nav_bar_title);
      title.setText(tag);
      setSubmenuOptions(submenu_profile);
      setSubmenuTitle(submenu_profile[0]);

      FragmentManager fragmentManager = getSupportFragmentManager();
      fragmentManager
          .beginTransaction()
          .replace(R.id.container, new Fragment_Profile_Overview(), tag)
          .addToBackStack(tag)
          .commit();
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
예제 #13
0
  @Override
  public void onAlbumListCellClicked(Album album) {

    // setFragment(FragmentDetail.TAG);

    Fragment temp = fragmentManager.findFragmentByTag(FragmentDetail.TAG);
    if (temp == null) {
      fragmentAlbumDetail = FragmentDetail.create(this);
      fragmentAlbumDetail.setAlbum(album);
      fragmentManager
          .beginTransaction()
          .setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
          // .setCustomAnimations(R.anim.slide_right_in, R.anim.slide_right_out)
          .hide(currentFrag)
          .add(R.id.mainframe, fragmentAlbumDetail, FragmentDetail.TAG)
          .addToBackStack(FragmentDetail.TAG)
          .commit();

    } else {
      fragmentAlbumDetail = (FragmentDetail) temp;
      fragmentAlbumDetail.setAlbum(album);
      fragmentManager
          .beginTransaction()
          .setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
          // .setCustomAnimations(R.anim.slide_right_in, R.anim.slide_right_out)
          .hide(currentFrag)
          .show(fragmentAlbumDetail)
          .commit();
    }
    // getSupportActionBar().setSubtitle("Albums");
    TextView tv =
        (TextView) getSupportActionBar().getCustomView().findViewById(R.id.action_bar_title);
    tv.setText(album.getAlbumName());
  }
예제 #14
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();
 }
예제 #15
0
  /* (non-Javadoc)
   * @see org.chaseme.activities.helpers.SuperUI#onCreate(android.os.Bundle)
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_flight);

    fragmentManager = getSupportFragmentManager();
    // modeInfoPanel = fragmentManager.findFragmentById(R.id.modeInfoPanel);
    failsafeTextView = findViewById(R.id.failsafeTextView);

    // Load the activity fragments
    Fragment modeRtl = fragmentManager.findFragmentById(R.id.modeInfoPanel);
    if (modeRtl == null) {
      modeRtl = new ModeRTLFragment();
      fragmentManager.beginTransaction().add(R.id.modeInfoPanel, modeRtl).commit();
    }

    mapFragment = fragmentManager.findFragmentById(R.id.mapFragment);
    if (mapFragment == null) {
      mapFragment = new FlightMapFragment();
      fragmentManager.beginTransaction().add(R.id.mapFragment, mapFragment).commit();
    }

    Fragment telemetryFragment = fragmentManager.findFragmentById(R.id.telemetryFragment);
    if (telemetryFragment == null) {
      telemetryFragment = new TelemetryFragment();
      fragmentManager.beginTransaction().add(R.id.telemetryFragment, telemetryFragment).commit();
    }

    Fragment editorTools = fragmentManager.findFragmentById(R.id.editorToolsFragment);
    if (editorTools == null) {
      editorTools = new FlightActionsFragment();
      fragmentManager.beginTransaction().add(R.id.editorToolsFragment, editorTools).commit();
    }
  }
예제 #16
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;
      }
    }
  }
 /**
  * @param fragmentsToInt - integer representation of fragments 0 - ExploreFragment, 1 -
  *     SearchResultFragment, 2 - RunsFragments 3 - LaunchHistoryFragments, 4 - MyWorkflowFragment,
  *     5 - FavouriteWorkflowFragment
  * @param backStackTag
  */
 private void beginFragmentTransaction(int[] fragmentsToInt, String backStackTag) {
   FragmentManager fm = parentActivity.getSupportFragmentManager();
   FragmentTransaction ft = fm.beginTransaction();
   // ft.setCustomAnimations(R.anim.push_left_in, R.anim.push_left_out);
   // boolean successfullypopped = fm.popBackStackImmediate(backStackTag, 1);
   // if(!successfullypopped){
   Fragment newFragment = new FragmentsContainer();
   Bundle args = new Bundle();
   args.putIntArray("fragmentsToInstantiate", fragmentsToInt);
   newFragment.setArguments(args);
   ft.addToBackStack(backStackTag);
   if (previousSelectedFragTag == null) {
     fm.beginTransaction().hide(fm.findFragmentByTag("StarterFragments")).commit();
   } else {
     fm.beginTransaction().hide(fm.findFragmentByTag(previousSelectedFragTag)).commit();
   }
   previousSelectedFragTag = backStackTag;
   ft.replace(R.id.main_panel_root, newFragment, backStackTag).commit();
   // }
   // smooth transaction
   new Handler()
       .postDelayed(
           new Runnable() {
             public void run() {
               // close the menu
               ((MainPanelActivity) parentActivity).getMenu().toggle();
             }
           },
           500);
 }
예제 #18
0
 @Override
 public void onNavigationDrawerItemSelected(int position) {
   // update the main content by replacing fragments
   FragmentManager fragmentManager = getSupportFragmentManager();
   switch (position) {
     case 2:
       fragmentManager
           .beginTransaction()
           .replace(R.id.container, NotificationFragment.newInstance(position + 1))
           .commit();
       break;
     case 3:
       fragmentManager
           .beginTransaction()
           .replace(R.id.container, InventoryFragment.newInstance(position + 1))
           .commit();
       break;
     default:
       fragmentManager
           .beginTransaction()
           .replace(R.id.container, HomeFragment.newInstance(position + 1))
           .commit();
       break;
   }
 }
예제 #19
0
 /** Toggle the RC fragment */
 private void toggleRCFragment() {
   if (rcFragment == null) {
     rcFragment = new RCFragment();
     fragmentManager.beginTransaction().add(R.id.containerRC, rcFragment).commit();
   } else {
     fragmentManager.beginTransaction().remove(rcFragment).commit();
     rcFragment = null;
   }
 }
  @Override
  protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    this.setContentView(R.layout.topiclist_activity);
    PullToRefreshAttacher.Options options = new PullToRefreshAttacher.Options();
    options.refreshScrollDistance = 0.3f;
    options.refreshOnUp = true;
    mPullToRefreshAttacher = PullToRefreshAttacher.get(this, options);

    if (ActivityUtil.isNotLessThan_4_0()) setNfcCallBack();

    if (null == findViewById(R.id.item_detail_container)) {
      dualScreen = false;
    }
    FragmentManager fm = getSupportFragmentManager();
    Fragment f1 = fm.findFragmentById(R.id.item_list);
    if (f1 == null) {
      f1 = new TopiclistContainer();
      Bundle args = new Bundle(); // (getIntent().getExtras());
      if (null != getIntent().getExtras()) {
        args.putAll(getIntent().getExtras());
      }
      args.putString("url", getIntent().getDataString());
      f1.setArguments(args);
      FragmentTransaction ft = fm.beginTransaction().add(R.id.item_list, f1);
      // .add(R.id.item_detail_container, f);
      ft.commit();
    }
    Fragment f2 = fm.findFragmentById(R.id.item_detail_container);
    if (null == f2) {
      f1.setHasOptionsMenu(true);
    } else if (!dualScreen) {
      this.setTitle(R.string.app_name);
      fm.beginTransaction().remove(f2).commit();
      f1.setHasOptionsMenu(true);
    } else {
      f1.setHasOptionsMenu(false);
      f2.setHasOptionsMenu(true);
    }

    int fid = getIntent().getIntExtra("fid", 0);
    if (fid != 0) {
      String boardName = BoardHolder.boardNameMap.get(fid);
      if (null != boardName) {
        strs[0] = boardName;
      }
    }
    int favor = getIntent().getIntExtra("favor", 0);
    int authorid = getIntent().getIntExtra("authorid", 0);
    if (favor == 0 && authorid == 0) {
      setNavigation();
    } else {
      flags = ThemeManager.ACTION_BAR_FLAG;
    }
  }
  @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);
    }
  }
예제 #22
0
  @Override
  public void onNavigationDrawerItemSelected(int position) {

    switch (position) {
      case 0:
        objFragment1 = fm.findFragmentByTag("MainFragment");
        if (objFragment1 == null) {
          objFragment1 = new MainFragment();
          fm.beginTransaction()
              .replace(R.id.container, objFragment1, "MainFragment")
              .addToBackStack("MainFragment")
              .commit();
        } else {
          fm.beginTransaction().replace(R.id.container, objFragment1).commit();
        }
        break;
      case 1:
        objFragment2 = fm.findFragmentByTag("WebViewFragment");
        if (objFragment2 == null) {
          objFragment2 = new WebViewFragment();
          fm.beginTransaction()
              .replace(R.id.container, objFragment2, "WebViewFragment")
              .addToBackStack("WebViewFragment")
              .commit();
        } else {
          fm.beginTransaction().replace(R.id.container, objFragment2).commit();
        }
        break;
      case 2:
        objFragment3 = fm.findFragmentByTag("TerminalFragment");
        if (objFragment3 == null) {
          objFragment3 = new TerminalFragment();
          fm.beginTransaction()
              .replace(R.id.container, objFragment3, "TerminalFragment")
              .addToBackStack("TerminalFragment")
              .commit();
        } else {
          fm.beginTransaction().replace(R.id.container, objFragment3).commit();
        }
        break;
      case 3:
        objFragment4 = fm.findFragmentByTag("AboutFragment");
        if (objFragment4 == null) {
          objFragment4 = new AboutFragment();
          fm.beginTransaction()
              .replace(R.id.container, objFragment4, "AboutFragment")
              .addToBackStack("AboutFragment")
              .commit();
        } else {
          fm.beginTransaction().replace(R.id.container, objFragment4).commit();
        }
        break;
    }

    // update the main content by replacing fragments
    /*FragmentManager fragmentManager = getSupportFragmentManager();
    fragmentManager.beginTransaction()
            .replace(R.id.container, objFragment)
            .commit();*/
  }
예제 #23
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // 设置需要显示右边主体部分的容器布局
    setContentView(R.layout.main_page);

    initData();

    //
    mFragmentManager = getSupportFragmentManager();

    if (mContent == null) {
      // 首页内容页Fragment
      mContent = new HomePageFragment();
    }

    // 使用FragmentManager管理器来装在Fragemnt
    mFragmentManager
        .beginTransaction()
        .add(R.id.main_page_container, mContent, "mContent")
        .commit();

    // 设置侧边栏容器布局文件
    setBehindContentView(R.layout.main_menu);

    // 添加侧边栏Fragment
    mFragmentManager
        .beginTransaction()
        .replace(R.id.main_menu_container, new MenuPageFragment())
        .commit();

    // 获取SlidingMenu
    SlidingMenu menu = getSlidingMenu();

    menu.setMode(SlidingMenu.LEFT);

    // 设置阴影
    menu.setShadowDrawable(R.drawable.menu_shape);

    // 阴影宽度
    // menu.setShadowWidth(20);
    menu.setShadowWidthRes(R.dimen.shadow_width);

    // 内容页面显示剩余宽度
    menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);

    // 菜单手势范围
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
  }
  public void onClick(View v) {
    switch (v.getId()) {

        // setting profile picture
      case R.id.profilePic:
        currentImageView = (ImageView) v;
        openImageIntent();
        break;

        // setting company picture
      case R.id.btn_pick:
        currentImageView = (ImageView) v;
        openImageIntent();
        break;

        // redirecting to VZFriends_Fragment
      case R.id.vzfrnds:
        Fragment newfragment = new VZFriends_Fragment();
        // get the id of fragment
        FrameLayout contentView2 = (FrameLayout) getActivity().findViewById(R.id.profile_frame);

        // Insert the fragment by replacing any existing fragment
        FragmentManager fragmentManager1 = getFragmentManager();
        fragmentManager1
            .beginTransaction()
            .replace(contentView2.getId(), newfragment)
            .addToBackStack(contentView2.toString())
            .commit();
        break;

        // redirecting to Referral_Fragmen
      case R.id.referralbtn:
        Fragment fragment = new Referral_Fragment();
        // get the id of fragment
        FrameLayout contentView3 = (FrameLayout) getActivity().findViewById(R.id.profile_frame);

        // Insert the fragment by replacing any existing fragment
        FragmentManager fragmentManager2 = getFragmentManager();
        fragmentManager2
            .beginTransaction()
            .replace(contentView3.getId(), fragment)
            .addToBackStack(contentView3.toString())
            .commit();

        break;
      default:
        break;
    }
  }
  @Override
  public void onConfigurationChanged(Configuration newConfig) {

    super.onConfigurationChanged(newConfig);

    if (getResources().getBoolean(R.bool.portrait_only)) {
      // do not rotate for phones
      //noinspection ResourceType
      setRequestedOrientation(Configuration.ORIENTATION_PORTRAIT);
    } else {

      // use layout for tablets - landscape or portrait.
      // save fragments for re-use in new layout!

      FragmentManager fragmentManager = getSupportFragmentManager();
      FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

      CategoryList attackFragment =
          (CategoryList)
              fragmentManager.findFragmentByTag(getResources().getString(R.string.items_attack));
      CategoryList defenseFragment =
          (CategoryList)
              fragmentManager.findFragmentByTag(getResources().getString(R.string.items_defense));
      HeroList heroFragment =
          (HeroList)
              fragmentManager.findFragmentByTag(getResources().getString(R.string.items_hero));

      fragmentTransaction.detach(attackFragment);
      fragmentTransaction.detach(defenseFragment);
      fragmentTransaction.detach(heroFragment);

      fragmentTransaction.commitAllowingStateLoss();
      fragmentManager.executePendingTransactions();

      // load appropriate layout
      Log.v(getClass().getCanonicalName(), "re-load layout for tablets");
      setContentView(R.layout.main);

      Log.v(getClass().getCanonicalName(), "re-use fragments");
      fragmentTransaction = fragmentManager.beginTransaction();
      fragmentTransaction.attach(defenseFragment);
      fragmentTransaction.attach(attackFragment);
      fragmentTransaction.attach(heroFragment);

      fragmentTransaction.commitAllowingStateLoss();
      fragmentManager.executePendingTransactions();
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
    setContentView(R.layout.new_card);
    gson = new Gson();
    user = gson.fromJson(new StoreData(getApplicationContext()).getUserDataAsString(), User.class);

    type = getIntent().getExtras().getString("type");
    if (getIntent().getExtras() != null) {
      if (getIntent().getExtras().containsKey("share")) {
        setShareHolder((ShareOwnership) getIntent().getExtras().get("share"));
        setInsertedServiceId(getShareHolder().getID());

      } else ShareHolder = new ShareOwnership();
      if (getIntent().getExtras().containsKey("shareHolders")) {
        setShareHolders((ArrayList<Object>) getIntent().getExtras().get("shareHolders"));
      }
    } else {
      ShareHolder = new ShareOwnership();
    }

    if (type.equals("1")) {
      fragmentManager = getSupportFragmentManager();
      fragmentManager
          .beginTransaction()
          .replace(R.id.content_frame, MainShareHolderFragment.newInstance("NewShareHolder"))
          .commit();
    }
  }
  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);
  }
 public void onKeyboardHide() {
   Log.i("KeyboardFragment", "Hiding keyboard");
   FragmentManager fm = getFragmentManager();
   FragmentTransaction ft = fm.beginTransaction();
   ft.hide(this);
   ft.commit();
 }
 public void onKeyboardShow() {
   Log.i("KeyboardFragment", "Showing keyboard");
   FragmentManager fm = getFragmentManager();
   FragmentTransaction ft = fm.beginTransaction();
   ft.show(this);
   ft.commit();
 }
  /**
   * * Swaps fragments in the main content view
   *
   * @param position - Defines the item "position" based on integer value
   */
  public void selectDrawerItem(int position) {
    // Create a new fragment and specify the planet to show based on position
    FragmentNavItem navItem = drawerNavItems.get(position);
    // Initialize fragment variable
    Fragment fragment = null;
    try {
      fragment = navItem.getFragmentClass().newInstance();

      Bundle args = navItem.getFragmentArgs();
      if (args != null) {
        fragment.setArguments(args);
      }
    } catch (Exception e) {
      e.printStackTrace();
      Log.e("MainActivity", "Error in creating fragment");
    }

    // Insert the fragment by replacing any existing fragment
    FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(drawerContainerRes, fragment).commit();

    // Highlight the selected item, update the title, and close the drawer
    lvDrawer.setItemChecked(position, true);
    setTitle(navItem.getTitle());
    closeDrawer(lvDrawer);
  }