Skip to content

Instantly share code, notes, and snippets.

@vahid-m
vahid-m / DefaultKeyBinding.dict
Created July 30, 2018 05:44 — forked from trusktr/DefaultKeyBinding.dict
My DefaultKeyBinding.dict for Mac OS X
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
This file remaps the key bindings of a single user on Mac OS X 10.5 to more
closely match default behavior on Windows systems. This makes the Command key
behave like Windows Control key. To use Control instead of Command, either swap
Control and Command in Apple->System Preferences->Keyboard->Modifier Keys...
or replace @ with ^ in this file.
Here is a rough cheatsheet for syntax.
Key Modifiers
@vahid-m
vahid-m / CircleTransform.java
Created August 9, 2018 12:11 — forked from julianshen/CircleTransform.java
CircleTransform for Picasso
/*
* Copyright 2014 Julian Shen
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@vahid-m
vahid-m / NumberPickerPreference.java
Created August 10, 2018 08:33 — forked from thom-nic/NumberPickerPreference.java
NumberPicker Preference Dialog for Android!
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.TypedArray;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;
import com.quietlycoding.android.picker.NumberPicker;
public class NumberPickerPreference extends DialogPreference {
@vahid-m
vahid-m / BaseRecyclerAdapter.java
Created October 1, 2018 07:34 — forked from EStepiuk/BaseRecyclerAdapter.java
Abstract RecyclerView.Adapter
//T is a type of items
//when inheriting, just create constructor matching super,
//and override viewHolder() method that will return ViewHolder for given item type
public abstract class BaseRecyclerAdapter<T> extends RecyclerView.Adapter<BaseRecyclerAdapter.BaseViewHolder> {
public interface OnItemClickListener<T> {
void onClick(T item);
}
@vahid-m
vahid-m / README.md
Created November 8, 2018 14:02 — forked from lopspower/README.md
Android Tools Attributes

Android Tools Attributes

Twitter

Android has a dedicated XML namespace intended for tools to be able to record information in XML files, and have that information stripped when the application is packaged such that there is no runtime or download size penalty. The namespace URI is http://schemas.android.com/tools and is usually bound to the tools: prefix:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
@vahid-m
vahid-m / RetrofitHelper.java
Created November 21, 2018 12:38 — forked from fobidlim/RetrofitHelper.java
Retrofit SSLHandShakeException
public class RetrofitHelper {
private static final String TAG = "RetrofitHelper";
private static RetrofitHelper mInstance;
private Retrofit mRetrofit;
private RetrofitHelper() {
}
public static RetrofitHelper getInstance() {
@vahid-m
vahid-m / PermissionRequest.java
Created December 31, 2018 07:19 — forked from talenguyen/PermissionRequest.java
Runtime permission Request
import android.app.Activity;
import android.content.pm.PackageManager;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AlertDialog;
public class PermissionRequest {
private static int RC = 1;
private final String permission;
@vahid-m
vahid-m / CenteredTitleToolbar.java
Created December 31, 2018 19:48 — forked from BenDLH/CenteredTitleToolbar.java
The Joy of Custom Views: How to make a centered title Toolbar in Android
//
// CenteredTitleToolbar
//
// Created by Ben De La Haye on 25/05/2016.
//
public class CenteredTitleToolbar extends Toolbar {
private TextView _titleTextView;
private int _screenWidth;
private boolean _centerTitle = true;
@vahid-m
vahid-m / PermissionsHelper.java
Created December 31, 2018 19:49 — forked from BenDLH/PermissionsHelper.java
Android Marshmallow Permissions Helper
package dk.shape.goboat.managers;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import java.util.ArrayList;
@vahid-m
vahid-m / SharedPreferencesSingletonEnumKeyTemplate.java
Created February 16, 2019 20:28 — forked from alphamu/SharedPreferencesSingletonEnumKeyTemplate.java
A SharedPreferences singleton that can be used to centralise and simplify reading and writing of SharedPerferences in your Android app. There are 2 versions, one that uses static String for Keys and an other that uses enums. Which one you use comes down to your preference, enums I feel provides better control when you have multiple programmers w…
#if (${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import android.content.Context;
import android.content.SharedPreferences;
/*
* A Singleton for managing your SharedPreferences.
*
* You should make sure to change the SETTINGS_NAME to what you want
* and choose the operating made that suits your needs, the default is