Java Code Examples for android.widget.ProgressBar#setPadding()

The following examples show how to use android.widget.ProgressBar#setPadding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserProfileActivity.java    From Capstone-Project with MIT License 6 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.findItem(R.id.menu_refresh).setEnabled(!mRefreshing && mRefreshMenuEnabled);
    if (mRefreshing) {
        mMenuItemRefreshActionView = new ProgressBar(this);

        // Make progress bar look at the same place as the original menu item was.
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ScreenUtils.dpToPxInt(getApplicationContext(), 48.0f),
                ScreenUtils.dpToPxInt(getApplicationContext(), 48.0f));
        mMenuItemRefreshActionView.setLayoutParams(layoutParams);
        mMenuItemRefreshActionView.setPadding(ScreenUtils.dpToPxInt(getApplicationContext(), 12.0f),
                ScreenUtils.dpToPxInt(getApplicationContext(), 12.0f),
                ScreenUtils.dpToPxInt(getApplicationContext(), 12.0f),
                ScreenUtils.dpToPxInt(getApplicationContext(), 12.0f));
    } else {
        mMenuItemRefreshActionView = null;
    }
    menu.findItem(R.id.menu_refresh).setActionView(mMenuItemRefreshActionView);

    return super.onPrepareOptionsMenu(menu);
}
 
Example 2
Source File: PostDetailsActivity.java    From Capstone-Project with MIT License 6 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.findItem(R.id.menu_refresh).setEnabled(!mRefreshing && !mFirstTimeLoading);
    if (mRefreshing) {
        mMenuItemRefreshActionView = new ProgressBar(this);

        // Make progress bar look at the same place as the original menu item was.
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ScreenUtils.dpToPxInt(getApplicationContext(), 48.0f),
                ScreenUtils.dpToPxInt(getApplicationContext(), 48.0f));
        mMenuItemRefreshActionView.setLayoutParams(layoutParams);
        mMenuItemRefreshActionView.setPadding(ScreenUtils.dpToPxInt(getApplicationContext(), 12.0f),
                ScreenUtils.dpToPxInt(getApplicationContext(), 12.0f),
                ScreenUtils.dpToPxInt(getApplicationContext(), 12.0f),
                ScreenUtils.dpToPxInt(getApplicationContext(), 12.0f));
    } else {
        mMenuItemRefreshActionView = null;
    }
    menu.findItem(R.id.menu_refresh).setActionView(mMenuItemRefreshActionView);

    return super.onPrepareOptionsMenu(menu);
}
 
Example 3
Source File: ViewMaker.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
static View getProgressWaitingItem() {

        ProgressBar cslp_progress_bar_waiting = new ProgressBar(G.context);
        cslp_progress_bar_waiting.setId(R.id.cslp_progress_bar_waiting);
        cslp_progress_bar_waiting.setPadding(i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4));
        cslp_progress_bar_waiting.setVisibility(View.VISIBLE);
        FrameLayout.LayoutParams layout_842 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layout_842.gravity = Gravity.CENTER;
        cslp_progress_bar_waiting.setIndeterminate(true);
        cslp_progress_bar_waiting.setLayoutParams(layout_842);

        return cslp_progress_bar_waiting;
    }
 
Example 4
Source File: DefaultTipsHelper.java    From GankGirl with GNU Lesser General Public License v2.1 5 votes vote down vote up
public DefaultTipsHelper(Context context, View view) {
    this.mView=view;
    this.mContext=context;
    mLoadingView = new ProgressBar(context);
    mLoadingView.setPadding(0, (int) DensityUtils.dip2px(context, 10),
            0, (int) DensityUtils.dip2px(context, 10));
    mLoadingView.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            (int) DensityUtils.dip2px(context, 40)));
}
 
Example 5
Source File: QuickReturnWithExtraOnScrollListenerFragment.java    From QuickReturn with Apache License 2.0 5 votes vote down vote up
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    if (firstVisibleItem + visibleItemCount == totalItemCount && getListView().getFooterViewsCount() == 0) {
        ProgressBar progressBar = new ProgressBar(getActivity());
        progressBar.setLayoutParams(new AbsListView.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT
        ));
        progressBar.setPadding(8, 8, 8, 8);
        getListView().addFooterView(progressBar);
    }
}
 
Example 6
Source File: LoadingAdapter.java    From v2ex-daily-android with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ProgressBar progressBar = new ProgressBar(mContext);
    int padding = ScreenUtils.dp(mContext, 8);
    progressBar.setPadding(padding, padding, padding, padding);
    return progressBar;
}
 
Example 7
Source File: WriteTag.java    From MifareClassicTool with GNU General Public License v3.0 4 votes vote down vote up
/**
 * This method is triggered by {@link #checkTag()} and writes a dump
 * to a tag.
 * @param writeOnPos A map within a map (all with type = Integer).
 * The key of the outer map is the sector number and the value is another
 * map with key = block number and value = write information. The write
 * information must be filtered (by {@link #checkTag()}) return values
 * of {@link MCReader#isWritableOnPositions(HashMap, SparseArray)}.<br />
 * Attention: This method does not any checking. The position and write
 * information must be checked by {@link #checkTag()}.
 * @param keyMap A key map generated by {@link KeyMapCreator}.
 */
private void writeDump(
        final HashMap<Integer, HashMap<Integer, Integer>> writeOnPos,
        final SparseArray<byte[][]> keyMap) {
    // Check for write data.
    if (writeOnPos.size() == 0) {
        // Nothing to write. Exit.
        Toast.makeText(this, R.string.info_nothing_to_write,
                Toast.LENGTH_LONG).show();
        return;
    }

    // Create reader.
    final MCReader reader = Common.checkForTagAndCreateReader(this);
    if (reader == null) {
        return;
    }

    // Display don't remove warning.
    LinearLayout ll = new LinearLayout(this);
    int pad = Common.dpToPx(10);
    ll.setPadding(pad, pad, pad, pad);
    ll.setGravity(Gravity.CENTER);
    ProgressBar progressBar = new ProgressBar(this);
    progressBar.setIndeterminate(true);
    pad = Common.dpToPx(5);
    progressBar.setPadding(0, 0, pad, 0);
    TextView tv = new TextView(this);
    tv.setText(getString(R.string.dialog_wait_write_tag));
    tv.setTextSize(18);
    ll.addView(progressBar);
    ll.addView(tv);
    final AlertDialog warning = new AlertDialog.Builder(this)
        .setTitle(R.string.dialog_wait_write_tag_title)
        .setView(ll)
        .create();
    warning.show();


    // Start writing in new thread.
    final Activity a = this;
    final Handler handler = new Handler();
    new Thread(() -> {
        // Write dump to tag.
        for (int sector : writeOnPos.keySet()) {
            byte[][] keys = keyMap.get(sector);
            for (int block : writeOnPos.get(sector).keySet()) {
                // Select key with write privileges.
                byte writeKey[] = null;
                boolean useAsKeyB = true;
                int wi = writeOnPos.get(sector).get(block);
                if (wi == 1 || wi == 4) {
                    writeKey = keys[0]; // Write with key A.
                    useAsKeyB = false;
                } else if (wi == 2 || wi == 5 || wi == 6) {
                    writeKey = keys[1]; // Write with key B.
                }

                // Write block.
                int result = reader.writeBlock(sector, block,
                        mDumpWithPos.get(sector).get(block),
                        writeKey, useAsKeyB);

                if (result != 0) {
                    // Error. Some error while writing.
                    handler.post(() -> Toast.makeText(a,
                            R.string.info_write_error,
                            Toast.LENGTH_LONG).show());
                    reader.close();
                    warning.cancel();
                    return;
                }
            }
        }
        // Finished writing.
        reader.close();
        warning.cancel();
        handler.post(() -> Toast.makeText(a, R.string.info_write_successful,
                Toast.LENGTH_LONG).show());
        a.finish();
    }).start();
}