afohrman a10070b6b3 Unify the creation of default CornerTreatments and EdgeTreatments.
Change the default CornerTreatment created in MaterialShapeUtils from CornerTreatment() to RoundedCornerTreatment(0). This matches the default previously created from ShapeAppearanceModel constructors.

This change unifies the defaults created in ShapeAppearanceModel's constructors with the default created by MaterialShapeUtils, by converging the two default corner and edge treatment creation methods into one method in MaterialShapeUtils. That method is then called from MaterialShapeUtils#createCornerTreatment#createCornerTreatment() and ShapeAppearanceModel's constructors.

This change also renames getDefaultCornerTreatment() to createDefaultCornerTreatment() to convey that the method instantiates an object.

PiperOrigin-RevId: 222269551
2018-12-06 11:15:10 -05:00

45 lines
1.4 KiB
Java

/*
* Copyright 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.material.shape;
import android.support.annotation.RestrictTo;
import android.support.annotation.RestrictTo.Scope;
/** Utility methods for {@link MaterialShapeDrawable} and related classes. */
@RestrictTo(Scope.LIBRARY_GROUP)
public class MaterialShapeUtils {
static CornerTreatment createCornerTreatment(@CornerFamily int cornerFamily, int cornerSize) {
switch (cornerFamily) {
case CornerFamily.ROUNDED:
return new RoundedCornerTreatment(cornerSize);
case CornerFamily.CUT:
return new CutCornerTreatment(cornerSize);
default:
return createDefaultCornerTreatment();
}
}
static CornerTreatment createDefaultCornerTreatment() {
return new RoundedCornerTreatment(0);
}
static EdgeTreatment createDefaultEdgeTreatment() {
return new EdgeTreatment();
}
}