Пример #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ui_picture_pager);

    if (getSupportActionBar() != null) {
      getSupportActionBar().setDisplayShowHomeEnabled(false);
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    mBean =
        savedInstanceState == null
            ? PhotosFragment.photos
            : (PhotosBean) savedInstanceState.getSerializable("bean");
    index =
        savedInstanceState == null
            ? getIntent().getIntExtra("index", 0)
            : savedInstanceState.getInt("index", 0);

    myViewPagerAdapter = new MyViewPagerAdapter(getFragmentManager());
    viewPager.setAdapter(myViewPagerAdapter);
    viewPager.setCurrentItem(index);
    viewPager.setOnPageChangeListener(this);
    if (size() > 1 && getSupportActionBar() != null)
      getSupportActionBar().setTitle(String.format("%d/%d", index + 1, size()));

    layStatus.setVisibility(View.VISIBLE);
    viewStatus.setVisibility(View.VISIBLE);
    txtStatus.setText(getStatus(index).getText());

    if (Build.VERSION.SDK_INT >= 19) {
      layToolbar.setPadding(
          0, layToolbar.getPaddingTop() + SystemUtils.getStatusBarHeight(this), 0, 0);

      if (SystemUtils.hasNavigationBar(this)) {
        layStatus.setPadding(0, 0, 0, SystemUtils.getNavigationBarHeight(this));
      }
    }

    getToolbar().setBackgroundColor(Color.TRANSPARENT);
  }
Пример #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ui_main);

    CacheClearFragment.clearCompress();

    BizFragment bizFragment = BizFragment.createBizFragment(this);
    bizFragment.createFabAnimator(fabBtn);
    fabBtn.setOnLongClickListener(
        new View.OnLongClickListener() {

          @Override
          public boolean onLongClick(View v) {
            // 触发一次刷新
            ((AsToolbar) getToolbar()).performDoublcClick();
            appBarLayout.setExpanded(true);

            return true;
          }
        });
    bizFragment.getFabAnimator().setDuration(200);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(false);

    setupDrawer(savedInstanceState);
    setupMenu(savedInstanceState);
    setupFab(savedInstanceState);
    setupAppBarLayout(savedInstanceState);

    if (savedInstanceState != null) {
      toolbarTitle = savedInstanceState.getString("toolbarTitle");
      if (!TextUtils.isEmpty(toolbarTitle)) getSupportActionBar().setTitle(toolbarTitle);
    }

    mInstance = this;

    OtherItemFragment.checkPhotoPermission(this, true);
  }