Skip to content

Commit 4b77a37

Browse files
committed
JAX updates from the Android presetation
1 parent 5a9cfce commit 4b77a37

33 files changed

Lines changed: 67 additions & 48 deletions

File tree

com.vogella.android.actionbar.navigationdrawer/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
1212

1313
# Project target.
14-
target=android-17
14+
target=android-19

com.vogella.android.animation.views/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
# project structure.
99

1010
# Project target.
11-
target=android-17
11+
target=android-19

com.vogella.android.customview.canvas/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
1212

1313
# Project target.
14-
target=android-17
14+
target=android-19
3.9 KB
Loading
23.6 KB
Loading

com.vogella.android.customview.canvas/res/layout/activity_main.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
android:layout_height="match_parent"
55
tools:context=".MainActivity" >
66

7-
<TextView
7+
<com.vogella.android.customview.canvas.DrawingView
8+
android:id="@+id/drawingView1"
9+
android:background="@drawable/splash1"
810
android:layout_width="wrap_content"
911
android:layout_height="wrap_content"
1012
android:layout_centerHorizontal="true"
11-
android:layout_centerVertical="true"
12-
android:text="@string/hello_world" />
13+
android:layout_centerVertical="true" />
1314

1415
</RelativeLayout>

com.vogella.android.customview.canvas/src/com/vogella/android/customview/canvas/DrawingView.java

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.vogella.android.customview.canvas;
22

33
import java.util.ArrayList;
4+
import java.util.Iterator;
45
import java.util.List;
56
import java.util.Random;
67

@@ -21,7 +22,6 @@ public class DrawingView extends View {
2122
/** Need to track this so the dirty region can accommodate the stroke. **/
2223
private static final float HALF_STROKE_WIDTH = STROKE_WIDTH / 2;
2324

24-
private Paint paint = new Paint();
2525
private List<Path> paths = new ArrayList<Path>();
2626
private List<Paint> paints = new ArrayList<Paint>();
2727

@@ -34,7 +34,7 @@ public class DrawingView extends View {
3434

3535
private int[] colors;
3636

37-
private Path path;
37+
private Path path = new Path();
3838

3939
private int nextColor;
4040

@@ -45,13 +45,19 @@ public DrawingView(Context context, AttributeSet attrs) {
4545

4646
colors = new int[] { Color.BLUE, Color.CYAN, Color.GREEN,
4747
Color.MAGENTA, Color.YELLOW, Color.RED, Color.WHITE };
48+
4849
random = new Random();
4950
nextColor = random.nextInt(colors.length);
50-
paint.setAntiAlias(true);
51-
paint.setColor(Color.WHITE);
52-
paint.setStyle(Paint.Style.STROKE);
53-
paint.setStrokeJoin(Paint.Join.ROUND);
54-
paint.setStrokeWidth(STROKE_WIDTH);
51+
for (int i = 0; i < colors.length; i++) {
52+
Paint paint = new Paint();
53+
paint.setAntiAlias(true);
54+
paint.setColor(colors[i]);
55+
paint.setStyle(Paint.Style.STROKE);
56+
paint.setStrokeJoin(Paint.Join.ROUND);
57+
paint.setStrokeWidth(STROKE_WIDTH);
58+
paints.add(paint);
59+
}
60+
5561
}
5662

5763
/**
@@ -67,10 +73,16 @@ public void clear() {
6773

6874
@Override
6975
protected void onDraw(Canvas canvas) {
70-
canvas.drawARGB(50, 255, 0, 0);
76+
if (isInEditMode()) {
77+
canvas.drawARGB(255, 255, 0, 0);
78+
}
79+
super.onDraw(canvas);
7180
int i = 0;
7281
for (Path path : paths) {
7382
canvas.drawPath(path, paints.get(i++));
83+
if (i == paints.size()) {
84+
i = 0;
85+
}
7486
}
7587
}
7688

@@ -81,16 +93,15 @@ public boolean onTouchEvent(MotionEvent event) {
8193

8294
switch (event.getAction()) {
8395
case MotionEvent.ACTION_DOWN:
96+
path = new Path();
97+
paths.add(path);
8498
path.moveTo(eventX, eventY);
8599
return true;
86100

87101
case MotionEvent.ACTION_MOVE:
102+
path.lineTo(eventX, eventY);
88103
case MotionEvent.ACTION_UP:
89-
90-
path.lineTo(x, y);
91-
92104
// After replaying history, connect the line to the touch point.
93-
path.lineTo(eventX, eventY);
94105
break;
95106

96107
default:

com.vogella.android.customview.canvas/src/com/vogella/android/customview/canvas/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class MainActivity extends Activity {
99
@Override
1010
protected void onCreate(Bundle savedInstanceState) {
1111
super.onCreate(savedInstanceState);
12-
setContentView(new SignatureView(this, null));
12+
setContentView(R.layout.activity_main);
1313
}
1414

1515
@Override
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3+
org.eclipse.jdt.core.compiler.compliance=1.6
4+
org.eclipse.jdt.core.compiler.source=1.6

com.vogella.android.customview.compoundview/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
1212

1313
# Project target.
14-
target=android-17
14+
target=android-19

0 commit comments

Comments
 (0)