Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a599796

Browse files
authoredMay 24, 2018
Merge pull request #21 from MertNYuksel/master
Disable viewoutlineprovider on pre lollipop devices
2 parents d1906af + 7dd5d70 commit a599796

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed
 

‎scalinglib/src/main/java/iammert/com/view/scalinglib/ScalingLayout.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public class ScalingLayout extends FrameLayout {
7878
/**
7979
* CustomOutline for elevation shadows
8080
*/
81+
@Nullable
8182
private ScalingLayoutOutlineProvider viewOutline;
8283

8384

@@ -153,7 +154,9 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
153154
settings.initialize(w, h);
154155
currentWidth = w;
155156
currentRadius = settings.getMaxRadius();
156-
viewOutline = new ScalingLayoutOutlineProvider(w, h, currentRadius);
157+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
158+
viewOutline = new ScalingLayoutOutlineProvider(w, h, currentRadius);
159+
}
157160
}
158161

159162
rectF.set(0, 0, w, h);
@@ -232,11 +235,11 @@ public void setListener(ScalingLayoutListener scalingLayoutListener) {
232235
* @param radius
233236
*/
234237
private void updateViewOutline(int height, int width, float radius) {
235-
viewOutline.setHeight(height);
236-
viewOutline.setWidth(width);
237-
viewOutline.setRadius(radius);
238238
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && ViewCompat.getElevation(this) > 0f) {
239239
try {
240+
viewOutline.setHeight(height);
241+
viewOutline.setWidth(width);
242+
viewOutline.setRadius(radius);
240243
setOutlineProvider(viewOutline);
241244
} catch (Exception e) {
242245
e.printStackTrace();

‎scalinglib/src/main/java/iammert/com/view/scalinglib/ScalingLayoutOutlineProvider.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package iammert.com.view.scalinglib;
22

33
import android.graphics.Outline;
4+
import android.os.Build;
5+
import android.support.annotation.RequiresApi;
46
import android.view.View;
57
import android.view.ViewOutlineProvider;
68

79
/**
810
* Created by mertsimsek on 08/01/2018.
911
*/
12+
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
1013
public class ScalingLayoutOutlineProvider extends ViewOutlineProvider {
1114

1215
private int width;

0 commit comments

Comments
 (0)
Please sign in to comment.