Skip to content

Instantly share code, notes, and snippets.

View nikartm's full-sized avatar
:electron:
Bio Robot

Ivan V nikartm

:electron:
Bio Robot
View GitHub Profile
@nikartm
nikartm / LoadingMaterialButton.kt
Created February 25, 2022 14:05
Loading [MaterialButton]. Support showing loading spinner on the button
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import androidx.swiperefreshlayout.widget.CircularProgressDrawable
import com.google.android.material.button.MaterialButton
/**
* Loading [MaterialButton]. Showing loading spinner on the button
*
@nikartm
nikartm / AndroidManifest.xml
Last active November 3, 2021 11:34
Timber log to file txt
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29"
tools:ignore="ScopedStorage" />
Use version 29 to work on Android 10. Need enable storage permission in app settings.
@nikartm
nikartm / android-ci.yml
Created January 7, 2021 11:31
Simple base CI/CD script, using Telegram bot to get application build status
name: Android CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
@nikartm
nikartm / ScrollToPosition.txt
Created October 30, 2020 13:47
Scroll to position when RecyclerView place into NestedScrollView. Using LinearLayoutManagersmoothScrollTo and rvBlocks.scrollToPosition will not work when RecyclerView placed into NestedScrollView but this solution worked perfectly.
<androidx.core.widget.NestedScrollView
android:id="@+id/nswContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@nikartm
nikartm / StickyDialog.kt
Created July 31, 2020 14:05
Floating sticky dialog for RecyclerView
/**
* Sticky dialog for [RecyclerView].
* Create instance when RecyclerView will be initialized and
* call [StickyDialog.show] when a user clicked by item in a list
*
* @author Ivan V on 31.07.2020.
* @version 1.0
*/
class StickyDialog : DialogFragment {
@nikartm
nikartm / SetBNVItemColor.txt
Last active May 28, 2020 20:00
Set color for the item in BottomNavigationView
private void onClickBnvMenu() {
bnvMenu.setOnNavigationItemSelectedListener(item -> {
final int itemId = item.getItemId();
if (selectedCategoryId == itemId) {
return false;
}
switch (itemId) {
case R.id.item_feed:
// Do something
@nikartm
nikartm / SimpleTimer
Last active April 23, 2020 23:48
Countdown timer
import android.os.CountDownTimer
import java.util.concurrent.TimeUnit
/**
* Countdown timer helper
* @author Ivan V on 23.04.2020.
* @version 1.0
*/
class SimpleTimer {
@nikartm
nikartm / README.md
Created May 25, 2019 07:53 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

All hex value from 100% to 0% alpha:

@nikartm
nikartm / Cache.java
Last active April 26, 2024 07:40
Android. Example how to save an image file in the App cache and get Uri for it. The Image will not be saved in a device gallery, only in an internal App cache.
package com.github.example;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;
@nikartm
nikartm / FooterBarLayout.java
Created March 6, 2018 14:54
FooterBarLayout
package ru.dasreda.dasreda;
import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.util.AttributeSet;
import android.widget.FrameLayout;
/**
* @author Ivan V on 06.03.2018.
* @version 1.0