Example usage for android.widget SeekBar setKeyProgressIncrement

List of usage examples for android.widget SeekBar setKeyProgressIncrement

Introduction

In this page you can find the example usage for android.widget SeekBar setKeyProgressIncrement.

Prototype

public void setKeyProgressIncrement(int increment) 

Source Link

Document

Sets the amount of progress changed via the arrow keys.

Usage

From source file:moe.yukinoneko.gcomic.module.gallery.external.ExternalGalleryActivity.java

@Override
public void init() {
    mDecorView = getWindow().getDecorView();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) bottomBar.getLayoutParams();
        lp.setMargins(0, 0, 0, Utils.getNavigationBarHeight(this));
    }/*w  w w . j av a2s  .c o m*/

    galleryPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            seekBar.setProgress(position);
            curPage.setText(String.valueOf(position + 1));
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
    mPagerAdapter = new ExternalGalleryPagerAdapter(getSupportFragmentManager());
    galleryPager.setAdapter(mPagerAdapter);

    seekBar.setKeyProgressIncrement(1);
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        int progress = 0;

        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            progress = i;
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            galleryPager.setCurrentItem(progress, false);
        }
    });

    curPage.setText("1");

    String path = FileUtlis.getPath(this, getIntent().getData());
    mToolbar.setTitle(path != null ? path.substring(path.lastIndexOf("/") + 1) : "No Title");
    presenter.fetchPicturesFromDisk(path);
}

From source file:moe.yukinoneko.gcomic.module.gallery.GalleryActivity.java

@Override
public void init() {
    mDecorView = getWindow().getDecorView();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) bottomBar.getLayoutParams();
        lp.setMargins(0, 0, 0, Utils.getNavigationBarHeight(this));
    }//from w  w  w.j ava2  s  . co  m

    mHandler = new Handler();
    mPreviousRunnable = new Runnable() {
        @Override
        public void run() {
            if (mCurChapterPosition < mChapters.size() - 1) {
                mLastChapterPosition = mCurChapterPosition;
                mCurChapterPosition += 1;
                fetchChapterContent(mChapters.get(mCurChapterPosition).chapterId);
            } else {
                galleryPager.setCurrentItem(1);
                galleryPager.setLocked(false);
                seekBar.setEnabled(true);
                showMessageSnackbar(R.string.already_first);
            }
        }
    };
    mNextRunnable = new Runnable() {
        @Override
        public void run() {
            if (mCurChapterPosition > 0) {
                mLastChapterPosition = mCurChapterPosition;
                mCurChapterPosition -= 1;
                fetchChapterContent(mChapters.get(mCurChapterPosition).chapterId);
            } else {
                galleryPager.setCurrentItem(mPagerAdapter.getCount() - 2);
                galleryPager.setLocked(false);
                seekBar.setEnabled(true);
                showMessageSnackbar(R.string.already_last);
            }
        }
    };

    galleryPager.setLocked(true);
    galleryPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            seekBar.setProgress(position - 1);

            intCurPage = position;
            if (intCurPage > mPagerAdapter.getCount() - 2) {
                intCurPage = mPagerAdapter.getCount() - 2;
            } else if (intCurPage < 1) {
                intCurPage = 1;
            }
            curPage.setText(String.valueOf(intCurPage));

            if (position == 0) {
                galleryPager.setLocked(true);
                seekBar.setEnabled(false);
                mHandler.postDelayed(mPreviousRunnable, 1000);
            } else if (position == mPagerAdapter.getCount() - 1) {
                galleryPager.setLocked(true);
                seekBar.setEnabled(false);
                mHandler.postDelayed(mNextRunnable, 1000);
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
    mPagerAdapter = new GalleryPagerAdapter(getSupportFragmentManager());
    galleryPager.setAdapter(mPagerAdapter);

    seekBar.setEnabled(false);
    seekBar.setKeyProgressIncrement(1);
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        int progress = 0;

        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            progress = i;
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            galleryPager.setCurrentItem(progress + 1, false);
        }
    });

    loadErrorLayout.setBackgroundColor(0xFF444444);
    loadErrorTips.setTextColor(0x80FFFFFF);

    Intent intent = getIntent();

    mComicId = intent.getIntExtra(GALLERY_CMOIC_ID, -1);
    firstLetter = intent.getStringExtra(GALLERY_CMOIC_FIRST_LETTER);
    mChapters = intent.getParcelableArrayListExtra(GALLERY_CHAPTER_LIST);
    mCurChapterPosition = intent.getIntExtra(GALLERY_CHAPTER_POSITION, -1);
    mLastChapterPosition = mCurChapterPosition;
    mHistoryBrowsePosition = intent.getIntExtra(GALLERY_BROWSE_POSITION, 1);
    mToolbar.setTitle(mChapters.get(mCurChapterPosition).chapterTitle);

    galleryPager.setCurrentItem(1, false);

    fetchChapterContent(mChapters.get(mCurChapterPosition).chapterId);
}

From source file:net.xpece.android.support.preference.SeekBarPreference.java

@Override
public void onBindViewHolder(final PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);

    final SeekBar seekBar = (SeekBar) holder.findViewById(R.id.seekbar);

    holder.itemView.setOnKeyListener(buildSeekBarKeyListener(seekBar));

    final TextView info = (TextView) holder.findViewById(R.id.seekbar_value);
    if (info != null) {
        mInfoViews.put(info, this);
        bindInfo(info);/* www  .j  a  v  a2  s .  c  o  m*/
    }

    if (seekBar == null) {
        Log.e(TAG, "SeekBar view is null in onBindViewHolder.");
        return;
    }
    seekBar.setOnSeekBarChangeListener(mSeekBarChangeListener);
    seekBar.setMax(mMax - mMin);
    // If the increment is not zero, use that. Otherwise, use the default mKeyProgressIncrement
    // in AbsSeekBar when it's zero. This default increment value is set by AbsSeekBar
    // after calling setMax. That's why it's important to call setKeyProgressIncrement after
    // calling setMax() since setMax() can change the increment value.
    if (mSeekBarIncrement != 0) {
        seekBar.setKeyProgressIncrement(mSeekBarIncrement);
    } else {
        mSeekBarIncrement = seekBar.getKeyProgressIncrement();
    }
    seekBar.setProgress(mSeekBarValue - mMin);
    seekBar.setEnabled(isEnabled());

    fixDrawableStateOnAndroid2(seekBar);
}