public void onSliding(View v) {
   if (spl.isOpen()) {
     spl.closePane();
   } else {
     spl.openPane();
   }
 }
Esempio n. 2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    view = inflater.inflate(R.layout.fragment_draw, container, false);
    frame_draw_layout = (LinearLayout) view.findViewById(R.id.frame_draw_layout);
    slidingPaneLayout = new SlidingPaneLayout(getActivity());
    try {
      Field f_overHang = SlidingPaneLayout.class.getDeclaredField("mOverhangSize");
      f_overHang.setAccessible(true);
      f_overHang.set(slidingPaneLayout, 0);
      slidingPaneLayout.setPanelSlideListener(this);
      slidingPaneLayout.setSliderFadeColor(getResources().getColor(android.R.color.transparent));
    } catch (Exception e) {
      e.printStackTrace();
    }

    View leftView = new View(getActivity());
    leftView.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    leftView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    slidingPaneLayout.addView(leftView, 0);

    ViewGroup decor = (ViewGroup) getActivity().getWindow().getDecorView();
    ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
    decorChild.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    decor.removeView(decorChild);
    decor.addView(slidingPaneLayout);
    slidingPaneLayout.addView(decorChild, 1);
    return view;
  }
 public void setNewPage(Fragment fragment, int pageIndex) {
   if (spl.isOpen()) {
     spl.closePane();
   }
   getSupportFragmentManager()
       .beginTransaction()
       .replace(R.id.layout_frame, fragment, "currentFragment")
       .commit();
 }
Esempio n. 4
0
 @Override
 public void onBackPressed() {
   if (!mSlidingLayout.isOpen()) {
     mSlidingLayout.openPane();
   } else {
     MyListFragment.contatti = true;
     super.onBackPressed();
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    UIUtils.tryTranslateHttpIntent(this);
    BeamUtils.tryUpdateIntentFromBeam(this);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_sessions_sandbox);

    final FragmentManager fm = getSupportFragmentManager();
    mTracksDropdownFragment =
        (TracksDropdownFragment) fm.findFragmentById(R.id.fragment_tracks_dropdown);

    mSlidingPaneLayout = (SlidingPaneLayout) findViewById(R.id.sliding_pane_layout);

    // Offset the left pane by its full width and left margin when collapsed
    // (ViewPager-like presentation)
    mSlidingPaneLayout.setParallaxDistance(
        getResources().getDimensionPixelSize(R.dimen.sliding_pane_width)
            + getResources().getDimensionPixelSize(R.dimen.multipane_padding));
    mSlidingPaneLayout.setSliderFadeColor(
        getResources().getColor(R.color.sliding_pane_content_fade));

    routeIntent(getIntent(), savedInstanceState != null);

    if (savedInstanceState != null) {
      if (mFullUI) {
        int viewType = savedInstanceState.getInt(STATE_VIEW_TYPE);
        getSupportActionBar().setSelectedNavigationItem(viewType);
      }

      mDetailFragment = fm.findFragmentById(R.id.fragment_container_detail);
      updateDetailBackground();
    }

    // This flag prevents onTabSelected from triggering extra master pane reloads
    // unless it's actually being triggered by the user (and not automatically by
    // the system)
    mInitialTabSelect = false;

    mImageLoader =
        new ImageLoader(this, R.drawable.person_image_empty)
            .setMaxImageSize(getResources().getDimensionPixelSize(R.dimen.speaker_image_size))
            .setFadeInImage(UIUtils.hasHoneycombMR1());

    EasyTracker.getInstance().setContext(this);
  }
  @Override
  protected void initViews(Bundle var) {
    slidingLeftFragment.setSlidingLeftListener(this);

    slidingPaneLayout.openPane();
    slidingPaneLayout.setPanelSlideListener(
        new SlidingPaneLayout.PanelSlideListener() {
          @Override
          public void onPanelSlide(View panel, float slideOffset) {
            if (slidingLeftFragment.isAnimation()) {
              if (mMenuPanel == null) {
                final int childCount = slidingPaneLayout.getChildCount();
                for (int i = 0; i < childCount; i++) {
                  final View child = slidingPaneLayout.getChildAt(i);
                  if (child != panel) {
                    mMenuPanel = child;
                    break;
                  }
                }
              }
              final float scaleLeft = 1 - 0.3f * (1 - slideOffset);
              mMenuPanel.setPivotX(-0.3f * mMenuPanel.getWidth());
              mMenuPanel.setPivotY(mMenuPanel.getHeight() / 2f);
              mMenuPanel.setScaleX(scaleLeft);
              mMenuPanel.setScaleY(scaleLeft);

              final float scale = 1 - 0.2f * slideOffset;
              panel.setPivotX(0);
              panel.setPivotY(panel.getHeight() / 2.0f);
              panel.setScaleX(scale);
              panel.setScaleY(scale);
            }
          }

          @Override
          public void onPanelOpened(View panel) {
            slidingLeftFragment.setHasOptionsMenu(false);
          }

          @Override
          public void onPanelClosed(View panel) {
            slidingLeftFragment.setHasOptionsMenu(true);
          }
        });
  }
 private void initData() {
   String[] strArr = getResources().getStringArray(R.array.url_arr);
   ArrayAdapter<String> adapter =
       new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, strArr);
   mListView.setAdapter(adapter);
   mListView.setOnItemClickListener(this);
   mWebview.setWebViewClient(new MyWebviewClient());
   mSlidingPaneLayout.setPanelSlideListener(this);
 }
 @Override
 public boolean onNavigationItemSelected(int itemPosition, long itemId) {
   loadTrackList(itemPosition); // itemPosition == view type
   if (!mInitialTabSelect) {
     onTrackSelected(mTracksDropdownFragment.getSelectedTrackId());
     mSlidingPaneLayout.openPane();
   }
   return true;
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        if (mSlidingPaneLayout.isSlideable() && !mSlidingPaneLayout.isOpen()) {
          // If showing the detail view, pressing Up should show the master pane.
          mSlidingPaneLayout.openPane();
          return true;
        }
        break;

      case R.id.menu_search:
        if (!UIUtils.hasHoneycomb()) {
          startSearch(null, false, Bundle.EMPTY, false);
          return true;
        }
        break;
    }
    return super.onOptionsItemSelected(item);
  }
Esempio n. 10
0
  @SuppressLint("NewApi")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    setContentView(R.layout.slidingpane_main_layout);
    Injector.get(this).inject(); // init views
    menuFragment = new MenuFragment();
    contentFragment = new HomeFragment();
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.slidingpane_menu, menuFragment);
    transaction.replace(R.id.slidingpane_content, contentFragment);
    transaction.commit();
    maxMargin = displayMetrics.heightPixels / 10;
    slidingPaneLayout.setPanelSlideListener(
        new PanelSlideListener() {
          @Override
          public void onPanelSlide(View panel, float slideOffset) {
            // TODO Auto-generated method stub
            //				int contentMargin = (int) (slideOffset * maxMargin);
            //				FrameLayout.LayoutParams contentParams = contentFragment
            //						.getCurrentViewParams();
            //				contentParams.setMargins(0, contentMargin, 0, contentMargin);
            //				contentFragment.setCurrentViewPararms(contentParams);
            //
            //				float scale = 1 - ((1 - slideOffset) * maxMargin * 2)
            //						/ (float) displayMetrics.heightPixels;
            //				Log.e("scale", scale + "sss" + slideOffset + "");
            //				menuFragment.getCurrentView().setScaleX(scale);// 设置缩放的基准点
            //				menuFragment.getCurrentView().setScaleY(scale);// 设置缩放的基准点
            //				menuFragment.getCurrentView().setPivotX(0);// 设置缩放和选择的点
            //				menuFragment.getCurrentView().setPivotY(
            //						displayMetrics.heightPixels / 2);
            //				menuFragment.getCurrentView().setAlpha(slideOffset);
          }

          @Override
          public void onPanelOpened(View panel) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onPanelClosed(View panel) {
            // TODO Auto-generated method stub

          }
        });
  }
  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 routeIntent(Intent intent, boolean updateSurfaceOnly) {
    Uri uri = intent.getData();
    if (uri == null) {
      return;
    }

    if (intent.hasExtra(Intent.EXTRA_TITLE)) {
      setTitle(intent.getStringExtra(Intent.EXTRA_TITLE));
    }

    String mimeType = getContentResolver().getType(uri);

    if (ScheduleContract.Tracks.CONTENT_ITEM_TYPE.equals(mimeType)) {
      // Load track details
      showFullUI(true);
      if (!updateSurfaceOnly) {
        // TODO: don't assume the URI will contain the track ID
        int defaultViewType =
            intent.getIntExtra(EXTRA_DEFAULT_VIEW_TYPE, TracksDropdownFragment.VIEW_TYPE_SESSIONS);
        String selectedTrackId = ScheduleContract.Tracks.getTrackId(uri);
        loadTrackList(defaultViewType, selectedTrackId);
        getSupportActionBar().setSelectedNavigationItem(defaultViewType);
        onTrackSelected(selectedTrackId);
        mSlidingPaneLayout.openPane();
      }

    } else if (ScheduleContract.Sessions.CONTENT_TYPE.equals(mimeType)) {
      // Load a session list, hiding the tracks dropdown and the tabs
      mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS;
      showFullUI(false);
      if (!updateSurfaceOnly) {
        loadSessionList(uri, null);
        mSlidingPaneLayout.openPane();
      }

    } else if (ScheduleContract.Sessions.CONTENT_ITEM_TYPE.equals(mimeType)) {
      // Load session details
      if (intent.hasExtra(EXTRA_MASTER_URI)) {
        mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS;
        showFullUI(false);
        if (!updateSurfaceOnly) {
          loadSessionList(
              (Uri) intent.getParcelableExtra(EXTRA_MASTER_URI),
              ScheduleContract.Sessions.getSessionId(uri));
          loadSessionDetail(uri);
        }
      } else {
        mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS; // prepare for onTrackInfo...
        showFullUI(true);
        if (!updateSurfaceOnly) {
          loadSessionDetail(uri);
          loadTrackInfoFromSessionUri(uri);
        }
      }

    } else if (ScheduleContract.Sandbox.CONTENT_TYPE.equals(mimeType)) {
      // Load a sandbox company list
      mViewType = TracksDropdownFragment.VIEW_TYPE_SANDBOX;
      showFullUI(false);
      if (!updateSurfaceOnly) {
        loadSandboxList(uri, null);
        mSlidingPaneLayout.openPane();
      }

    } else if (ScheduleContract.Sandbox.CONTENT_ITEM_TYPE.equals(mimeType)) {
      // Load company details
      mViewType = TracksDropdownFragment.VIEW_TYPE_SANDBOX;
      showFullUI(false);
      if (!updateSurfaceOnly) {
        Uri masterUri = intent.getParcelableExtra(EXTRA_MASTER_URI);
        if (masterUri == null) {
          masterUri = ScheduleContract.Sandbox.CONTENT_URI;
        }
        loadSandboxList(masterUri, ScheduleContract.Sandbox.getCompanyId(uri));
        loadSandboxDetail(uri);
      }
    }

    updateDetailBackground();
  }
 private void openPane() {
   mPanes.openPane();
 }
Esempio n. 16
0
 private void closeMenu() {
   if (sPaneLy.isSlideable()) {
     // We close the left fragment
     sPaneLy.closePane();
   }
 }
Esempio n. 17
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();
 }