Skip to content

Instantly share code, notes, and snippets.

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

Nilesh Singh n1lesh

🏠
Working from home
View GitHub Profile
@n1lesh
n1lesh / SampleCardView.xml
Created December 18, 2017 15:02
Android CardView Sample - XML
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="250dp"
app:cardBackgroundColor="@android:color/white"
app:cardCornerRadius="0dp"
app:cardMaxElevation="1dp"
app:cardElevation="0.7dp"
app:contentPadding="10dp"
app:contentPaddingBottom="0dp"
app:cardPreventCornerOverlap="true"
@n1lesh
n1lesh / SampleCardView.java
Created December 18, 2017 15:01
Android CardView Sample - Java Raw
CardView cardView = (CardView) findViewById(R.id.cardView);
cardView.setUseCompatPadding(true);
cardView.setContentPadding(30, 30, 30, 0);
cardView.setPreventCornerOverlap(true);
cardView.setCardBackgroundColor(Color.WHITE);
cardView.setCardElevation(2.1f);
cardView.setRadius(0);
cardView.setMaxCardElevation(3f);
@n1lesh
n1lesh / MessageReceiver.java
Created December 18, 2017 08:33
Sample Code for Push Notifications (FCM) on Android - Message Receiver
package com.mynotificationsapp.android;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
@n1lesh
n1lesh / InstanceIdService.java
Created December 18, 2017 08:31
Sample Code for Push Notifications (FCM) on Android - Instance ID Service
package com.mynotificationsapp.android;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
@n1lesh
n1lesh / AndroidManifest.xml
Created December 18, 2017 08:30
Sample Code for Push Notifications (FCM) on Android - Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mynotificationsapp.android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
@n1lesh
n1lesh / SampleCardView.java
Created August 4, 2017 06:47
Android CardView Sample - XML and Java Raw
CardView cardView = (CardView) findViewById(R.id.cardView);
cardView.setUseCompatPadding(true);
cardView.setContentPadding(30, 30, 30, 0);
cardView.setPreventCornerOverlap(true);
cardView.setCardBackgroundColor(Color.WHITE);
cardView.setCardElevation(2.1f);
cardView.setRadius(0);
cardView.setMaxCardElevation(3f);
@n1lesh
n1lesh / SafeBrowsingManifest.xml
Last active August 28, 2022 23:53
Enable Safe Browsing in WebViews - Android O
<manifest>
<application>
. . .
<meta-data android:name="android.webkit.WebView.EnableSafeBrowsing"
android:value="true" />
. . .
</application>
</manifest>
@n1lesh
n1lesh / ButtonSpringEffect.java
Last active June 22, 2017 10:28
Getting spring like effect on Android Buttons with ViewPropertyAnimator
final Button button = (Button) findViewById(R.id.v);
final ViewPropertyAnimator animator = button.animate();
animator.setDuration(200);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
button.setEnabled(false);
@n1lesh
n1lesh / LinearGradientDrawable.java
Last active January 30, 2022 03:57
Android Gradient Toolbar and Statusbar
RelativeLayout layout = (RelativeLayout) findViewById(R.id.rel);
GradientDrawable drawable = new GradientDrawable();
drawable.setColors(new int[] {
Color.parseColor("#FFF6B7"),
Color.parseColor("#F6416C")
});
drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
drawable.setOrientation(GradientDrawable.Orientation.LEFT_RIGHT);
@n1lesh
n1lesh / fcm1.js
Last active May 31, 2023 12:24
Firebase Cloud Messaging with Node.js
'use strict'
const app = require('express')(),
request = require('request'),
mongo = require('mongodb'),
bodyParser = require('body-parser')
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({
extended: false