This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
canvas.withTranslate(200f, 300f, { | |
drawCircle(...) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Wrap the specified [block] in calls to [Canvas.save]/[Canvas.translate] | |
* and [Canvas.restoreToCount]. | |
*/ | |
inline fun Canvas.withTranslation( | |
x: Float = 0.0f, | |
y: Float = 0.0f, | |
block: Canvas.() -> Unit | |
) { | |
val checkpoint = save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
canvas.save() | |
canvas.translate(200f, 300f) | |
canvas.drawCircle(...) // drawn on the translated canvas | |
canvas.restore() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val translateCheckpoint = canvas.save() | |
canvas.translate(200f, 300f) | |
canvas.drawCircle(150f, 150f, RADIUS, circlePaint) // drawn on the translated canvas | |
val rotateCheckpoint = canvas.save() | |
canvas.rotate(45f) | |
canvas.drawRect(rect, rectPaint) // drawn on the translated and rotated canvas | |
canvas.restoreToCount(rotateCheckpoint) | |
canvas.restoreToCount(translateCheckpoint) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProjectEditorFragment : Fragment { | |
@Inject | |
lateinit var viewModelFactory: ViewModelProvider.Factory | |
private lateinit var viewModel: ProjectEditorViewModel | |
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
val view = inflater.inflate(R.layout.fragment_editor_initial, container, false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProjectEditorViewModel : ViewModel() { | |
private val _state = MutableLiveData<EditorState>() | |
val state: LiveData<EditorState> | |
get() = _state | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package za.co.riggaroo.motionsense | |
import android.app.Activity | |
import android.graphics.Bitmap | |
import android.os.Bundle | |
import android.os.Handler | |
import android.util.Log | |
import android.widget.ImageView | |
import com.google.android.things.pio.Gpio | |
import com.google.android.things.pio.GpioCallback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context | |
import android.graphics.Bitmap | |
import android.graphics.BitmapFactory | |
import android.graphics.ImageFormat | |
import android.graphics.Matrix | |
import android.hardware.camera2.* | |
import android.hardware.camera2.CameraAccessException.CAMERA_ERROR | |
import android.media.ImageReader | |
import android.os.Handler | |
import android.util.Log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/local/bin/bash | |
# Prerequistes: You need to install imagemagick and pdfimages for this script to work | |
# Usage - ./convert_book.sh pdf_name.pdf | |
# output - zip file with images and bookdetails.json file | |
# This script assumes the normal structure of a book dash book and wont work for bigger books or books with different formatting to the standard book dash book | |
# it is always advised to check the output zipped file to ensure its correct | |
folderName=$(basename "$1") | |
folderName="${folderName%.*}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FriendsActivity extends AppCompatActivity { | |
private static final String TAG = "MainActivity"; | |
public static final String FEATURE_FLAG_ADD_FRIENDS = "feature_add_friends"; | |
private FirebaseRemoteConfig remoteConfig; | |
private Button buttonAddFriend; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { |