Skip to content

Instantly share code, notes, and snippets.

View maiconhellmann's full-sized avatar
:octocat:

Maicon Hellmann maiconhellmann

:octocat:
View GitHub Profile
@maiconhellmann
maiconhellmann / RecyclerViewAdapter.kt
Last active November 28, 2017 10:11
RecyclerView/RxEvent/ViewHolder/Adapter example in Kotlin
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import kotlinx.android.synthetic.main.item_container.view.*
import rx.Observable
import rx.subjects.PublishSubject
import javax.inject.Inject
class RecyclerViewAdapter
@maiconhellmann
maiconhellmann / ripple_attrs.txt
Created November 21, 2017 16:37
Ripple effect example
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
@maiconhellmann
maiconhellmann / ViewExtensions.kt
Created November 21, 2017 16:40
Kotlin extensions for View
import android.support.design.widget.Snackbar
import android.view.View
import com.github.clans.fab.FloatingActionMenu
fun View.visible(){
this.visibility = View.VISIBLE
}
fun View.visible(visible : Boolean){
if(visible){
visible()
@maiconhellmann
maiconhellmann / ContextExctensions.kt
Created November 21, 2017 16:41
Kotlin extensions for Context
import android.content.ComponentName
import android.content.Context
import android.content.CursorLoader
import android.content.pm.PackageManager
import android.net.ConnectivityManager
import android.net.Uri
import android.os.Looper
import android.provider.MediaStore
import android.support.annotation.ColorRes
import android.support.annotation.StringRes
@maiconhellmann
maiconhellmann / UnsafeOkHttpClient.kt
Last active May 1, 2024 14:12
UnsafeHttpClient wrote in Kotlin
import android.annotation.SuppressLint
import okhttp3.OkHttpClient
import java.security.cert.CertificateException
import javax.net.ssl.SSLContext
import javax.net.ssl.TrustManager
import javax.net.ssl.X509TrustManager
object UnsafeOkHttpClient {
fun Builder(): OkHttpClient.Builder {
try {
@maiconhellmann
maiconhellmann / MaskExtension.kt
Created November 21, 2017 16:45
MaskExtension wrote in Kotlin
import android.support.annotation.StringDef
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
@StringDef(PHONE_9_MASK, PHONE_8_MASK, CPF_MASK, ZIP_CODE_PT_BR, MONTH_YEAR, CREDIT_CARD)
@Retention(AnnotationRetention.SOURCE)
annotation class MaskType
const val PHONE_9_MASK = "(##) #####-####"
@maiconhellmann
maiconhellmann / DateExtension.kt
Last active August 17, 2023 07:36
Date extensions wrote in Kotlin
import java.text.SimpleDateFormat
import java.util.*
/**
* Pattern: yyyy-MM-dd HH:mm:ss
*/
fun Date.formatToServerDateTimeDefaults(): String{
val sdf= SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
return sdf.format(this)
}
@maiconhellmann
maiconhellmann / RxJavaTimerTask.kt
Last active November 4, 2020 23:22
Timer task in RxJava kotlin/java
val subscription = Observable.interval(0, 5, TimeUnit.SECONDS)
.timeInterval()
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe {
//TODO
}
@maiconhellmann
maiconhellmann / CustomMapMarker.java
Created December 2, 2017 14:07
Custom map Marker in Java
private MarkerOptions createMarkerIcon(LatLng position) {
FrameLayout frameLayout = new FrameLayout(getContext());
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
frameLayout.setLayoutParams(params);
View markerView = getActivity().getLayoutInflater().inflate(R.layout.custom_map_marker, frameLayout);
BitmapDescriptor bitmapMerged = BitmapDescriptorFactory.fromBitmap(BitmapUtils.createDrawableFromView(getContext(), markerView));
@maiconhellmann
maiconhellmann / sendImageMultipartRetrofitRxJava.kt
Created March 11, 2018 12:10
Send image or file multipart retrofit RxJava
//Preparing the request
val filePart = MultipartBody.Part
.createFormData("file", "fileName",
RequestBody.create(MediaType.parse("image/jpeg"), File("/your/File/Path.jpg")))
//service.sendFile(id, filePart)
//Request definition retrofit
@PUT("https://www.yourdomain.com/api/file/{id}")
@Multipart
fun sendFile(@Path("id") id: Long, @Part file: MultipartBody.Part ) : Observable<YourModel>