This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import timber.log.Timber | |
| import kotlin.properties.ReadOnlyProperty | |
| import kotlin.reflect.KProperty | |
| class MyClass { | |
| // This will automatically have the TAG "MyClass" | |
| private val log by timber() | |
| fun logSomething() { | |
| log.i("Hello") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Fade a view to visible or gone. This function is idempotent - it can be called over and over again with the same | |
| * value without affecting an in-progress animation. | |
| */ | |
| fun View.fadeTo(visible: Boolean, duration: Long = 500, startDelay: Long = 0, toAlpha: Float = 1f) { | |
| // Make this idempotent. | |
| val tagKey = "fadeTo".hashCode() | |
| if (visible == isVisible && animation == null && getTag(tagKey) == null) return | |
| if (getTag(tagKey) == visible) return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class WifiNetworksFragment : TonalFragment(R.layout.wifi_networks_fragment) { | |
| // This automatically creates and clears the binding in a lifecycle-aware way. | |
| private val binding: WifiNetworksFragmentBinding by viewBinding() | |
| ... | |
| } | |
| class WifiNetworkView @JvmOverloads constructor( | |
| context: Context, | |
| attrs: AttributeSet? = null, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ChatRoomsFragment : Fragment() { | |
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
| super.onViewCreated(view, savedInstanceState) | |
| viewModel = ViewModelProviders.of(this, factory).get(ChatRoomsViewModel::class.java) | |
| subscribeUi() | |
| } | |
| private fun subscribeUi() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.nezspencer.test | |
| import android.os.Bundle | |
| import android.support.annotation.NonNull | |
| import android.support.v7.app.AppCompatActivity | |
| import android.text.Editable | |
| import android.text.TextUtils | |
| import android.text.TextWatcher | |
| import android.widget.EditText | |
| import java.text.NumberFormat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Copyright (C) 2017 The Android Open Source Project | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Abbrevation | Description | |
|---|---|---|
| center | Centers any view in the parent horizontally and vertically | |
| centerh | Centers any view horizontally in the parent | |
| centerv | Centers any view vertically in the parent | |
| vertical | Centers any view vertically in any other view | |
| horizontal | Centers any view horizontally in any other view | |
| fill | Fills any view on all edges to parent | |
| over | Puts any view over an other view by setting same constrains as the original view. Works like fill but for any other view | |
| above | Puts any view above another view | |
| below | Puts any view below another view |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // When the EditText is touched, disable touches on it's ScrollView's parents. | |
| // Once the user lifts up their finger, enable touches on on the ScrollView's parents once again. | |
| @OnTouch(R.id.edit_text) | |
| boolean handleNoteFieldTouch(View v, MotionEvent event) { | |
| v.getParent().getParent().requestDisallowInterceptTouchEvent(true); | |
| switch (event.getAction() & MotionEvent.ACTION_MASK){ | |
| case MotionEvent.ACTION_UP: | |
| v.getParent().getParent().requestDisallowInterceptTouchEvent(false); | |
| break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #/bin/sh | |
| ffmpeg -i input -c:v libx264 -preset slow -profile:v high -crf 18 -coder 1 -pix_fmt yuv420p -movflags +faststart -g 30 -bf 2 -c:a aac -b:a 384k -profile:a aac_low output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AccountHolder extends MvpViewHolder implements AccountView { | |
| @InjectPresenter | |
| AccountPresenter mAccountPresenter; | |
| /** | |
| @BindView(R.id.item_account_check_box) | |
| CheckBox mCheckBox; | |
| ... | |
| **/ |
NewerOlder