Skip to content

Instantly share code, notes, and snippets.

View socmia's full-sized avatar
🌴
On vacation

Le Van Long socmia

🌴
On vacation
  • Viet Nam
  • 07:12 (UTC +07:00)
View GitHub Profile
/**
* Using reflection to override default typeface
* NOTICE: DO NOT FORGET TO SET TYPEFACE FOR APP THEME AS DEFAULT TYPEFACE WHICH WILL BE OVERRIDDEN
*Use
* @param context to work with assets
* @param defaultFontNameToOverride for example "monospace"
* @param customFontFileNameInAssets file name of the font from assets
*/
public static void overrideFont(Context context, String defaultFontNameToOverride, String customFontFileNameInAssets) {
try {
<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
<item name="android:windowContentTransitions">true</item>
<item name="android:textColorSecondary">@color/secondary_text</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
<item name="android:colorAccent">@color/pink</item>
<item name="colorControlHighlight">@color/accent_translucent</item>
<item name="android:typeface">serif</item>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:textColorSecondary">@color/secondary_text</item>
<item name="android:windowBackground">@color/windowBackground</item>
<item name="colorControlHighlight">@color/accent_translucent</item>
<item name="colorAccent">@color/pink</item>
public abstract class SwipeDismissBaseActivity extends AppCompatActivity {
private static final int SWIPE_MIN_DISTANCE = 120;
private static final int SWIPE_MAX_OFF_PATH = 250;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;
private GestureDetector gestureDetector;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gestureDetector = new GestureDetector(new SwipeDetector());
@socmia
socmia / Dagger2.java
Created May 31, 2017 02:35
We create a class called NetModule.java and annotate it with @module to signal to Dagger to search within the available methods for possible instance providers. The methods that will actually expose available return types should also be annotated with @provides decorator. The Singleton annotation also signals to the Dagger compiler that the inst…
@Module
public class NetModule {
String mBaseUrl;
// Constructor needs one parameter to instantiate.
public NetModule(String baseUrl) {
this.mBaseUrl = baseUrl;
}
@socmia
socmia / countries.json
Last active October 18, 2018 14:13 — forked from smitroshin/countries.json
Countries - name, dial_code, code
[
{
"name": "Afghanistan",
"dial_code": "+93",
"code": "AF"
},
{
"name": "Aland Islands",
"dial_code": "+358",
"code": "AX"
let total = 0;
orders.forEach(order => total += order.value);
console.log(total);
///////////// Map function
let ordersWithShipping = orders.map(order => {
order.shipping = calculateShipping(order);
order.total = order.value + order.shipping;
return order;
});
class SegmentView(context: Context, attrs: AttributeSet) : LinearLayout(context, attrs) {
init {
View.inflate(context, R.layout. segment_button, this);
val btnSeg1: Button = findViewById(R.id.button)
val btnSeg2: Button = findViewById(R.id.button2)
}
}
<resources>
<style name="Button.Flat" parent="Widget.AppCompat.Button">
<item name="android:textColor">@color/colorAccent</item>
<item name="android:background">@drawable/bg_button_state</item>
</style>
<style name="Button.Colored" parent="Widget.AppCompat.Button.Colored">
<item name="android:background">@drawable/bg_button_solid</item>
<item name="android:textColor">#727272</item>
</style>
@socmia
socmia / Storing-Images-On-Github.md
Created March 11, 2019 03:45 — forked from joncardasis/Storing-Images-On-Github.md
Storing Images and Demos in your Repo

Storing Images and Demos in your Repo

In this quick walkthough you'll learn how to create a separate branch in your repo to house your screenshots and demo gifs for use in your master's readme.

How to

1. Clone a fresh copy of your repo

In order to prevent any loss of work it is best to clone the repo in a separate location to complete this task.

2. Create a new branch

Create a new branch in your repo by using git checkout --orphan assets