@Override
 public void onCreate(Bundle savedInstanceState) {
   requestWindowFeature(Window.FEATURE_NO_TITLE);
   if (Build.VERSION.SDK_INT > 10) {
     getWindow().setFlags(0x01000000, 0x01000000);
   }
   super.onCreate(savedInstanceState);
   Bundle bundle = new Bundle();
   if (getIntent() != null) {
     Serializable serializable = getIntent().getSerializableExtra("SUBLIST");
     bundle.putSerializable("SUBLIST", serializable);
   }
   if (savedInstanceState != null) {
     weatherCitySelectFragment =
         (WeatherCitySelectFragment)
             getSupportFragmentManager()
                 .getFragment(savedInstanceState, "WeatherCitySelectFragment");
     weatherSettingFragment =
         (WeatherSettingFragment)
             getSupportFragmentManager().getFragment(savedInstanceState, "WeatherSettingFragment");
   }
   if (weatherCitySelectFragment == null) {
     weatherCitySelectFragment = WeatherCitySelectFragment.newInstance(bundle);
   }
   if (weatherSettingFragment == null) {
     weatherSettingFragment = new WeatherSettingFragment();
   }
   // set the Behind View
   setBehindContentView(R.layout.menu_frame);
   FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
   t.replace(R.id.menu_frame, weatherCitySelectFragment);
   t.commit();
   // customize the SlidingMenu
   SlidingMenu sm = getSlidingMenu();
   sm.setMode(SlidingMenu.LEFT_RIGHT);
   sm.setShadowWidthRes(R.dimen.shadow_width);
   sm.setShadowDrawable(R.drawable.shadow);
   sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
   sm.setFadeDegree(0.35f);
   sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
   sm.setSecondaryMenu(R.layout.menu_frame_two);
   sm.setSecondaryShadowDrawable(R.drawable.shadowright);
   getSupportFragmentManager()
       .beginTransaction()
       .replace(R.id.menu_frame_two, weatherSettingFragment)
       .commit();
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.frame_content);
    setBehindContentView(R.layout.frame_menu);

    //	setSecondaryMenu

    SlidingMenu sm = getSlidingMenu();
    sm.setShadowWidth(50);
    sm.setShadowDrawable(R.drawable.shadow);
    sm.setBehindOffset(60);
    sm.setFadeDegree(0.35f);
    sm.setMode(SlidingMenu.LEFT_RIGHT);
    //  sm.set

    sm.setSecondaryMenu(R.layout.test1);
    sm.setSecondaryShadowDrawable(R.drawable.shadow);

    //    sm.setMenu(R.layout.frame_menu);
    // sm.setLeft(R.layout.frame_menu);
    // 设置slding menu的几种手势模式
    // TOUCHMODE_FULLSCREEN 全屏模式,在content页面中,滑动,可以打开sliding menu
    // TOUCHMODE_MARGIN 边缘模式,在content页面中,如果想打开slding ,你需要在屏幕边缘滑动才可以打开slding menu
    // TOUCHMODE_NONE 自然是不能通过手势打开啦
    sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

    //		FragmentTransaction fragmentTransaction=getFragmentManager().beginTransaction();
    //		MenuFragment menuFragment = new MenuFragment();
    //      //  fragmentTransaction.replace(R.id.menu, menuFragment);
    //        fragmentTransaction.replace(R.id.content, new ContentFragment("Welcome"),"Welcome");
    //        fragmentTransaction.commit();
    //
    //    //    getActionBar().setDisplayHomeAsUpEnabled(true);
  }
Beispiel #3
0
 /**
  * Set the secondary behind view (right menu) content from a layout resource. The resource will be
  * inflated, adding all top-level views to the behind view.
  *
  * @param res the new content
  */
 public void setSecondaryMenu(int res) {
   setSecondaryMenu(LayoutInflater.from(getContext()).inflate(res, null));
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Utils.isWide(this)) { // wide enough, switch to tablet layout
      final Intent intent = new Intent();
      intent.setClass(this, TabletActivity.class);
      startActivity(intent);
      finish();

      return;
    }

    mPrefs = getPreferences(MODE_PRIVATE);

    mMenu = getSlidingMenu();
    mMenu.setMode(SlidingMenu.LEFT_RIGHT);
    mMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    mMenu.setBehindOffset((int) getResources().getDimension(R.dimen.sliding_menu_offset));
    mMenu.setFadeDegree(0.5f);
    mMenu.setShadowWidthRes(R.dimen.sliding_menu_shadow);
    mMenu.setShadowDrawable(R.drawable.shadow_left);
    mMenu.setSecondaryShadowDrawable(R.drawable.shadow_right);

    // activity content
    setContentView(R.layout.activity_phone);

    mContainerVcard = findViewById(R.id.container_vcard);
    mVerticalLeft = findViewById(R.id.vertical_left);
    mVerticalRight = findViewById(R.id.vertical_right);
    mHintLeft = findViewById(R.id.side_hint_left);
    mHintRight = findViewById(R.id.side_hint_right);

    setBehindContentView(R.layout.menu_primary);
    mMenu.setSecondaryMenu(R.layout.menu_secondary);

    if (savedInstanceState == null) {
      // vcard
      getSupportFragmentManager()
          .beginTransaction()
          .replace(R.id.container_vcard, new VcardFragment())
          .commit();

      /*
       *  displaying of layout waits until onCreate completes
       *  load another fragments little bit later to allow fast displaying of activity_phone one
       */
      sHandler.postDelayed(
          new Runnable() {
            @Override
            public void run() {

              // networks
              getSupportFragmentManager()
                  .beginTransaction()
                  .replace(R.id.container_networks, new NetworksFragment())
                  .commit();

              // timeline
              getSupportFragmentManager()
                  .beginTransaction()
                  .replace(R.id.container_timeline, new TimelineFragment())
                  .commit();
            }
          },
          250);
    }

    mMenu.setOnOpenedListener(
        new SlidingMenu.OnOpenedListener() {
          @Override
          public void onOpened() {
            if (mAnimVcardOut.isRunning()) {
              mAnimVcardOut.end();
            }
            mAnimVcardOut.setTarget(mContainerVcard);
            mAnimVcardOut.start();

            if (mMenu.isSecondaryMenuShowing()) {
              if (mAnimVerticalRightIn.isRunning()) {
                mAnimVerticalRightIn.end();
              }
              mAnimVerticalRightIn.setTarget(mVerticalRight);
              mAnimVerticalRightIn.start();
            } else {
              if (mAnimVerticalLeftIn.isRunning()) {
                mAnimVerticalLeftIn.end();
              }
              mAnimVerticalLeftIn.setTarget(mVerticalLeft);
              mAnimVerticalLeftIn.start();
            }

            final SharedPreferences.Editor edit = mPrefs.edit();
            edit.putBoolean(Constants.PREF_SIDE_USED, true);
            edit.commit();

            if (mTracker != null) {
              mTracker.sendEvent("activity_phone", "open", "slide_menu", 0l);

              GAServiceManager.getInstance().dispatch();
            }
          }
        });

    mMenu.setOnClosingListener(
        new SlidingMenu.OnClosingListener() {
          @Override
          public void onClosing() {
            if (mVerticalLeft.getVisibility() == View.VISIBLE) {
              if (mAnimVerticalLeftIn.isRunning()) {
                mAnimVerticalLeftIn.end();
              }
              mVerticalLeft.setVisibility(View.INVISIBLE);
            } else if (mVerticalRight.getVisibility() == View.VISIBLE) {
              if (mAnimVerticalRightIn.isRunning()) {
                mAnimVerticalRightIn.end();
              }
              mVerticalRight.setVisibility(View.INVISIBLE);
            }

            if (mAnimVcardOut.isRunning()) {
              mAnimVcardOut.end();
            }
            mContainerVcard.setAlpha(1.0f); // TODO: level 11+
            mContainerVcard.setVisibility(View.VISIBLE);
          }
        });
  }