-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathUtils.java
More file actions
39 lines (32 loc) · 1.07 KB
/
Copy pathUtils.java
File metadata and controls
39 lines (32 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.futuremind.recyclerviewfastscroll;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.View;
/**
* Created by mklimczak on 31/07/15.
*/
public class Utils {
public static float getViewRawY(View view) {
int[] location = new int[2];
location[1] = (int) view.getY();
((View)view.getParent()).getLocationInWindow(location);
return location[1];
}
public static float getViewRawX(View view) {
int[] location = new int[2];
location[0] = (int) view.getX();
((View)view.getParent()).getLocationInWindow(location);
return location[0];
}
public static float getValueInRange(float min, float max, float value) {
float minimum = Math.max(min, value);
return Math.min(minimum, max);
}
public static void setBackground(View view, Drawable drawable){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
view.setBackground(drawable);
} else {
view.setBackgroundDrawable(drawable);
}
}
}