Skip to content

Instantly share code, notes, and snippets.

View addam01's full-sized avatar
👻
Out and About

Addam Rashidi Zulkeple addam01

👻
Out and About
View GitHub Profile
@addam01
addam01 / RxJava Iterate.kt
Created March 4, 2020 11:08
RxJava RxKotlin for iterating a list of observables
class RxJavaIterate{
val users: List<User> = listOf()
//We want to iterate each of these users in the list and perform a function individually in each items
//One By One
Observable.from(users)
.map(i -> {
//transform users to username string
//save each i into db
@addam01
addam01 / 1 Filter Recycler View.md
Last active March 4, 2020 07:22
Filterable RecyclerView for Android

DEPENDENCIES

  • implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
  • implementation "io.reactivex.rxjava2:rxjava:2.1.9"
  • implementation "io.reactivex.rxjava2:rxkotlin:2.2.0"
  • implementation 'com.jakewharton.rxbinding2:rxbinding-kotlin:2.1.1'
  • implementation "android.arch.lifecycle:extensions:1.1.1"

Process Flow

@addam01
addam01 / dimens.xml
Last active November 23, 2018 07:09
Default Android Resource xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--textsize-->
<dimen name="small_text_10sp">10sp</dimen>
<dimen name="small_text_12sp">12sp</dimen>
<dimen name="medium_text_14sp">14sp</dimen>
<dimen name="medium_text_16sp">16sp</dimen>
<dimen name="large_text_18sp">18sp</dimen>
<dimen name="large_text_20sp">20sp</dimen>
@addam01
addam01 / Readme.md
Last active November 1, 2018 07:40
Android RxKotlin and OKHttp Interceptor

Sample for using OkHTTP interceptor for RxKotlin and Retrofit

  • Interceptor will add the token into preference once after login
  • Interceptor try to run the request once using current token in the OKHttp builder class
  • If failed, it'll intercept by calling TokenRefreshInterceptor.kt
  • TokenRefreshInterceptor.kt will try again, if got 200 from API
    • It'll call the refresh API by appending refresh token from preference to refresh the token
  • Then proceed to call original request in makeTokenRefreshCall
@addam01
addam01 / CustomTextView.java
Created August 1, 2017 08:05
Android Custom Textview
public class CustomTextView extends TextView {
public CustomTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(attrs);
}
public CustomTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init(attrs);
@addam01
addam01 / SSLCustomSocket.java
Created February 25, 2016 04:27
Android Custom SSL Connection with Self signed Cert
/*Create a certificate factory based on X509 standard, this hold the algorithm for most certs*/
CertificateFactory cf = CertificateFactory.getInstance("X.509");
/*Get the .pem cert from cert file stored in \app\src\main\res\raw*/
InputStream caInput = mContext.getResources().openRawResource(R.raw.cert);
/*Then generate the raw file into certification file*/
Certificate ca = cf.generateCertificate(caInput);
/*Close the inputstream. This is important!*/
caInput.close();
/*Generate the KeyStore, DO NOT USE "BKS". Just use the default type!*/
public class MVPJSONParse {
public static void Decode(){
}
/* Helper function. put it in the same page, or in a library */
protected static String downloadFile(String URL, String category) {
String data;
// to fill-in url content
StringBuilder builder = new StringBuilder();
try {