Skip to content

Commit

Permalink
Merge pull request #21 from MertNYuksel/master
Browse files Browse the repository at this point in the history
Disable viewoutlineprovider on pre lollipop devices
  • Loading branch information
iammert authored May 24, 2018
2 parents d1906af + 7dd5d70 commit a599796
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public class ScalingLayout extends FrameLayout {
/**
* CustomOutline for elevation shadows
*/
@Nullable
private ScalingLayoutOutlineProvider viewOutline;


Expand Down Expand Up @@ -153,7 +154,9 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
settings.initialize(w, h);
currentWidth = w;
currentRadius = settings.getMaxRadius();
viewOutline = new ScalingLayoutOutlineProvider(w, h, currentRadius);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
viewOutline = new ScalingLayoutOutlineProvider(w, h, currentRadius);
}
}

rectF.set(0, 0, w, h);
Expand Down Expand Up @@ -232,11 +235,11 @@ public void setListener(ScalingLayoutListener scalingLayoutListener) {
* @param radius
*/
private void updateViewOutline(int height, int width, float radius) {
viewOutline.setHeight(height);
viewOutline.setWidth(width);
viewOutline.setRadius(radius);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && ViewCompat.getElevation(this) > 0f) {
try {
viewOutline.setHeight(height);
viewOutline.setWidth(width);
viewOutline.setRadius(radius);
setOutlineProvider(viewOutline);
} catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package iammert.com.view.scalinglib;

import android.graphics.Outline;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.view.View;
import android.view.ViewOutlineProvider;

/**
* Created by mertsimsek on 08/01/2018.
*/
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class ScalingLayoutOutlineProvider extends ViewOutlineProvider {

private int width;
Expand Down

0 comments on commit a599796

Please sign in to comment.