Skip to content

Instantly share code, notes, and snippets.

View Kolyall's full-sized avatar
📱

Nick Unuchek Kolyall

📱
View GitHub Profile
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.drawable.GradientDrawable.Orientation;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.FloatRange;
import android.util.Log;
@Kolyall
Kolyall / viewStub.java
Created November 15, 2017 21:38
viewStub and Butterknife example
public class EstadoActual extends Fragment {
// this controls work perfect
@InjectView(R.id.txtWork1) AutoCompleteTextView txtWork1;
@InjectView(R.id.txtWork2) EditText txtWork2;
// this controls are inside the viewstub,
@InjectView(R.id.viewstub) ViewStub viewStub;
MyDynamicView myDynamicView;
@Kolyall
Kolyall / appVersion.gradle
Last active August 16, 2018 15:19
Maven Publish
ext {
def propertiesFile = file('properties/version/version.properties')
appVersionCode = 1;
appVersionName = "1.0";
if (propertiesFile.canRead()) {
Properties properties = new Properties()
properties.load(new FileInputStream(propertiesFile))
appVersionCode = Integer.parseInt(properties['VERSION_CODE']).intValue();
appVersionName = String.valueOf(properties['VERSION_NAME']);
} else {
@Kolyall
Kolyall / README.md
Last active November 1, 2018 08:58
Add buildConfigFields from .properties file via code

Add buildConfigFields from .properties file Create file in folder: D:\MyProject\app\properties\api\debug.properties

@Kolyall
Kolyall / README.md
Last active November 8, 2018 09:02
Choose image source dialog

Image source pick for activity/fragment by using Gallery or Take photo

@Kolyall
Kolyall / PDFTools.java
Created November 22, 2018 19:10
PDFTools
public class PDFTools {
private static final String GOOGLE_DRIVE_PDF_READER_PREFIX = "http://drive.google.com/viewer?url=";
private static final String PDF_MIME_TYPE = "application/pdf";
private static final String HTML_MIME_TYPE = "text/html";
public static void showPDFUrl( final Context context, final String pdfUrl ) {
if ( isPDFSupported( context ) ) {
downloadAndOpenPDF(context, pdfUrl);
} else {
askToOpenPDFThroughGoogleDrive( context, pdfUrl );
@Kolyall
Kolyall / MainFragment.java
Last active November 27, 2018 05:23
Custom view in menuItem
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
setHasOptionsMenu(true);
}
MenuItem menuItemCart;
@Override
@Kolyall
Kolyall / MainFragment.java
Created November 27, 2018 05:44
Add svg image to textView with selector
Drawable drawable = ContextCompat.getDrawable(this, R.drawable.ic_arrow_down_small).mutate();
ColorStateList colours = getResources().getColorStateList(R.color.arrow_down_selector);
Drawable drawableCompat = DrawableCompat.wrap(drawable);
DrawableCompat.setTintList(drawableCompat, colours);
titleView.setCompoundDrawablesWithIntrinsicBounds(null, null, drawableCompat , null);
@Kolyall
Kolyall / getPicFromAsset.kt
Created February 28, 2019 07:26
Get Bitmap from assets
private fun getPicFromAsset(imageView: ImageView, assetName: String): Bitmap? {
// Get the dimensions of the View
val targetW = imageView.width
val targetH = imageView.height
if (targetW == 0 || targetH == 0) {
// view has no dimensions set
return null
}
@Kolyall
Kolyall / README.md
Last active November 13, 2019 06:34
TextView patterns

TextView:

  1. Max Length with ellipsize at end
  2. Clear focus from EditText after open a screen