Skip to content

Instantly share code, notes, and snippets.

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

Ivan V nikartx

:electron:
Bio Robot
View GitHub Profile
@nikartx
nikartx / BuildCleaner.run.xml
Last active September 3, 2024 13:56
Remove all 'build' dirs from all modules in android project. Better and faster then Clean Project.
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="BuildCleaner" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="$PROJECT_DIR$/scripts/buildCleaner.sh" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="/usr/bin/env" />
@nikartx
nikartx / 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
*
@nikartx
nikartx / 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.
@nikartx
nikartx / 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:
@nikartx
nikartx / 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">
@nikartx
nikartx / 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 {
@nikartx
nikartx / 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
@nikartx
nikartx / 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 {
@nikartx
nikartx / 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:

@nikartx
nikartx / 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;