Java Code Examples for android.view.Window#setCallback()

The following examples show how to use android.view.Window#setCallback() . 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: Dialog.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
Dialog(@NonNull Context context, @StyleRes int themeResId, boolean createContextThemeWrapper) {
    if (createContextThemeWrapper) {
        if (themeResId == ResourceId.ID_NULL) {
            final TypedValue outValue = new TypedValue();
            context.getTheme().resolveAttribute(R.attr.dialogTheme, outValue, true);
            themeResId = outValue.resourceId;
        }
        mContext = new ContextThemeWrapper(context, themeResId);
    } else {
        mContext = context;
    }

    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

    final Window w = new PhoneWindow(mContext);
    mWindow = w;
    w.setCallback(this);
    w.setOnWindowDismissedCallback(this);
    w.setOnWindowSwipeDismissedCallback(() -> {
        if (mCancelable) {
            cancel();
        }
    });
    w.setWindowManager(mWindowManager, null, null);
    w.setGravity(Gravity.CENTER);

    mListenersHandler = new ListenersHandler(this);
}
 
Example 2
Source File: RobotoInflater.java    From Android-RobotoTextView with Apache License 2.0 5 votes vote down vote up
public static void attach(@NonNull Activity activity) {
    if (activity instanceof AppCompatActivity) {
        LayoutInflaterCompat.setFactory(activity.getLayoutInflater(),
                new RobotoInflater(((AppCompatActivity) activity).getDelegate(), activity.getWindow()));
    } else {
        final Window window = activity.getWindow();
        final Window.Callback callback = window.getCallback();
        LayoutInflaterCompat.setFactory(activity.getLayoutInflater(),
                new RobotoInflater(AppCompatDelegate.create(activity, StubAppCompatCallback.INSTANCE), window));
        window.setCallback(callback);
    }
}
 
Example 3
Source File: MonitorActivityLifecycleCallbacks.java    From BehaviorCollect with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
    Window window = activity.getWindow();
    Window.Callback callback= window.getCallback();
    window.setCallback(new MonitorCallback(activity,callback));
}