Example usage for android.view Window FEATURE_PROGRESS

List of usage examples for android.view Window FEATURE_PROGRESS

Introduction

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

Prototype

int FEATURE_PROGRESS

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

Click Source Link

Document

Flag for the progress indicator feature.

Usage

From source file:org.appcelerator.titanium.TiBaseActivity.java

protected void setNavBarHidden(boolean hidden) {
    if (!hidden) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            // Do not enable these features on Honeycomb or later since it will break the action bar.
            this.requestWindowFeature(Window.FEATURE_LEFT_ICON);
            this.requestWindowFeature(Window.FEATURE_RIGHT_ICON);
        }//from  w  ww .j a  va2s  .c o m

        this.requestWindowFeature(Window.FEATURE_PROGRESS);
        this.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    } else {
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    }
}

From source file:android.support.v7.app.AppCompatDelegateImplV7.java

private void ensureSubDecor() {
    if (!mSubDecorInstalled) {
        final LayoutInflater inflater = LayoutInflater.from(mContext);

        if (!mWindowNoTitle) {
            if (mIsFloating) {
                // If we're floating, inflate the dialog title decor
                mSubDecor = (ViewGroup) inflater.inflate(R.layout.abc_dialog_title_material, null);
            } else if (mHasActionBar) {
                /**/*from w ww  . j av a2 s  .c o m*/
                 * This needs some explanation. As we can not use the android:theme attribute
                 * pre-L, we emulate it by manually creating a LayoutInflater using a
                 * ContextThemeWrapper pointing to actionBarTheme.
                 */
                TypedValue outValue = new TypedValue();
                mContext.getTheme().resolveAttribute(R.attr.actionBarTheme, outValue, true);

                Context themedContext;
                if (outValue.resourceId != 0) {
                    themedContext = new ContextThemeWrapper(mContext, outValue.resourceId);
                } else {
                    themedContext = mContext;
                }

                // Now inflate the view using the themed context and set it as the content view
                mSubDecor = (ViewGroup) LayoutInflater.from(themedContext).inflate(R.layout.abc_screen_toolbar,
                        null);

                mDecorContentParent = (DecorContentParent) mSubDecor.findViewById(R.id.decor_content_parent);
                mDecorContentParent.setWindowCallback(getWindowCallback());

                /**
                 * Propagate features to DecorContentParent
                 */
                if (mOverlayActionBar) {
                    mDecorContentParent.initFeature(FEATURE_ACTION_BAR_OVERLAY);
                }
                if (mFeatureProgress) {
                    mDecorContentParent.initFeature(Window.FEATURE_PROGRESS);
                }
                if (mFeatureIndeterminateProgress) {
                    mDecorContentParent.initFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
                }
            }
        } else {
            if (mOverlayActionMode) {
                mSubDecor = (ViewGroup) inflater.inflate(R.layout.abc_screen_simple_overlay_action_mode, null);
            } else {
                mSubDecor = (ViewGroup) inflater.inflate(R.layout.abc_screen_simple, null);
            }

            if (Build.VERSION.SDK_INT >= 21) {
                // If we're running on L or above, we can rely on ViewCompat's
                // setOnApplyWindowInsetsListener
                ViewCompat.setOnApplyWindowInsetsListener(mSubDecor, new OnApplyWindowInsetsListener() {
                    @Override
                    public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                        final int top = insets.getSystemWindowInsetTop();
                        final int newTop = updateStatusGuard(top);

                        if (top != newTop) {
                            insets = insets.replaceSystemWindowInsets(insets.getSystemWindowInsetLeft(), newTop,
                                    insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
                        }

                        // Now apply the insets on our view
                        return ViewCompat.onApplyWindowInsets(v, insets);
                    }
                });
            } else {
                // Else, we need to use our own FitWindowsViewGroup handling
                ((FitWindowsViewGroup) mSubDecor)
                        .setOnFitSystemWindowsListener(new FitWindowsViewGroup.OnFitSystemWindowsListener() {
                            @Override
                            public void onFitSystemWindows(Rect insets) {
                                insets.top = updateStatusGuard(insets.top);
                            }
                        });
            }
        }

        if (mSubDecor == null) {
            throw new IllegalArgumentException("AppCompat does not support the current theme features");
        }

        if (mDecorContentParent == null) {
            mTitleView = (TextView) mSubDecor.findViewById(R.id.title);
        }

        // Make the decor optionally fit system windows, like the window's decor
        ViewUtils.makeOptionalFitsSystemWindows(mSubDecor);

        final ViewGroup decorContent = (ViewGroup) mWindow.findViewById(android.R.id.content);
        final ViewGroup abcContent = (ViewGroup) mSubDecor.findViewById(R.id.action_bar_activity_content);

        // There might be Views already added to the Window's content view so we need to
        // migrate them to our content view
        while (decorContent.getChildCount() > 0) {
            final View child = decorContent.getChildAt(0);
            decorContent.removeViewAt(0);
            abcContent.addView(child);
        }

        // Now set the Window's content view with the decor
        mWindow.setContentView(mSubDecor);

        // Change our content FrameLayout to use the android.R.id.content id.
        // Useful for fragments.
        decorContent.setId(View.NO_ID);
        abcContent.setId(android.R.id.content);

        // The decorContent may have a foreground drawable set (windowContentOverlay).
        // Remove this as we handle it ourselves
        if (decorContent instanceof FrameLayout) {
            ((FrameLayout) decorContent).setForeground(null);
        }

        // If a title was set before we installed the decor, propogate it now
        CharSequence title = getTitle();
        if (!TextUtils.isEmpty(title)) {
            onTitleChanged(title);
        }

        applyFixedSizeWindow();

        onSubDecorInstalled(mSubDecor);

        mSubDecorInstalled = true;

        // Invalidate if the panel menu hasn't been created before this.
        // Panel menu invalidation is deferred avoiding application onCreateOptionsMenu
        // being called in the middle of onCreate or similar.
        // A pending invalidation will typically be resolved before the posted message
        // would run normally in order to satisfy instance state restoration.
        PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, false);
        if (!isDestroyed() && (st == null || st.menu == null)) {
            invalidatePanelMenu(FEATURE_ACTION_BAR);
        }
    }
}

From source file:android.support.v7ox.app.AppCompatDelegateImplV7.java

private ViewGroup createSubDecor() {
    TypedArray a = mContext.obtainStyledAttributes(R.styleable.AppCompatTheme);

    if (!a.hasValue(R.styleable.AppCompatTheme_windowActionBar_ox)) {
        a.recycle();//  w w  w .j  a  v a2s  . co  m
        throw new IllegalStateException(
                "You need to use a Theme.AppCompat theme (or descendant) with this activity.");
    }

    if (a.getBoolean(R.styleable.AppCompatTheme_windowNoTitle_ox, false)) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    } else if (a.getBoolean(R.styleable.AppCompatTheme_windowActionBar_ox, false)) {
        // Don't allow an action bar if there is no title.
        requestWindowFeature(FEATURE_SUPPORT_ACTION_BAR);
    }
    if (a.getBoolean(R.styleable.AppCompatTheme_windowActionBarOverlay_ox, false)) {
        requestWindowFeature(FEATURE_SUPPORT_ACTION_BAR_OVERLAY);
    }
    if (a.getBoolean(R.styleable.AppCompatTheme_windowActionModeOverlay_ox, false)) {
        requestWindowFeature(FEATURE_ACTION_MODE_OVERLAY);
    }
    mIsFloating = a.getBoolean(R.styleable.AppCompatTheme_android_windowIsFloating, false);
    a.recycle();

    final LayoutInflater inflater = LayoutInflater.from(mContext);
    ViewGroup subDecor = null;

    if (!mWindowNoTitle) {
        if (mIsFloating) {
            // If we're floating, inflate the dialog title decor
            subDecor = (ViewGroup) inflater.inflate(R.layout.abc_dialog_title_material, null);

            // Floating windows can never have an action bar, reset the flags
            mHasActionBar = mOverlayActionBar = false;
        } else if (mHasActionBar) {
            /**
             * This needs some explanation. As we can not use the android:theme attribute
             * pre-L, we emulate it by manually creating a LayoutInflater using a
             * ContextThemeWrapper pointing to actionBarTheme.
             */
            TypedValue outValue = new TypedValue();
            mContext.getTheme().resolveAttribute(R.attr.actionBarTheme_ox, outValue, true);

            Context themedContext;
            if (outValue.resourceId != 0) {
                themedContext = new ContextThemeWrapper(mContext, outValue.resourceId);
            } else {
                themedContext = mContext;
            }

            // Now inflate the view using the themed context and set it as the content view
            subDecor = (ViewGroup) LayoutInflater.from(themedContext).inflate(R.layout.abc_screen_toolbar,
                    null);

            mDecorContentParent = (DecorContentParent) subDecor.findViewById(R.id.decor_content_parent);
            mDecorContentParent.setWindowCallback(getWindowCallback());

            /**
             * Propagate features to DecorContentParent
             */
            if (mOverlayActionBar) {
                mDecorContentParent.initFeature(FEATURE_SUPPORT_ACTION_BAR_OVERLAY);
            }
            if (mFeatureProgress) {
                mDecorContentParent.initFeature(Window.FEATURE_PROGRESS);
            }
            if (mFeatureIndeterminateProgress) {
                mDecorContentParent.initFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
            }
        }
    } else {
        if (mOverlayActionMode) {
            subDecor = (ViewGroup) inflater.inflate(R.layout.abc_screen_simple_overlay_action_mode, null);
        } else {
            subDecor = (ViewGroup) inflater.inflate(R.layout.abc_screen_simple, null);
        }

        if (Build.VERSION.SDK_INT >= 21) {
            // If we're running on L or above, we can rely on ViewCompat's
            // setOnApplyWindowInsetsListener
            ViewCompat.setOnApplyWindowInsetsListener(subDecor, new OnApplyWindowInsetsListener() {
                @Override
                public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                    final int top = insets.getSystemWindowInsetTop();
                    final int newTop = updateStatusGuard(top);

                    if (top != newTop) {
                        insets = insets.replaceSystemWindowInsets(insets.getSystemWindowInsetLeft(), newTop,
                                insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
                    }

                    // Now apply the insets on our view
                    return ViewCompat.onApplyWindowInsets(v, insets);
                }
            });
        } else {
            // Else, we need to use our own FitWindowsViewGroup handling
            ((FitWindowsViewGroup) subDecor)
                    .setOnFitSystemWindowsListener(new FitWindowsViewGroup.OnFitSystemWindowsListener() {
                        @Override
                        public void onFitSystemWindows(Rect insets) {
                            insets.top = updateStatusGuard(insets.top);
                        }
                    });
        }
    }

    if (subDecor == null) {
        throw new IllegalArgumentException("AppCompat does not support the current theme features: { "
                + "windowActionBar: " + mHasActionBar + ", windowActionBarOverlay: " + mOverlayActionBar
                + ", android:windowIsFloating: " + mIsFloating + ", windowActionModeOverlay: "
                + mOverlayActionMode + ", windowNoTitle: " + mWindowNoTitle + " }");
    }

    if (mDecorContentParent == null) {
        mTitleView = (TextView) subDecor.findViewById(R.id.title);
    }

    // Make the decor optionally fit system windows, like the window's decor
    ViewUtils.makeOptionalFitsSystemWindows(subDecor);

    final ViewGroup decorContent = (ViewGroup) mWindow.findViewById(android.R.id.content);
    final ContentFrameLayout abcContent = (ContentFrameLayout) subDecor
            .findViewById(R.id.action_bar_activity_content);

    // There might be Views already added to the Window's content view so we need to
    // migrate them to our content view
    while (decorContent.getChildCount() > 0) {
        final View child = decorContent.getChildAt(0);
        decorContent.removeViewAt(0);
        abcContent.addView(child);
    }

    // Now set the Window's content view with the decor
    mWindow.setContentView(subDecor);

    // Change our content FrameLayout to use the android.R.id.content id.
    // Useful for fragments.
    decorContent.setId(View.NO_ID);
    abcContent.setId(android.R.id.content);

    // The decorContent may have a foreground drawable set (windowContentOverlay).
    // Remove this as we handle it ourselves
    if (decorContent instanceof FrameLayout) {
        decorContent.setForeground(null);
    }

    abcContent.setAttachListener(new ContentFrameLayout.OnAttachListener() {
        @Override
        public void onAttachedFromWindow() {
        }

        @Override
        public void onDetachedFromWindow() {
            dismissPopups();
        }
    });

    return subDecor;
}

From source file:ca.spencerelliott.mercury.Changesets.java

public void refreshChangesets() {
    //Set up the window to show the progress dialog in the title bar
    this.getWindow().setFeatureInt(Window.PROGRESS_VISIBILITY_ON, 1);
    this.getWindow().setFeatureInt(Window.FEATURE_PROGRESS, 0);
    this.setProgressBarVisibility(true);

    //Create a new thread to process all the data in the background
    startThread();//w  ww .  jav a 2  s.co m
}

From source file:com.andrewshu.android.reddit.mail.InboxListActivity.java

private void enableLoadingScreen() {
    if (Util.isLightTheme(mSettings.getTheme())) {
        findViewById(R.id.loading_light).setVisibility(View.VISIBLE);
        findViewById(R.id.loading_dark).setVisibility(View.GONE);
    } else {/*  ww w . j  ava2  s.c  o  m*/
        findViewById(R.id.loading_light).setVisibility(View.GONE);
        findViewById(R.id.loading_dark).setVisibility(View.VISIBLE);
    }
    synchronized (MESSAGE_ADAPTER_LOCK) {
        if (mMessagesAdapter != null)
            mMessagesAdapter.mIsLoading = true;
    }
    getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_START);
}

From source file:com.andrewshu.android.reddit.mail.InboxListActivity.java

private void disableLoadingScreen() {
    resetUI(mMessagesAdapter);
    getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_END);
}

From source file:com.andrewshu.android.reddit.user.ProfileActivity.java

private void enableLoadingScreen() {
    if (Util.isLightTheme(mSettings.getTheme())) {
        findViewById(R.id.loading_light).setVisibility(View.VISIBLE);
        findViewById(R.id.loading_dark).setVisibility(View.GONE);
    } else {/*from  w  ww  .  j  a  va2 s . com*/
        findViewById(R.id.loading_light).setVisibility(View.GONE);
        findViewById(R.id.loading_dark).setVisibility(View.VISIBLE);
    }
    synchronized (MESSAGE_ADAPTER_LOCK) {
        if (mThingsAdapter != null)
            mThingsAdapter.mIsLoading = true;
    }
    getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_START);
}

From source file:com.andrewshu.android.reddit.profile.ProfileActivity.java

private void enableLoadingScreen() {
    if (Util.isLightTheme(mSettings.getTheme())) {
        setContentView(R.layout.loading_light);
    } else {/*from  www.j  av a2s . com*/
        setContentView(R.layout.loading_dark);
    }
    synchronized (MESSAGE_ADAPTER_LOCK) {
        if (mThingsAdapter != null)
            mThingsAdapter.mIsLoading = true;
    }
    getWindow().setFeatureInt(Window.FEATURE_PROGRESS, 0);
}

From source file:com.andrewshu.android.reddit.user.ProfileActivity.java

private void disableLoadingScreen() {
    resetUI(mThingsAdapter);
    getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_END);
}

From source file:com.andrewshu.android.reddit.profile.ProfileActivity.java

private void disableLoadingScreen() {
    resetUI(mThingsAdapter);
    getWindow().setFeatureInt(Window.FEATURE_PROGRESS, 10000);
}