use of net.iGap.observers.rx.IGSingleObserver in project iGap-Android by KianIranian-STDG.
the class StickerRepository method getUserStickersGroup.
public void getUserStickersGroup() {
CompositeDisposable compositeDisposable = new CompositeDisposable();
stickerApi.getUserStickersGroup().subscribeOn(Schedulers.newThread()).map(dataModel -> {
List<StructIGStickerGroup> groups = new ArrayList<>();
for (int i = 0; i < dataModel.getData().size(); i++) {
StructIGStickerGroup stickerGroup = new StructIGStickerGroup(dataModel.getData().get(i));
groups.add(stickerGroup);
}
return groups;
}).subscribe(new IGSingleObserver<List<StructIGStickerGroup>>(compositeDisposable) {
@Override
public void onSuccess(List<StructIGStickerGroup> structIGStickerGroups) {
updateStickers(structIGStickerGroups);
if (!compositeDisposable.isDisposed())
compositeDisposable.dispose();
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
if (!compositeDisposable.isDisposed())
compositeDisposable.dispose();
}
});
}
Aggregations