I needed to be able to filter which items of a ManyRelatedField
were returned, based on some attributes of the request user. Normally, all items in the relationship are returned, however I was able to override the ManyRelatedField.to_attribute()
function to enable additional filtering of the relationship.
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 MyServiceImpl extends DeviceServiceGrpc.DeviceServiceImplBase { | |
@Override | |
public StreamObserver<GetLocationRequest> getLocations(StreamObserver<GetLocationResponse> responseObserver) { | |
RequestBridge<GetLocationRequest> request = new RequestBridge<>(); | |
ResponseBridge response = new ResponseBridge((ServerCallStreamObserver) responseObserver); | |
request.map(this::doGetLocation) | |
.subscribe(response); | |
return request; | |
} |
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 ClickToSelectEditText <T> extends AppCompatEditText { | |
CharSequence mHint; | |
OnItemSelectedListener<T> onItemSelectedListener; | |
ListAdapter mSpinnerAdapter; | |
public ClickToSelectEditText(Context context) { | |
super(context); | |
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
// The following code allows an app to report Crashlytics crashes separately | |
// for release and debug buildTypes when using Gradle. This code should be inserted | |
// into the specified locations within your build.gradle (Module:app) file | |
// The buildTypes { } block should be inserted inside the android { } block | |
buildTypes { | |
release { | |
minifyEnabled false | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
ext.crashlyticsApiSecret = "release api secret" |
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.content.res.TypedArray; | |
import android.graphics.Canvas; | |
import android.graphics.drawable.Drawable; | |
import android.util.AttributeSet; | |
import android.widget.ImageView; | |
public class ForegroundImageView extends ImageView { | |
private Drawable foreground; |
#Intro
Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3
Kotlin project website is at kotlin.jetbrains.org.
All the codes here can be copied and run on Kotlin online editor.
Let's get started.