Skip to content

Commit 282dc9a

Browse files
author
Ivan Navas
committed
Merge branch 'master' into develop
Conflicts: MaterialDesign/src/com/gc/materialdesign/views/Slider.java
2 parents 525b7a9 + 9324f50 commit 282dc9a

File tree

5 files changed

+509
-472
lines changed

5 files changed

+509
-472
lines changed

MaterialDesign/src/com/gc/materialdesign/views/CheckBox.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import android.view.MotionEvent;
1717
import android.view.View;
1818
import android.widget.RelativeLayout;
19+
import android.widget.TextView;
1920

2021
public class CheckBox extends CustomView {
2122

@@ -70,20 +71,45 @@ public void run() {
7071
});
7172

7273
checkView = new Check(getContext());
74+
checkView.setId(View.generateViewId());
7375
RelativeLayout.LayoutParams params = new LayoutParams(Utils.dpToPx(20,
7476
getResources()), Utils.dpToPx(20, getResources()));
7577
params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
7678
checkView.setLayoutParams(params);
7779
addView(checkView);
7880

81+
// Adding text view to checkbox
82+
int textResource = attrs.getAttributeResourceValue(ANDROIDXML, "text", -1);
83+
String text = null;
84+
85+
if(textResource != -1) {
86+
text = getResources().getString(textResource);
87+
} else {
88+
text = attrs.getAttributeValue(ANDROIDXML, "text");
89+
}
90+
91+
if(text != null) {
92+
params.removeRule(RelativeLayout.CENTER_IN_PARENT);
93+
params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
94+
TextView textView = new TextView(getContext());
95+
RelativeLayout.LayoutParams textViewLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
96+
LayoutParams.WRAP_CONTENT);
97+
textViewLayoutParams.addRule(RelativeLayout.RIGHT_OF, checkView.getId());
98+
textViewLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
99+
textViewLayoutParams.setMargins(10, 0, 0, 0);
100+
textView.setLayoutParams(textViewLayoutParams);
101+
textView.setText(text);
102+
103+
addView(textView);
104+
}
79105
}
80-
106+
81107
@Override
82108
public void invalidate() {
83109
checkView.invalidate();
84110
super.invalidate();
85111
}
86-
112+
87113

88114
@Override
89115
public boolean onTouchEvent(MotionEvent event) {
@@ -137,7 +163,7 @@ private void changeBackgroundColor(int color) {
137163

138164
/**
139165
* Make a dark color to press effect
140-
*
166+
*
141167
* @return
142168
*/
143169
protected int makePressColor() {

MaterialDesign/src/com/gc/materialdesign/views/ProgressBarIndeterminate.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ public void onAnimationEnd(Animator arg0) {
3636
// Repeat animation
3737
ViewHelper.setX(progressView,-progressView.getWidth()/2);
3838
cont += suma;
39-
ObjectAnimator anim2Repeat = ObjectAnimator.ofFloat(progressView, "x", getWidth());
40-
anim2Repeat.setDuration(duration/cont);
41-
anim2Repeat.addListener(this);
42-
anim2Repeat.start();
39+
try {
40+
ObjectAnimator anim2Repeat = ObjectAnimator.ofFloat(progressView, "x", getWidth());
41+
anim2Repeat.setDuration(duration/cont);
42+
anim2Repeat.addListener(this);
43+
anim2Repeat.start();
44+
} catch (java.lang.ArrayIndexOutOfBoundsException e) {
45+
// ignore this error that sometimes comes from the NineOldAndroids 2.4 library
46+
}
4347
if(cont == 3 || cont == 1) suma *=-1;
4448

4549
}

0 commit comments

Comments
 (0)