Skip to content

Instantly share code, notes, and snippets.

View luizmarcus's full-sized avatar

Luiz Marcus luizmarcus

View GitHub Profile
Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
Palette.Swatch vibrantSwatchDark = palette.getDarkVibrantSwatch();
Palette.Swatch vibrantSwatchLight = palette.getLightVibrantSwatch();
Palette.Swatch mutedSwatch = palette.getMutedSwatch();
Palette.Swatch mutedSwatchDark = palette.getDarkMutedSwatch();
Palette.Swatch mutedSwatchLight = palette.getLightMutedSwatch();
if (vibrantSwatch!=null) {
vibrant.setBackgroundColor(vibrantSwatch.getRgb());
vibrantText.setTextColor(vibrantSwatch.getTitleTextColor());
vibrantText.setText("Vibrant");
}
if (vibrantSwatchDark!=null) {
vibrantDark.setBackgroundColor(vibrantSwatchDark.getRgb());
vibrantDarkText.setTextColor(vibrantSwatchDark.getTitleTextColor());
vibrantDarkText.setText("Vibrant Dark");
apply plugin: 'com.android.application'
apply plugin: 'android-apt'//plugin que auxilia no processamento das annotations
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "br.com.luizmarcus.exemploannotations"
minSdkVersion 15
@EActivity(R.layout.activity_main)
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}
@EActivity(R.layout.activity_main)
public class MainActivity extends AppCompatActivity {
@ViewById
protected ImageView imagem;
@ViewById(R.id.viewText)
protected TextView texto;
@ViewById
/**
* Chamado após carregar as views
*/
@AfterViews
void loadViews(){
texto.setText("Views inicializadas");
}
/*
* Chamado quando o botão é clicado
* */
@Click(R.id.botao)
void baixarImagem(){
texto.setText("Baixando imagem");
executarDownload();
}
/*
* Cria um thread em background para executar o método
* */
@Background
void executarDownload(){
Bitmap img = null;
try {
InputStream in = new java.net.URL(IMG_URL).openStream();
img = BitmapFactory.decodeStream(in);
} catch (Exception e) {
@EActivity(R.layout.activity_main)
public class MainActivity extends AppCompatActivity {
private static final String IMG_URL = "https://pixabay.com/static/uploads/photo/2013/10/22/03/49/waterfall-199204_960_720.jpg";
@ViewById
protected ImageView imagem;
@ViewById(R.id.viewText)
protected TextView texto;
//Antes da alteração
<activity android:name="br.com.luizmarcus.exemploannotations.MainActivity" >
//Após a alteração
<activity android:name="br.com.luizmarcus.exemploannotations.MainActivity_" >