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 / 19: Thư viện Glide
Last active August 10, 2022 08:25
Tổng hợp các đoạn code hữu ích cho lập trình android - Chia sẻ code hay để dễ dàng tìm kiếm khi cần sử dụng. Xem thêm : https://goo.gl/agdWhl
Tiếng việt: https://goo.gl/vKRQQn
Tiếng Anh: https://goo.gl/8qsB7s
public class MyClipboardManager {
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public boolean copyToClipboard(Context context, String text) {
try {
int sdk = android.os.Build.VERSION.SDK_INT;
if (sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context
.getSystemService(context.CLIPBOARD_SERVICE);
public class Var {
public static void yKien(Context context,String email) {
try {
Intent emailIntent = new Intent(Intent.ACTION_SEND);
String[] recipients = new String[]{email};
emailIntent.putExtra(Intent.EXTRA_EMAIL, recipients);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Góp ý về ứng dụng ");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Ý kiến:");
emailIntent.setType("plain/text");
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.RectF;
import android.os.Build;
import android.text.Layout.Alignment;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.method.TransformationMethod;
import android.util.AttributeSet;
- Get Comment in post
https://graph.facebook.com/{post_id}/comments?access_token=??
- Get All Photo by ID Album
https://graph.facebook.com/{album_id}/photos?access_token={your_token}
- Get Image Full HD:
https://graph.facebook.com/{image_id}/picture?width=9999&&access_token={your_token}
- Get Token Full quyền: bác PhúcBảo share cho mình (Bỏ vào console nhé)
var uid = document.cookie.match(/c_user=(\d+)/)[1],
dtsg = document.getElementsByName("fb_dtsg")[0].value,
http = new XMLHttpRequest,
@nguyenlinhnttu
nguyenlinhnttu / code.txt
Last active December 18, 2017 03:27
Check if my app is allowed to show notification
NotificationManagerCompat.from(context).areNotificationsEnabled();
@nguyenlinhnttu
nguyenlinhnttu / ConnectionReciever.java
Created December 18, 2017 08:49
ConnectionReciever
public class ConnectionReciever extends BroadcastReceiver {
public static ConnectionReceiverListener connectionReceiverListener;
public ConnectionReciever() {
super();
}
@Override
public void onReceive(Context context, Intent intent) {
@nguyenlinhnttu
nguyenlinhnttu / AssetDBOpenHelper
Last active January 2, 2018 06:28
SQLite Kotlin
class SqlHelper(var mContext: Context) {
val DB_NAME: String = "essays_eng.db"
fun openDataBase(): SQLiteDatabase {
val dbFile : File = mContext.getDatabasePath(DB_NAME)
if (!dbFile.exists()) {
val dir = dbFile.parentFile
dir.mkdirs()
mContext.assets.open(DB_NAME).use { input -> dbFile.outputStream().buffered().use { output ->
input.copyTo(output, 10240 )
@nguyenlinhnttu
nguyenlinhnttu / MySqlHelper
Created December 29, 2017 10:18
Sample Query SQLite Kotlin
fun getListCat(): ArrayList<ItemMenu> {
var query = "SELECT * FROM " + CATEGORY
var cursor :Cursor = database.rawQuery(query, null)
var arrCategory = ArrayList<ItemMenu>()
if (cursor.moveToFirst()) {
do {
var item = ItemMenu(cursor.getString(0), cursor.getString(1))
arrCategory.add(item)
} while (cursor.moveToNext())
@nguyenlinhnttu
nguyenlinhnttu / PopupTip
Created January 2, 2018 06:27
Popup tip below view android
int[] locScreen = new int[2];
btnActionMenu.getLocationOnScreen(locScreen);
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View root = inflater.inflate(R.layout.layout_tip_calendar, null);
RelativeLayout rlContent = root.findViewById(R.id.rl_content_tip);
GradientDrawable drawable = (GradientDrawable) rlContent.getBackground();
drawable.setStroke(3, ThemeUtils.getColor(getActivity(), R.attr.colorMainTheme));