Skip to content

Instantly share code, notes, and snippets.

View akbarsha03's full-sized avatar
🎯
I just keep trying

Akbarsha M akbarsha03

🎯
I just keep trying
View GitHub Profile
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, "emailaddress@emailaddress.com");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT, "I'm email body.");
startActivity(Intent.createChooser(intent, "Send Email"));
/**
* Calls the specified function [block] and returns its result.
*/
@kotlin.internal.InlineOnly
public inline fun <R> run(block: () -> R): R = block()
@akbarsha03
akbarsha03 / RxJavaRecursiveUsingPublishSubject.java
Last active January 8, 2017 06:05
RxJava recursive function using PublishSubject
PublishSubject<Integer> limit = PublishSubject.create();
limit.concatMap(integer -> Observable.just(integer + 1)) // Assuming this gives network result based upon the artist id you provided
.doOnNext(integer -> {
// Based on the network result i make my conditions here
Timber.d("Publish: doOnNext: %d", integer);
if (integer < 10) {
// Pass the artist id to make the next call
limit.onNext(integer);
} else {
@akbarsha03
akbarsha03 / Permission.java
Created November 24, 2015 13:49
Check Permission
private boolean isPermsAvailable() {
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|| ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_GRANTED
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Vibrator;
/**
* Uses a combination of a PageTransformer and swapping X & Y coordinates
* of touch events to create the illusion of a vertically scrolling ViewPager.
*
* Requires API 11+
*
*/
public class VerticalViewPager extends ViewPager {
public VerticalViewPager(Context context) {
@akbarsha03
akbarsha03 / ShakeDetector.java
Created April 28, 2015 13:11
from square.github.io // seismic / jakewharton
// Copyright 2010 Square, Inc.
package com.squareup.seismic;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import java.util.ArrayList;
import java.util.List;
// Copyright 2010 Square, Inc.
package com.squareup.seismic;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import java.util.ArrayList;
import java.util.List;
// Copyright 2010 Square, Inc.
package com.squareup.seismic;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import java.util.ArrayList;
import java.util.List;
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array