Example usage for android.view Window FEATURE_INDETERMINATE_PROGRESS

List of usage examples for android.view Window FEATURE_INDETERMINATE_PROGRESS

Introduction

In this page you can find the example usage for android.view Window FEATURE_INDETERMINATE_PROGRESS.

Prototype

int FEATURE_INDETERMINATE_PROGRESS

To view the source code for android.view Window FEATURE_INDETERMINATE_PROGRESS.

Click Source Link

Document

Flag for indeterminate progress.

Usage

From source file:com.actionbarsherlock.internal.ActionBarSherlockCompat.java

private void onIntChanged(int featureId, int value) {
    if (featureId == Window.FEATURE_PROGRESS || featureId == Window.FEATURE_INDETERMINATE_PROGRESS) {
        updateProgressBars(value);/*from w ww  .j a  v  a 2s.co m*/
    }
}

From source file:com.actionbarsherlock.internal.ActionBarSherlockCompat.java

private void updateProgressBars(int value) {
    IcsProgressBar circularProgressBar = getCircularProgressBar(true);
    IcsProgressBar horizontalProgressBar = getHorizontalProgressBar(true);

    final int features = mFeatures;//getLocalFeatures();
    if (value == Window.PROGRESS_VISIBILITY_ON) {
        if ((features & (1 << Window.FEATURE_PROGRESS)) != 0) {
            int level = horizontalProgressBar.getProgress();
            int visibility = (horizontalProgressBar.isIndeterminate() || level < 10000) ? View.VISIBLE
                    : View.INVISIBLE;
            horizontalProgressBar.setVisibility(visibility);
        }//from   ww w .  j a v a2s.  co m
        if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0) {
            circularProgressBar.setVisibility(View.VISIBLE);
        }
    } else if (value == Window.PROGRESS_VISIBILITY_OFF) {
        if ((features & (1 << Window.FEATURE_PROGRESS)) != 0) {
            horizontalProgressBar.setVisibility(View.GONE);
        }
        if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0) {
            circularProgressBar.setVisibility(View.GONE);
        }
    } else if (value == Window.PROGRESS_INDETERMINATE_ON) {
        horizontalProgressBar.setIndeterminate(true);
    } else if (value == Window.PROGRESS_INDETERMINATE_OFF) {
        horizontalProgressBar.setIndeterminate(false);
    } else if (Window.PROGRESS_START <= value && value <= Window.PROGRESS_END) {
        // We want to set the progress value before testing for visibility
        // so that when the progress bar becomes visible again, it has the
        // correct level.
        horizontalProgressBar.setProgress(value - Window.PROGRESS_START);

        if (value < Window.PROGRESS_END) {
            showProgressBars(horizontalProgressBar, circularProgressBar);
        } else {
            hideProgressBars(horizontalProgressBar, circularProgressBar);
        }
    } else if (Window.PROGRESS_SECONDARY_START <= value && value <= Window.PROGRESS_SECONDARY_END) {
        horizontalProgressBar.setSecondaryProgress(value - Window.PROGRESS_SECONDARY_START);

        showProgressBars(horizontalProgressBar, circularProgressBar);
    }
}

From source file:android.support.v7.internal.widget.ActionBarOverlayLayout.java

@Override
public void initFeature(int windowFeature) {
    pullChildren();/*from w  w  w .  j a va2  s .c o m*/
    switch (windowFeature) {
    case Window.FEATURE_PROGRESS:
        mDecorToolbar.initProgress();
        break;
    case Window.FEATURE_INDETERMINATE_PROGRESS:
        mDecorToolbar.initIndeterminateProgress();
        break;
    case Window.FEATURE_ACTION_BAR_OVERLAY:
        setOverlayMode(true);
        break;
    }
}

From source file:com.itude.mobile.mobbl.core.controller.MBViewManager.java

protected void onPreCreate() {
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
}

From source file:de.ub0r.android.websms.WebSMS.java

/**
 * {@inheritDoc}//from   ww w  .j a v  a2s .c  o m
 */
@SuppressWarnings({ "unchecked", "deprecation" })
@Override
public final void onCreate(final Bundle savedInstanceState) {
    this.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    this.setTheme(PreferencesActivity.getTheme(this));
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate(" + savedInstanceState + ")");
    this.threadHandler = new Handler();

    // Restore preferences
    de.ub0r.android.lib.Utils.setLocale(this);

    this.cbmgr = (ClipboardManager) this.getSystemService(CLIPBOARD_SERVICE);

    // save ref to me.
    me = this;
    final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(this);

    // inflate XML
    this.setContentView(R.layout.main);
    this.getSupportActionBar().setHomeButtonEnabled(true);

    // indeterminate progress bar is spinning by default so stop it,
    // updateProgressBar will start it again if necessary
    this.setSupportProgressBarIndeterminateVisibility(false);

    this.etTo = (MultiAutoCompleteTextView) this.findViewById(R.id.to);
    this.etText = (EditText) this.findViewById(R.id.text);
    this.etTextLabel = (TextView) this.findViewById(R.id.text_);
    this.tvPaste = (TextView) this.findViewById(R.id.text_paste);
    this.tvClear = (TextView) this.findViewById(R.id.text_clear);

    this.vCustomSender = (ToggleButton) this.findViewById(R.id.custom_sender);
    this.vFlashSMS = (ToggleButton) this.findViewById(R.id.flashsms);
    this.vSendLater = (ToggleButton) this.findViewById(R.id.send_later);

    if (isNewVersion()) {
        Log.i(TAG, "detected version update");
        SharedPreferences.Editor editor = p.edit();
        editor.remove(PREFS_CONNECTORS); // remove cache
        editor.apply();
        rules.upgrade();
    }

    // get cached Connectors
    String s = p.getString(PREFS_CONNECTORS, null);
    if (TextUtils.isEmpty(s)) {
        this.updateConnectors();

    } else if (CONNECTORS.size() == 0) {
        // skip static remaining connectors
        try {
            ArrayList<ConnectorSpec> cache;
            cache = (ArrayList<ConnectorSpec>) (new ObjectInputStream(new BufferedInputStream(
                    new ByteArrayInputStream(Base64.decode(s, Base64.DEFAULT)), BUFSIZE))).readObject();
            CONNECTORS.addAll(cache);
            if (p.getBoolean(PREFS_AUTOUPDATE, true)) {
                updateFreecount();
            }
        } catch (Exception e) {
            Log.d(TAG, "error loading connectors", e);
        }
    }
    Log.d(TAG, "loaded connectors: " + CONNECTORS.size());

    if (PSEUDO_CONNECTORS.size() == 0) {
        PSEUDO_CONNECTORS.add(rules.getSpec(this));
    }

    if (savedInstanceState == null) {
        this.revertPrefsToStdConnector();
        // note: do not revert to std connector on orientation change
    }

    this.reloadPrefs();

    if (savedInstanceState != null) {
        this.lastTo = savedInstanceState.getString(EXTRA_TO);
        this.lastMsg = savedInstanceState.getString(EXTRA_TEXT);
    }

    // register Listener
    this.vCustomSender.setOnClickListener(this);
    this.vSendLater.setOnClickListener(this);
    this.findViewById(R.id.select).setOnClickListener(this);
    View v = this.findViewById(R.id.clear);
    v.setOnClickListener(this);
    v.setOnLongClickListener(this);
    this.findViewById(R.id.emo).setOnClickListener(this);
    this.tvPaste.setOnClickListener(this);
    this.tvClear.setOnClickListener(this);
    this.etText.addTextChangedListener(this.twCount);
    this.etText.addTextChangedListener(this.twButtons);
    this.etTo.addTextChangedListener(this.twButtons);
    this.etTo.setAdapter(new MobilePhoneAdapter(this));
    this.etTo.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
    this.etTo.requestFocus();

    this.parseIntent(this.getIntent());

    boolean checkPrefix = true;
    boolean showIntro = false;
    if (TextUtils.isEmpty(p.getString(PREFS_SENDER, null))
            && TextUtils.isEmpty(p.getString(PREFS_DEFPREFIX, null)) && CONNECTORS.size() == 0) {
        checkPrefix = false;
        showIntro = true;
    }

    requestPermission(Manifest.permission.READ_CONTACTS, PERMISSIONS_REQUEST_READ_CONTACTS,
            R.string.permissions_read_contacts, null);
    if (TextUtils.isEmpty(p.getString(PREFS_SENDER, null))
            || TextUtils.isEmpty(p.getString(PREFS_DEFPREFIX, null))) {
        fetchSenderAndPrefixFromPhoneNumber();
    }

    // check default prefix
    if (checkPrefix && !p.getString(PREFS_DEFPREFIX, "").startsWith("+")) {
        this.log(R.string.log_wrong_defprefix);
    }

    if (showIntro) {
        // skip help intro for at least 2min
        if (System.currentTimeMillis() > p.getLong(PREFS_LASTHELP, 0L)
                + de.ub0r.android.lib.Utils.MINUTES_IN_MILLIS * 2) {
            p.edit().putLong(PREFS_LASTHELP, System.currentTimeMillis()).apply();
            this.startActivity(new Intent(this, HelpIntroActivity.class));
        }
    }

}

From source file:com.actionbarsherlock.internal.ActionBarSherlockCompat.java

private void showProgressBars(IcsProgressBar horizontalProgressBar, IcsProgressBar spinnyProgressBar) {
    final int features = mFeatures;//getLocalFeatures();
    if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0
            && spinnyProgressBar.getVisibility() == View.INVISIBLE) {
        spinnyProgressBar.setVisibility(View.VISIBLE);
    }/*www. j  a  va2s.  com*/
    // Only show the progress bars if the primary progress is not complete
    if ((features & (1 << Window.FEATURE_PROGRESS)) != 0 && horizontalProgressBar.getProgress() < 10000) {
        horizontalProgressBar.setVisibility(View.VISIBLE);
    }
}

From source file:com.actionbarsherlock.internal.ActionBarSherlockCompat.java

private void hideProgressBars(IcsProgressBar horizontalProgressBar, IcsProgressBar spinnyProgressBar) {
    final int features = mFeatures;//getLocalFeatures();
    Animation anim = AnimationUtils.loadAnimation(mActivity, android.R.anim.fade_out);
    anim.setDuration(1000);// w ww .j a v a  2  s.com
    if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0
            && spinnyProgressBar.getVisibility() == View.VISIBLE) {
        spinnyProgressBar.startAnimation(anim);
        spinnyProgressBar.setVisibility(View.INVISIBLE);
    }
    if ((features & (1 << Window.FEATURE_PROGRESS)) != 0
            && horizontalProgressBar.getVisibility() == View.VISIBLE) {
        horizontalProgressBar.startAnimation(anim);
        horizontalProgressBar.setVisibility(View.INVISIBLE);
    }
}

From source file:com.actionbarsherlock.internal.ActionBarSherlockCompat.java

@Override
public boolean requestFeature(int featureId) {
    if (DEBUG)//from   w w w. j a  va 2  s  .  c o m
        Log.d(TAG, "[requestFeature] featureId: " + featureId);

    if (mContentParent != null) {
        throw new AndroidRuntimeException("requestFeature() must be called before adding content");
    }

    switch (featureId) {
    case Window.FEATURE_ACTION_BAR:
    case Window.FEATURE_ACTION_BAR_OVERLAY:
    case Window.FEATURE_ACTION_MODE_OVERLAY:
    case Window.FEATURE_INDETERMINATE_PROGRESS:
    case Window.FEATURE_NO_TITLE:
    case Window.FEATURE_PROGRESS:
        mFeatures |= (1 << featureId);
        return true;

    default:
        return false;
    }
}

From source file:com.actionbarsherlock.internal.ActionBarSherlockCompat.java

private void installDecor() {
    if (DEBUG)//from  w  w  w . ja v  a 2s . com
        Log.d(TAG, "[installDecor]");

    if (mDecor == null) {
        mDecor = (ViewGroup) mActivity.getWindow().getDecorView().findViewById(android.R.id.content);
    }
    if (mContentParent == null) {
        //Since we are not operating at the window level we need to take
        //into account the fact that the true decor may have already been
        //initialized and had content attached to it. If that is the case,
        //copy over its children to our new content container.
        List<View> views = null;
        if (mDecor.getChildCount() > 0) {
            views = new ArrayList<View>(1); //Usually there's only one child
            for (int i = 0, children = mDecor.getChildCount(); i < children; i++) {
                View child = mDecor.getChildAt(0);
                mDecor.removeView(child);
                views.add(child);
            }
        }

        mContentParent = generateLayout();

        //Copy over the old children. See above for explanation.
        if (views != null) {
            for (View child : views) {
                mContentParent.addView(child);
            }
        }

        mTitleView = (TextView) mDecor.findViewById(android.R.id.title);
        if (mTitleView != null) {
            if (hasFeature(Window.FEATURE_NO_TITLE)) {
                mTitleView.setVisibility(View.GONE);
                if (mContentParent instanceof FrameLayout) {
                    ((FrameLayout) mContentParent).setForeground(null);
                }
            } else {
                mTitleView.setText(mTitle);
            }
        } else {
            wActionBar = (ActionBarView) mDecor.findViewById(R.id.abs__action_bar);
            if (wActionBar != null) {
                wActionBar.setWindowCallback(this);
                if (wActionBar.getTitle() == null) {
                    wActionBar.setWindowTitle(mActivity.getTitle());
                }
                if (hasFeature(Window.FEATURE_PROGRESS)) {
                    wActionBar.initProgress();
                }
                if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) {
                    wActionBar.initIndeterminateProgress();
                }

                //Since we don't require onCreate dispatching, parse for uiOptions here
                int uiOptions = loadUiOptionsFromManifest(mActivity);
                if (uiOptions != 0) {
                    mUiOptions = uiOptions;
                }

                boolean splitActionBar = false;
                final boolean splitWhenNarrow = (mUiOptions
                        & ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW) != 0;
                if (splitWhenNarrow) {
                    splitActionBar = getResources_getBoolean(mActivity, R.bool.abs__split_action_bar_is_narrow);
                } else {
                    splitActionBar = mActivity.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme)
                            .getBoolean(R.styleable.SherlockTheme_windowSplitActionBar, false);
                }
                final ActionBarContainer splitView = (ActionBarContainer) mDecor
                        .findViewById(R.id.abs__split_action_bar);
                if (splitView != null) {
                    wActionBar.setSplitView(splitView);
                    wActionBar.setSplitActionBar(splitActionBar);
                    wActionBar.setSplitWhenNarrow(splitWhenNarrow);

                    mActionModeView = (ActionBarContextView) mDecor.findViewById(R.id.abs__action_context_bar);
                    mActionModeView.setSplitView(splitView);
                    mActionModeView.setSplitActionBar(splitActionBar);
                    mActionModeView.setSplitWhenNarrow(splitWhenNarrow);
                } else if (splitActionBar) {
                    Log.e(TAG, "Requested split action bar with incompatible window decor! Ignoring request.");
                }

                // Post the panel invalidate for later; avoid application onCreateOptionsMenu
                // being called in the middle of onCreate or similar.
                mDecor.post(new Runnable() {
                    @Override
                    public void run() {
                        //Invalidate if the panel menu hasn't been created before this.
                        if (!mIsDestroyed && !mActivity.isFinishing() && mMenu == null) {
                            dispatchInvalidateOptionsMenu();
                        }
                    }
                });
            }
        }
    }
}

From source file:com.aslanoba.hwc.SettingsActivity.java

/** Called when the activity is first created.
 * Usually, the input parameter oSavedInstanceState is null. However, if the activity has already
 * started, and then sent to the background, and destroyed due to low memory, when the
 * settingsActivity is brought to foreground again, the parameter will contain the pending ui
 * change, we need to apply those change to UI to follow the Android design guide line.
 *//* w  w  w . j  a  va2s . c  o  m*/
@Override
public void onCreate(Bundle oSavedInstanceState) {
    super.onCreate(oSavedInstanceState);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    m_oInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    populateRegistrationMethods();
}