Skip to content

Instantly share code, notes, and snippets.

Avatar

Vasili Chyrvon Jeevuz

View GitHub Profile
View CursorRecyclerAdapter.java
package jeevuz.recyclerview;
import android.database.ContentObserver;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.os.Handler;
import android.support.v7.widget.RecyclerView;
import android.widget.Filter;
import android.widget.FilterQueryProvider;
import android.widget.Filterable;
View Remove ripple effect from CheckBox
private void removeRippleEffectFromCheckBox(CheckBox checkBox) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Drawable drawable = checkBox.getBackground();
if (drawable instanceof RippleDrawable) {
drawable = ((RippleDrawable) drawable).findDrawableByLayerId(0);
checkBox.setBackground(drawable);
}
}
}
View Request contact't name, number and thumbnail path
// Start activity for result to pick contact phone
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT_REQUEST_CODE);
// In the onActivityResult
case PICK_CONTACT_REQUEST_CODE:
if (resultCode == RESULT_OK) {
// Get the URI that points to the selected contact
Uri contactDataUri = data.getData();
@Jeevuz
Jeevuz / NavigationView Dynamic Menu
Last active Mar 15, 2016
Investigation results of getting this work.
View NavigationView Dynamic Menu
// Add the view(s)
mNavigationView.getMenu().add(R.id.group_name, R.id.predefined_id, 0, "Title");
mNavigationView.getMenu().findItem(R.id.action_skip).setIcon(R.drawable.custom_icon_with_selector);
...
// Allow changing of selected item via NavigationView.setCheckedItem(id)
mNavigationView.getMenu().setGroupCheckable(R.id.group_name, true, true);
// Remove tinting to see the custom icons
mNavigationView.setItemIconTintList(null)
@Jeevuz
Jeevuz / Timestamp.java
Last active Mar 24, 2016
java.sql.Timestamp subclass with ability to parse and hold the raw server string with microseconds and optional format parts. Has usefull method daysFromToday()
View Timestamp.java
package com.example;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
View ConnectionUtils.java
package ru.mobileup.grushasdk.utils;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
import android.net.wifi.WifiManager;
/**
* @author Vasili Chyrvon (vasili.chyrvon@gmail.com)
@Jeevuz
Jeevuz / ImagePickerWithCrop.java
Last active Nov 8, 2016 — forked from Mariovc/ImagePickerWithCrop.java
[Android] Advanced utility for picking an image from Gallery/Camera with Android Intents (Crop included. uCrop library is used)
View ImagePickerWithCrop.java
package com.example.utils;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
View .gitignore
# Build files and folders
build/
.gradle/
# Local
local.properties
captures/
# Idea files
.idea/
@Jeevuz
Jeevuz / EnterStringDialogFragment.java
Last active Jan 18, 2017
Dialog to ask for string to enter
View EnterStringDialogFragment.java
package ru.mobileup.myalarm2.ui.dialog;
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatDialogFragment;
import android.widget.EditText;
@Jeevuz
Jeevuz / ProgressDimDialogFragment.kt
Created Mar 30, 2017
Progress DialogFragment with only progress view on the dimmed screen
View ProgressDimDialogFragment.kt
/**
* Dialog fragment showing progress widget on dimmed screen.
* @author Vasili Chyrvon (vasili.chyrvon@gmail.com)
*/
class ProgressDimDialogFragment : AppCompatDialogFragment() {
companion object {
val TAG = "ProgressDimDialogFragment"
private val ARGS_DISPATCH_BACK_PRESS = "args_dispatches_back_press"