Skip to content

Instantly share code, notes, and snippets.

View fatorx's full-sized avatar
💭
Learning and learning.

Fabio de Souza fatorx

💭
Learning and learning.
View GitHub Profile
@fatorx
fatorx / gist:678dfaaf37ff993d164f
Last active September 22, 2015 14:46
Elemento não é exibido na tela
Se o elemento não for exibido, mesmo no preview do Android Studio,
verificar se não está dentro de um ScrollView
@fatorx
fatorx / getView.java
Last active August 29, 2015 14:27
Pegar a view carregada por uma Activity
View view = getWindow().getDecorView().findViewById(android.R.id.content);
/**
* Em alguns casos, é interessante ter acesso a view. Eu seto componentes fora da Activity, em outra classe,
* para me organizar melhor, e isso foi de grande ajuda (motivo da solução: usar o Butter Knife fora da activity)
* /
@fatorx
fatorx / UriResource.java
Last active August 29, 2015 14:25
Acessar recursos do Android como uma URI
/*
Em alguns casos, no do lib de carregamento de imagens Fresco (http://frescolib.org/), é necessário
utilizar uri's. Para carregar um recurso local como um URI, segue trecho de código.
*/
Uri path = Uri.parse("android.resource://com.yourdomain.yourapp/" + R.drawable.ic_notif_single_tick);
/*
Onde com.yourdomain.yourapp é o pacote de seu aplicativo.
*/
@fatorx
fatorx / recycler-view-note
Created June 23, 2015 19:35
Recycler View - recado a comunidade
Sempre setar o Layout Manager
recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
não esquecer nunca.
@fatorx
fatorx / gist:1826e9acedf4ec269e4b
Created June 17, 2015 13:35
Java Math - Return point float number between two integers
int seconds = 88200;
int secHour = 3600;
float val = ( (float) seconds / (float) secHour);
System.out.println( val );
@fatorx
fatorx / note
Created June 15, 2015 13:30
Problemas com escopo de execução de Threads
http://stackoverflow.com/questions/3875184/cant-create-handler-inside-thread-that-has-not-called-looper-prepare
http://stackoverflow.com/questions/5009816/cant-create-handler-inside-thread-which-has-not-called-looper-prepare
@fatorx
fatorx / note
Created June 15, 2015 12:30
Meu primeiro contato com threads
final Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
switch(msg.what){
case 0:
nextActivity();
progress.dismiss();
}
super.handleMessage(msg);
}
@fatorx
fatorx / dex-compiler.txt
Last active August 29, 2015 14:22
Remover completamente um aplicativo do Android
http://badlogicgames.com/forum/viewtopic.php?t=19301&p=81023
So I appear to have solved this now...Even though the application was uninstalled from the device for all users, uninstalled via the ADB and did not appear on the list of packages from the ADB, it was still present on the device. On the device, under "Settings -> Apps -> All", at the very bottom was an entry for my application. It was tagged as "Not installed for all users", after selecting it and opening the top-right menu, I could select "Uninstall for all users". For some reason, this fixes the issue.
--------------------------------
Quando ocorrer o erro de não ser possível reinstalar o aplicativo via APK.
@fatorx
fatorx / layout.xml
Created June 2, 2015 19:46
Linear Layout - alinhar um elemento no centro
<LinearLayout
android:layout_width="270dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_vertical"
android:background="#993366">
<TextView
android:id="@+id/tvTitleActivity"
android:layout_gravity="center"
@fatorx
fatorx / activity_main.xml
Created June 2, 2015 15:10
Estilos para Widgets - Toolbar como exemplo
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context=".MainActivityFragment">
<include layout="@layout/toolbar_main" />
</LinearLayout>