Skip to content

Instantly share code, notes, and snippets.

View nguyenlinhnttu's full-sized avatar
🎯
Focusing

Nguyen Linh nguyenlinhnttu

🎯
Focusing
View GitHub Profile
@nguyenlinhnttu
nguyenlinhnttu / gist:9dbc6ee1590c4bbcc30b602513b6a823
Created July 3, 2018 10:22
Android Preventing Double Click On A Button
private long mLastClickTime = 0;
...
// inside onCreate or so:
findViewById(R.id.button).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// mis-clicking prevention, using threshold of 1000 ms
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define NUM_LINE 10
float arrayIndex[NUM_LINE];
int getArrayIndex(float min, float max, float unit) {
float tmp, grp_unit;
float grp_min, grp_max;
public static void makeFullTranspatentStatusBar(Activity activity) {
if (Build.VERSION.SDK_INT >= 19 && Build.VERSION.SDK_INT < 21) {
setWindowFlag(activity, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, true);
}
if (Build.VERSION.SDK_INT >= 19) {
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
if (Build.VERSION.SDK_INT >= 21) {
setWindowFlag(activity, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
activity.getWindow().setStatusBarColor(ContextCompat.getColor(activity, R.color.color_tran_opacity));
@nguyenlinhnttu
nguyenlinhnttu / ReadMe
Created May 29, 2018 03:07 — forked from pankaj89/ReadMe
Retrofit RxJava
Build Gradles
===============
//Retrofit
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'io.reactivex.rxjava2:rxjava:2.1.6'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
//Retrofit logs
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
package com.location;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentSender;
import android.location.Location;
public class NetWorkUtils {
public static boolean isNetworkAvailable(Context context) {
ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService("connectivity");
if (connectivity == null) {
return false;
}
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info == null) {
return false;
}
@nguyenlinhnttu
nguyenlinhnttu / PROGUARD ANDROID
Created February 1, 2018 04:48
PROGUARD ANDROID
#================================= DEFAULT PROGUARD RULES =========================================#
#Use 5 step of optimization
-optimizationpasses 5
#When not preverifing in a case-insensitive filing system, such as Windows. This tool will unpack your processed jars,(if using windows you should then use):
-dontusemixedcaseclassnames
#Specifies not to ignore non-public library classes. As of version 4.5, this is the default setting
-dontskipnonpubliclibraryclasses
@nguyenlinhnttu
nguyenlinhnttu / DialogFragmentCallback.md
Created January 25, 2018 08:59 — forked from Joev-/DialogFragmentCallback.md
Getting results from DialogFragment to calling Fragment using Callbacks

##Getting results from DialogFragments to another Fragment.

When setting up the DialogFragment make a call to Fragment.setTargetFragment()
Then from DialogFragment you can access the main fragment with Fragment.getTargetFragment()
Use interfaces to provide the required actions to the calling Fragment.

##Example code.

###AddFriendDialogFragment - Calls back to calling fragment.

@nguyenlinhnttu
nguyenlinhnttu / CustomFontTextView
Created January 5, 2018 08:07
Custom TextView/Button/ ------- Cache Font
public class CustomFontTextView extends AppCompatTextView {
private static final String ANDROID_SCHEMA = "http://schemas.android.com/apk/res/android";
public CustomFontTextView(Context context, AttributeSet attrs) {
super(context, attrs);
applyCustomFont(context, attrs);
}
public CustomFontTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
public void goapps(View v) {
Intent intent = new Intent("android.intent.action.VIEW");
intent.setData(Uri.parse("market://search?q=pub:ltsolution"));
startActivity(intent);
}