Skip to content

Instantly share code, notes, and snippets.

View ar-android's full-sized avatar
:octocat:
NULL

Ahmad Rosid ar-android

:octocat:
NULL
View GitHub Profile
/**
* convert milisec to hh:MM:ss
* @param millisUntilFinished
* @return String time
*/
public static String convertMilisecToHMmSs(long millisUntilFinished) {
return String.format("%02d:%02d:%02d",
TimeUnit.MILLISECONDS.toHours(millisUntilFinished),
TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished) - TimeUnit.HOURS.toMinutes(
TimeUnit.MILLISECONDS.toHours(millisUntilFinished)),
@ar-android
ar-android / EndlessRecyclerOnScrollListener.java
Created March 13, 2017 18:58 — forked from ssinss/EndlessRecyclerOnScrollListener.java
Endless RecyclerView OnScrollListener
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
@ar-android
ar-android / BackgroundUploader.java
Created February 13, 2017 08:53 — forked from vuhung3990/BackgroundUploader.java
background upload with progress
package com.grasys.shortupload.helper;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataOutputStream;
// WEEK
Calendar first = Calendar.getInstance();
first.add(Calendar.DAY_OF_WEEK, first.getFirstDayOfWeek() - first.get(Calendar.DAY_OF_WEEK));
int startWeek = first.get(Calendar.DATE);
int endWeek = startWeek + 6;
// MONTH
// start = 1
Calendar date = Calendar.getInstance();
@ar-android
ar-android / FRP iOS Learning resources.md
Created February 13, 2017 12:04 — forked from JaviLorbada/FRP iOS Learning resources.md
The best FRP iOS resources.

Videos

@ar-android
ar-android / update.java
Created February 13, 2017 08:52 — forked from vuhung3990/update.java
File write, read, delete example ,must have READ, WRITE permissions
/**
* Write content into file
*
* @param path require WRITE_EXTERNAL
* @param contentString
*/
public static void writeContentFile(String path, String contentString) {
File file = new File(path);
if (!file.exists())
@ar-android
ar-android / gist:1b1ef871d2a330876ef0d1a2ed79d480
Created February 13, 2017 12:22 — forked from prime31/gist:5675017
Simple PHP script showing how to send an Android push notification. Be sure to replace the API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call scriptName.php?id=THE_DEVICE_REGISTRATION_ID
<?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
@ar-android
ar-android / get app info from the Manifest file
Created February 13, 2017 08:23 — forked from vuhung3990/get app info from the Manifest file
Get app info from the Manifest file
/**
* Get the "android:versionName" value from the Manifest file.
*
* @param context The current Context or Activity that this method is called from
* @return the application version string, or "Unknown" if versionName cannot be found for
* the given context.
*/
public static String getVersionName(Context context) {
String versionName;
try {
@ar-android
ar-android / README-Template.md
Created November 3, 2017 08:29 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@ar-android
ar-android / RxJava.md
Created March 21, 2016 00:22 — forked from cesarferreira/RxJava.md
Party tricks with RxJava, RxAndroid & Retrolambda

View Click

Instead of the verbose setOnClickListener:

RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));

Filter even numbers

Observable
    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)