Merge pull request #8 from adnio/master
Added clear canvas functionality
This commit is contained in:
commit
0cb1d29776
4 changed files with 15 additions and 0 deletions
|
@ -85,6 +85,13 @@ public class MyCanvas extends View {
|
|||
canvas.drawPath(mPath, mPaint);
|
||||
}
|
||||
|
||||
public void clearCanvas(){
|
||||
mPath = new Path();
|
||||
mPaths = new LinkedHashMap<>();
|
||||
pathsUpdated();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private void actionDown(float x, float y) {
|
||||
mPath.reset();
|
||||
mPath.moveTo(x, y);
|
||||
|
|
|
@ -84,6 +84,9 @@ public class MainActivity extends SimpleActivity implements MyCanvas.PathsChange
|
|||
case R.id.settings:
|
||||
startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
|
||||
return true;
|
||||
case R.id.clear:
|
||||
mMyCanvas.clearCanvas();
|
||||
return true;
|
||||
case R.id.about:
|
||||
startActivity(new Intent(getApplicationContext(), AboutActivity.class));
|
||||
return true;
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
android:id="@+id/settings"
|
||||
android:title="@string/settings"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/clear"
|
||||
android:title="@string/clear"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/about"
|
||||
android:title="@string/about"
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
<!-- Settings -->
|
||||
<string name="settings">Settings</string>
|
||||
<string name="clear">Clear</string>
|
||||
<string name="dark_theme">Dark theme</string>
|
||||
|
||||
<!-- About -->
|
||||
|
|
Loading…
Reference in a new issue