android {
//...
buildTypes {
This file contains 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 android.support.design.widget.AppBarLayout; | |
/** | |
* App bar collapsing state | |
* @author Paulo Caldeira <[email protected]>. | |
*/ | |
public abstract class AppBarStateChangeListener implements AppBarLayout.OnOffsetChangedListener { | |
// State | |
public enum State { | |
EXPANDED, |
This file contains 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 dagger.Component | |
import dagger.Module | |
import dagger.Provides | |
import javax.inject.Inject | |
import javax.inject.Singleton | |
interface Heater { | |
fun on() | |
fun off() | |
} |
Centralize the support libraries dependencies in gradle
Working with multi-modules project, it is very useful to centralize the dependencies, especially the support libraries.
A very good way is to separate gradle build files, defining something like:
root
--gradleScript
----dependencies.gradle
This file contains 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
public void onShareClick(View v) { | |
Resources resources = getResources(); | |
Intent emailIntent = new Intent(); | |
emailIntent.setAction(Intent.ACTION_SEND); | |
// Native email client doesn't currently support HTML, but it doesn't hurt to try in case they fix it | |
emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(resources.getString(R.string.share_email_native))); | |
emailIntent.putExtra(Intent.EXTRA_SUBJECT, resources.getString(R.string.share_email_subject)); | |
emailIntent.setType("message/rfc822"); |
This file contains 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.laimiux.dayahead.ui.util; | |
import android.content.Context; | |
import android.os.Bundle; | |
import android.os.Parcelable; | |
import android.support.v4.view.PagerAdapter; | |
import android.util.Log; | |
import android.util.SparseArray; | |
import android.view.LayoutInflater; | |
import android.view.View; |
This file contains 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
FullScreenDialog dialog = new FullScreenDialog(); | |
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); | |
dialog.show(ft, FullScreenDialog.TAG); |
This file contains 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.your.package; | |
import java.util.Random; | |
import android.app.Activity; | |
import android.content.Context; | |
import android.graphics.BitmapFactory; | |
import android.graphics.BitmapShader; | |
import android.graphics.Canvas; | |
import android.graphics.Color; |