@Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   View rootView = inflater.inflate(R.layout.profile_control, container, false);
   relativeLayout = (RelativeLayout) rootView.findViewById(R.id.gatt_service_carousel);
   pager = (ViewPager) rootView.findViewById(R.id.myviewpager);
   application = (CySmartApplication) getActivity().getApplication();
   PAGES = 0;
   mpdia = new ProgressDialog(getActivity());
   mpdia.setCancelable(false);
   setCarouselView();
   setHasOptionsMenu(true);
   /**
    * Getting the orientation of the device. Set margin for pages as a negative number, so a part
    * of next and previous pages will be showed
    */
   if (getActivity().getResources().getConfiguration().orientation
       == Configuration.ORIENTATION_PORTRAIT) {
     pager.setPageMargin(-width / 3);
   } else if (getActivity().getResources().getConfiguration().orientation
       == Configuration.ORIENTATION_LANDSCAPE) {
     pager.setPageMargin(-width / 2);
   }
   return rootView;
 }
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  private void init(Context context) {
    // Disable clipping of children so non-selected pages are visible
    setClipChildren(false);

    // Child clipping doesn't work with hardware acceleration in Android 3.x/4.x
    // You need to set this value here if using hardware acceleration in an
    // application targeted at these releases.
    if (Build.VERSION.SDK_INT >= 11) {
      setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    // 添加ViewPager
    mPager = new ViewPager(context);
    mPager.setId(R.id.pager);
    // If hardware acceleration is enabled, you should also remove
    // clipping on the pager for its children.
    mPager.setClipChildren(false);
    mPager.setPageMargin(pageMargin);
    mPager.setOnPageChangeListener(this);
    // Necessary or the pager will only have one extra page to show
    // make this at least however many pages you can see
    mPager.setOffscreenPageLimit(calcOffscreenPageLimit());
    mPager.setLayoutParams(
        new FrameLayout.LayoutParams(pageWidth, pageHeight, Gravity.CENTER_HORIZONTAL));
    this.addView(mPager);
  }
  private void init() {
    if (null == mAdapter) {
      // print(true, "init() " + coverList.size());
      mAdapter =
          new AlbumFragmentPagerAdapter(
              getActivity().getSupportFragmentManager(), coverList.size(), "", mPager);

      mAdapter.setOnGetItem(
          new OnGetItem() {

            @Override
            public ImageFragment onGetNewItem(int position) {
              // 生成新的 cover 图片实例
              return ImageFragment.newInstance(coverList.get(position).getId(), true);
            }
          });

      mPager.setAdapter(mAdapter);
      mPager.setPageMargin(mPagerMargin);
      mPager.setOffscreenPageLimit(3);
      // set container touch event assign to pager's touch event
      mContainer.setOnTouchListener(mOnTouchListener);

      // set container to refresh when pager's page changed
      mPager.setOnPageChangeListener(mOnPageChangeListener);
      mPager.setOnTouchListener(mOnTouchListener);
      // 设置选中的页面
      mPager.setCurrentItem(selectedPosition);
    } else {
      mAdapter.notifyDataSetChanged();
    }
  }
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.network_monitor_content);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    final ViewPager pager = (ViewPager) findViewById(R.id.network_monitor_pager);

    final FragmentManager fm = getSupportFragmentManager();

    if (pager != null) {
      final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.network_monitor_pager_tabs);
      pagerTabs.addTabLabels(
          R.string.network_monitor_peer_list_title, R.string.network_monitor_block_list_title);

      final PagerAdapter pagerAdapter = new PagerAdapter(fm);

      pager.setAdapter(pagerAdapter);
      pager.setOnPageChangeListener(pagerTabs);
      pager.setPageMargin(2);
      pager.setPageMarginDrawable(R.color.bg_less_bright);

      peerListFragment = new PeerListFragment();
      blockListFragment = new BlockListFragment();
    } else {
      peerListFragment = (PeerListFragment) fm.findFragmentById(R.id.peer_list_fragment);
      blockListFragment = (BlockListFragment) fm.findFragmentById(R.id.block_list_fragment);
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_my_tba, container, false);
    mViewPager = (ViewPager) v.findViewById(R.id.my_tba_pager);
    // Make this ridiculously big
    mViewPager.setOffscreenPageLimit(50);
    mViewPager.setPageMargin(Utilities.getPixelsFromDp(getActivity(), 16));
    mTabs = (SlidingTabs) v.findViewById(R.id.my_tba_tabs);
    ViewCompat.setElevation(mTabs, getResources().getDimension(R.dimen.toolbar_elevation));

    /**
     * Fix for really strange bug. Menu bar items wouldn't appear only when navigated to from
     * 'Events' in the nav drawer Bug is some derivation of this:
     * https://code.google.com/p/android/issues/detail?id=29472 So set the view pager's adapter in
     * another thread to avoid a race condition, or something.
     */
    mViewPager.post(
        () -> {
          mViewPager.setAdapter(new MyTBAFragmentPagerAdapter(getChildFragmentManager()));
          mTabs.setViewPager(mViewPager);
        });

    return v;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final SharedPreferences sp =
        this.getActivity().getSharedPreferences("linefriend", Context.MODE_APPEND);

    View rootView = inflater.inflate(R.layout.fragment_category_all, container, false);

    tabs = (PagerSlidingTabStrip) rootView.findViewById(R.id.tabs);
    pager = (ViewPager) rootView.findViewById(R.id.pager);
    adapter = new MyPagerAdapter(this.getChildFragmentManager());

    pager.setAdapter(adapter);

    final int pageMargin =
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);

    tabs.setTextSize(DisplayUtil.sp2px(this.getActivity(), 15));
    //		tabs.setTextColor(Color.parseColor("#828181"));
    tabs.setViewPager(pager);

    return rootView;
  }
Example #7
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_viewpager, container, false);

    mAdapter = new TabPagerAdapter(getChildFragmentManager());

    mViewPager = (ViewPager) view.findViewById(R.id.viewpager);
    mViewPager.setAdapter(mAdapter);
    mViewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.spacing_minor));

    mSlidingTabStrip = (SlidingTabLayout) view.findViewById(R.id.viewpager_tabs);
    mSlidingTabStrip.setViewPager(mViewPager);
    mSlidingTabStrip.setTabListener(
        new SlidingTabLayout.TabListener() {
          @Override
          public void onTabSelected(int pos) {
            // NO-OP
          }

          @Override
          public void onTabReSelected(int pos) {
            final Fragment fragment = mAdapter.getItem(pos);
            if (fragment instanceof ListFragment) {
              ((ListFragment) fragment).smoothScrollTo(0);
            }
          }
        });

    if (savedInstanceState != null) {
      mCurrentItem = savedInstanceState.getInt(SAVE_SELECTED_TAB);
    }

    return view;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState, R.layout.view_pager_multi_fragment_demo);

    viewPager = (ViewPager) findViewById(R.id.view_pager);
    indexText = (TextView) findViewById(R.id.view_pager_index);
    viewPagerContainer = (RelativeLayout) findViewById(R.id.pager_layout);
    viewPager.setAdapter(new MyPagerAdapter());
    // to cache all page, or we will see the right item delayed
    viewPager.setOffscreenPageLimit(TOTAL_COUNT);
    viewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.page_margin));
    viewPager.setOnPageChangeListener(new MyOnPageChangeListener());

    viewPagerContainer.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // dispatch the events to the ViewPager, to solve the problem that we can swipe only the
            // middle view.
            return viewPager.dispatchTouchEvent(event);
          }
        });
    indexText.setText(new StringBuilder().append("1/").append(TOTAL_COUNT));
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_article_detail);

    getLoaderManager().initLoader(0, null, this);

    mPagerAdapter = new MyPagerAdapter(getFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    mPager.setPageMargin(
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
    mPager.setPageMarginDrawable(new ColorDrawable(0x22000000));

    mPager.addOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {

          @Override
          public void onPageSelected(int position) {
            if (mCursor != null) {
              mCursor.moveToPosition(position);
            }
            mSelectedItemId = mCursor.getLong(ArticleLoader.Query._ID);
          }
        });

    if (savedInstanceState == null) {
      if (getIntent() != null && getIntent().getData() != null) {
        mStartId = ItemsContract.Items.getItemId(getIntent().getData());
        mSelectedItemId = mStartId;
      }
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mShareIntent = new Intent();
    mShareIntent.setAction(Intent.ACTION_SEND);
    mShareIntent.setType("text/plain");
    mShareIntent.putExtra(Intent.EXTRA_TEXT, "From me to you, this text is new.");

    tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
    ViewPager pager = (ViewPager) findViewById(R.id.pager);

    adapter = new MyPagerAdapter(getSupportFragmentManager());

    pager.setAdapter(adapter);

    final int pageMargin =
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);

    tabs.setViewPager(pager);
  }
Example #11
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (MizLib.hasKitKat()) {
      setTheme(R.style.Mizuu_Theme_Translucent_FullScreen);
    } else {
      setTheme(R.style.Mizuu_Theme_Transparent_FullScreen);
    }

    ViewUtils.setupWindowFlagsForStatusbarOverlay(getWindow(), true);

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    ViewUtils.setProperToolbarSize(this, mToolbar);

    getSupportActionBar()
        .setBackgroundDrawable(getResources().getDrawable(R.drawable.transparent_actionbar));

    mBus = MizuuApplication.getBus();

    mPortraitPhotos = getIntent().getBooleanExtra("portraitPhotos", true);
    mPhotos = getIntent().getStringArrayExtra("photos");

    getSupportActionBar()
        .setTitle(
            (getIntent().getIntExtra("selectedIndex", 0) + 1)
                + " "
                + getString(R.string.of)
                + " "
                + mPhotos.length);

    mViewPager = (ViewPager) findViewById(R.id.awesomepager);
    mViewPager.setPageMargin(MizLib.convertDpToPixels(getApplicationContext(), 16));
    mViewPager.setAdapter(new ActorPhotosAdapter(getSupportFragmentManager()));
    mViewPager.setOnPageChangeListener(
        new SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int arg0) {
            getSupportActionBar()
                .setTitle((arg0 + 1) + " " + getString(R.string.of) + " " + mPhotos.length);
          }
        });
    mViewPager.setCurrentItem(getIntent().getIntExtra("selectedIndex", 0));

    View decorView = getWindow().getDecorView();
    decorView.setOnSystemUiVisibilityChangeListener(
        new OnSystemUiVisibilityChangeListener() {
          @Override
          public void onSystemUiVisibilityChange(int visibility) {
            if (visibility == 0) {
              // The UI is visible due to user interaction - let's hide it again after three seconds
              mHandler.postDelayed(mHideSystemUiRunnable, 3000);
            }
          }
        });
  }
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.address_book_content);

    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    final FragmentManager fragmentManager = getFragmentManager();

    walletAddressesFragment = (WalletAddressesFragment) fragmentManager.findFragmentByTag(TAG_LEFT);
    sendingAddressesFragment =
        (SendingAddressesFragment) fragmentManager.findFragmentByTag(TAG_RIGHT);

    final FragmentTransaction removal = fragmentManager.beginTransaction();

    if (walletAddressesFragment == null) walletAddressesFragment = new WalletAddressesFragment();
    else removal.remove(walletAddressesFragment);

    if (sendingAddressesFragment == null) sendingAddressesFragment = new SendingAddressesFragment();
    else removal.remove(sendingAddressesFragment);

    if (!removal.isEmpty()) {
      removal.commit();
      fragmentManager.executePendingTransactions();
    }

    final ViewPager pager = (ViewPager) findViewById(R.id.address_book_pager);
    if (pager != null) {
      pager.setAdapter(
          new TwoFragmentAdapter(
              fragmentManager, walletAddressesFragment, sendingAddressesFragment));

      final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.address_book_pager_tabs);
      pagerTabs.addTabLabels(
          R.string.address_book_list_receiving_title, R.string.address_book_list_sending_title);

      pager.setOnPageChangeListener(pagerTabs);
      final int position = getIntent().getBooleanExtra(EXTRA_SENDING, true) ? 1 : 0;
      pager.setCurrentItem(position);
      pager.setPageMargin(2);
      pager.setPageMarginDrawable(R.color.bg_less_bright);

      pagerTabs.onPageSelected(position);
      pagerTabs.onPageScrolled(position, 0, 0);
    } else {
      fragmentManager
          .beginTransaction()
          .add(R.id.wallet_addresses_fragment, walletAddressesFragment, TAG_LEFT)
          .add(R.id.sending_addresses_fragment, sendingAddressesFragment, TAG_RIGHT)
          .commit();
    }

    updateFragments();
  }
 private void showMyTopic() {
   MyPagerAdapter adapter = new MyPagerAdapter(getSupportFragmentManager());
   pager.setAdapter(adapter);
   int pageMargin =
       (int)
           TypedValue.applyDimension(
               TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
   pager.setPageMargin(pageMargin);
   tabs.setViewPager(pager);
 }
  /** Initiate ViewPager and PagerAdapter */
  public void initPager() {
    // Initiate PagerAdapter
    PagerAdapter mPagerAdapter = new PagerAdapter(getFragmentManager());

    Bundle bundle = new Bundle();
    bundle.putString(MIME_TYPE, Audio.Playlists.CONTENT_TYPE);
    bundle.putLong(BaseColumns._ID, PLAYLIST_RECENTLY_ADDED);

    // Get tab visibility preferences
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    Set<String> defaults =
        new HashSet<String>(Arrays.asList(getResources().getStringArray(R.array.tab_titles)));
    Set<String> tabs_set = sp.getStringSet(TABS_ENABLED, defaults);
    // if its empty fill reset it to full defaults
    // stops app from crashing when no tabs are shown
    // TODO:rewrite activity to not crash when no tabs are chosen to show
    if (tabs_set.size() == 0) {
      tabs_set = defaults;
    }

    // Only show tabs that were set in preferences
    // Recently added tracks
    if (tabs_set.contains(getResources().getString(R.string.tab_recent)))
      mPagerAdapter.addFragment(new RecentlyAddedFragment(bundle));
    // Artists
    if (tabs_set.contains(getResources().getString(R.string.tab_artists)))
      mPagerAdapter.addFragment(new ArtistsFragment());
    // Albums
    if (tabs_set.contains(getResources().getString(R.string.tab_albums)))
      mPagerAdapter.addFragment(new AlbumsFragment());
    // // Tracks
    if (tabs_set.contains(getResources().getString(R.string.tab_songs)))
      mPagerAdapter.addFragment(new TracksFragment());
    // // Playlists
    if (tabs_set.contains(getResources().getString(R.string.tab_playlists)))
      mPagerAdapter.addFragment(new PlaylistsFragment());
    // // Genres
    if (tabs_set.contains(getResources().getString(R.string.tab_genres)))
      mPagerAdapter.addFragment(new GenresFragment());

    // Initiate ViewPager
    ViewPager mViewPager = (ViewPager) findViewById(R.id.viewPager);
    mViewPager.setPageMargin(getResources().getInteger(R.integer.viewpager_margin_width));
    mViewPager.setPageMarginDrawable(R.drawable.viewpager_margin);
    mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount());
    mViewPager.setAdapter(mPagerAdapter);
    // mViewPager.setCurrentItem(0);

    // Tabs
    initScrollableTabs(mViewPager);

    // Theme chooser
    ThemeUtils.initThemeChooser(this, mViewPager, "viewpager", THEME_ITEM_BACKGROUND);
    ThemeUtils.setMarginDrawable(this, mViewPager, "viewpager_margin");
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (vGroup == null) {
      vGroup = (ViewGroup) inflater.inflate(R.layout.fragment_media_player, null, false);
      ivBackGround = (ImageView) vGroup.findViewById(R.id.ivBackGround);
      vpAlbumArtPager = (ViewPager) vGroup.findViewById(R.id.vpAlbumArtPager);
      mSeekBar = (SeekBar) vGroup.findViewById(R.id.mSeekBar);
      lytMain = (RelativeLayout) vGroup.findViewById(R.id.lytMain);
      // ivAlbumArt = (ImageView) vGroup.findViewById(R.id.ivAlbumArt);
      tvSongName = (TextView) vGroup.findViewById(R.id.tvTitle);
      tvArtist = (TextView) vGroup.findViewById(R.id.tvArtist);
      btnForward = (ImageButton) vGroup.findViewById(R.id.btnForward);
      btnBack = (ImageButton) vGroup.findViewById(R.id.btnBack);
      setUpVisualizerAndSeekBar();
      btnForward.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              mediaPlayerListener.onNextSong(true);
              setUpViews();
              setViewPagerToCurrentIndex();
            }
          });

      loadBackGround();

      btnBack.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              mediaPlayerListener.onPreviousSong(true);
              setUpViews();
              setViewPagerToCurrentIndex();
            }
          });
      mAdapter = new PlaceSlidesFragmentAdapter(getChildFragmentManager());
      vpAlbumArtPager.setAdapter(mAdapter);

      vpAlbumArtPager.setPageMargin(-150);
      vpAlbumArtPager.offsetTopAndBottom(-50);
      vpAlbumArtPager.setPageTransformer(false, new ZoomOutPageTransformer());
      vpAlbumArtPager.setHorizontalFadingEdgeEnabled(true);
      vpAlbumArtPager.setFadingEdgeLength(100);

      vpAlbumArtPager.addOnPageChangeListener(this);

      lastPage = CloudifyController.getInstance().getSongIndex();
      vpAlbumArtPager.setCurrentItem(lastPage);
    }
    return vGroup;
  }
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    // Getting the width on orientation changed
    Display display = getActivity().getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;

    /**
     * Getting the orientation of the device. Set margin for pages as a negative number, so a part
     * of next and previous pages will be showed
     */
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
      pager.setPageMargin(-width / 2);
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
      pager.setPageMargin(-width / 3);
    }
    pager.refreshDrawableState();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      getWindow()
          .getDecorView()
          .setSystemUiVisibility(
              View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    }
    setContentView(R.layout.activity_article_detail);

    getLoaderManager().initLoader(0, null, this);

    mPagerAdapter = new MyPagerAdapter(getFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    mPager.setPageMargin(
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
    mPager.setPageMarginDrawable(new ColorDrawable(0x22000000));

    mPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageScrollStateChanged(int state) {
            super.onPageScrollStateChanged(state);
          }

          @Override
          public void onPageSelected(int position) {
            if (mCursor != null) {
              mCursor.moveToPosition(position);
            }
            mSelectedItemId = mCursor.getLong(ArticleLoader.Query._ID);
          }
        });

    // Enable up button on toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    if (savedInstanceState == null) {
      if (getIntent() != null && getIntent().getData() != null) {
        mStartId = ItemsContract.Items.getItemId(getIntent().getData());
        mSelectedItemId = mStartId;
      }
    }
  }
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle savedInstanceState) {

    View result = inflater.inflate(R.layout.routes_tab_layout, group, false);
    mViewPager = (ViewPager) result.findViewById(R.id.pager);
    mViewPager.setAdapter(new MyPagerAdapter(getActivity(), getChildFragmentManager()));

    final int pageMargin =
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
    mViewPager.setPageMargin(pageMargin);
    // Cambio hehco?

    return result;
  }
Example #19
0
  /**
   * Sets up the local pager widget. Should be called from onCreate() after both the cursor and
   * adapter are created.
   */
  protected void setupPager() {
    syncFragment = (SyncUpdateFragment) fragmentManager.findFragmentByTag(SyncUpdateFragment.TAG);
    if (syncFragment == null) {
      syncFragment = new SyncUpdateFragment();
      fragmentManager.beginTransaction().add(syncFragment, SyncUpdateFragment.TAG).commit();
    }

    pager = (ViewPager) findViewById(R.id.reading_pager);
    pager.setPageMargin(UIUtils.convertDPsToPixels(getApplicationContext(), 1));
    pager.setPageMarginDrawable(R.drawable.divider_light);
    pager.setOnPageChangeListener(this);

    pager.setAdapter(readingAdapter);
    pager.setCurrentItem(passedPosition);
    this.enableOverlays();
  }
 @SuppressLint("NewApi")
 private void init() {
   titleBar = (RelativeLayout) findViewById(R.id.album_titlebar);
   if (android.os.Build.VERSION.SDK_INT >= 11) {
     titleBar.setTranslationY(
         -getResources().getDimensionPixelSize(R.dimen.album_titlebar_height));
   } else {
     titleBar.setVisibility(View.GONE);
   }
   back = (ImageView) findViewById(R.id.album_back);
   title = (TextView) findViewById(R.id.album_title);
   String flag = getIntent().getStringExtra(AlbumSearchActivity.FLAG);
   if (AlbumSearchActivity.FLAG_PHOTO.equals(flag)) {
     title.setText(R.string.album_browse_title_photo);
   } else if (AlbumSearchActivity.FLAG_VEDIO.equals(flag)) {
     title.setText(R.string.album_browse_title_vedio);
   }
   titleDelete = (ImageView) findViewById(R.id.album_delete);
   if (!getSharedPreferences(SettingSafeKeyActivity.NAME, Context.MODE_PRIVATE)
       .getBoolean(SettingSafeKeyActivity.KEY, false)) {
     titleDelete.setVisibility(View.VISIBLE);
   }
   Log.d(
       "TAG",
       "albumBrowseKey="
           + getSharedPreferences(SettingSafeKeyActivity.NAME, Context.MODE_PRIVATE)
               .getBoolean(SettingSafeKeyActivity.KEY, false));
   viewPager = (ViewPager) findViewById(R.id.album_browse_pager);
   viewPager.setOffscreenPageLimit(0); // 设置为0的时候,viewpager加载三页,第四页的时候就会销毁第一页
   viewPager.setPageMargin(
       getResources().getDimensionPixelSize(R.dimen.album_browse_pager_margin));
   ArrayList<PhotoSearch> photoSearchs = getIntent().getParcelableArrayListExtra(PHOTOSEARCHS);
   adapter =
       new AlbumBrowseAdapter(
           this,
           photoSearchs,
           flag,
           getIntent().getIntExtra(AlbumSearchActivity.STATUS_BAR_HEIGHT, 0),
           viewPager);
   viewPager.setAdapter(adapter);
   viewPager.setCurrentItem(getIntent().getIntExtra(POSITION, 0));
   // index = getIntent().getIntExtra(POSITION, 0);
   // photos = photoSearchs;
   switcher = (ImageSwitcher) findViewById(R.id.album_browse_switcher);
   // switcher.setFactory(this);
   // switcher.setOnTouchListener(this);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    try {
      //  mHasAnimation = getIntent().getBooleanExtra(SingleActivity.EXTRA_HAS_ANIM, false);
    } catch (Exception e) {
      // ignore
    }

    setContentView(getMainViewResId());
    initViews();

    mPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.page_margin_width));
    mPager.setPageMarginDrawable(R.color.page_viewer_margin_color);
  }
 protected void onCreate(Bundle bundle) {
   super.onCreate(bundle);
   requestWindowFeature(1);
   ViewPager viewpager;
   Resources resources;
   try {
     v = getIntent().getBooleanExtra("extra.has_anim", false);
   } catch (Exception exception) {
   }
   setContentView(h());
   i();
   viewpager = r;
   resources = getResources();
   com.dianxinos.dxbs.R.dimen _tmp = ly.d;
   viewpager.setPageMargin(resources.getDimensionPixelSize(0x7f080109));
   r.setPageMarginDrawable(0x106000d);
 }
Example #23
0
  private void setOneFragmentInScreen(FermatFragmentFactory walletFragmentFactory) {

    try {
      WalletNavigationStructure walletRuntime = getWalletRuntimeManager().getLastWallet();
      String walletPublicKey = walletRuntime.getPublicKey();
      String walletCategory = walletRuntime.getWalletCategory();
      String walletType = walletRuntime.getWalletType();

      FermatSession walletSession = getWalletSessionManager().getWalletSession(walletPublicKey);
      String fragment = walletRuntime.getLastActivity().getLastFragment().getType();

      if (walletFragmentFactory != null) {

        TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
        tabLayout.setVisibility(View.GONE);

        ViewPager pagertabs = (ViewPager) findViewById(R.id.pager);
        pagertabs.setVisibility(View.VISIBLE);

        adapter =
            new TabsPagerAdapter(
                getFragmentManager(),
                getApplicationContext(),
                walletFragmentFactory,
                fragment,
                walletSession,
                getWalletResourcesProviderManager());
        pagertabs.setAdapter(adapter);

        // pagertabs.setCurrentItem();
        final int pageMargin =
            (int)
                TypedValue.applyDimension(
                    TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
        pagertabs.setPageMargin(pageMargin);
        // pagertabs.setCurrentItem(tabStrip.getStartItem(), true);

        // tabLayout.setupWithViewPager(pagertabs);
        // pagertabs.setOffscreenPageLimit(tabStrip.getTabs().size());
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Example #24
0
  private void setOneFragmentInScreen() throws InvalidParameterException {

    SubAppRuntimeManager subAppRuntimeManager = getSubAppRuntimeMiddleware();
    SubApps subAppType = subAppRuntimeManager.getLastSubApp().getType();

    com.bitdubai.fermat_android_api.layer.definition.wallet.interfaces.SubAppFragmentFactory
        subAppFragmentFactory = SubAppFragmentFactory.getFragmentFactoryBySubAppType(subAppType);
    String fragment =
        subAppRuntimeManager.getLastSubApp().getLastActivity().getLastFragment().getType();
    SubAppsSession subAppsSession = getSubAppSessionManager().getSubAppsSession(subAppType);

    try {
      if (subAppFragmentFactory != null) {

        TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
        tabLayout.setVisibility(View.GONE);

        ViewPager pagertabs = (ViewPager) findViewById(R.id.pager);
        pagertabs.setVisibility(View.VISIBLE);

        adapter =
            new TabsPagerAdapter(
                getFragmentManager(),
                getApplicationContext(),
                subAppFragmentFactory,
                fragment,
                subAppsSession,
                getSubAppResourcesProviderManager(),
                getResources());
        pagertabs.setAdapter(adapter);

        final int pageMargin =
            (int)
                TypedValue.applyDimension(
                    TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
        pagertabs.setPageMargin(pageMargin);
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @Override
  protected void initView() {
    pager_layout = mConvertView.findViewById(R.id.pager_layout);
    mPager = (ViewPager) mConvertView.findViewById(R.id.mPager);
    mPager.setOffscreenPageLimit(TOTAL_COUNT);
    mPager.setPageMargin(20);
    mOpertionGroupView = (LinearLayout) mConvertView.findViewById(R.id.opertion_group_view);
    mPage = (LinearLayout) mConvertView.findViewById(R.id.pages);
    mDownloadOrDeleteButton = (Button) mConvertView.findViewById(R.id.delete_or_download);
    mDownloadOrDeleteButton.setOnClickListener(this);

    downloadCancel = mConvertView.findViewById(R.id.download_cancel);
    downloadProgress = (ProgressBar) mConvertView.findViewById(R.id.download_progress);
    downloadSize = (TextView) mConvertView.findViewById(R.id.download_size);
    downloadPercent = (TextView) mConvertView.findViewById(R.id.download_precent);
    processView = mConvertView.findViewById(R.id.process_view);

    PhotoOnPageChangeListener pageChangeListener = new PhotoOnPageChangeListener();
    mPager.setOnPageChangeListener(pageChangeListener);

    pager_layout.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // dispatch the events to the ViewPager, to solve the problem that we can swipe only the
            // middle view.
            return mPager.dispatchTouchEvent(event);
          }
        });
    downloadCancel.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if ((PRODUCT_STATUS == PRODUCT_STATUS_DOWNLOADING) && downLoadID != -1) {
              DownloadUtils.cancleDownload(mActivity, downLoadID, mData.product_id);
              downLoadHelper.cancleDownloadFile(mData.product_id);
              refreshProductStatus(queryProductStatus(mData.product_id));
            }
          }
        });
  }
  @AfterViews
  protected final void init() {
    ActionBar actionBar = getSupportActionBar();
    if (mUserObject.isMe()) {
      fragmentTitles = getResources().getStringArray(R.array.user_me_program_title);
      actionBar.setTitle("我的项目");
    } else {
      fragmentTitles = getResources().getStringArray(R.array.user_program_title);
      actionBar.setTitle("TA的项目");
    }

    MyPagerAdapter adapter = new MyPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(adapter);
    int pageMargin =
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);
    tabs.setViewPager(pager);
  }
Example #27
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    myFragmentView = inflater.inflate(R.layout.fragment_home, container, false);

    tabs = (PagerSlidingTabStrip) myFragmentView.findViewById(R.id.tabs);
    pager = (ViewPager) myFragmentView.findViewById(R.id.pager);
    pagerAdapter = new MyPagerAdapter(getChildFragmentManager());
    pager.setAdapter(pagerAdapter);
    final int pageMargin =
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
    pager.setPageMargin(pageMargin);
    tabs.setViewPager(pager);
    //        if(mParamPatientData.getpIsInClinic() > 0) {
    //            pager.setCurrentItem(1);
    //        }

    return myFragmentView;
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   initData();
   setContentView(R.layout.activity_viewpager_transform);
   viewpager = (ViewPager) findViewById(R.id.viewpager);
   viewpager.setPageMargin(-200);
   viewpager.setOffscreenPageLimit(3);
   viewpager.setPageTransformer(true, new ZoomOutPageTransformer());
   mAdapter = new MyPagerAdapter();
   viewpager.setAdapter(mAdapter);
   findViewById(R.id.reduce)
       .setOnClickListener(
           new View.OnClickListener() {
             @Override
             public void onClick(View v) {
               mViews.remove(2);
               mAdapter.notifyDataSetChanged();
             }
           });
 }
Example #29
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);

    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
      getSupportActionBar().setTitle(null);
    }

    ViewPageAdapter adapter = new ViewPageAdapter(getSupportFragmentManager());
    viewPager.setAdapter(adapter);

    pagerSlidingTabStrip.setViewPager(viewPager);
    int pageMargin =
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
    viewPager.setPageMargin(pageMargin);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_pager);

    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setPageMargin((int) (getResources().getDisplayMetrics().density * 15));
    mPager.setAdapter(
        new PagerAdapter() {
          @Override
          public int getCount() {
            return imgsId.length;
          }

          @Override
          public boolean isViewFromObject(View view, Object object) {
            return view == object;
          }

          @Override
          public Object instantiateItem(ViewGroup container, int position) {
            PhotoView view = new PhotoView(ViewPagerActivity.this);
            view.enable();
            view.setImageResource(imgsId[position]);
            container.addView(view);
            return view;
          }

          @Override
          public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);
          }
        });

    mPager.setCurrentItem(2);
  }