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 class Pessoa{ | |
String cpf; | |
String nome; | |
//Gerar métodos get e set dos parâmetros | |
} |
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 interface PessoaApi { | |
@GET("/pessoas/{cpf}") | |
Pessoa getPessoa( | |
@Path("cpf") String cpf | |
); | |
} |
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
private static final String API_URL = "http://seusite.com/api"; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
textView = (TextView) findViewById(R.id.textView); | |
BackgroundTask task = new BackgroundTask(); | |
task.execute(); |
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 class Evento { | |
private String alerta; | |
public Evento(String alerta){ | |
this.alerta = alerta; | |
} | |
public String getAlerta(){ | |
return alerta; | |
} |
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 class EventoReceiver extends BroadcastReceiver { | |
private EventBus bus = EventBus.getDefault(); | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
Evento evento = null; | |
if(intent.getAction().equals(Intent.ACTION_POWER_CONNECTED)){ | |
evento=new Evento("Carregando!"); | |
} else if(intent.getAction().equals(Intent.ACTION_POWER_DISCONNECTED)){ |
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
<receiver android:name=".EventoReceiver"> | |
<intent-filter> | |
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" /> | |
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" /> | |
</intent-filter> | |
</receiver> |
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 class MainActivity extends Activity { | |
private EventBus bus = EventBus.getDefault(); | |
private TextView view; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); |
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
BitmapDrawable bitmapDrawable = (BitmapDrawable) imageView.getDrawable(); | |
Bitmap bitmap = bitmapDrawable.getBitmap(); | |
//Caso a imagem tenha sido carregada da Web, esse trecho de código deve ser inserido após ela ter sido carregada completamente. |
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
//forma síncrona | |
Palette.Builder builder = new Palette.Builder(bitmap); | |
Palette palette = builder.generate(); |
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
//forma assíncrona | |
Palette.Builder pallete = new Palette.Builder(bitmap); | |
pallete.generate(new Palette.PaletteAsyncListener() { | |
@Override | |
public void onGenerated(Palette palette) { | |
//código | |
} | |
}); |
OlderNewer