Skip to content

Instantly share code, notes, and snippets.

View gabrielbmoro's full-sized avatar
👋
Hii

Gabriel Bronzatti Moro gabrielbmoro

👋
Hii
View GitHub Profile
@gabrielbmoro
gabrielbmoro / GeneralBaseAdapter.kt
Last active September 8, 2019 19:46
GeneralBaseAdapter is used for any recyclerview list as adapter.
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import com.gabrielbmoro.programmingchallenge.BR
import androidx.annotation.LayoutRes
abstract class GeneralBaseAdapter<T> : RecyclerView.Adapter<GeneralBaseAdapter.GeneralViewHolder>() {
@gabrielbmoro
gabrielbmoro / BaseViewModel.kt
Created September 8, 2019 19:21
BaseViewModel is an abstraction used to do the ViewModel able to implement the Observable behavior.
import android.app.Application
import androidx.databinding.Bindable
import androidx.databinding.Observable
import androidx.databinding.PropertyChangeRegistry
import androidx.lifecycle.AndroidViewModel
open class BaseViewModel(application: Application) : AndroidViewModel(application), Observable {
@Transient
private var mCallbacks: PropertyChangeRegistry? = null
@gabrielbmoro
gabrielbmoro / FullScreenMode.xml
Created September 14, 2019 19:06
Full Screen Mode Style
<!-- Reference: https://stackoverflow.com/questions/2868047/fullscreen-activity-in-android -->
<style name="Base.ProgrammingChallange.FullScreen" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
@gabrielbmoro
gabrielbmoro / SimpleAnimation.kt
Created September 24, 2019 02:23
Simple animation using translation property
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
super.onCreate(savedInstanceState, persistentState)
var multiplier = 1
val lastMultiplier = 2
val viewToAnimate : View = findViewById(R.id.vwContent)
findViewById<Button>(R.id.btnDispare).apply{
setOnClickListener {
ObjectAnimator.ofFloat(
@gabrielbmoro
gabrielbmoro / Global.kt
Created October 14, 2019 15:18
It is used to send notification from child views to parents
import io.reactivex.Observable
import io.reactivex.subjects.PublishSubject
class RxBus {
private val bus : PublishSubject<Any> = PublishSubject.create()
fun send(any : Any) = bus.onNext(any)
@gabrielbmoro
gabrielbmoro / editor_component.dart
Created March 22, 2020 22:27
Learning Flutter - Alura - First course
import 'package:flutter/material.dart';
class Editor extends StatelessWidget {
final TextEditingController controller;
final String labelText;
final String hintText;
final IconData icon;
Editor(this.labelText, {this.controller, this.hintText, this.icon});

[BOARD TICKET ID] - PR title

Description

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Type

  • Bugfix
fun setProgressBarColor(@ColorRes colorRes: Int) {
val unwrappedDrawable = progressbar.progressDrawable
DrawableCompat.setTint(unwrappedDrawable, ContextCompat.getColor(context, colorRes))
}
@gabrielbmoro
gabrielbmoro / ContextUtils.kt
Created August 10, 2020 14:38
Change the soft input mode
/**
* Make sure that @param softInputMode is a value from WindowManager.LayoutParams, for example:
* - SOFT_INPUT_ADJUST_PAN
*
* @return the previous softInputMode
*/
fun FragmentActivity.setSoftInputMode(softInputMode: Int): Int? {
val previousSoftInputMode: Int? =
try {
packageManager.getActivityInfo(
@gabrielbmoro
gabrielbmoro / FragmentExample.kt
Last active October 4, 2020 14:55
Starting with Dagger Hilt
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.viewModels
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class InputAlertDialogFragment : DialogFragment() {
private val viewModel by viewModels<ViewModelExample>()