Skip to content

Instantly share code, notes, and snippets.

@vuhung3990
vuhung3990 / get All Media Files On Device.java
Last active August 14, 2023 11:42
get all video and image file on device
/**
* get all video path on device
* permission: READ_EXTERNAL_STORAGE
* @param context
* @return list file media
*/
public static List<File> getAllMediaFilesOnDevice(Context context) {
List<File> files = new ArrayList<>();
try {
@vuhung3990
vuhung3990 / BackgroundUploader.java
Last active December 3, 2021 22:14
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;
@vuhung3990
vuhung3990 / degrees2meters.js
Created August 3, 2021 00:34 — forked from onderaltintas/degrees2meters.js
javascript coordinate conversions between 900913(3857) - 4326(lat lon)
var degrees2meters = function(lon,lat) {
var x = lon * 20037508.34 / 180;
var y = Math.log(Math.tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180);
y = y * 20037508.34 / 180;
return [x, y]
}
//test
lon= -77.035974
lat = 38.898717
@vuhung3990
vuhung3990 / SNTP.java
Created March 4, 2015 06:50
use sntp (android)
/*
* Copyright (C) 2008 The Android Open Source Project
*
* 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
@vuhung3990
vuhung3990 / rank.json
Last active September 29, 2019 04:48
sample
{
"last_update": "2019/09/29 12:00:17",
"data": [
{
"index": 1,
"flag": "vn",
"city": "Ha Noi",
"nation": "Viet Nam",
"aqi": 180
},

Keybase proof

I hereby claim:

  • I am vuhung3990 on github.
  • I am petertux (https://keybase.io/petertux) on keybase.
  • I have a public key ASDIoJzOCbmTyRCKu6UlZ5leJZj9mM9n4ww8V-_FUw5vYwo

To claim this, I am signing this object:

@vuhung3990
vuhung3990 / ImageSliderAdapter.java
Last active August 1, 2019 08:05
simple image slider for android
public class ImageSliderAdapter extends FragmentPagerAdapter {
private final List<Fragment> fragmentList = new ArrayList<>();
public ImageSliderAdapter(@NonNull FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
return fragmentList.get(position);
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>MobileLiveChat: Activity</title>
<link rel="self" href="http://10.64.100.201/projects/mobilelivechat/activity.atom?key=5817b30bb840c72acd2b1e4771c0022ea87e9c4e"/>
<link rel="alternate" href="http://10.64.100.201/projects/mobilelivechat/activity"/>
<id>http://10.64.100.201/</id>
<icon>http://10.64.100.201/favicon.ico</icon>
<updated>2019-04-26T10:28:57Z</updated>
<author>
<name>Redmine</name>
@vuhung3990
vuhung3990 / complex device id
Last active November 12, 2018 01:34
get unique device id android
/**
* get unique device id, reuire permission READ_PHONE_STATE
*
* @param context
* @return unique id string
*/
public static String getDeviceId(Context context) {
String deviceID = null;
// TODO: check from pref if null -> generate
@vuhung3990
vuhung3990 / .editorconfig
Created September 20, 2018 13:41
EditorConfig for android project (2 space style)
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*.{java,kt,xml}]
end_of_line = lf
insert_final_newline = true