Skip to content

Instantly share code, notes, and snippets.

Avatar
💜

Rebecca Franks riggaroo

💜
View GitHub Profile
@riggaroo
riggaroo / tools_namespace_example.xml
Last active Nov 2, 2015
Example usage of the tools namespace for creating a meaningful Design View
View tools_namespace_example.xml
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
tools:visibility="visible"
tools:text="Rebecca Franks" />
@riggaroo
riggaroo / BaseResponse.java
Created Apr 13, 2016
Retrofit 2.0 - Parsing Error Responses
View BaseResponse.java
public static BaseResponseDto parseError(Response<?> response) {
Converter<ResponseBody, BaseResponseDto> converter =
Injection.getRetrofitInstance()
.responseBodyConverter(BaseResponseDto.class, new Annotation[0]);
BaseResponseDto error;
try {
error = converter.convert(response.errorBody());
} catch (IOException e) {
View keybase.md

Keybase proof

I hereby claim:

  • I am riggaroo on github.
  • I am riggaroo (https://keybase.io/riggaroo) on keybase.
  • I have a public key ASBwdwxxd9GeCz_wXXJYp-hWBxALsHCP9wZLUxYZpcx2cAo

To claim this, I am signing this object:

@riggaroo
riggaroo / FriendsActivity.java
Last active Nov 23, 2016
Firebase Staged Rollout Features - Sample Gist showing how to use Firebase Remote Config for stage rollout of features.
View FriendsActivity.java
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) {
@riggaroo
riggaroo / create_bookdashbook.sh
Last active Jan 8, 2017
Script for creating book dash books from PDF for android app.
View create_bookdashbook.sh
#/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%.*}"
View CustomCamera.kt
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
View MotionSensorMainActivity.kt
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
@riggaroo
riggaroo / ProjectEditorViewModel.kt
Created Feb 2, 2019
ProjectEditorViewModel using AndroidViewModel, exposing UI state
View ProjectEditorViewModel.kt
class ProjectEditorViewModel : ViewModel() {
private val _state = MutableLiveData<EditorState>()
val state: LiveData<EditorState>
get() = _state
}
@riggaroo
riggaroo / ProjectEditorFragment.kt
Last active Feb 3, 2019
ProjectEditorFragment showing how to use ViewModels to restore state.
View ProjectEditorFragment.kt
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)
@riggaroo
riggaroo / CustomView-Snippet2.kt
Last active Mar 21, 2019
Custom Drawing on Canvas without KTX
View CustomView-Snippet2.kt
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)