Skip to content

Instantly share code, notes, and snippets.

View rezaiyan's full-sized avatar
👋

Ali Rezaiyan rezaiyan

👋
View GitHub Profile
@staltz
staltz / music.md
Last active September 29, 2023 15:42
coding music

Not for everyone. Each programmer has their own appreciation of what is good coding music.

For when I need to think deep, debug something, or design

(From most influential to least)

public class PermissionUtil {
/*
* Check if version is marshmallow and above.
* Used in deciding to ask runtime permission
* */
public static boolean shouldAskPermission() {
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M);
}
private static boolean shouldAskPermission(Context context, String permission){
if (shouldAskPermission()) {
  • Functional Programming is a model of programming that transform and compose stream of immutable sequences by applying map, filter and reduce. Events are immutable because you can't change history.
  • Reactive Programming is a model of programming focuses on data flow and change propagation.
  • ReactiveX is an API that focuses on asynchronous composition and manipulation of observable streams of data or events by using a combination of the Observer pattern, Iterator pattern, and features of Functional Programming.
  • RxJava is the open-source implementation of ReactiveX in Java.
  • RxJava is a Java VM implementation of ReactiveX (Reactive Extensions): a library for composing asynchronous and event-based programs by using observable sequences.
  • RxAndroid is a lightweight extension to RxJava that providers a Scheduler for Android’s Main Thread, as well as the ability to create a Scheduler that runs on any given Android Handler class.
  • The two main classes are Observable and Subscriber.
  • `O
#
# Circle CI & gradle.properties live in harmony
#
# Android convention is to store your API keys in a local, non-versioned
# gradle.properties file. Circle CI doesn't allow users to upload pre-populated
# gradle.properties files to store this secret information, but instaed allows
# users to store such information as environment variables.
#
# This script creates a local gradle.properties file on current the Circle CI
# instance. It then reads environment variable TEST_API_KEY_ENV_VAR which a user
@danylovolokh
danylovolokh / repeatWhen_takeUntil_filter_example.java
Last active February 21, 2021 23:56
Server polling and retry operations when failed. With Retrofit and RxJava.
/**
* This is a class that should be
* mapped on your json response from the server
*/
class ServerPollingResponse {
boolean isJobDone;
@Override
public String toString() {
return "isJobDone=" + isJobDone;
@riggaroo
riggaroo / RestServiceMockUtils.java
Last active May 1, 2021 17:52
Mocking API Responses using a Retrofit Client in Android
public class RestServiceMockUtils {
public static String convertStreamToString(InputStream is) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line).append("\n");
}
reader.close();
@wenzhixin
wenzhixin / ubuntu14.04-command-line-install-android-sdk
Last active January 16, 2024 21:15
Ubuntu 14.04 command line install android sdk
# install openjdk
sudo apt-get install openjdk-7-jdk
# download android sdk
wget http://dl.google.com/android/android-sdk_r24.2-linux.tgz
tar -xvf android-sdk_r24.2-linux.tgz
cd android-sdk-linux/tools
# install all sdk packages
@john990
john990 / SelectImage.java
Created March 27, 2015 06:54
android select image from gallery or camera, and crop
private String cameraFileName;
@Override
public void choiceAvatarFromCamera() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraFileName = Constants.DOWNLOAD_IMAGE_PATH + System.currentTimeMillis();
File file = new File(Constants.DOWNLOAD_IMAGE_PATH);
if(!file.exists()){
file.mkdirs();
}
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(cameraFileName)));
@homj
homj / GridSpanSizeLookupHelper.java
Last active June 30, 2022 02:39
A ItemDecoration to center the contents of a RecyclerView. This comes in handy when you want to build a responsive UI.
/*
* Copyright 2015 Johannes Homeier
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing