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
#!/bin/zsh | |
function get_devices() { | |
all_devices=$(command adb devices) | |
all_devices=${all_devices#"List of devices attached"} | |
# Find how many devices we have | |
num_matches=$(echo $all_devices | egrep -o "([[:alnum:]-]+[[:space:]]+device$)" | wc -l) | |
# If there are multiple, ask for which device to send the command to |
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
private fun ImageFile.toAttachment(): Attachment { | |
return Attachment().also { | |
it.fileName = imageName | |
it.updateTime = updateTime | |
} | |
} |
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
data class KotlinAttachment ( | |
var fileName: String = "default-kotlin-file-name", | |
var updateTime: String = "1970/1/1" | |
) | |
fun ImageFile.toKotlinAttachment(): KotlinAttachment { | |
return KotlinAttachment().apply { | |
fileName = imageName | |
updateTime = updateTime // self-assignment warning |
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
fun ImageFile.toAttachment(): Attachment { | |
return Attachment().apply { | |
fileName = imageName | |
updateTime = updateTime // No self-assignment warning | |
} | |
} |
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
data class ImageFile ( | |
val imageName: String, | |
val imageType: Int, | |
val updateTime: String | |
) |
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 Attachment { | |
public String getFileName() { | |
return fileName; | |
} | |
public void setFileName(String fileName) { | |
this.fileName = fileName; | |
} |
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 RxSearchObservable { | |
public static Observable<String> fromView(SearchView searchView) { | |
final PublishSubject<String> subject = PublishSubject.create(); | |
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { | |
@Override | |
public boolean onQueryTextSubmit(String s) { | |
subject.onComplete(); |
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 com.yourpackage.model.Price | |
import com.yourpackage.model.Ticket | |
import io.reactivex.Single | |
import retrofit2.http.GET | |
import retrofit2.http.Query | |
interface ApiService { | |
@GET("airline/tickets") | |
fun searchTickets(@Query("from") from: String, @Query("to") to: String): Single<List<Ticket>> |
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 com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory | |
import info.androidhive.flighttickets.app.Const | |
import okhttp3.OkHttpClient | |
import okhttp3.logging.HttpLoggingInterceptor | |
import retrofit2.Retrofit | |
import retrofit2.converter.gson.GsonConverterFactory | |
import java.util.concurrent.TimeUnit | |
// Use as val apiService = ApiClient.client?.create(ApiService::class.java) |
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
curl -X POST \ | |
-H "Authorization: key= YOUR-API-KEY" \ | |
-H "Content-Type: application/json" \ | |
-d '{ | |
"registration_ids": [ | |
"YOUR-GCM-REGISTRATION-ID" | |
], | |
"data": { | |
"message": "Hello Message" | |
}, |
NewerOlder