示例#1
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());
    }
  }
示例#2
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   // 监听按下返回键
   if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
     /*已经是最后一个fragment
      * getSupportFragmentManager()或者getFragmentManager()
      * 具体要看你add to back stack 是用哪个*/
     // if no more history in stack
     if (PageService.getInstance().getTopPage() != null)
       PageService.getInstance().getTopPage().OnNavBack();
     LOG.i(this, "触发回退键");
   }
   return true;
 }
示例#3
0
  public void pop() {

    if (PageService.getInstance().getStackSize() > 1) {
      fragmentManger
          .beginTransaction()
          .setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right)
          .remove(
              fragmentManger.findFragmentByTag(
                  PageService.getInstance().getTopPage().getPageName()))
          .commit();
      PageService.getInstance().popPage();
      if (PageService.getInstance().getTopPage() != null)
        fragmentManger
            .beginTransaction()
            .show(
                fragmentManger.findFragmentByTag(
                    PageService.getInstance().getTopPage().getPageName()))
            .commit();
    }
  }
示例#4
0
  public void switchs(String name) {
    if (name.equals("main")) {
      int a = 1;
      a = 2;
      ;;
    }
    PageService.getInstance().popPage();
    Page p = PageFactory.CreatePage(name);
    PageService.getInstance().pushPage(p);
    NormalPagFragement fragements;
    try {
      fragements = new NormalPagFragement(p);

      fragmentManger
          .beginTransaction()
          .setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right)
          .replace(0x1237156, fragements, p.getPageName())
          .commit();
    } catch (LuaException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      RuntimeContext.showLuaError(e.getMessage());
    }
  }