public void onSliding(View v) {
   if (spl.isOpen()) {
     spl.closePane();
   } else {
     spl.openPane();
   }
 }
 public void setNewPage(Fragment fragment, int pageIndex) {
   if (spl.isOpen()) {
     spl.closePane();
   }
   getSupportFragmentManager()
       .beginTransaction()
       .replace(R.id.layout_frame, fragment, "currentFragment")
       .commit();
 }
  private void loadSandboxDetail(Uri companyUri) {
    SandboxDetailFragment fragment = new SandboxDetailFragment();
    fragment.setArguments(
        BaseActivity.intentToFragmentArguments(new Intent(Intent.ACTION_VIEW, companyUri)));
    getSupportFragmentManager()
        .beginTransaction()
        .replace(R.id.fragment_container_detail, fragment)
        .commit();
    mDetailFragment = fragment;
    updateDetailBackground();

    // If loading session details in portrait, hide the master pane
    mSlidingPaneLayout.closePane();
  }
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   switch (position) {
     case 0:
       mWebview.loadUrl("http://www.sina.com.cn");
       break;
     case 1:
       mWebview.loadUrl("http://www.qq.com");
       break;
     case 2:
       mWebview.loadUrl("http://www.baidu.com");
       break;
   }
   mSlidingPaneLayout.closePane();
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    switch (id) {
      case R.id.opciones:
        if (mPanes.closePane()) {
          closePane();
        } else {
          openPane();
        }
        break;
      case R.id.salir:
        Salir();
        break;
    }

    return super.onOptionsItemSelected(item);
  }
 private void closeMenu() {
   if (sPaneLy.isSlideable()) {
     // We close the left fragment
     sPaneLy.closePane();
   }
 }
Exemple #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_my);
    // actionBar=getSupportActionBar();
    checkPlayServices();
    int dpValue = 50; // margin in dips
    float d = this.getResources().getDisplayMetrics().density;
    final int margin = (int) (dpValue * d);

    mSlidingLayout = (SlidingPaneLayout) findViewById(R.id.sliding_pane_layout);
    final View Fmargin = mSlidingLayout.findViewById(R.id.content_pane);
    final ViewGroup.MarginLayoutParams lp =
        (ViewGroup.MarginLayoutParams) Fmargin.getLayoutParams();

    mSlidingLayout.setPanelSlideListener(
        new SlidingPaneLayout.PanelSlideListener() {
          @Override
          public void onPanelSlide(View panel, float slideOffset) {
            if (add) {

            } else {

            }
          }

          @Override
          public void onPanelOpened(View panel) {
            getSupportFragmentManager()
                .findFragmentById(R.id.content_pane)
                .setHasOptionsMenu(false);
            getSupportFragmentManager().findFragmentById(R.id.list_pane).setHasOptionsMenu(true);
            // actionBar.removeAllTabs();
            // actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
            add = true;
            lp.setMargins(margin, 0, 0, 0);
            Fmargin.setLayoutParams(lp);
          }

          @Override
          public void onPanelClosed(View panel) {
            getSupportFragmentManager().findFragmentById(R.id.content_pane).setHasOptionsMenu(true);
            getSupportFragmentManager().findFragmentById(R.id.list_pane).setHasOptionsMenu(false);
            if (!MyListFragment.contatti) {
              // actionBar.removeAllTabs();
              // actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
              add = true;
              lp.setMargins(margin, 0, 0, 0);
              Fmargin.setLayoutParams(lp);
            } else if (add) {
              // actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
              // actionBar.addTab(actionBar.newTab().setText("Utenti
              // ChipChat").setTabListener(tabListener));
              // actionBar.addTab(actionBar.newTab().setText("Altri
              // Utenti").setTabListener(tabListener));
              Log.i(TAG, "addTab");
              add = false;
              lp.setMargins(0, 0, 0, 0);
              Fmargin.setLayoutParams(lp);
            }
          }
        });
    if (getIntent().getStringExtra("Destinatario") != null) {
      MyListFragment.contatti = false;
      mSlidingLayout.closePane();
      FragmentManager fragmentManager = getSupportFragmentManager();
      FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
      DetailFragment fragment = new DetailFragment();
      fragmentTransaction.replace(R.id.content_pane, fragment);
      fragmentTransaction.commit();
      DetailFragment.destinatario = getIntent().getStringExtra("Destinatario");
      DetailFragment.animato = getIntent().getBooleanExtra("Animato", true);
    } else mSlidingLayout.openPane();
    /*findViewById(R.id.chat_content).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mSlidingLayout.closePane();
        }
    });*/
  }
 private void closePane() {
   mPanes.closePane();
 }