Example usage for android.app Activity getWindow

List of usage examples for android.app Activity getWindow

Introduction

In this page you can find the example usage for android.app Activity getWindow.

Prototype

public Window getWindow() 

Source Link

Document

Retrieve the current android.view.Window for the activity.

Usage

From source file:com.fuzz.android.limelight.LimeLight.java

private static void createDelayedRecordingWindow(Activity activity, int delay) {
    activity.getWindow().getDecorView().postDelayed(new Runnable() {
        @Override/*from ww  w  .j  ava2  s. c  o  m*/
        public void run() {
            if (book != null) {
                book.refreshWindow();
            }
            if (!mRecorderWindow.isShowing()) {
                mRecorderWindow.show(getRootView());
            }
            updateScrubber(View.FOCUS_RIGHT);
            LimeLightLog.i("Created recording window.");
        }
    }, delay);
}

From source file:de.domjos.schooltools.helper.Helper.java

public static void closeSoftKeyboard(Activity activity) {
    activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}

From source file:com.example.android.leanback.BackgroundHelper.java

static public void attach(Activity activity) {
    if (!ENABLED) {
        return;/* w  ww . j a  va2s.c o  m*/
    }
    if (DEBUG)
        Log.v(TAG, "attach to activity " + activity);
    BackgroundManager.getInstance(activity).attach(activity.getWindow());
}

From source file:com.example.jhon.venue.Util.TransitionHelper.java

/**???
 * ???UI//???/*ww  w . ja v  a2  s  .com*/
 * Create the transition participants required during a activity transition while
 * avoiding glitches with the system UI.
 *
 * @param activity The activity used as start for the transition.//activity?
 * @param includeStatusBar If false, the status bar will not be added as the transition//false??
 *        participant.
 * @return All transition participants.//??
 */
public static Pair<View, String>[] createSafeTransitionParticipants(@NonNull Activity activity,
        boolean includeStatusBar, @Nullable Pair... otherParticipants) {
    // Avoid system UI glitches as described here:??UI
    // https://plus.google.com/+AlexLockwood/posts/RPtwZ5nNebb
    View decor = activity.getWindow().getDecorView();
    //activity.getWindow()?? .getDecorView()????/?????
    View statusBar = null;//??
    if (includeStatusBar) {//?????
        statusBar = decor.findViewById(android.R.id.statusBarBackground);//??
    }
    View navBar = decor.findViewById(android.R.id.navigationBarBackground);//?

    // Create pair of transition participants.???
    List<Pair> participants = new ArrayList<>(3);
    addNonNullViewToTransitionParticipants(statusBar, participants);
    addNonNullViewToTransitionParticipants(navBar, participants);
    // only add transition participants if there's at least one none-null element
    if (otherParticipants != null && !(otherParticipants.length == 1//otherParticipants?
            && otherParticipants[0] == null)) {
        participants.addAll(Arrays.asList(otherParticipants));
    }
    return participants.toArray(new Pair[participants.size()]);//list?
}

From source file:com.fuzz.android.limelight.LimeLight.java

public static View getRootView(Activity activity) {
    View view = null;/* w  w  w.j a va2s  .co  m*/
    try {
        view = activity.getWindow().getDecorView();
    } catch (NullPointerException npe) {
        LimeLightLog.e("The provided activity was null");
    }
    return view;
}

From source file:com.marc.marclibs.utils.StatusBarCompat.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static View compat(Activity activity, int statusColor) {
    int color = ContextCompat.getColor(activity, R.color.primary_light);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (statusColor != INVALID_VAL) {
            color = statusColor;//from   www .j  a v  a  2s.  c  o m
        }
        activity.getWindow().setStatusBarColor(color);
        return null;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
            && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
        if (statusColor != INVALID_VAL) {
            color = statusColor;
        }
        View statusBarView = contentView.getChildAt(0);
        if (statusBarView != null && statusBarView.getMeasuredHeight() == getStatusBarHeight(activity)) {
            statusBarView.setBackgroundColor(color);
            return statusBarView;
        }
        statusBarView = new View(activity);
        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                getStatusBarHeight(activity));
        statusBarView.setBackgroundColor(color);
        contentView.addView(statusBarView, lp);
        return statusBarView;
    }
    return null;

}

From source file:com.yunyou.yike.utils.StatusBarCompat.java

public static View compat(Activity activity, int statusColor) {
    int color = ContextCompat.getColor(activity, R.color.colorPrimaryDark);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (statusColor != INVALID_VAL) {
            color = statusColor;/*w w w.j a  v  a2s.  c  o  m*/
        }
        activity.getWindow().setStatusBarColor(color);
        return null;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
            && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
        if (statusColor != INVALID_VAL) {
            color = statusColor;
        }
        View statusBarView = contentView.getChildAt(0);
        if (statusBarView != null && statusBarView.getMeasuredHeight() == getStatusBarHeight(activity)) {
            statusBarView.setBackgroundColor(color);
            return statusBarView;
        }
        statusBarView = new View(activity);
        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                getStatusBarHeight(activity));
        statusBarView.setBackgroundColor(color);
        contentView.addView(statusBarView, lp);
        return statusBarView;
    }
    return null;

}

From source file:com.bs.hjsyxt.utils.StatusBarCompat.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static View compat(Activity activity, int statusColor) {
    int color = ContextCompat.getColor(activity, R.color.colorPrimaryDark);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (statusColor != INVALID_VAL) {
            color = statusColor;/*w ww . ja  v  a  2 s  .co  m*/
        }
        activity.getWindow().setStatusBarColor(color);
        return null;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
            && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
        if (statusColor != INVALID_VAL) {
            color = statusColor;
        }
        View statusBarView = contentView.getChildAt(0);
        if (statusBarView != null && statusBarView.getMeasuredHeight() == getStatusBarHeight(activity)) {
            statusBarView.setBackgroundColor(color);
            return statusBarView;
        }
        statusBarView = new View(activity);
        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                getStatusBarHeight(activity));
        statusBarView.setBackgroundColor(color);
        contentView.addView(statusBarView, lp);
        return statusBarView;
    }
    return null;

}

From source file:com.yoyiyi.bookreadercopy.utils.StatusBarCompat.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP) //21
public static View compat(Activity activity, int statusColor) {
    int color = ContextCompat.getColor(activity, R.color.colorPrimaryDark);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (statusColor != INVALID_VAL) {
            color = statusColor;//w w w . java 2  s  .c  om
        }
        activity.getWindow().setStatusBarColor(color);
        return null;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
            && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
        if (statusColor != INVALID_VAL) {
            color = statusColor;
        }
        View statusBarView = contentView.getChildAt(0);
        if (statusBarView != null && statusBarView.getMeasuredHeight() == getStatusBarHeight(activity)) {
            statusBarView.setBackgroundColor(color);
            return statusBarView;
        }
        statusBarView = new View(activity);
        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                getStatusBarHeight(activity));
        statusBarView.setBackgroundColor(color);
        contentView.addView(statusBarView, lp);
        return statusBarView;
    }
    return null;

}

From source file:Main.java

public static void showAsPopup(Activity activity) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        return;//w w w.  j  ava  2s.  c  o m
    }
    activity.requestWindowFeature(Window.FEATURE_ACTION_BAR);

    //To show activity as dialog and dim the background, you need to declare android:theme="@style/PopupTheme" on for the chosen activity on the manifest
    Window window = activity.getWindow();
    window.setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND);

    Display display = activity.getWindowManager().getDefaultDisplay();
    WindowManager.LayoutParams params = window.getAttributes();
    params.height = (int) (display.getHeight() * 0.95);
    params.width = Math.min((int) (display.getWidth() * 0.9), (int) (params.height * 0.85));
    params.gravity = Gravity.BOTTOM;
    params.alpha = 1.0f;
    params.dimAmount = 0.5f;
    window.setAttributes(params);
}