Java 类android.view.WindowInsets 实例源码

项目:ubiquitous    文件:MyWatchFace.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources resources = MyWatchFace.this.getResources();
    boolean isRound = insets.isRound();
    mXOffset = resources.getDimension(isRound
            ? R.dimen.digital_x_offset_round : R.dimen.digital_x_offset);
    float textSize = resources.getDimension(isRound
            ? R.dimen.digital_text_size_round : R.dimen.digital_text_size);

    float textSizeSmall = resources.getDimension(R.dimen.digital_text_size_small);
    float textSizeVerySmall = resources.getDimension(R.dimen.digital_text_very_size_small);
    mTextPaint.setTextSize(textSize);
    dateTextPaint.setTextSize(textSizeSmall);
    lineTextPaint.setTextSize(textSizeVerySmall);
    mLowTempPaint.setTextSize(mLowTextSize);
    mHighTempPaint.setTextSize(mHighTextSize);
}
项目:airgram    文件:DrawerLayoutContainer.java   
public DrawerLayoutContainer(Context context) {
    super(context);

    minDrawerMargin = (int) (MIN_DRAWER_MARGIN * AndroidUtilities.density + 0.5f);
    setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
    setFocusableInTouchMode(true);

    if (Build.VERSION.SDK_INT >= 21) {
        setFitsSystemWindows(true);
        setOnApplyWindowInsetsListener(new OnApplyWindowInsetsListener() {
            @SuppressLint("NewApi")
            @Override
            public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
                final DrawerLayoutContainer drawerLayout = (DrawerLayoutContainer) v;
                lastInsets = insets;
                drawerLayout.setWillNotDraw(insets.getSystemWindowInsetTop() <= 0 && getBackground() == null);
                drawerLayout.requestLayout();
                return insets.consumeSystemWindowInsets();
            }
        });
        setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }

    shadowLeft = getResources().getDrawable(R.drawable.menu_shadow);
}
项目:Android_Sunshine_Watch    文件:MyWatchFace.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources resources = MyWatchFace.this.getResources();
    boolean isRound = insets.isRound();
    mXOffset = resources.getDimension(isRound
            ? R.dimen.digital_text_size_round : R.dimen.digital_text_size);
    float textSize = resources.getDimension(isRound
            ? R.dimen.digital_text_size_round : R.dimen.digital_text_size);


    hourPaint.setTextSize(textSize);
    minutePaint.setTextSize(textSize);
    colonPaint.setTextSize(textSize);
    highPaint.setTextSize(textSize);
    lowPaint.setTextSize(textSize);
    colonWidth = colonPaint.measureText(":");
}
项目:PlusGram    文件:DrawerLayoutContainer.java   
public DrawerLayoutContainer(Context context) {
    super(context);

    minDrawerMargin = (int) (MIN_DRAWER_MARGIN * AndroidUtilities.density + 0.5f);
    setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
    setFocusableInTouchMode(true);

    if (Build.VERSION.SDK_INT >= 21) {
        setFitsSystemWindows(true);
        setOnApplyWindowInsetsListener(new OnApplyWindowInsetsListener() {
            @SuppressLint("NewApi")
            @Override
            public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
                final DrawerLayoutContainer drawerLayout = (DrawerLayoutContainer) v;
                lastInsets = insets;
                drawerLayout.setWillNotDraw(insets.getSystemWindowInsetTop() <= 0 && getBackground() == null);
                drawerLayout.requestLayout();
                return insets.consumeSystemWindowInsets();
            }
        });
        setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }

    shadowLeft = getResources().getDrawable(R.drawable.menu_shadow);
}
项目:RLibrary    文件:UILayoutImpl.java   
@Override
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mInsets[0] = insets.getSystemWindowInsetLeft();
        mInsets[1] = insets.getSystemWindowInsetTop();
        mInsets[2] = insets.getSystemWindowInsetRight();
        mInsets[3] = insets.getSystemWindowInsetBottom();

        post(new Runnable() {
            @Override
            public void run() {
                notifyListener();
            }
        });
        return super.onApplyWindowInsets(insets.replaceSystemWindowInsets(insets.getSystemWindowInsetLeft(), 0,
                insets.getSystemWindowInsetRight(), lockHeight ? 0 : insets.getSystemWindowInsetBottom()));
    } else {
        return super.onApplyWindowInsets(insets);
    }
}
项目:Interessant    文件:InsetsDrawerLayout.java   
@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
    int l = insets.getSystemWindowInsetLeft();
    int t = insets.getSystemWindowInsetTop();
    int r = insets.getSystemWindowInsetRight();

    toolbar.setPadding(l, toolbar.getPaddingTop() + t, 0, 0);

    final boolean ltr = recyclerView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;

    setPadding(getPaddingLeft(), getPaddingTop(), getPaddingEnd() + (ltr ? r : 0),
            getPaddingBottom()
    );

    setOnApplyWindowInsetsListener(null);
    return insets.consumeSystemWindowInsets();
}
项目:SunshineWithWear    文件:MyDigitalWatchFace.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources resources = MyDigitalWatchFace.this.getResources();
    boolean isRound = insets.isRound();
    mXOffset = resources.getDimension(isRound
            ? R.dimen.digital_x_offset_round : R.dimen.digital_x_offset);

    textPaintTime.setTextSize(resources.getDimension(R.dimen.time_text_size));
    textPaintTimeBold.setTextSize(resources.getDimension(R.dimen.time_text_size));
    textPaintDate.setTextSize(resources.getDimension(R.dimen.date_text_size));
    textPaintTemp.setTextSize(resources.getDimension(R.dimen.temp_text_size));
    textPaintTempBold.setTextSize(resources.getDimension(R.dimen.temp_text_size));
}
项目:nano-go-ubiquitous    文件:WatchFaceService.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    Resources res = WatchFaceService.this.getResources();
    boolean isRound = insets.isRound();

    float highTempTextSize = res.getDimension(isRound ? R.dimen.round_size_text_high_temp : R.dimen.square_size_text_high_temp);
    float lowTempTextSize = res.getDimension(isRound ? R.dimen.round_size_text_low_temp : R.dimen.square_size_text_low_temp);
    float textSize = res.getDimension(isRound ? R.dimen.clock_text_size_round : R.dimen.clock_text_size);
    float dateTextSize = res.getDimension(isRound ? R.dimen.round_size_text_date : R.dimen.square_size_text_date);

    highTempPaint.setTextSize(highTempTextSize);
    lowTempPaint.setTextSize(lowTempTextSize);
    timePaint.setTextSize(textSize);
    datePaint.setTextSize(dateTextSize);
}
项目:ubiquitous    文件:MyWatchFace.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources resources = MyWatchFace.this.getResources();
    boolean isRound = insets.isRound();
    mXOffset = resources.getDimension(isRound
            ? R.dimen.digital_x_offset_round : R.dimen.digital_x_offset);
    float textSize = resources.getDimension(isRound
            ? R.dimen.digital_text_size_round : R.dimen.digital_text_size);

    float textSizeSmall = resources.getDimension(R.dimen.digital_text_size_small);
    float textSizeVerySmall = resources.getDimension(R.dimen.digital_text_very_size_small);
    mTextPaint.setTextSize(textSize);
    dateTextPaint.setTextSize(textSizeSmall);
    lineTextPaint.setTextSize(textSizeVerySmall);
    mLowTempPaint.setTextSize(mLowTextSize);
    mHighTempPaint.setTextSize(mHighTextSize);
}
项目:Go-Ubiquitous    文件:SunshineWatchFace.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources resources = SunshineWatchFace.this.getResources();
    boolean isRound = insets.isRound();
    mXOffset = resources.getDimension(isRound
            ? R.dimen.digital_x_offset_round : R.dimen.digital_x_offset);
    float textSize = resources.getDimension(isRound
            ? R.dimen.digital_text_size_round : R.dimen.digital_text_size);
    float textDateSize = resources.getDimension(isRound
            ? R.dimen.digital_date_text_size_round : R.dimen.digital_date_text_size);


    mTextPaint.setTextSize(textSize);
    mAlphaTextPaint.setTextSize(textDateSize);
    mAlphaTempPaint.setTextSize(textDateSize);


}
项目:wearDrip    文件:HeadingListView.java   
@Override public WindowInsets onApplyWindowInsets(final WindowInsets insets) {
    heading.setTextColor(-1);
    if(insets.isRound()) {
        heading.setGravity(Gravity.CENTER_HORIZONTAL);

        // Adjust paddings for round devices
        if(!hasAdjustedPadding) {
            final int padding = heading.getPaddingTop();
            heading.setPadding(padding, 2 * padding, padding, padding);
            list.setPadding(padding, 0, padding, 0);
            hasAdjustedPadding = true;
        }
    } else {
        heading.setGravity(Gravity.START);
    }
    return super.onApplyWindowInsets(insets);
}
项目:go-ubiquitous    文件:SunshineWatchFace.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);
    // Load resources that have alternate values for round watches.
    Resources resources = SunshineWatchFace.this.getResources();
    boolean isRound = insets.isRound();
    mTimeXOffset = resources.getDimension(isRound
            ? R.dimen.digital_time_x_offset_round : R.dimen.digital_time_x_offset);
    float timeTextSize = resources.getDimension(isRound
            ? R.dimen.digital_time_text_size_round : R.dimen.digital_time_text_size);
    mTimePaint.setTextSize(timeTextSize);
    float dateTextSize = resources.getDimension(isRound
            ? R.dimen.date_text_size_round : R.dimen.date_text_size);
    mDatePaint.setTextSize(dateTextSize);
    float temperatureTextSize = resources.getDimension(isRound
            ? R.dimen.temperature_text_size_round : R.dimen.temperature_text_size);
    mTemperaturePaint.setTextSize(temperatureTextSize);
}
项目:UdacityProject6    文件:SunshineWatchFace.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources resources = SunshineWatchFace.this.getResources();
    float textSize = resources.getDimension(R.dimen.digital_text_size);
    float smallTextSize = resources.getDimension(R.dimen.digital_small_text_size);
    float mediumTextSize = resources.getDimension(R.dimen.digital_medium_text_size);

    mTimePaint.setTextSize(textSize);
    mDatePaint.setTextSize(smallTextSize);
    mAmPmPaint.setTextSize(textSize);
    mMinTempPaint.setTextSize(mediumTextSize);
    mMaxTempPaint.setTextSize(mediumTextSize);

    mMinTempPaint.setARGB(240,240,240,240);
    mDatePaint.setARGB(240,240,240,240);
}
项目:Sunshinewear    文件:WatchFace.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources resources = WatchFace.this.getResources();
    boolean isRound = insets.isRound();

    mXOffset = resources.getDimension(isRound
            ? R.dimen.digital_x_offset_round : R.dimen.digital_x_offset);

    mYOffset = resources.getDimension(isRound
            ? R.dimen.digital_y_offset_round : R.dimen.digital_y_offset);

    float textSize = resources.getDimension(isRound
            ? R.dimen.digital_text_size_round : R.dimen.digital_text_size);

    mTextPaint.setTextSize(textSize);
}
项目:insets-dispatcher    文件:InsetsDispatcherHelper.java   
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
public WindowInsets onApplyWindowInsets(@Nullable WindowInsets insets) {
    if (insets != null) {
        mInsets = new Rect(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
    }

    for (int i = 0; i < mView.getChildCount(); i++) {
        final View child = mView.getChildAt(i);

        if (!(child instanceof InsetsDispatchReceiver)) {
            InsetsDispatcherLayoutParamsHelper helper = ((InsetsDispatcherLayoutParams) child.getLayoutParams()).getHelper();
            if (helper != null) {
                applyInsets(mInsets, child, helper.useLeftInset, helper.useTopInset, helper.useRightInset, helper.useBottomInset, helper.insetsUseMargin);
            } else {
                applyInsets(mInsets, child, false, false, false, false, false);
            }
        }
    }

    applyInsets(mInsets, mView, mUseLeftInset, mUseTopInset, mUseRightInset, mUseBottomInset, mInsetsUseMargin);

    ViewCompat.postInvalidateOnAnimation(mView);

    return insets;
}
项目:MirageWatch    文件:MyWatchFace.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources res = MyWatchFace.this.getResources();
    boolean isRound = insets.isRound();

    // 時間部分のサイズ
    float textSize = res.getDimension(isRound
            ? R.dimen.digital_text_size_round : R.dimen.digital_text_size);
    // 日付部分のサイズ
    float dateSize = res.getDimension(isRound ? R.dimen.date_text_size_round : R.dimen.date_text_size_sq);
    // バッテリーレベルのサイズ
    float battSize = res.getDimension(isRound ? R.dimen.batt_text_size_ro : R.dimen.batt_text_size_sq);

    mHourPaint.setTextSize(textSize);
    mMinutesPaint.setTextSize(textSize);
    mSeparatorPaint.setTextSize(textSize);

    mDatePaint.setTextSize(dateSize);

    mBattTextPaint.setTextSize(battSize);
}
项目:ticdesign    文件:AlertController.java   
private void setupDecor() {
    final View decor = mWindow.getDecorView();
    final View parent = mWindow.findViewById(R.id.parentPanel);
    if (parent != null && decor != null) {
        decor.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
            @Override
            public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
                if (insets.isRound()) {
                    // TODO: Get the padding as a function of the window size.
                    int roundOffset = mContext.getResources().getDimensionPixelOffset(
                            R.dimen.alert_dialog_round_padding);
                    parent.setPadding(roundOffset, roundOffset, roundOffset, roundOffset);
                }
                return insets.consumeSystemWindowInsets();
            }
        });
        decor.setFitsSystemWindows(true);
        decor.requestApplyInsets();
    }
}
项目:excited-android    文件:InsetsCoordinatorLayout.java   
private boolean applySystemWindowInsets(WindowInsets insets) {
    boolean consumed = false;

    mInsets = new Rect(
            insets.getSystemWindowInsetLeft(),
            insets.getSystemWindowInsetTop(),
            insets.getSystemWindowInsetRight(),
            insets.getSystemWindowInsetBottom());

    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);

        Rect childInsets = new Rect(
                insets.getSystemWindowInsetLeft(),
                insets.getSystemWindowInsetTop(),
                insets.getSystemWindowInsetRight(),
                insets.getSystemWindowInsetBottom());

        child.dispatchApplyWindowInsets(insets.replaceSystemWindowInsets(childInsets));

        consumed = true;
    }

    return consumed;
}
项目:excited-android    文件:InsetsFrameLayout.java   
private boolean applySystemWindowInsets(WindowInsets insets) {
    boolean consumed = false;

    mInsets = new Rect(
            (prevent ^ PREVENT_LEFT) > 0 ? insets.getSystemWindowInsetLeft() : 0,
            (prevent ^ PREVENT_TOP) > 0 ? insets.getSystemWindowInsetTop() : 0,
            (prevent ^ PREVENT_RIGHT) > 0 ? insets.getSystemWindowInsetRight() : 0,
            (prevent ^ PREVENT_BOTTOM) > 0 ? insets.getSystemWindowInsetBottom() : 0);

    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);

        Rect childInsets = new Rect(
                (prevent ^ PREVENT_LEFT) > 0 ? insets.getSystemWindowInsetLeft() : 0,
                (prevent ^ PREVENT_TOP) > 0 ? insets.getSystemWindowInsetTop() : 0,
                (prevent ^ PREVENT_RIGHT) > 0 ? insets.getSystemWindowInsetRight() : 0,
                (prevent ^ PREVENT_BOTTOM) > 0 ? insets.getSystemWindowInsetBottom() : 0);

        child.dispatchApplyWindowInsets(insets.replaceSystemWindowInsets(childInsets));

        consumed = true;
    }

    return consumed;
}
项目:io16watchface    文件:IOWatchFace.java   
@Override
public void onApplyWindowInsets(WindowInsets insets){
    super.onApplyWindowInsets(insets);

    boolean isRound=insets.isRound();

    digitSize=(getResources().getDisplayMetrics().widthPixels)/(isRound ? 10.5f : 9.5f);

    paths=new float[10][];
    cachedDigits=new Bitmap[10];
    paint.setColor(0xFFFFFFFF);
    for(int i=0;i<10;i++){
        paths[i]=new float[DigitPaths.PATHS[i].length];
        for(int j=0; j<paths[i].length; j++){
            paths[i][j]=DigitPaths.PATHS[i][j]*digitSize;
        }
        cachedDigits[i]=Bitmap.createBitmap(Math.round(digitSize*2), Math.round(digitSize*2), Bitmap.Config.ALPHA_8);
        Canvas canvas=new Canvas(cachedDigits[i]);
        canvas.translate(digitSize, digitSize);
        canvas.drawLines(paths[i], paint);
    }

}
项目:FMTech    文件:PlayDrawerLayout.java   
@TargetApi(20)
protected void onFinishInflate()
{
  super.onFinishInflate();
  this.mDrawerRoot = ((ViewGroup)findViewById(R.id.play_drawer_root));
  this.mDrawerList = ((ListView)findViewById(R.id.play_drawer_list));
  this.mDockedActionView = ((TextView)findViewById(R.id.play_drawer_docked_action));
  this.mDockedActionView.setVisibility(8);
  if (Build.VERSION.SDK_INT >= 21) {
    this.mDrawerRoot.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener()
    {
      @TargetApi(20)
      public final WindowInsets onApplyWindowInsets(View paramAnonymousView, WindowInsets paramAnonymousWindowInsets)
      {
        return paramAnonymousWindowInsets.consumeSystemWindowInsets();
      }
    });
  }
}
项目:FMTech    文件:DrawerLayoutCompatApi21.java   
public static void applyMarginInsets(ViewGroup.MarginLayoutParams paramMarginLayoutParams, Object paramObject, int paramInt)
{
  WindowInsets localWindowInsets = (WindowInsets)paramObject;
  if (paramInt == 3) {
    localWindowInsets = localWindowInsets.replaceSystemWindowInsets(localWindowInsets.getSystemWindowInsetLeft(), localWindowInsets.getSystemWindowInsetTop(), 0, localWindowInsets.getSystemWindowInsetBottom());
  }
  for (;;)
  {
    paramMarginLayoutParams.leftMargin = localWindowInsets.getSystemWindowInsetLeft();
    paramMarginLayoutParams.topMargin = localWindowInsets.getSystemWindowInsetTop();
    paramMarginLayoutParams.rightMargin = localWindowInsets.getSystemWindowInsetRight();
    paramMarginLayoutParams.bottomMargin = localWindowInsets.getSystemWindowInsetBottom();
    return;
    if (paramInt == 5) {
      localWindowInsets = localWindowInsets.replaceSystemWindowInsets(0, localWindowInsets.getSystemWindowInsetTop(), localWindowInsets.getSystemWindowInsetRight(), localWindowInsets.getSystemWindowInsetBottom());
    }
  }
}
项目:nano-go-ubiquitous    文件:WatchFaceService.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    Resources res = WatchFaceService.this.getResources();
    boolean isRound = insets.isRound();

    float highTempTextSize = res.getDimension(isRound ? R.dimen.round_size_text_high_temp : R.dimen.square_size_text_high_temp);
    float lowTempTextSize = res.getDimension(isRound ? R.dimen.round_size_text_low_temp : R.dimen.square_size_text_low_temp);
    float textSize = res.getDimension(isRound ? R.dimen.clock_text_size_round : R.dimen.clock_text_size);
    float dateTextSize = res.getDimension(isRound ? R.dimen.round_size_text_date : R.dimen.square_size_text_date);

    highTempPaint.setTextSize(highTempTextSize);
    lowTempPaint.setTextSize(lowTempTextSize);
    timePaint.setTextSize(textSize);
    datePaint.setTextSize(dateTextSize);
}
项目:SpritzerWear    文件:ShapeWear.java   
/**
 * Initialized to determine screen shape
 * @param view
 */
private static void initShapeDetection(View view){
    view.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            if (insets.isRound()) {
                shape = ScreenShape.ROUND;
                if(screenWidthPX == 320 && screenHeightPX == 290) {
                    shape = ScreenShape.MOTO_ROUND;
                }
            } else {
                shape = ScreenShape.RECTANGLE;
            }
            if(onShapeChangeListener != null){
                onShapeChangeListener.shapeDetected(getShape());
            }
            return insets;
        }
    });
}
项目:NaikSoftware-Lib-Android    文件:ViewUtils.java   
public static void setStatusBarColor(Activity activity, View root, Integer color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (activity != null) {
            activity.getWindow().getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            activity.getWindow().setStatusBarColor(color);

            // adjust insets to fix status bar transparency issue
            if (root != null) {
                root.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
                    @Override
                    public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
                        return insets.consumeSystemWindowInsets();
                    }
                });
            }
        }
    }
}
项目:WearPreferenceActivity    文件:HeadingListView.java   
@Override public WindowInsets onApplyWindowInsets(final WindowInsets insets) {
    if(insets.isRound()) {
        heading.setGravity(Gravity.CENTER_HORIZONTAL);

        // Adjust paddings for round devices
        if(!hasAdjustedPadding) {
            final int padding = heading.getPaddingTop();
            heading.setPadding(padding, 2 * padding, padding, padding);
            list.setPadding(padding, 0, padding, 0);
            hasAdjustedPadding = true;
        }
    } else {
        heading.setGravity(Gravity.START);
    }
    return super.onApplyWindowInsets(insets);
}
项目:pretty-girl    文件:InsetCoordinatorLayout.java   
@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
    int l = insets.getSystemWindowInsetLeft();
    int t = insets.getSystemWindowInsetTop();
    int r = insets.getSystemWindowInsetRight();
    int b = insets.getSystemWindowInsetBottom();
    toolbar.setPadding(l, t, 0, 0);

    recyclerView.setPaddingRelative(recyclerView.getPaddingLeft() + l,
            recyclerView.getPaddingTop(),
            recyclerView.getPaddingRight(),
            recyclerView.getPaddingBottom() + b);

    final boolean ltr = recyclerView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;

    setPadding(getPaddingLeft(), getPaddingTop(), getPaddingEnd() + (ltr ? r : 0),
            getPaddingBottom()
    );

    setOnApplyWindowInsetsListener(null);
    return insets.consumeSystemWindowInsets();
}
项目:WearGuitarTuner    文件:MainActivity.java   
@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
    if(insets.isRound()) {
        roundScreen = true;
        Log.i(LOGTAG, "onApplyWindowInsets: detected a round Screen!");
    }
    else {
        roundScreen = false;
        Log.i(LOGTAG, "onApplyWindowInsets: detected a rectangular Screen!");
    }

    // Update the value in the preferences:
    SharedPreferences.Editor edit = preferences.edit();
    edit.putBoolean(getString(R.string.pref_roundScreen), roundScreen);
    edit.apply();

    // note: Because at this early stage of execution, the googleApiClient is most likely
    // not connected. So we will sync the roundScreen setting in the onConnected() callback...

    // unregister the window insets listener:
    fl_root.setOnApplyWindowInsetsListener(null);

    return insets;
}
项目:MirageWatch    文件:MyWatchFace.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources res = MyWatchFace.this.getResources();
    boolean isRound = insets.isRound();

    // 時間部分のサイズ
    float textSize = res.getDimension(isRound
            ? R.dimen.digital_text_size_round : R.dimen.digital_text_size);
    // 日付部分のサイズ
    float dateSize = res.getDimension(isRound ? R.dimen.date_text_size_round : R.dimen.date_text_size_sq);
    // バッテリーレベルのサイズ
    float battSize = res.getDimension(isRound ? R.dimen.batt_text_size_ro : R.dimen.batt_text_size_sq);

    mHourPaint.setTextSize(textSize);
    mMinutesPaint.setTextSize(textSize);
    mSeparatorPaint.setTextSize(textSize);

    mDatePaint.setTextSize(dateSize);

    mBattTextPaint.setTextSize(battSize);
}
项目:ComedoresUGR    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final Resources res = getResources();
    final GridViewPager pager = (GridViewPager) findViewById(R.id.pager);
    pager.setOnApplyWindowInsetsListener(new OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            final boolean round = insets.isRound();
            int rowMargin = res.getDimensionPixelOffset(R.dimen.page_row_margin);
            int colMargin = res.getDimensionPixelOffset(round ?
                    R.dimen.page_column_margin_round : R.dimen.page_column_margin);
            pager.setPageMargins(rowMargin, colMargin);
            return insets;
        }
    });

    menu = new com.iblancasa.comedoresUGR.Menu(this,pager,getFragmentManager());

}
项目:Sunshine-Wear    文件:SunshineWatchFace.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources resources = SunshineWatchFace.this.getResources();
    boolean isRound = insets.isRound();
    mXOffset = resources.getDimension(isRound
            ? R.dimen.digital_x_offset_round : R.dimen.digital_x_offset);
    float textSize = resources.getDimension(isRound
            ? R.dimen.digital_text_size_round : R.dimen.digital_text_size);

    mTextPaint.setTextSize(textSize);

    textSize = resources.getDimension(isRound
            ? R.dimen.digital_date_size_round : R.dimen.digital_date_size);

    mDatePaint.setTextSize(textSize);
    mMaxPaint.setTextSize(textSize);
    mMinPaint.setTextSize(textSize);

    format = new SimpleDateFormat("EEE, MMM dd", Locale.US);
}
项目:ShapeWear    文件:ShapeWear.java   
/**
 * Initialized to determine screen shape
 * @param view
 */
private static void initShapeDetection(View view){
    view.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            if (insets.isRound()) {
                shape = ScreenShape.ROUND;
                if(screenWidthPX == 320 && screenHeightPX == 290) {
                    shape = ScreenShape.MOTO_ROUND;
                }
            } else {
                shape = ScreenShape.RECTANGLE;
            }
            if(onShapeChangeListener != null){
                onShapeChangeListener.shapeDetected(getShape());
            }
            return insets;
        }
    });
}
项目:earth    文件:EarthWatchFaceService.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    if (insets.isRound()) {
        inset = -2;
        setWatchFaceStyle(new WatchFaceStyle.Builder(EarthWatchFaceService.this)
                .setHotwordIndicatorGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM)
                .setPeekOpacityMode(WatchFaceStyle.PEEK_OPACITY_MODE_TRANSLUCENT)
                .setShowSystemUiTime(true)
                .setShowUnreadCountIndicator(true)
                .setStatusBarGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP)
                .setViewProtectionMode(WatchFaceStyle.PROTECT_HOTWORD_INDICATOR
                        | WatchFaceStyle.PROTECT_STATUS_BAR)
                .build());
    } else {
        inset = getResources().getDimensionPixelOffset(R.dimen.padding_square);
        setWatchFaceStyle(new WatchFaceStyle.Builder(EarthWatchFaceService.this)
                .setHotwordIndicatorGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM)
                .setPeekOpacityMode(WatchFaceStyle.PEEK_OPACITY_MODE_TRANSLUCENT)
                .setShowSystemUiTime(true)
                .setShowUnreadCountIndicator(true)
                .setStatusBarGravity(Gravity.END | Gravity.TOP)
                .setViewProtectionMode(WatchFaceStyle.PROTECT_HOTWORD_INDICATOR
                        | WatchFaceStyle.PROTECT_STATUS_BAR)
                .build());
    }
}
项目:MyCTFWriteUps    文件:ViewCompatLollipop.java   
public static void setOnApplyWindowInsetsListener(View view, OnApplyWindowInsetsListener onapplywindowinsetslistener)
{
    view.setOnApplyWindowInsetsListener(new android.view.View.OnApplyWindowInsetsListener(onapplywindowinsetslistener) {

        final OnApplyWindowInsetsListener val$listener;

        public WindowInsets onApplyWindowInsets(View view1, WindowInsets windowinsets)
        {
            windowinsets = new WindowInsetsCompatApi21(windowinsets);
            return ((WindowInsetsCompatApi21)listener.onApplyWindowInsets(view1, windowinsets)).unwrap();
        }


        {
            listener = onapplywindowinsetslistener;
            super();
        }
    });
}
项目:sunshine-wear-watchface    文件:SunshineWatchFace.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources resources = SunshineWatchFace.this.getResources();
    boolean isRound = insets.isRound();
    mXOffset = resources.getDimension(isRound
            ? R.dimen.digital_x_offset_round : R.dimen.digital_x_offset);
    float textSize = resources.getDimension(isRound
            ? R.dimen.digital_text_size_round : R.dimen.digital_text_size);
    float dateSize = resources.getDimension(isRound
            ? R.dimen.digital_date_text_size_round : R.dimen.digital_date_text_size);
    mHourPaint.setTextSize(textSize);
    mMinutePaint.setTextSize(textSize);
    mMaxTempPaint.setTextSize(textSize);
    mMinTempPaint.setTextSize(textSize);
    mDatePaint.setTextSize(dateSize);
}
项目:Paginize    文件:ContainerViewManager.java   
@TargetApi(20)
public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
  if (insets != null) {
    if (mApplyInsetsToShadow && mShadowView != null) {
      MarginLayoutParams lp = (MarginLayoutParams)mShadowView.getLayoutParams();
      if (lp.topMargin != insets.getSystemWindowInsetTop()) {
        lp.topMargin = insets.getSystemWindowInsetTop();
      }
    }

    final int childCount = getChildCount();
    for (int i = 0; i < childCount; ++i) {
      getChildAt(i).dispatchApplyWindowInsets(insets);
    }
  }
  return insets;
}
项目:gopro-remote    文件:PagerActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pager);
    setAmbientEnabled();
    final Resources res = getResources();
    final GridViewPager pager = ButterKnife.findById(this, R.id.pager);
    pager.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            int rowMargin = res.getDimensionPixelOffset(R.dimen.page_row_margin);
            int colMargin = res.getDimensionPixelOffset(insets.isRound() ? R.dimen.page_column_margin_round : R.dimen.page_column_margin);
            pager.setPageMargins(rowMargin, colMargin);
            return insets;
        }
    });
    adapter = new GridPagerAdapter(getFragmentManager());
    pager.setAdapter(adapter);
    ((DotsPageIndicator) ButterKnife.findById(this, R.id.indicator)).setPager(pager);
}
项目:watchface-utc    文件:UTCWatchFaceService.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "onApplyWindowInsets: " + (insets.isRound() ? "round" : "square"));
    }
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources resources = UTCWatchFaceService.this.getResources();
    mIsRound = insets.isRound();
    float hourTextSize = resources.getDimension(mIsRound
            ? R.dimen.utc_hour_text_size_round : R.dimen.utc_hour_text_size);

    mHourPaint.setTextSize(hourTextSize);
    mUTCLabelPaint.setTextSize(hourTextSize);
}
项目:AndroidWearable-Samples    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final Resources res = getResources();
    final GridViewPager pager = (GridViewPager) findViewById(R.id.pager);
    pager.setOnApplyWindowInsetsListener(new OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            // Adjust page margins:
            //   A little extra horizontal spacing between pages looks a bit
            //   less crowded on a round display.
            final boolean round = insets.isRound();
            int rowMargin = res.getDimensionPixelOffset(R.dimen.page_row_margin);
            int colMargin = res.getDimensionPixelOffset(round ?
                    R.dimen.page_column_margin_round : R.dimen.page_column_margin);
            pager.setPageMargins(rowMargin, colMargin);
            return insets;
        }
    });
    pager.setAdapter(new SampleGridPagerAdapter(this, getFragmentManager()));
}
项目:muzei    文件:MuzeiWatchFace.java   
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);
    mIsRound = insets.isRound();
    Paint.Align textAlign = mIsRound ? Paint.Align.CENTER : Paint.Align.RIGHT;
    mClockPaint.setTextAlign(textAlign);
    mClockAmbientShadowPaint.setTextAlign(textAlign);
    mDateAmbientShadowPaint.setTextAlign(textAlign);
    mDatePaint.setTextAlign(textAlign);
    float textSize = getResources().getDimension(mIsRound
            ? R.dimen.clock_text_size_round
            : R.dimen.clock_text_size);
    mClockPaint.setTextSize(textSize);
    mClockAmbientShadowPaint.setTextSize(textSize);
    recomputeClockTextHeight();
    float dateTextSize = getResources().getDimension(mIsRound
            ? R.dimen.date_text_size_round
            : R.dimen.date_text_size);
    mDatePaint.setTextSize(dateTextSize);
    mDateAmbientShadowPaint.setTextSize(dateTextSize);
    recomputeDateTextHeight();
    updateWatchFaceStyle();
}