Add comments to the CreateSudokuSpecialButtonLayout and SudokuSpecialButtonLayout class

This commit is contained in:
uykek 2020-08-10 11:53:49 +02:00
parent 6f14b1fffd
commit f6948f8aeb
2 changed files with 8 additions and 0 deletions

View file

@ -181,6 +181,7 @@ public class CreateSudokuSpecialButtonLayout extends LinearLayout implements IHi
break; break;
case NoteToggle: case NoteToggle:
Drawable drawable = ContextCompat.getDrawable(context, fixedButtons[i].getType().getResID()); Drawable drawable = ContextCompat.getDrawable(context, fixedButtons[i].getType().getResID());
// prepare canvas for the rotation of the note drawable
setUpVectorDrawable(drawable); setUpVectorDrawable(drawable);
canvas.rotate(gameController.getNoteStatus() ? 45.0f : 0.0f, bitMap.getWidth()/2, bitMap.getHeight()/2); canvas.rotate(gameController.getNoteStatus() ? 45.0f : 0.0f, bitMap.getWidth()/2, bitMap.getHeight()/2);
@ -199,6 +200,9 @@ public class CreateSudokuSpecialButtonLayout extends LinearLayout implements IHi
} }
} }
/*
Set up the vector drawables so that they can be properly displayed despite using theme attributes for their fill color
*/
private void setUpVectorDrawable(Drawable drawable) { private void setUpVectorDrawable(Drawable drawable) {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
bitMap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), bitMap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),

View file

@ -194,6 +194,7 @@ public class SudokuSpecialButtonLayout extends LinearLayout implements IHighligh
break; break;
case NoteToggle: case NoteToggle:
Drawable drawable = ContextCompat.getDrawable(context, fixedButtons[i].getType().getResID()); Drawable drawable = ContextCompat.getDrawable(context, fixedButtons[i].getType().getResID());
// prepare canvas for the rotation of the note drawable
setUpVectorDrawable(drawable); setUpVectorDrawable(drawable);
canvas.rotate(gameController.getNoteStatus() ? 45.0f : 0.0f, bitMap.getWidth()/2, bitMap.getHeight()/2); canvas.rotate(gameController.getNoteStatus() ? 45.0f : 0.0f, bitMap.getWidth()/2, bitMap.getHeight()/2);
@ -212,6 +213,9 @@ public class SudokuSpecialButtonLayout extends LinearLayout implements IHighligh
} }
} }
/*
Set up the vector drawables so that they can be properly displayed despite using theme attributes for their fill color
*/
private void setUpVectorDrawable(Drawable drawable) { private void setUpVectorDrawable(Drawable drawable) {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
bitMap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), bitMap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),