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 ofReactiveX
in Java.RxJava
is a Java VM implementation ofReactiveX
(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
andSubscriber
. - `O
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/bash | |
#hi | |
SAVEIFS=$IFS | |
IFS=$(echo -en "\n\b") | |
for rootFolder in */ ; do | |
if [ -d $rootFolder"build" ]; then | |
echo "do you want to delete build folders of \"${rootFolder%?}\" project?" | |
read ans | |
if [ "$ans" = "y" ] || [ "$ans" = "Y" ]; then |
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 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()) { |
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 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))); |
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/bash | |
#hi | |
echo [UBUNTU PASSWORD] | sudo -S ls | |
INPUT_NUMBER=$1 | |
SERVER_URL="" | |
case $INPUT_NUMBER in | |
1) SERVER_URL="us2.cisadd3.com:800" ;; | |
2) SERVER_URL="de.cisadd3.com:800" ;; | |
3) SERVER_URL="uk.cisadd2.com" ;; | |
4) SERVER_URL="nl.cisadd2.com" ;; |
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
/** | |
* Let's say we want to display a list of Animals in a RecyclerView. | |
* The list can contain items of type Dog, Cat and Snake. | |
*/ | |
// AdapterDelegate for Dog. | |
fun dogAdapterDelegate(picasso : Picasso) = adapterDelegate<Dog, Animal>(R.layout.item_dog){ // Generics Types means this AdapterDelegate is used if item is instanceof Dog (whole list is List<Anmial>) | |
// this block is run once in onCreateViewHolder. Think of it as an intializer for a ViewHolder. | |
val name = findViewById(R.id.name) | |
val image = findViewById(R.id.image) |
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 VerticalTimelineDecoration extends RecyclerView.ItemDecoration { | |
Paint paintFill = null; | |
Paint paintStrokeFill = null; | |
Paint paintStroke = null; | |
Paint paintDotLine = null; | |
Paint paintText=null; | |
Paint paintTextBold=null; |
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
/** | |
* 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; |
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 com.androidrecipes.downloader; | |
import android.app.Activity; | |
import android.app.DownloadManager; | |
import android.content.BroadcastReceiver; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.content.IntentFilter; | |
import android.content.SharedPreferences; | |
import android.database.Cursor; |
OlderNewer