Skip to content

Instantly share code, notes, and snippets.

View zakrodionov's full-sized avatar
🇺🇦
Peace For Ukraine

Zakhar Rodionov zakrodionov

🇺🇦
Peace For Ukraine
View GitHub Profile
@zakrodionov
zakrodionov / ConnectivityListener.kt
Last active September 10, 2023 14:15
Observe network status
package com.zakrodionov.commonApp.app.platform
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.net.ConnectivityManager
import android.net.Network
import android.os.Build
import androidx.core.content.ContextCompat.getSystemService
@zakrodionov
zakrodionov / Method1.kt
Last active November 16, 2021 16:25
Hide keyboard on outside touch (3 popular methods) //Best on top
fun Activity.hideKeyboardOnClickOutsideEditText(view: View) {
// Set up touch listener for non-text box views to hide keyboard.
var previousAction = 0
val onTouchListener = View.OnTouchListener { v, event ->
if (currentFocus != null
&& event.action != MotionEvent.ACTION_DOWN
&& event.action != MotionEvent.ACTION_MOVE
&& previousAction != MotionEvent.ACTION_MOVE
) {
currentFocus?.clearFocus()
@zakrodionov
zakrodionov / SampleAuthenticator.kt
Created February 27, 2020 07:48 — forked from farhanjk/SampleAuthenticator.kt
Sample Okhttp3 Authenticator
/*
SampleAuthenticator (c) by Farhan Khan
SampleAuthenticator is licensed under a
Creative Commons Attribution 3.0 Unported License.
http://creativecommons.org/licenses/by/3.0/
*/
class SampleAuthenticator(
@zakrodionov
zakrodionov / Rovas code style.md
Last active November 12, 2019 16:46
Rovas code styles
@zakrodionov
zakrodionov / Полезные команды
Last active October 17, 2019 06:16
Замена символов переименование полезные команды#regexp
for f in *\ *; do mv "$f" "${f// /_}"; done --удаляет пробелы в названии файлов
for a_file in *;do mv -v "$a_file" `echo "$a_file" | tr [:upper:] [:lower:]` ;done; ---делает lowercase
rename 's/[\(\)]//g' *.txt переименует все файлы .txt, удалив круглые скобки.
rename 's/[\-]//g' *.jpg удалив минус(-).
for file in *; do mv "$file" `echo $file | tr '-' '_'` ; done - замена - на _
class AddressesSpinnerAdapter(
context: Context,
textViewResourceId: Int = android.R.layout.simple_spinner_item
) : ArrayAdapter<AddressesSpinnerItem>(context, textViewResourceId) {
var values: ArrayList<AddressesSpinnerItem> = arrayListOf()
set(value) {
field.clear()
field = value
notifyDataSetChanged()
@zakrodionov
zakrodionov / HorizontalPaddingDecoration.kt
Last active September 11, 2019 15:03
ItemDecoration #view
class HorizontalPaddingDecoration(
private val padding: Float = 2f,
private val firstLastPadding: Float = 20f
) : RecyclerView.ItemDecoration() {
override fun getItemOffsets(
outRect: Rect,
view: View,
parent: RecyclerView,
state: RecyclerView.State
@zakrodionov
zakrodionov / ExpandDelegate.kt
Created July 19, 2019 08:44
expand delegate, item in recyclerview #view
// Example
fun expandAdapterDelegate() = adapterDelegateLayoutContainer<ExpandedItem, DisplayableItem>(R.layout.item_expanded) {
llArrowContainer.setOnClickListener {
val isExpand = !item.isExpanded
item.isExpanded = isExpand
expandText(isExpand, ivArrow, llTextContainer)
}
bind {
package com.kevicsalazar.utils;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;
public class AnimationUtils {
// Attention
public static AnimatorSet loadBounceAnimator(View target) {
AnimatorSet animatorSet = new AnimatorSet();
@zakrodionov
zakrodionov / DialogFragAnim_snippet.java
Last active June 13, 2019 12:09 — forked from jasco/DialogFragAnim_snippet.java
DialogFragment enter/exit animations #view #animation
// example courtesy of http://adilatwork.blogspot.com/2012/11/android-dialogfragment-enter-and-exit.html
// file location: src/main/java/com/example/
@Override
public void onStart() {
super.onStart();
// safety check
if (getDialog() == null) {
return;