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 / 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
@nikartx
nikartx / FooterBarBehavior.java
Last active May 12, 2019 16:09
FooterBarBehavior
import android.content.Context;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.util.AttributeSet;
import android.view.View;
/**
* @author Ivan V on 06.03.2018.
* @version 1.0
*/
@nikartx
nikartx / Java declination age method
Last active December 11, 2017 13:45
Склонение возраста (ru)
public static String getAgeWithDeclination(double age){
String result;
List<Double> units = Arrays.asList(2d, 3d, 4d);
List<Double> dozens = Arrays.asList(11d, 12d, 13d, 14d);
if(age != 11 && age % 10 == 1) {
result = age + " год";
} else if(age % 1 != 0d || (units.contains(age % 10) && !dozens.contains(age % 100))) {
result = age + " года";
} else {
@nikartx
nikartx / ru_cities.xml
Created April 29, 2017 20:23
All Russian Cities xml
<?xml version="1.0"?>
<string-array name="cities">
<item>Абаза, Хакасия</item>
<item>Абакан, Хакасия</item>
<item>Абдулино, Оренбургская область</item>
<item>Абинск, Краснодарский край</item>
<item>Агидель, Башкортостан</item>
<item>Агрыз, Татарстан</item>
<item>Адыгейск, Адыгея</item>
<item>Азнакаево, Татарстан</item>
@nikartx
nikartx / gitignore file
Created April 27, 2017 09:48
Gitignore for Android
# Android Studio
.gradle
/local.properties
.DS_Store
/build
/captures
app/build/
gradle/
*.iml
.idea
@nikartx
nikartx / ImgRedactor
Created January 13, 2017 11:26
Get bitmap shader circle img
// Get bitmap shader circle img
public static Bitmap getCircleMaskedBitmapShader(Bitmap source, int radius) {
if (source == null) { return null; }
int diam = radius << 1;
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
Bitmap scaledBitmap = scaleTo(source, diam);
final Shader shader = new BitmapShader(scaledBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
@nikartx
nikartx / Add new contact without confirmation
Last active November 18, 2016 11:41
Android add contact
try {
String DisplayName = "XYZ";
String MobileNumber = "123456";
String HomeNumber = "1111";
String WorkNumber = "2222";
String emailID = "[email protected]";
String company = "bad";
String jobTitle = "abcd";
ArrayList<ContentProviderOperation> ops = new ArrayList < ContentProviderOperation > ();
@nikartx
nikartx / menu_hide.js
Created February 23, 2016 08:35
JS hide menu and open on click
//Hide products blocks
$(document).ready(function() {
$('.btn').click(function() { //Click on button
$(".cont").not(this).slideUp().prev().removeClass("active"); //Hide all open blocks
$(this).next().find(".cont").not(":visible").slideDown().prev().addClass("active"); //Open current block
});
});
<!-- Start products menu -->
<div class="container prod_block">
@nikartx
nikartx / JS_setTimeout
Created February 5, 2016 17:48
JS timeout for hover over an element
//Set timeout if hover over an element
$(document).ready(function() {
$('#slider').hover(
// if hover over an element
function(){
setTimeout(function() {
$('i.arrows').css({"opacity":"1"});
},
300);
@nikartx
nikartx / DatePHP
Created August 29, 2015 17:43
Print by php in the russian locale - date, month, week day and time
<?php
// Вывод даты на русском
$monthes = array(
1 => 'Января', 2 => 'Февраля', 3 => 'Марта', 4 => 'Апреля',
5 => 'Мая', 6 => 'Июня', 7 => 'Июля', 8 => 'Августа',
9 => 'Сентября', 10 => 'Октября', 11 => 'Ноября', 12 => 'Декабря'
);
echo(date('d ') . $monthes[(date('n'))] . date(' Y, H:i'));
// Вывод дня недели