예제 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.b_activity);
    FilterFragment = new BrowseFilterFragment();
    ListFragment = new BrowseListFragment();

    // creates a list adapter for our stub exercises
    adapter = new BrowseAdapter(this, 0, mBrowseExerciseList);

    // adds fragments to layout/b_activity.xml
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.add(R.id.exerciseFiltersContainer, FilterFragment);
    transaction.add(R.id.exerciseListContainer, ListFragment);
    transaction.commit();

    WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    SCREENWIDTH = size.x;
    SCREENHEIGHT = size.y;
    slideVal = -(int) (SCREENWIDTH / 5);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_menu, container, false);

    // Make sure the two menu fragments are created.
    FragmentManager fm = getChildFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    mFragment1 = fm.findFragmentByTag("f1");
    if (mFragment1 == null) {
      mFragment1 = new FragmentMenuSupport.MenuFragment();
      ft.add(mFragment1, "f1");
    }
    mFragment2 = fm.findFragmentByTag("f2");
    if (mFragment2 == null) {
      mFragment2 = new FragmentMenuSupport.Menu2Fragment();
      ft.add(mFragment2, "f2");
    }
    ft.commit();

    // Watch check box clicks.
    mCheckBox1 = (CheckBox) v.findViewById(R.id.menu1);
    mCheckBox1.setOnClickListener(mClickListener);
    mCheckBox2 = (CheckBox) v.findViewById(R.id.menu2);
    mCheckBox2.setOnClickListener(mClickListener);

    // Make sure fragments start out with correct visibility.
    updateFragmentVisibility();

    return v;
  }
예제 #3
0
  /** Lays out the list of customers */
  private void layoutCustomer() {
    if (!started || getView() == null) {
      return;
    }

    LinearLayout panelCustomerInfo =
        (LinearLayout) getView().findViewById(R.id.linearLayoutCustomerInfo);

    panelCustomerInfo.removeAllViews();

    final FragmentTransaction ft = getFragmentManager().beginTransaction();

    if (customer != null) {
      CustomerThumbnailFragment customerThumbnail = new CustomerThumbnailFragment();
      customerThumbnail.setCustomer(customer);
      ft.add(R.id.linearLayoutCustomerInfo, customerThumbnail);

      List<Reading> readings = customer.getReadings();

      if (readings.size() > 0) {
        ReadingThumbnailFragment readingThumbnail = new ReadingThumbnailFragment();
        readingThumbnail.setReading(readings.get(readings.size() - 1));
        readingThumbnail.setHideCustomer(true);
        ft.add(R.id.linearLayoutCustomerInfo, readingThumbnail);
      }

      getView().findViewById(R.id.buttonScan).setEnabled(true);
    } else {
      getView().findViewById(R.id.buttonScan).setEnabled(false);
    }

    ft.commit();
  }
예제 #4
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();
    }
  }
예제 #5
0
  public static void RecreateFragemnt(
      FragmentManager manager, String fragmentName, int containerId, String tag) {
    List<Fragment> fragments = manager.getFragments();
    FragmentTransaction transaction = manager.beginTransaction();
    boolean isexist = false;
    try {
      for (Fragment fragment : fragments) {
        transaction.hide(fragment);
        if (fragment.getClass().toString().contains(fragmentName)) {
          transaction.remove(fragment);
          Class c = Class.forName(fragmentName);
          Fragment newfragment = (Fragment) c.newInstance();
          transaction.add(containerId, newfragment, tag);
          isexist = true;
          transaction.show(newfragment);
        }
      }
      if (!isexist) {
        Class c = Class.forName(fragmentName);
        Fragment newfragment = (Fragment) c.newInstance();
        transaction.add(containerId, newfragment, tag);
        transaction.show(newfragment);
      }
      transaction.commit();
    } catch (Exception ex) {

    }
  }
  public void changeFragment() {
    FragmentTransaction trx = getSupportFragmentManager().beginTransaction();
    trx.hide(loginNotFragment);
    trx.hide(fragments[currentTabIndex]);
    // 将之前tab设为未选中状态
    mTabs[currentTabIndex].setSelected(false);
    // 更新当前tab值
    currentTabIndex = index;
    // 把当前tab设为选中状态
    mTabs[currentTabIndex].setSelected(true);

    if (currentTabIndex != 0 && currentTabIndex != 1) {
      SSOAuth ssoAuth = SSOAuth.getInstance(this);
      if (ssoAuth.getCurrUser() == null) {
        if (!loginNotFragment.isAdded()) {
          trx.add(R.id.fragment_container, loginNotFragment);
        }
        trx.show(loginNotFragment).commit();
        return;
      }
    }

    if (!fragments[currentTabIndex].isAdded()) {
      trx.add(R.id.fragment_container, fragments[currentTabIndex]);
    }
    trx.show(fragments[currentTabIndex]).commit();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getSupportFragmentManager().findFragmentByTag(TAG) == null) {
      Intent miIntent = getIntent();

      final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();

      if (miIntent.getStringExtra("origin") != null) {

        if (miIntent.getStringExtra("origin").equals("home")) {
          ft.add(android.R.id.content, new ImageGridFragment(), TAG);

        } else if (miIntent.getStringExtra("origin").equals("leg")) {
          ft.add(android.R.id.content, new ImageGridForLeg(), TAG);

        } else if (miIntent.getStringExtra("origin").equals("position")) {
          ft.add(android.R.id.content, new FragPosition(), TAG);
        }
      }

      ft.commit();
    }
  }
예제 #8
0
  public void switchContent(Fragment fragment) {
    try {
      FragmentTransaction t = fm.beginTransaction();
      List<Fragment> flist = fm.getFragments();
      if (flist == null) {
        t.add(R.id.main_content, fragment);
      } else {
        if (!flist.contains(fragment)) {
          t.add(R.id.main_content, fragment);
        }
        t.hide(slist.get(slist.size() - 1));
        t.show(fragment);
      }

      if (slist.contains(fragment)) {
        slist.remove(fragment);
      }

      slist.add(fragment);

      t.commitAllowingStateLoss();

    } catch (Exception e) {
    }
  }
예제 #9
0
  @Override
  public void onTabSelected(Tab tab, FragmentTransaction ft) {

    if (tab.getPosition() == 0) {
      // Check if the fragment is already initialized
      mMapFragment = getSupportFragmentManager().findFragmentByTag("map");
      if (mMapFragment == null) {
        // If not, instantiate and add it to the activity
        mMapFragment = new ViewMapFragment_();
        ft.add(R.id.container, mMapFragment, "map");
      } else {
        // If it exists, simply attach it in order to show it
        ft.show(mMapFragment);
      }
    }
    if (tab.getPosition() == 1) {
      // Check if the fragment is already initialized
      mMapFragment = getSupportFragmentManager().findFragmentByTag("list");
      if (mListFragment == null) {
        // If not, instantiate and add it to the activity
        //	mListFragment = new RestroomListFragment_();
        ft.add(R.id.container, mListFragment, "list");
      } else {
        // If it exists, simply attach it in order to show it
        ft.show(mListFragment);
      }
    }
  }
 private void initialiseColourPicker() {
   FragmentManager fm = getFragmentManager();
   FragmentTransaction ft = fm.beginTransaction();
   if (persistenceManager.getLightMode() == Profile.LightMode.RGBW) {
     // RGBW
     RGBWColourWheelFragment colourFragment =
         RGBWColourWheelFragment.newInstance(PersistenceManager.DEFAULT_COLOUR);
     ft.add(R.id.flThemeColourPicker, colourFragment).commit();
   } else if (persistenceManager.getLightMode() == Profile.LightMode.RGBA) {
     // RGBA
     RGBAColourWheelFragment colourFragment =
         RGBAColourWheelFragment.newInstance(PersistenceManager.DEFAULT_COLOUR);
     ft.add(R.id.flThemeColourPicker, colourFragment).commit();
   } else if (persistenceManager.getLightMode() == Profile.LightMode.RGBWW) {
     // RGBWW
     RGBWWColourWheelFragment colourFragment =
         RGBWWColourWheelFragment.newInstance(PersistenceManager.DEFAULT_COLOUR);
     ft.add(R.id.flThemeColourPicker, colourFragment).commit();
   } else if (persistenceManager.getLightMode() == Profile.LightMode.RGBAWW) {
     // RGBAWW
     RGBAWWColourWheelFragment colourFragment =
         RGBAWWColourWheelFragment.newInstance(PersistenceManager.DEFAULT_COLOUR);
     ft.add(R.id.flThemeColourPicker, colourFragment).commit();
   } else {
     // RGB
     RGBColourWheelFragment colourFragment =
         RGBColourWheelFragment.newInstance(PersistenceManager.DEFAULT_COLOUR);
     ft.add(R.id.flThemeColourPicker, colourFragment).commit();
   }
 }
예제 #11
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();
  }
예제 #12
0
  /**
   * Creates/Restore the layer switcher or restore the old one and add all other menu
   *
   * @param savedInstanceState
   * @param layerManager
   */
  private void setupLeftMenu(Bundle savedInstanceState, MultiSourceOverlayManager layerManager) {
    // work on fragment management
    FragmentManager fManager = getSupportFragmentManager();
    LayerSwitcherFragment osf;
    if (savedInstanceState != null) {
      osf = (LayerSwitcherFragment) fManager.findFragmentById(R.id.left_drawer_container);
      if (osf == null) {
        Log.e("MAPSACTIVITY", "unable to restore layer switcher");
      }
      layerManager.setLayerChangeListener(osf);
      layerManager.restoreInstanceState(savedInstanceState);

    } else {
      layerManager.defaultInit();
      //			@SuppressWarnings("unchecked")
      //			ArrayList<Layer> layers =  (ArrayList<Layer>) LocalPersistence.readObjectFromFile(this,
      // LocalPersistence.CURRENT_MAP);
      //			if(layers != null){
      //				layerManager.setLayers(layers);
      //			}else{

      if (getIntent() != null
          && getIntent().getExtras() != null
          && getIntent().getExtras().containsKey(MSM_MAP)) {

        layerManager.loadMap((MSMMap) getIntent().getExtras().getSerializable(MSM_MAP));

      } else {
        boolean dontLoadMBTileLayer =
            MapFilesProvider.getBackgroundSourceType() == BackgroundSourceType.MBTILES;
        MSMMap map = SpatialDbUtils.mapFromDb(dontLoadMBTileLayer);
        StorageUtils.setupSources(this);
        // This adds layers also if its called loadMap but it will not order layers
        // layerManager.loadMap(map);
        // so use this instead
        addLayersOrdered(map.layers);
      }

      //			}
      // setup left drawer fragments
      if (mDrawerMode != DrawerMode.NONE) {

        osf = new LayerSwitcherFragment();
        layerManager.setLayerChangeListener(osf);
        FragmentTransaction fragmentTransaction = fManager.beginTransaction();
        fragmentTransaction.add(R.id.left_drawer_container, osf);
        GenericMenuFragment other = new GenericMenuFragment();
        // fragmentTransaction.add(R.id.right_drawer, other);
        if (mDrawerMode == DrawerMode.BOTH) {

          SourcesFragment sf = new SourcesFragment();
          fragmentTransaction.add(R.id.right_drawer, sf);
        }
        fragmentTransaction.commit();
      }
    }
  }
예제 #13
0
  private void setTabSelection(int index) {
    // 开启一个Fragment事务
    FragmentTransaction transaction = manager.beginTransaction();
    clearState();
    hideFragments(transaction);
    switch (index) {
      case 0:
        //                ivHome.setImageResource(R.mipmap.home_select);
        UtilAnimation.scaleView(ivHome, R.mipmap.home_select);
        tvHome.setTextColor(0xffffffff);
        if (homeFragment == null) {
          homeFragment = new HomeFragment();
          transaction.add(R.id.activity_layout, homeFragment);
        } else {
          transaction.show(homeFragment);
        }
        break;

      case 1:
        //                ivType.setImageResource(R.mipmap.type_select);
        UtilAnimation.scaleView(ivType, R.mipmap.type_select);
        tvType.setTextColor(0xffffffff);
        if (typeFragment == null) {
          typeFragment = new TypeFragment();
          transaction.add(R.id.activity_layout, typeFragment);
        } else {
          transaction.show(typeFragment);
        }
        break;
      case 2:
        //                ivFood.setImageResource(R.mipmap.food_select);
        UtilAnimation.scaleView(ivFood, R.mipmap.food_select);
        tvFood.setTextColor(0xffffffff);
        if (foodFragment == null) {
          foodFragment = new FoodFragment();
          transaction.add(R.id.activity_layout, foodFragment);
        } else {
          transaction.show(foodFragment);
        }
        break;
      case 3:
        //                ivMine.setImageResource(R.mipmap.mine_select);
        tvMine.setTextColor(0xffffffff);
        UtilAnimation.scaleView(ivMine, R.mipmap.mine_select);
        if (mineFragment == null) {
          mineFragment = new MineFragment();
          transaction.add(R.id.activity_layout, mineFragment);
        } else {
          transaction.show(mineFragment);
        }
        break;

      default:
        break;
    }
    transaction.commit();
  }
  private void setSelect(int num) {
    set2normal();
    FragmentManager manager = getSupportFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();
    hideFragment(transaction);
    switch (num) {
      case ConstantUtils.NUMBER.ZERO:
        mTabImg1.setImageResource(R.drawable.fragment_tab_1_sel);
        mTabText1.setTextColor(getResources().getColor(R.color.main_tab_text_select));
        mHeadText.setText(mTabText1.getText().toString());
        if (null == mFrag1) {
          mFrag1 = new FragmentStatic("fragment_tab");
          transaction.add(R.id.fragment_tab_content, mFrag1);
        } else {
          transaction.show(mFrag1);
        }
        break;
      case ConstantUtils.NUMBER.TWO:
        mTabImg2.setImageResource(R.drawable.fragment_tab_2_sel);
        mTabText2.setTextColor(getResources().getColor(R.color.main_tab_text_select));
        mHeadText.setText(mTabText2.getText().toString());
        if (null == mFrag2) {
          mFrag2 = new FragmentDynamic();
          transaction.add(R.id.fragment_tab_content, mFrag2);
        } else {
          transaction.show(mFrag2);
        }
        break;
      case ConstantUtils.NUMBER.THREE:
        mTabImg3.setImageResource(R.drawable.fragment_tab_3_sel);
        mTabText3.setTextColor(getResources().getColor(R.color.main_tab_text_select));
        mHeadText.setText(mTabText3.getText().toString());
        if (null == mFrag3) {
          mFrag3 = new FragmentLife1();
          transaction.add(R.id.fragment_tab_content, mFrag3);
        } else {
          transaction.show(mFrag3);
        }
        break;
      case ConstantUtils.NUMBER.FOUR:
        mTabImg4.setImageResource(R.drawable.fragment_tab_4_sel);
        mTabText4.setTextColor(getResources().getColor(R.color.main_tab_text_select));
        mHeadText.setText(mTabText4.getText().toString());
        if (null == mFrag4) {
          mFrag4 = new FragmentLife2();
          transaction.add(R.id.fragment_tab_content, mFrag4);
        } else {
          transaction.show(mFrag4);
        }
        break;

      default:
        break;
    }
    transaction.commit();
  }
예제 #15
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;
    }
  }
예제 #16
0
  public void setChioceItem(int index) {
    if (fManager == null) {
      return;
    }
    FragmentTransaction transaction = fManager.beginTransaction();
    hideFragments(transaction);
    switch (index) {
      case 1:
        if (fhd == null) {
          fhd = new HuDongFragment1();
          transaction.add(R.id.main_fragment, fhd);
        } else {
          transaction.show(fhd);
        }
        break;

      case 2:
        if (fjjy == null) {
          fjjy = new JieYueFragment2();
          transaction.add(R.id.main_fragment, fjjy);
        } else {
          transaction.show(fjjy);
        }
        break;
      case 3:
        if (fqz == null) {
          fqz = new QiangZuoFragment3();
          transaction.add(R.id.main_fragment, fqz);
        } else {
          transaction.show(fqz);
        }
        break;
      case 4:
        if (fxs == null) {
          fxs = new XinShengDaoHangFragment4();
          transaction.add(R.id.main_fragment, fxs);
        } else {
          transaction.show(fxs);
        }

        break;
      case 5:
        if (ffaxian == null) {
          ffaxian = new FaXianFragment5();
          transaction.add(R.id.main_fragment, ffaxian);
        } else {
          transaction.show(ffaxian);
        }
        break;
    }
    transaction.commit();
  }
예제 #17
0
  // 底部按钮的点击事件
  @Override
  public void onCheckedChanged(RadioGroup group, int checkedId) {
    // TODO Auto-generated method stub
    // 得到一个碎片管理器
    fragmentManager = this.getSupportFragmentManager();
    // 开始准备切换
    fragmentTransaction = fragmentManager.beginTransaction();

    if (allSchoolFragment != null) {
      fragmentTransaction.hide(allSchoolFragment);
    }
    if (zhaoSchoolFragment != null) {
      fragmentTransaction.hide(zhaoSchoolFragment);
    }
    if (colSchoolFragment != null) {
      fragmentTransaction.hide(colSchoolFragment);
    }

    switch (checkedId) {
      case R.id.allschool_rg_index:
        if (allSchoolFragment == null) {
          allSchoolFragment = new AllSchoolFragment();
          fragmentTransaction.add(R.id.allschool_fl, allSchoolFragment);
        } else {
          fragmentTransaction.show(allSchoolFragment);
        }
        break;
      case R.id.inschool_rg_bm:
        if (zhaoSchoolFragment == null) {
          zhaoSchoolFragment = new ZhaoSchoolFragment();
          fragmentTransaction.add(R.id.allschool_fl, zhaoSchoolFragment);
        } else {
          fragmentTransaction.show(zhaoSchoolFragment);
        }
        break;
      case R.id.colschool_rg_sc:
        if (colSchoolFragment == null) {
          colSchoolFragment = new ColSchoolFragment();
          fragmentTransaction.add(R.id.allschool_fl, colSchoolFragment);
        } else {
          fragmentTransaction.show(colSchoolFragment);
        }
        break;

      default:
        break;
    }

    // 选择好Fragment进行提交
    fragmentTransaction.commit();
  }
예제 #18
0
  public void setChioceItem(int index) {

    FragmentTransaction transaction = fManager.beginTransaction();
    clearChioce();
    hideFragments(transaction);
    switch (index) {
      case 0:
        meet_image.setImageResource(R.drawable.ic_tabbar_contacts_pressed);
        meet_text.setTextColor(blue);
        meet_layout.setBackgroundResource(R.drawable.ic_tabbar_bg_click);
        if (fg1 == null) {

          fg1 = new fg1();
          transaction.add(R.id.content, fg1);
        } else {

          transaction.show(fg1);
        }
        break;

      case 1:
        contacts_image.setImageResource(R.drawable.ic_tabbar_contacts_pressed);
        contacts_text.setTextColor(blue);
        contacts_layout.setBackgroundResource(R.drawable.ic_tabbar_bg_click);
        if (fg2 == null) {

          fg2 = new fg2();
          transaction.add(R.id.content, fg2);
        } else {

          transaction.show(fg2);
        }
        break;

      case 2:
        settings_image.setImageResource(R.drawable.ic_tabbar_settings_pressed);
        settings_text.setTextColor(blue);
        settings_layout.setBackgroundResource(R.drawable.ic_tabbar_bg_click);
        if (fg3 == null) {

          fg3 = new fg3();
          transaction.add(R.id.content, fg3);
        } else {

          transaction.show(fg3);
        }
        break;
    }
    transaction.commit();
  }
예제 #19
0
  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);
  }
예제 #20
0
  // 定义一个选中一个item后的处理
  public void setChioceItem(int index) {
    // 重置选项+隐藏所有Fragment
    FragmentTransaction transaction = fManager.beginTransaction();
    clearChioce();
    hideFragments(transaction);
    switch (index) {
      case 0:
        course_image.setImageResource(R.drawable.index_home_press);
        course_text.setTextColor(this.getResources().getColor(R.color.red));
        //                course_layout.setBackgroundResource(R.drawable.ic_tabbar_bg_click);
        if (fg1 == null) {
          // 如果fg1为空,则创建一个并添加到界面上
          fg1 = new HomePageFragment();
          transaction.add(R.id.content, fg1);
        } else {
          // 如果MessageFragment不为空,则直接将它显示出来
          transaction.show(fg1);
        }
        break;

      case 1:
        found_image.setImageResource(R.drawable.index_rank_press);
        found_text.setTextColor(this.getResources().getColor(R.color.red));
        //                found_layout.setBackgroundResource(R.drawable.ic_tabbar_bg_click);
        if (fg2 == null) {
          // 如果fg1为空,则创建一个并添加到界面上
          fg2 = new RankingFragment();
          transaction.add(R.id.content, fg2);
        } else {
          // 如果MessageFragment不为空,则直接将它显示出来
          transaction.show(fg2);
        }
        break;

      case 2:
        settings_image.setImageResource(R.drawable.index_personal_press);
        settings_text.setTextColor(this.getResources().getColor(R.color.red));
        //                settings_layout.setBackgroundResource(R.drawable.ic_tabbar_bg_click);
        if (fg3 == null) {
          // 如果fg1为空,则创建一个并添加到界面上
          fg3 = new PersonalFragment();
          transaction.add(R.id.content, fg3);
        } else {
          // 如果MessageFragment不为空,则直接将它显示出来
          transaction.show(fg3);
        }
        break;
    }
    transaction.commit();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate");

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setSupportProgressBarIndeterminateVisibility(false);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    setContentView(R.layout.activity_multipane);

    // FragmentManager.enableDebugLogging(true);

    if (savedInstanceState != null) executeState(savedInstanceState);
    else executeDefaultInstanceState();

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    createSearchModeCustomView(actionBar);

    mResizeButton.setOnClickListener(this);

    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction t = fm.beginTransaction();

    mWorkerFragment = (CombinedWorkerFragment) fm.findFragmentByTag(CombinedWorkerFragment.TAG);
    if (mWorkerFragment == null) {
      mWorkerFragment = new CombinedWorkerFragment();
      t.add(mWorkerFragment, CombinedWorkerFragment.TAG);
    }

    mListFragment = (POIsListFragment) fm.findFragmentById(R.id.list_layout);
    if (mListFragment == null) {
      mListFragment = POIsListFragment.newInstance(false, true);
      t.add(R.id.list_layout, mListFragment, POIsListFragment.TAG);
    }

    mMapFragment = (POIsMapsforgeFragment) fm.findFragmentById(R.id.map_layout);
    if (mMapFragment == null) {
      mMapFragment = POIsMapsforgeFragment.newInstance(false, true);
      t.add(R.id.map_layout, mMapFragment, POIsMapsforgeFragment.TAG);
    }

    mDetailFragment = (POIDetailFragment) fm.findFragmentById(R.id.detail_layout);
    if (mDetailFragment == null) {
      mDetailFragment = POIDetailFragment.newInstance();
      t.add(R.id.detail_layout, mDetailFragment);
    }

    t.commit();
  }
예제 #22
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();
   }
 }
예제 #23
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_student, container, false);
    ButterKnife.bind(this, view);

    ViewModelFactory viewModelFactory =
        ((ApplicationExtension) getContext().getApplicationContext()).getViewModelFactory();
    mManageStudentsViewModel = viewModelFactory.getManageStudentsViewModel();

    FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
    transaction.add(R.id.studentListFrame, new StudentListFragment(), "tag1");
    transaction.add(R.id.studentDetailFrame, new StudentDetailFragment(), "tag2");
    transaction.commit();
    return view;
  }
예제 #24
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);
  }
예제 #25
0
  /** {@inheritDoc} */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    mIsSplashEnd = false;
    mIsGcmRegistered = false;

    // Begin GCM jobs.
    if (savedInstanceState == null) {
      final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
      ft.add(new PushRegistrationFragment(), "registration").commit();
    }

    mTimer =
        new CountDownTimer(Config.SPLASH_TIME_MILLIS, Config.SPLASH_TIME_MILLIS) {
          @Override
          public void onTick(long millisUntilFinished) {
            // do nothing
          }

          @Override
          public void onFinish() {
            mIsSplashEnd = true;
            startNextActivity();
          }
        }.start();
  }
예제 #26
0
  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();
          }
        });
  }
예제 #27
0
 private void initFragment(Fragment userhomeFragment) {
   // Add the NotesFragment to the layout
   FragmentManager fragmentManager = getSupportFragmentManager();
   FragmentTransaction transaction = fragmentManager.beginTransaction();
   transaction.add(R.id.container_user_home, userhomeFragment);
   transaction.commit();
 }
예제 #28
0
 @Override
 public void onClick(View v) {
   fraTra = getChildFragmentManager().beginTransaction();
   switch (v.getId()) {
     case R.id.btn_girl:
       btn_girl.setTextColor(getResources().getColor(R.color.pciture_blue));
       btn_boy.setTextColor(getResources().getColor(R.color.pciture_text));
       if (boy_fragment != null) {
         fraTra.hide(boy_fragment);
       }
       fraTra.show(gril_fragment);
       break;
     case R.id.btn_boy:
       btn_boy.setTextColor(getResources().getColor(R.color.pciture_blue));
       btn_girl.setTextColor(getResources().getColor(R.color.pciture_text));
       if (boy_fragment == null) {
         boy_fragment = new BoyFragment();
         fraTra.add(R.id.main_layout, boy_fragment);
       } else {
         gril_fragment.onResume();
       }
       if (gril_fragment != null) {
         fraTra.hide(gril_fragment);
       }
       fraTra.show(boy_fragment);
       break;
     default:
       break;
   }
   fraTra.commit();
 }
예제 #29
0
 private void initFragment() {
   manager = getChildFragmentManager();
   fraTra = manager.beginTransaction();
   gril_fragment = new GirlFragment();
   fraTra.add(R.id.main_layout, gril_fragment);
   fraTra.commit();
 }
예제 #30
0
  @Override
  public void initView() {

    fm = getSupportFragmentManager();
    ft = fm.beginTransaction();
    bt_home = (Button) findViewById(R.id.bt_home);
    bt_search = (Button) findViewById(R.id.bt_search);
    bt_message = (Button) findViewById(R.id.bt_message);
    bt_user = (Button) findViewById(R.id.bt_user);
    unreadLabel = (TextView) findViewById(R.id.unread_msg_number);

    //        if (fm.findFragmentByTag("HOME") == null) {
    ft.add(R.id.rl_fragment_contanier, (HomeFragment) FragmentFactory.getFragment(HOME), "HOME")
        .add(
            R.id.rl_fragment_contanier,
            (MessageFragment) FragmentFactory.getFragment(MESSAGE),
            "MESSAGE")
        .hide((MessageFragment) FragmentFactory.getFragment(MESSAGE))
        .add(
            R.id.rl_fragment_contanier,
            (FindFragment) FragmentFactory.getFragment(LOOKINGFORTEACHER),
            "LOOKINGFORTEACHER")
        .hide((FindFragment) FragmentFactory.getFragment(LOOKINGFORTEACHER))
        .add(R.id.rl_fragment_contanier, FragmentFactory.getFragment(MYINFO), "MYINFO")
        .hide(((MyFragment) FragmentFactory.getFragment(MYINFO)));
    ft.show((HomeFragment) FragmentFactory.getFragment(HOME)).commit();
    bt_home.setCompoundDrawablesWithIntrinsicBounds(
        null, getResources().getDrawable(R.mipmap.tab_ico_home_pre), null, null);
    //        bt_home.setSelected(true);
    showLogD("==============================================");
  }