Skip to content

Instantly share code, notes, and snippets.

@duynhm
duynhm / DaggerApi.java
Last active December 27, 2018 03:47
Code minh họa cho bài viết Dagger 2 — Part 1 — Các Annotation trong dagger 2
public @interface Component {
Class<?>[] modules() default {};
Class<?>[] dependencies() default {};
}
public @interface Subcomponent {
Class<?>[] modules() default {};
}
public @interface Module {
@duynhm
duynhm / Click_word.java
Last active September 10, 2019 06:02
Spannable Click TextView Android
//click từng kí tự
private SpannableStringBuilder addClickablePart1(String str) {
SpannableStringBuilder ssb = new SpannableStringBuilder(str);
String[] array = str.split(" ");
int next = 0;
int start = 0;
for (final String s : array) {
start = str.indexOf(s, next);
ssb.setSpan(new NonUnderlinedClickableSpan() {
@Override
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
"to": "/topics/foo-bar",
"data": {
"message": "This is a Firebase Cloud Messaging Topic Message!",
}
}
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="0dp"
android:id="@+id/edt1"
style="@style/edt_otp"
/>
<!--style-->
<!--animation ripple when click cardview-->
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground">
@duynhm
duynhm / style.xml
Created December 13, 2016 07:23
các style xml cần nhớ
<!--Đổi màu item option menu trên toolbar-->
<item name="android:actionMenuTextColor">@color/primary</item>
@duynhm
duynhm / viewpager.java
Created December 16, 2016 03:45
Các note lien quan đến ViewPager
//viewPager
/*FragmentPagerAdapter
This version of the pager is best for use when there are a handful of typically more static fragments to be paged through, such as a set of tabs. The fragment of each page the user visits will be kept in memory, though its view hierarchy may be destroyed when not visible. This can result in using a significant amount of memory since fragment instances can hold on to an arbitrary amount of state. For larger sets of pages, consider FragmentStatePagerAdapter.
*/
/*FragmentStatePagerAdapter:
This version of the pager is more useful when there are a large number of pages, working more like a list view. When pages are not visible to the user, their entire fragment may be destroyed, only keeping the saved state of that fragment. This allows the pager to hold on to much less memory associated with each visited page as compared to FragmentPagerAdapter at the cost of potentially more overhead when switching between pages.*/
/*setOffscreenPageLimit(int limit)
Set the number of pages
@duynhm
duynhm / GET and POST Requests in Google Apps Script
Created March 29, 2018 02:38
GET and POST Requests in Google Apps Script
function doGet(e) {
if(typeof e !== 'undefined')
return ContentService.createTextOutput(JSON.stringify(e.parameter));
}
function doPost(e) {
if(typeof e !== 'undefined')
@duynhm
duynhm / Report generation.yaml
Created September 10, 2018 07:20
Writes data to the workbook, reads and applies basic formatting, and adds a chart bound to that data. - Shared with Script Lab
name: Report generation
description: 'Writes data to the workbook, reads and applies basic formatting, and adds a chart bound to that data.'
author: duynhm
host: EXCEL
api_set: {}
script:
content: |
$("#create-report").click(() => tryCatch(createReport));
/** Load sample data into a new worksheet and create a chart */