Skip to content

Instantly share code, notes, and snippets.

@apvasanth03
apvasanth03 / PDFUtil
Created February 4, 2017 04:53
Android PDF Generator example
package com.vm.trinity.common.ui;
import android.annotation.TargetApi;
import android.graphics.Canvas;
import android.graphics.pdf.PdfDocument;
import android.os.AsyncTask;
import android.os.Build;
import android.util.Log;
import android.view.View;
@nonsintetic
nonsintetic / readme.md
Last active January 20, 2025 15:41
PHP - Get YouTube subscriber count with Youtube API v3

How to:

Here's a 'simple' way to get the YouTube subscriber number from Google's Youtube API v3:

  1. Go to https://console.developers.google.com/apis/library
  2. Log in with your Google account.
  3. Next to the logo click on 'Project' and 'Create project'. Name it whatever you want and click on 'Create'.
  4. Wait until the project is created, the page will switch to it by itself, it will take a couple of seconds up to a minute. Once it's done it will be selected next to the logo.
  5. Once it's created and selected, click on 'Credentials' from the menu on the left.
  6. Click on 'Create Credentials' and choose 'API Key'. You can restrict it to specific IPs, or types of requests (website, android, ios etc.) if you want, it's safer that way.
@liberorignanese
liberorignanese / MarginSpan.java
Last active January 12, 2024 18:05
Android TextInputLayout with credit card mask
package com.liberorignanese.android.gist;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.text.style.ReplacementSpan;
/**
* Created by Libero Rignanese.
*/
@williamwebb
williamwebb / DataBindingAdapter.java
Last active February 8, 2016 21:41
RecycleView adapter for use with Android's DataBinding plugin.
package io.jug6ernaut.fln2.views;
import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.support.annotation.AnyRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
@alunsford3
alunsford3 / MapViewHolder.java
Last active November 20, 2024 03:35
RecyclerViews with MapViews
public class MapViewHolder extends RecyclerView.ViewHolder {
private MapViewListItemView mMapViewListItemView;
public MapViewHolder(MapViewListItemView mapViewListItemView) {
super(mapViewListItemView);
mMapViewListItemView = mapViewListItemView;
}
public void mapViewListItemViewOnCreate(Bundle savedInstanceState) {
@alphamu
alphamu / SharedPreferencesSingletonEnumKeyTemplate.java
Last active March 9, 2023 11:59
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
@kevinvanmierlo
kevinvanmierlo / BaseActivity.java
Last active September 1, 2020 15:22
Same Navigation Drawer on different Activities
public class BaseActivity extends AppCompatActivity
{
public DrawerLayout drawerLayout;
public ListView drawerList;
private ActionBarDrawerToggle drawerToggle;
protected void onCreate(Bundle savedInstanceState)
{
// R.id.drawer_layout should be in every activity with exactly the same id.
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
@gabrielemariotti
gabrielemariotti / Readme.md
Last active January 1, 2025 22:35
A SimpleSectionedRecyclerViewAdapter: use this class to realize a simple sectioned `RecyclerView.Adapter`.

You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.

The RecyclerView should use a LinearLayoutManager. You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)

This is a porting of the class SimpleSectionedListAdapter provided by Google

Screen

Example:

@gabrielemariotti
gabrielemariotti / Toolbar.java
Created August 4, 2014 13:22
Android-L: A little example of the new Toolbar view.
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
//Title and subtitle
toolbar.setTitle("MY toolbar");
toolbar.setSubtitle("Subtitle");
//Menu
toolbar.inflateMenu(R.menu.toolbar_menu);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@ishitcno1
ishitcno1 / MainActivity.java
Created March 14, 2014 10:00
Two DatePickerDialog in the same Activity of Android. Use inner class for conveniention. Use a flag to detect which EditText should be change.
package com.edinstudio.app.samples.datepicker;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.DatePicker;
import android.widget.EditText;