Skip to content

Instantly share code, notes, and snippets.

View msomu's full-sized avatar
🏠
Working from home

Somasundaram M msomu

🏠
Working from home
View GitHub Profile
@msomu
msomu / justickets.sh
Last active March 22, 2017 17:45
pull db from mobile
adb shell "run-as in.justickets.android.staging chmod 666 /data/data/in.justickets.android.staging/files/justickets.realm"
adb -d shell 'run-as in.justickets.android.staging cp /data/data/in.justickets.android.staging/files/justickets.realm /sdcard/justickets.realm'
adb pull /sdcard/justickets.realm
@msomu
msomu / MainActivity.java
Created November 9, 2016 06:32
This will create a simple notification with actions in it.
private void createSimpleNotificationWithAction() {
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("My notification")
.setContentText("Hello World!");
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(this, MainActivity.class);
// The stack builder object will contain an artificial back stack for the
@msomu
msomu / MainActivity.java
Created November 9, 2016 06:27
This will create a larger notification InBoxStyle Notification
private void createInboxStyleNotification() {
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("My notification")
.setContentText("Hello World!");
NotificationCompat.InboxStyle inboxStyle =
new NotificationCompat.InboxStyle();
String[] events = new String[6];
events[0] = "Line 1";
@msomu
msomu / MainActivity.java
Created November 9, 2016 06:23
This is a simple method which will create a Notification on Android.
private void createSimpleNotification() {
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("My notification")
.setContentText("Hello World!");
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(this, MainActivity.class);
// The stack builder object will contain an artificial back stack for the
@msomu
msomu / adb.sh
Created August 31, 2016 11:31
To pull it from android
adb shell
run-as com.example.app
cp databases/failname.db /sdcard
exit
exit
adb pull /sdcard/failname.db
@msomu
msomu / CursorRecyclerViewAdapter.java
Created April 16, 2016 21:06
CursorRecyclerViewAdapter for cursor with recylerView
package com.msomu.popularmovies;
/**
* Created by msomu on 17/04/16.
*/
/*
* Copyright (C) 2014 skyfish.jy@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@msomu
msomu / adapter.java
Created March 29, 2016 10:20
Android image place holder
RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) holder.image.getLayoutParams();
float ratio = item.getHeight() / item.getWidth();
rlp.height = (int) (rlp.width * ratio);
holder.image.setLayoutParams(rlp);
Picasso.with(holder.image.getContext()).load(item.getPic()).into(holder.image);
holder.text.setText(item.getName());
holder.itemView.setTag(item);
@msomu
msomu / Image.java
Created February 2, 2016 11:51
Image
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.net.Uri;
import android.util.Log;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
@msomu
msomu / angular.js
Created January 28, 2016 14:39
Angular HttpService
// Simple GET request example:
$http({
method: 'GET',
url: '/someUrl'
}).then(function successCallback(response) {
// this callback will be called asynchronously
// when the response is available
}, function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
@msomu
msomu / ValidateUtils.java
Last active December 2, 2015 07:46
My Validate Utils
import android.app.Activity;
import android.support.design.widget.TextInputLayout;
import android.view.View;
import android.view.WindowManager;
import android.widget.EditText;
import java.util.regex.Matcher;
import java.util.regex.Pattern;