Skip to content

Instantly share code, notes, and snippets.

View dinorahto's full-sized avatar

Dinorah Tovar dinorahto

View GitHub Profile
@dinorahto
dinorahto / HeadersParams.kt
Created May 1, 2019 17:40
Adding Headers as parameters
@Headers("Content-Type:application/json; charset=UTF-8")
@GET("yourwebsite/{someParam}/login")
fun logout(@Header(UUID.randomUUID().toString()) authToken: String?, @Path("someParam") someParam: String?): Observable<LoginResponseViewModel>
@dinorahto
dinorahto / TextInputLayout.kt
Created May 1, 2019 17:42
Text Input Layout for Drawable Left without padding 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"
@dinorahto
dinorahto / pipeline.yml
Created May 1, 2019 17:43
Bitbucket Pipelines
image: java:8
pipelines:
branches:
deployment:
- step:
caches:
- gradle
- android-sdk
@dinorahto
dinorahto / Headers.kt
Created May 1, 2019 17:44
Headers In retrofit
@Headers("Content-Type:application/json; charset=UTF-8")
@GET("yourwebsite/{someParam}/login")
fun logout(@Path("someParam") someParam: String?): Observable<LoginResponseViewModel>
@dinorahto
dinorahto / MainActivity.kt
Created May 1, 2019 17:45
MainActivity and ViewModel 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
@dinorahto
dinorahto / BasePresenter.kt
Created May 1, 2019 17:47
Base Presenter and Disposable Subscribers
/**
* 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.
*/
@dinorahto
dinorahto / ApplicationOwner.kt
Created May 1, 2019 17:48
Lifecycle owner with application owner to check the status of the application
/**
* Created by Dinorah Tovar on 2/22/18.
* Application Owner using lifecycleObserver to know the application of
* the application.
*/
class ApplicationOwner : LifecycleObserver {
/**
* Companion Object
@dinorahto
dinorahto / InterceptorSinglenton.kt
Created May 1, 2019 17:49
Interceptor with Dagger as Singleton
@Provides
@Singleton
fun getUnsafeOkHttpClient(): OkHttpClient {
val interceptor = HttpLoggingInterceptor()
interceptor.level = HttpLoggingInterceptor.Level.BODY
val builder = OkHttpClient.Builder()
builder.addInterceptor(interceptor)
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.followRedirects(true)
@dinorahto
dinorahto / ItemHolder.java
Last active May 1, 2019 17:56
RecyclerView RecyclerAdapter and ItemHolder for multiple views
/**
* Created by Dinorah Tovar on 12/20/17.
* RecyclerViewHolder in separated files
* Butterknife options for inflate holder is avaliable with comments
*/
public class FirstHolder extends RecyclerView.ViewHolder {
private TextView textView;
// @BindView(R.id.textView2) TextView ButterknifeTextView;
@dinorahto
dinorahto / ViewPagerAdapter.kt
Created May 1, 2019 17:58
ViewPager adapter for not drag event
/**
* Created by Dinorah Tovar on 12/20/17.
* ViewPager
*/
public class CustomViewPager extends ViewPager {
public CustomViewPager(Context context) {
super(context);
setMyScroller();