This file contains hidden or 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 static void getTotalHeightofListView(ListView listView) { | |
ListAdapter mAdapter = listView.getAdapter(); | |
int totalHeight = 0; | |
int listWidth = listView.getMeasuredWidth(); | |
for (int i = 0; i < mAdapter.getCount(); i++) { | |
View mView = mAdapter.getView(i, null, listView); |
This file contains hidden or 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 org.apache.log4j.Logger | |
import org.junit.Test | |
import java.time.* | |
import java.time.format.DateTimeFormatter | |
open class ZonedDateTimeWithEpochTest { | |
@Test | |
fun dateTimesExchanges_Between_Brazil_USA_West_Epoch_should_be_the_same() { |
This file contains hidden or 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
promise.then ( | |
successFn | |
); | |
observable.subscribe ( | |
nextFn | |
); | |
This file contains hidden or 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
const subject = new Rx.Subject(); | |
/* Observers são consumidores dos valores entregues pelos Subjects (ou Observables). | |
São simplemente objetos com três callbacks, um para cada tipo de notificação | |
que pode ser entregue pelo Subject/Observable: next, error e complete.*/ | |
const observerA = { | |
next: valor => console.log(`observerA consumindo informação: ${valor}`), | |
error: err => console.log('observerA recebendo uma notificação de erro'), | |
complete: () => console.log('observerA sendo informando que o subject foi finalizado') | |
} |
This file contains hidden or 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
/* Caso comum de uso dos Observables, sendo retornado por uma função que faz | |
chamadas assíncronas (requisições http). | |
Código exemplifica como é a criação "explícita" de um Observable, | |
mas existem outros métodos que fazem isso por você, | |
como Rx.Observable.of(<SeuObjetoRetornado>)*/ | |
const obterRecursoDaApi = Rx.Observable.create(observer => { | |
setTimeout(() => { | |
observer.next([{id: 1, titulo: 'algum título'}, {id: 2, titulo: 'outro título'}]); | |
observer.complete(); |
This file contains hidden or 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
@Component({ | |
selector: 'my-app' | |
}) | |
export class MyComponent implements OnInit, OnDestroy { | |
public processamentoSubject = new BehaviorSubject<Processamento[]>(null); | |
public processamentos$: Observable<Processamento[]> = this.processamentoSubject.asObservable(); | |
// 1. Criar objeto subject de bool. | |
destroy$: Subject<boolean> = new Subject<boolean>(); |
This file contains hidden or 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
const subject = new Rx.Subject(); | |
const subscription = subject.subscribe({ | |
next: valor => console.log(`observerB consumindo informação: ${valor}`), | |
error: err => console.log('observerB recebendo uma notificação de erro') | |
}) | |
subject.next(1) | |
/* Cancelando a "inscrição" no Stream de eventos emitidos pela instância de `subject`. |
This file contains hidden or 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
@Injectable() | |
export class CoursesService { | |
constructor() { } | |
findAllCourses(): Observable<Course[]> {// ... //} | |
findLatestLessons(): Observable<Lesson[]> {// ... //} | |
findCourseByUrl(courseUrl:string): Observable<Course> {// ... //} |
This file contains hidden or 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
@Injectable() | |
export class ProcessamentoService { | |
private headers: Headers; | |
private baseUrl: string; | |
private historicoProcessamentosSubject = new Subject<Processamento[]>(); | |
historicoProcessamentos$: Observable<Processamento[]> = this.historicoProcessamentosSubject.asObservable(); |
This file contains hidden or 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
// Senha informada e com suporte para push notification | |
if (!sessionStorage.getItem('notificacao-push-permissao')) { | |
/* Apenas no 1* acesso do usuário a essa funcionalidade, deverá ser exibida e mensagem de Permitir, caso ele tenha permitido | |
/ e posteriormente bloqueado, ele já terá visto essa mensagem, caso ele tenha apagado os dados do localStorage | |
/ (apenas usuários avançados o farão) essa mensagem irá aparecer, mas como ele já terá permitido a notificação, a mensagem nativa | |
/ do browser não será exibida (UX ruim, mas dificilmente irá ocorrer) | |
/ * no iOS o localStorage é apagado periodicamente, porém, como não têm suporte à push notification, sem problemas... */ | |
this.props.messageService.show('Click \'ALLOW\' to be notified of your password, even with your phone in your pocket!') | |
} |
OlderNewer