List of usage examples for android.app Activity getWindow
public Window getWindow()
From source file:android.support.v17.leanback.app.GuidedStepFragment.java
/** * Adds the specified GuidedStepFragment as content of Activity; no backstack entry is added so * the activity will be dismissed when BACK key is pressed. The method is typically called in * Activity.onCreate() when savedInstanceState is null. When savedInstanceState is not null, * the Activity is being restored, do not call addAsRoot() to duplicate the Fragment restored * by FragmentManager./*from w ww. j av a2s . co m*/ * {@link #UI_STYLE_ACTIVITY_ROOT} is assigned. * * Note: currently fragments added using this method must be created programmatically rather * than via XML. * @param activity The Activity to be used to insert GuidedstepFragment. * @param fragment The GuidedStepFragment to be inserted into the fragment stack. * @param id The id of container to add GuidedStepFragment, can be android.R.id.content. * @return The ID returned by the call FragmentTransaction.commit, or -1 there is already * GuidedStepFragment. */ public static int addAsRoot(Activity activity, GuidedStepFragment fragment, int id) { // Workaround b/23764120: call getDecorView() to force requestFeature of ActivityTransition. activity.getWindow().getDecorView(); FragmentManager fragmentManager = activity.getFragmentManager(); if (fragmentManager.findFragmentByTag(TAG_LEAN_BACK_ACTIONS_FRAGMENT) != null) { Log.w(TAG, "Fragment is already exists, likely calling " + "addAsRoot() when savedInstanceState is not null in Activity.onCreate()."); return -1; } FragmentTransaction ft = fragmentManager.beginTransaction(); fragment.setUiStyle(UI_STYLE_ACTIVITY_ROOT); return ft.replace(id, fragment, TAG_LEAN_BACK_ACTIONS_FRAGMENT).commit(); }
From source file:com.nick.scalpel.core.AutoFoundWirer.java
@Override public void wire(Activity activity, Field field) { WireParam param = getParam(activity, field); if (param == null) return;/*from ww w . j av a2 s . c o m*/ switch (param.type) { case VIEW: wire(activity.getWindow().getDecorView(), activity, field); break; default: wire(activity.getApplicationContext(), activity, field); break; } }
From source file:openscience.crowdsource.video.experiments.MainActivity.java
public static void setTaskBarColored(android.app.Activity context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window w = context.getWindow(); w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // todo: resolve default top bar height issue or find enother way to change top bar color // int statusBarHeight = 50; View view = new View(context); // view.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); // view.getLayoutParams().height = statusBarHeight; // ((ViewGroup) w.getDecorView()).addView(view); view.setBackgroundColor(context.getResources().getColor(R.color.colorStatusBar)); }/*from ww w . j av a 2s . c om*/ }
From source file:mirko.android.datetimepicker.date.DatePickerDialogSupport.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Activity activity = getActivity(); activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); mVibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE); if (savedInstanceState != null) { mCalendar.set(Calendar.YEAR, savedInstanceState.getInt(KEY_SELECTED_YEAR)); mCalendar.set(Calendar.MONTH, savedInstanceState.getInt(KEY_SELECTED_MONTH)); mCalendar.set(Calendar.DAY_OF_MONTH, savedInstanceState.getInt(KEY_SELECTED_DAY)); mEnableClearButton = savedInstanceState.getBoolean(KEY_ENABLE_CLEAR_BUTTON, false); }//from w w w . ja va 2 s . c o m }
From source file:com.oginotihiro.datepicker.DatePickerDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Activity activity = getActivity(); activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); mVibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE); if (savedInstanceState != null) { mCalendar.set(Calendar.YEAR, savedInstanceState.getInt(KEY_SELECTED_YEAR)); mCalendar.set(Calendar.MONTH, savedInstanceState.getInt(KEY_SELECTED_MONTH)); mCalendar.set(Calendar.DAY_OF_MONTH, savedInstanceState.getInt(KEY_SELECTED_DAY)); mMinYear = savedInstanceState.getInt(KEY_YEAR_START); mMaxYear = savedInstanceState.getInt(KEY_YEAR_END); mWeekStart = savedInstanceState.getInt(KEY_WEEK_START); mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE); mColor = savedInstanceState.getInt(KEY_COLOR); mDarkColor = savedInstanceState.getInt(KEY_DARK_COLOR); }/*www. j a va 2 s .c o m*/ }
From source file:org.jitsi.android.gui.fragment.ProximitySensorFragment.java
/** * Turns the screen off.// www. ja va 2 s .co m */ private void screenOff() { Activity activity = getActivity(); if (activity == null || sensorDisabled) return; if (screenOffLock == null) { this.screenOffLock = JitsiApplication.getPowerManager().newWakeLock(PROXIMITY_SCREEN_OFF_WAKE_LOCK, "proximity_off"); } if (!screenOffLock.isHeld()) { logger.debug("Acquire lock"); activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); screenOffLock.acquire(); } }
From source file:jp.seesaa.android.datetimepicker.date.DatePickerDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Activity activity = getActivity(); activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); if (savedInstanceState != null) { mCalendar.set(Calendar.YEAR, savedInstanceState.getInt(KEY_SELECTED_YEAR)); mCalendar.set(Calendar.MONTH, savedInstanceState.getInt(KEY_SELECTED_MONTH)); mCalendar.set(Calendar.DAY_OF_MONTH, savedInstanceState.getInt(KEY_SELECTED_DAY)); }/*w w w. j a v a 2 s . c om*/ // setStyle(STYLE_NO_TITLE, R.style.dtp_alertdialog); }
From source file:org.zywx.wbpalmstar.plugin.uexiconlist.EUExIconList.java
/** * ??IconList view? ??/* ww w . j a va 2s .com*/ * */ private void resetFrame() { ((Activity) mContext).runOnUiThread(new Runnable() { @Override public void run() { if (mgr == null) { mgr = new LocalActivityManager((Activity) mContext, false); mgr.dispatchCreate(null); } Activity activity = mgr.getActivity(IconListActivity.TAG); if (activity != null) { ViewGroup subView = (ViewGroup) activity.getWindow().getDecorView(); if (IconListOption.isFollowWebRoll()) { AbsoluteLayout.LayoutParams lParams = (LayoutParams) subView.getLayoutParams(); lParams.width = (int) UIConfig.getScaleWidth(); lParams.height = (int) UIConfig.getScaleHight(); lParams.x = (int) UIConfig.getScaleX(); lParams.y = (int) UIConfig.getScaleY(); // AbsoluteLayout.LayoutParams lp = new AbsoluteLayout.LayoutParams( // (int) UIConfig.getScaleWidth(), // (int) UIConfig.getScaleHight(), // (int) UIConfig.getScaleX(), // (int) UIConfig.getScaleY()); subView.setLayoutParams(lParams); } else { FrameLayout.LayoutParams lParams = (FrameLayout.LayoutParams) subView.getLayoutParams(); lParams.width = (int) UIConfig.getScaleWidth(); lParams.height = (int) UIConfig.getScaleHight(); lParams.leftMargin = (int) UIConfig.getScaleX(); lParams.topMargin = (int) UIConfig.getScaleY(); // FrameLayout.LayoutParams lp = new // FrameLayout.LayoutParams( // (int) UIConfig.getScaleWidth(), // (int) UIConfig.getScaleHight()); // lp.leftMargin = (int) UIConfig.getScaleX(); // lp.topMargin = (int) UIConfig.getScaleY(); subView.setLayoutParams(lParams); } subView.invalidate(); mEuExIconListHandler.send2Callback(WHAT_RESET_FRAME, null); } } }); }
From source file:com.philliphsu.bottomsheetpickers.date.BottomSheetDatePickerDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Activity activity = getActivity(); activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); setCancelable(false);/* w w w. j a v a 2 s .c om*/ if (savedInstanceState != null) { mCalendar.set(Calendar.YEAR, savedInstanceState.getInt(KEY_SELECTED_YEAR)); mCalendar.set(Calendar.MONTH, savedInstanceState.getInt(KEY_SELECTED_MONTH)); mCalendar.set(Calendar.DAY_OF_MONTH, savedInstanceState.getInt(KEY_SELECTED_DAY)); } }
From source file:com.haofeng.superne.thirdparty.crouton.Manager.java
@TargetApi(19) private void handleTranslucentActionBar(ViewGroup.MarginLayoutParams params, Activity activity) { // Translucent status is only available as of Android 4.4 Kit Kat. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { final int flags = activity.getWindow().getAttributes().flags; final int translucentStatusFlag = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; /* Checks whether translucent status is enabled for this window. * If true, sets the top margin to show the crouton just below the action bar. */ if ((flags & translucentStatusFlag) == translucentStatusFlag) { final int actionBarContainerId = Resources.getSystem().getIdentifier("action_bar_container", "id", "android"); final View actionBarContainer = activity.findViewById(actionBarContainerId); // The action bar is present: the app is using a Holo theme. if (actionBarContainer != null) { final ViewGroup.MarginLayoutParams marginParams = (ViewGroup.MarginLayoutParams) params; marginParams.topMargin = actionBarContainer.getBottom(); }/* w w w .j a v a 2 s . c om*/ } } }