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.mindorks.snaphelperexample.ui.common; | |
import android.support.annotation.NonNull; | |
import android.support.annotation.Nullable; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.LinearSnapHelper; | |
import android.support.v7.widget.OrientationHelper; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.View; |
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 BoardDefaults { | |
private static final String DEVICE_EDISON_ARDUINO = "edison_arduino"; | |
private static final String DEVICE_EDISON = "edison"; | |
private static final String DEVICE_RPI3 = "rpi3"; | |
private static final String DEVICE_NXP = "imx6ul"; | |
private static String sBoardVariant = ""; | |
/** | |
* Return the GPIO pin that the LED is connected on. | |
* For example, on Intel Edison Arduino breakout, pin "IO13" is connected to an onboard LED |
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 void onCreate() { | |
if (DEVELOPER_MODE) { | |
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() | |
.detectDiskReads() | |
.detectDiskWrites() | |
.detectNetwork() // or .detectAll() for all detectable problems | |
.penaltyLog() | |
.build()); | |
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() | |
.detectLeakedSqlLiteObjects() |
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
@Target(ElementType.METHOD) | |
@Retention(RetentionPolicy.RUNTIME) | |
@interface Status { | |
public enum Priority {LOW, MEDIUM, HIGH} | |
Priority priority() default Priority.LOW; | |
String author() default “Amit”; | |
int completion() default 0; | |
} |
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
Class foo = Foo.class; | |
for(Method method : foo.getMethods()) { | |
Status statusAnnotation = (Status)method.getAnnotation(Status.class); | |
if(statusAnnotation != null) { | |
System.out.println(" Method Name : " + method.getName()); | |
System.out.println(" Author : " + statusAnnotation.author()); | |
System.out.println(" Priority : " + statusAnnotation.priority()); | |
System.out.println(" Completion Status : " + statusAnnotation.completion()); | |
} | |
} |
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 CompositeDisposableExampleActivity extends AppCompatActivity { | |
private final CompositeDisposable disposables = new CompositeDisposable(); | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
doSomeWork(); | |
} | |
@Override |
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
/* | |
* First of all we are getting my friends list from | |
* server, then by using flatMap we are emitting users | |
* one by one and then after applying filter we are | |
* returning only those who are following me one by one. | |
*/ | |
/* | |
* This observable return the list of User who are my friends | |
*/ |
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 observable return the list of User who loves cricket | |
*/ | |
private Observable<List<User>> getCricketFansObservable() { | |
return RxAndroidNetworking.get("https://fierce-cove-29863.herokuapp.com/getAllCricketFans") | |
.build() | |
.getObjectListObservable(User.class); | |
} | |
/* |
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
RxAndroidNetworking.get("https://fierce-cove-29863.herokuapp.com/getAnUser/{userId}") | |
.addPathParameter("userId", "1") | |
.build() | |
.getObjectObservable(ApiUser.class) // This returns you an Observable | |
.subscribeOn(Schedulers.io()) // do the network call on another thread | |
.observeOn(AndroidSchedulers.mainThread()) // return the result in mainThread | |
.map(new Func1<ApiUser, User>() { | |
@Override | |
public User call(ApiUser apiUser) { | |
// here we get ApiUser from server |