Skip to content
This repository has been archived by the owner on Jun 28, 2020. It is now read-only.

Commit

Permalink
supporting sdk from 14
Browse files Browse the repository at this point in the history
  • Loading branch information
romtsn committed Jan 13, 2017
1 parent 10081e9 commit afce3ea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.rom4ek.arcnavigationview;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
Expand Down Expand Up @@ -64,6 +65,7 @@ public void init(Context context, AttributeSet attrs) {
THRESHOLD = Math.round(ArcViewSettings.dpToPx(getContext(), 15)); //some threshold for child views while remeasuring them
}

@SuppressLint("RtlHardcoded")
private Path createClipPath() {
final Path path = new Path();
arcPath = new Path();
Expand Down Expand Up @@ -154,20 +156,21 @@ private void calculateLayoutAndChildren() {
width = getMeasuredWidth();
if (width > 0 && height > 0) {
clipPath = createClipPath();
ViewCompat.setElevation(this, settings.getElevation());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setOutlineProvider(new ViewOutlineProvider() {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void getOutline(View view, Outline outline) {
if (clipPath.isConvex()) {
outline.setConvexPath(clipPath);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
ViewCompat.setElevation(this, settings.getElevation());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setOutlineProvider(new ViewOutlineProvider() {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void getOutline(View view, Outline outline) {
if (clipPath.isConvex()) {
outline.setConvexPath(clipPath);
}
}
}
});
});
}
}

// if (settings.isCropInside()) {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View v = getChildAt(i);
Expand All @@ -178,15 +181,18 @@ public void getOutline(View view, Outline outline) {
} else {
v.setBackgroundDrawable(settings.getBackgroundDrawable());
}
ViewCompat.setElevation(v, settings.getElevation());

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
ViewCompat.setElevation(v, settings.getElevation());
}
//TODO: adjusting child views to new width in their rightmost/leftmost points related to path
// adjustChildViews((ViewGroup) v);
}
}
}
}

@SuppressWarnings("unused")
@SuppressLint("RtlHardcoded")
private void adjustChildViews(ViewGroup container) {
final int containerChildCount = container.getChildCount();
PathMeasure pathMeasure = new PathMeasure(arcPath, false);
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ allprojects {
ext {
sdk = 25
buildTools = "25.0.1"
minSdk = 16
libraryVersion = "1.0.1"
minSdk = 14
libraryVersion = "1.0.2"
supportVersion = "25.1.0"
}

0 comments on commit afce3ea

Please sign in to comment.