Skip to content

Instantly share code, notes, and snippets.

View alimogh's full-sized avatar

alimogh

View GitHub Profile
@alimogh
alimogh / AndroidManifest.xml
Created May 10, 2021 05:26 — forked from BrandonSmith/AndroidManifest.xml
Quick example of how to schedule a notification in the future using AlarmManager
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cards.notification">
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
@alimogh
alimogh / CheatSheet.java
Created May 10, 2021 05:21 — forked from romannurik/CheatSheet.java
Android helper class for showing cheat sheets (tooltips) for icon-only UI elements on long-press. This is already default platform behavior for icon-only action bar items and tabs. This class provides this behavior for any other such UI element.
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@alimogh
alimogh / Menu.java
Created May 10, 2021 04:50 — forked from Superpat/Menu.java
A small java command line api to generate a menu that can return a generic
import java.util.List;
import java.util.Optional;
import java.util.Scanner;
/** Menu api for the command line
* <p>
* Takes a list of options containing a value and a menu title, when called, the menu returns an optional type containing the option.
* </p>
* @author Patrick Marchand <mail@patrickmarchand.com>
* @version 0.2
@alimogh
alimogh / MoveDirectoryContents.java
Created April 30, 2021 03:14 — forked from saurabhkpatel/MoveDirectoryContents.java
Move Directory contents : Android/Java
/**
* This utility method moves contents from sourceDirectory to destinationDirectory
*
* @param sourceDirectory : from where to get contents
* @param destinationDirectory : where to move contents
* @return true if success, false otherwise.
*/
public static boolean moveDirectoryContents(@NonNull File sourceDirectory, @NonNull File destinationDirectory) {
if (!sourceDirectory.exists()) {
return false;
/**
* This is a direct port of https://github.com/nathan-fiscaletti/ansi-util
*
* @author Nathan Fiscaletti
* @see https://github.com/nathan-fiscaletti/ansi-util
*
* Usage:
*
* StringBuilder sb = new StringBuilder();
*
@alimogh
alimogh / Spinner Setup (Activity)
Created March 21, 2021 19:48 — forked from Suleiman19/Spinner Setup (Activity)
Theme Aware Material Design Spinner
Spinner spinner = (Spinner) findViewById(R.id.main_spinner);
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getSupportActionBar().getThemedContext(),
R.layout.spinner_list_style,
getResources().getStringArray(R.array.countries));
spinnerAdapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
spinner.setAdapter(spinnerAdapter);
@alimogh
alimogh / webView Back Button Press Example
Created July 29, 2020 16:28 — forked from mattieapps/webView Back Button Press Example
A working way of making Android WebView go back one page on "back key" press
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
mWebView.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
@alimogh
alimogh / MyActivity.java
Created May 3, 2020 22:50 — forked from markushi/MyActivity.java
Reveal Color View Demo
package at.markushi.reveal;
import android.app.Activity;
import android.graphics.Color;
import android.graphics.Point;
import android.os.Bundle;
import android.view.View;
import at.markushi.ui.RevealColorView;