Skip to content

Instantly share code, notes, and snippets.

View dinorahtovar's full-sized avatar

Dinorah Tovar dinorahtovar

View GitHub Profile
@dinorahtovar
dinorahtovar / MainActivity.kt
Last active May 1, 2019 17:37
MVVM Architecture
/**
* Created by Dinorah Tovar on 18/01/19.
* Main Activity that verify if the user is availbale
*/
class MainActivity : AppCompatActivity() {
private var viewModel: MainViewModel? = null
/**
* On Create View instance
@dinorahtovar
dinorahtovar / bitbucket-pipelines.yml
Created January 12, 2019 00:29
Bitbucket Pipeline Android
image: java:8
pipelines:
branches:
deployment:
- step:
caches:
- gradle
- android-sdk
/**
* Created by Dinorah Tovar on 8/21/18
* All presenter should extend from this.
*/
open class BasePresenter : DisposableImpl {
/**
* Save disposables in a list to dispose them once user is navigate out of screen.
*/
/**
* Created by Dinorah Tovar on 8/21/18
* All fragments should extend from this fragment.
*/
open class BaseFragment : Fragment() {
/**
* Keep reference of the active presenter
*/
@dinorahtovar
dinorahtovar / BaseActivity.kt
Last active January 10, 2019 23:24
Dispose subscriber's on Android
/**
* Created by Dinorah Tovar on 8/21/18
* Base custom activity managing all the disposables
*/
open class BaseActivity : AppCompatActivity() {
/**
* Keep reference of the active presenter.
*/
@dinorahtovar
dinorahtovar / ApplicationOwner.kt
Last active November 15, 2018 16:20
LifecycleObserver to check OnPause and OnResume
/**
* Created by Dinorah Tovar on 2/22/18.
* Application Owner using lifecycleObserver to know the application of
* the application.
*/
class ApplicationOwner : LifecycleObserver {
/**
* Companion Object
@dinorahtovar
dinorahtovar / textInput.xml
Created August 7, 2018 15:44
Custom Text Input Layout without padding implementation in XML
<com.our.project.common.PasswordTextInputLayout
android:id="@+id/login_password_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="2dp"
android:theme="@style/EditTextBlue"
app:errorEnabled="false"
app:hintEnabled="true"
@dinorahtovar
dinorahtovar / TextInputLayoutNoPaddingHintWithDrawable.kt
Created July 20, 2018 23:06
TextInputLayout with a drawable, but without the padding in the Hint
import android.content.Context
import android.graphics.Rect
import android.support.design.widget.TextInputLayout
import android.util.AttributeSet
import java.lang.reflect.InvocationTargetException
import java.lang.reflect.Method
/**
* Created by Dinorah Tovar on 6/19/18
* Password with
@dinorahtovar
dinorahtovar / Two observables with FlatMap.kt
Last active July 20, 2018 22:44
Flat map of observables with a Retrofit Request.
/**
* Returns an observable from a function that decrypts stored user data
*/
fun currentUserObservable(): Observable<UserViewModel> {
return Observable.create(ObservableOnSubscribe<UserViewModel> { subscriber ->
val user = currentUser()
if (user != null)
subscriber.onNext(user)
else
subscriber.onError(Throwable("User is null"))
@Headers("Content-Type:application/json; charset=UTF-8")
@GET("yourwebsite/{someParam}/login")
fun logout(@Path("someParam") someParam: String?): Observable<LoginResponseViewModel>