Skip to content

Instantly share code, notes, and snippets.

View thanhcs94's full-sized avatar
🏠
Working from home

ThanhCS94 thanhcs94

🏠
Working from home
View GitHub Profile
@thanhcs94
thanhcs94 / react_native_structure.js
Created March 17, 2017 14:08
React-native structure
|-src
|- components
|- scenes
|- style
|- utils
constain.js
index.android.js
index.ios.js
/** details **/
@thanhcs94
thanhcs94 / AdjustableImageView.java
Created February 4, 2017 04:36
AdjustableImageView
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.ImageView;
/**
* Created by nuuneoi on 2/17/15 AD.
*/
@thanhcs94
thanhcs94 / MapOnlickItemInforWindown.java
Created January 6, 2017 09:56
MapOnlickItemInforWindown.java
/*** MaiFragment **/
/**
* Created by ThanhCS94 on 1/6/17.
* I'm HIDING. Don't waste your time to find me.
*/
public class SimpleMapsActivity extends Fragment implements OnMapReadyCallback {
public static String TAG = "MAPS";
private ViewGroup infoWindow;
@thanhcs94
thanhcs94 / googlesignin_getaccestoken.java
Created October 24, 2016 11:14
get accesstoken ,sigin google plus
package com.google.devrel.samples.gmstest.app;
import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@thanhcs94
thanhcs94 / takescreenshot.java
Created July 31, 2016 05:00
Take screen shot of specific view
private void takeScreenshot() {
Date now = new Date();
android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss", now);
try {
// image naming and path to include sd card appending name you choose for file
String mPath = Environment.getExternalStorageDirectory().toString() + "/" + now + ".jpg";
// create bitmap screen capture
View v1 = //your view here, example linnerlayout, framlayout..
@thanhcs94
thanhcs94 / getEmail.java
Created July 13, 2016 00:44
GetUserEmail
Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
Account[] accounts = AccountManager.get(this).getAccounts();
for (Account account : accounts) {
if (emailPattern.matcher(account.name).matches()) {
String possibleEmail = account.name;
Log.wtf(TAG+"-possibleEmail : ", possibleEmail);
}
}
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cal = Calendar.getInstance();
Date start = new Date();
try {
start = dateFormat.parse(time);
} catch (ParseException e) {
e.printStackTrace();
}
tvDate.setText(new DateTimeUtil().getDiff(start, cal.getTime()));
//
public class FontTextView extends TextView {
public FontTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
parseAttributes(context, attrs);
}
public FontTextView(Context context, AttributeSet attrs) {
super(context, attrs);
parseAttributes(context, attrs);
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#293131" />
<corners android:radius="15dp" />
<padding
android:left="15dp"
android:top="4dp"
android:right="15dp"
android:bottom="4dp" />
@thanhcs94
thanhcs94 / sharetospecificapp.java
Created April 11, 2016 18:19
sharetospecificapp
void share(String nameApp, String imagePath) {
try
{
List<Intent> targetedShareIntents = new ArrayList<Intent>();
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("image/png");
List<ResolveInfo> resInfo = context.getPackageManager().queryIntentActivities(share, 0);
if (!resInfo.isEmpty()){
for (ResolveInfo info : resInfo) {
Intent targetedShare = new Intent(android.content.Intent.ACTION_SEND);