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.text.SpannableStringBuilder | |
import android.text.Spanned.SPAN_INCLUSIVE_EXCLUSIVE | |
import java.util.ArrayDeque | |
import java.util.Deque | |
// https://gist.github.com/JakeWharton/11274467 | |
public class Truss { | |
private val builder: SpannableStringBuilder = SpannableStringBuilder() | |
private val stack: Deque<Span> = ArrayDeque() |
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
void fetchTopTrendingList() { | |
OkHttpClient okHttpClient = new OkHttpClient.Builder() | |
.addNetworkInterceptor(new StethoInterceptor()) | |
.build(); | |
Retrofit retrofit = new Retrofit.Builder() | |
.baseUrl(BuildConfig.SERVER_URL) | |
.client(okHttpClient) | |
.addConverterFactory(GsonConverterFactory.create()) | |
.addCallAdapterFactory(RxJava2CallAdapterFactory.create()) |
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 java.lang.reflect.Method; | |
import java.lang.reflect.Field; | |
import java.lang.reflect.Modifier; | |
import java.lang.reflect.Constructor; | |
class ReflectionExample { | |
public static void main(String args[]) throws Exception { | |
// Examining & constructing object for Test class at runtime | |
Class<?> clazz = Class.forName("Test"); | |
Test test = (Test) clazz.newInstance(); |
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
void getNowPlayingMovies() { | |
Retrofit retrofit = new Retrofit.Builder() | |
.baseUrl(BuildConfig.BASE_URL) | |
.addConverterFactory(GsonConverterFactory.create()) | |
.addCallAdapterFactory(RxJava2CallAdapterFactory.create()) | |
.build(); | |
TmdbInterface tmdbInterface = retrofit.create(TmdbInterface.class); | |
Observable<HashMap<Integer, String>> genresListResponseObservable = |
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
/** | |
* Compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object. | |
* Parameters: | |
* anObject The object to compare this String against | |
* Returns: | |
* true if the given object represents a String equivalent to this string, false otherwise | |
* See also: | |
* compareTo(java.lang.String) | |
* equalsIgnoreCase(java.lang.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
/* | |
* Go to https://graph.facebook.com/<user_name_here> | |
* Copy your id | |
* This will open up facebook app if the user has it installed | |
* Otherwise it will open facebook in the browser | |
*/ | |
public Intent getOpenFacebookIntent(Context context) { | |
try { | |
context.getPackageManager().getPackageInfo("com.facebook.katana", 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 HelloWorld { | |
public static void main(String args[]) { | |
System.out.println("Hello World!"); | |
} | |
} |