This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.filipkowicz.headeritemdecorator | |
/* | |
solution based on - based on Sevastyan answer on StackOverflow | |
changes: | |
- take to account views offsets | |
- transformed to Kotlin | |
- now works on viewHolders |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GalleryActivity : AppCompatActivity() { | |
private val PICK_IMAGE_REQUEST = 71 | |
private var filePath: Uri? = null | |
private var firebaseStore: FirebaseStorage? = null | |
private var storageReference: StorageReference? = null | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_gallery) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context | |
import android.net.ConnectivityManager | |
import android.net.NetworkCapabilities | |
import android.os.Build | |
val Context.isConnected: Boolean | |
get() { | |
val connectivityManager = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
return when { | |
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/Zhuinden/fragmentviewbindingdelegate-kt | |
import android.view.View | |
import androidx.fragment.app.Fragment | |
import androidx.lifecycle.DefaultLifecycleObserver | |
import androidx.lifecycle.Lifecycle | |
import androidx.lifecycle.LifecycleOwner | |
import androidx.lifecycle.Observer | |
import androidx.viewbinding.ViewBinding | |
import kotlin.properties.ReadOnlyProperty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserAdapter : RecyclerView.Adapter<UserAdapter.UserViewHolder> { | |
var users: List<User> = emptyList() | |
set(value) { | |
field = value | |
notifyDataSetChanged() | |
} | |
// This keeps track of the currently selected position | |
var selectedPosition by Delegates.observable(-1) { property, oldPos, newPos -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Fragment.isGranted(permission: AppPermission) = run { | |
context?.let { | |
(PermissionChecker.checkSelfPermission(it, permission.permissionName | |
) == PermissionChecker.PERMISSION_GRANTED) | |
} ?: false | |
} | |
fun Fragment.shouldShowRationale(permission: AppPermission) = run { | |
shouldShowRequestPermissionRationale(permission.permissionName) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun TextInputEditText.isNotNullOrEmpty(errorString: String): Boolean { | |
val textInputLayout = this.parent.parent as TextInputLayout | |
textInputLayout.errorIconDrawable = null | |
this.onChange { textInputLayout.error = null } | |
return if (this.text.toString().trim().isEmpty()) { | |
textInputLayout.error = errorString | |
false | |
} else { | |
true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sriyank.spannablestring | |
import android.graphics.Color | |
import android.graphics.Typeface | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.text.Spannable | |
import android.text.SpannableString | |
import android.text.SpannableStringBuilder | |
import android.text.TextPaint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.annotation.SuppressLint | |
import android.content.Context | |
import android.text.Layout | |
import android.text.Spannable | |
import android.text.SpannableStringBuilder | |
import android.text.Spanned | |
import android.text.StaticLayout | |
import android.text.TextPaint | |
import android.text.method.LinkMovementMethod | |
import android.text.style.ClickableSpan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.os.Handler; | |
import android.util.AttributeSet; | |
import android.widget.TextView; | |
public class TypeWriter extends TextView { | |
private CharSequence mText; | |
private int mIndex; | |
private long mDelay = 150; //Default 150ms delay |