Skip to content

Instantly share code, notes, and snippets.

View rinav's full-sized avatar
🏗️
building...

Rinav rinav

🏗️
building...
  • HTC Global Services Pvt Ltd
  • Bangalore
View GitHub Profile
@rinav
rinav / Android: get CountryCode from TelephonyManager
Last active March 1, 2017 09:59
Android: Get CountryCode and Locale from TelephonyManager
// get current location iso code
TelephonyManager telMgr = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
String curLocale = telMgr.getNetworkCountryIso().toUpperCase();
Log.d(Constants.LOG_TAG, "CurrLocale: " + curLocale);
//gets the international dialling code for our current location
String curDCode = String.format("%d", phoneUtil.getCountryCodeForRegion(curLocale));
Log.d(Constants.LOG_TAG, "curDCode: " + curDCode);
@rinav
rinav / generateHashForFacebook
Created July 3, 2014 09:06
Generate Facebook Key Hash
/*
* This method is useful for generating KeyHash for facebook sdk app
* When this doesnot work
*
* keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
*/
private void generateHash() {
// Copyright 2012 Square, Inc.
package com.squareup.widgets;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ImageView;
/** Maintains an aspect ratio based on either width or height. Disabled by default. */
public class AspectRatioImageView extends ImageView {
Ionic and ngCordova upload example
@rinav
rinav / AnimatedActivity.java
Created October 13, 2015 09:56 — forked from kwent/AnimatedActivity.java
Activity transition animations like the Vine Android application. - See more at: http://blog.quent.in/index.php/2013/06/activity-transition-animations-like-the-vine-android-application/
public class AnimatedActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//opening transition animations
overridePendingTransition(R.anim.activity_open_translate,R.anim.activity_close_scale);
}
@rinav
rinav / .gitconfig
Last active September 17, 2017 17:47
default git config
# https://gist.github.com/pksunkara/988716
# https://gist.github.com/arlimus/5883472
[user]
name = Rinav Gangar
email = rinav4all@gmail.com
[core]
# excludesfile = /home/rinav/.gitignore-global
pager = less -FRX
@rinav
rinav / Interceptor.java
Created January 20, 2016 11:18 — forked from alex-shpak/Interceptor.java
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
private class HttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON
@rinav
rinav / findNCopy.md
Created April 14, 2016 09:49
find files by extension and copy them to specific directory

shell find . -type f -name "*.aar" -exec cp {} /run/media/rinav/sdk/video\ aar/ \;

@rinav
rinav / LocalBroadcastExampleActivity.java
Created May 27, 2016 07:36 — forked from Antarix/LocalBroadcastExampleActivity.java
Simple Example of using LocalBroadcastManager in Android
import android.app.Activity;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;
@rinav
rinav / android_toolbar_color_changes.txt
Created June 23, 2016 13:01
Android Toolbar text and popup color tests
Toolbar text and popup color tests
1)
Input:
app:theme="@style/ThemeOverlay.AppCompat.Light"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
Output:
Toolbar: black text, primaryColor background
Popup: black text, white background