Skip to content

Instantly share code, notes, and snippets.

Avatar

Luiz Marcus luizmarcus

View GitHub Profile
View Pessoa.java
public class Pessoa{
String cpf;
String nome;
//Gerar métodos get e set dos parâmetros
}
View PessoaAPI.java
public interface PessoaApi {
@GET("/pessoas/{cpf}")
Pessoa getPessoa(
@Path("cpf") String cpf
);
}
View MainActivity.java
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();
View Evento.java
public class Evento {
private String alerta;
public Evento(String alerta){
this.alerta = alerta;
}
public String getAlerta(){
return alerta;
}
View EventoReceiver.java
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)){
View AndroidMainfest.xml
<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>
View MainActivity.java
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);
View ExemploPalete_Bitmap.java
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.
View ExemploPalete_FormaSincrona.java
//forma síncrona
Palette.Builder builder = new Palette.Builder(bitmap);
Palette palette = builder.generate();
View ExemploPalete_FormaAssincrona.java
//forma assíncrona
Palette.Builder pallete = new Palette.Builder(bitmap);
pallete.generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
//código
}
});
You can’t perform that action at this time.