Search in sources :

Example 1 with Empty

use of se.zinokader.spotiq.util.type.Empty in project SpotiQ by ZinoKader.

the class SongRecyclerAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(SongHolder songHolder, int i) {
    Song song = songs.get(i);
    Context context = songHolder.itemView.getContext();
    songHolder.itemView.setOnClickListener(view -> onClickSubject.onNext(song));
    songHolder.itemView.setOnLongClickListener(view -> {
        curentlyLongClicking = true;
        onLongClickSubject.onNext(song);
        return true;
    });
    songHolder.itemView.setOnTouchListener((view, motionEvent) -> {
        view.onTouchEvent(motionEvent);
        if (motionEvent.getAction() == MotionEvent.ACTION_UP && curentlyLongClicking) {
            onLongClickEndSubject.onNext(new Empty());
            curentlyLongClicking = false;
        }
        return true;
    });
    String artistsName = ArtistMapper.joinArtistNames(song.getArtists());
    Glide.with(context).load(song.getAlbumArtUrl()).diskCacheStrategy(DiskCacheStrategy.SOURCE).placeholder(R.drawable.image_album_placeholder).fitCenter().override(ApplicationConstants.LOW_QUALITY_ALBUM_ART_DIMENSION, ApplicationConstants.LOW_QUALITY_ALBUM_ART_DIMENSION).into(songHolder.albumArt);
    songHolder.songName.setText(song.getName());
    songHolder.artistsName.setText(artistsName);
    songHolder.albumName.setText(song.getAlbum().name);
}
Also used : Context(android.content.Context) Song(se.zinokader.spotiq.model.Song) Empty(se.zinokader.spotiq.util.type.Empty)

Example 2 with Empty

use of se.zinokader.spotiq.util.type.Empty in project SpotiQ by ZinoKader.

the class LoginPresenter method logInFailed.

void logInFailed(boolean hasPremium) {
    String errorMessage = hasPremium ? "Something went wrong on Spotify authentication" : "You need a Spotify Premium account to log in";
    Observable.just(new Empty()).observeOn(AndroidSchedulers.mainThread()).delay(ApplicationConstants.SHORT_ACTION_DELAY_SEC, TimeUnit.SECONDS, AndroidSchedulers.mainThread()).compose(this.deliverFirst()).subscribe(delayFinishedDelivery -> delayFinishedDelivery.split((loginView, empty) -> {
        loginView.resetProgress();
        loginView.showMessage(errorMessage);
    }, (loginView, throwable) -> {
        loginView.showMessage("Login failed, please try again");
    }));
}
Also used : TimeUnit(java.util.concurrent.TimeUnit) Inject(javax.inject.Inject) ApplicationConstants(se.zinokader.spotiq.constant.ApplicationConstants) BasePresenter(se.zinokader.spotiq.feature.base.BasePresenter) Empty(se.zinokader.spotiq.util.type.Empty) Observable(io.reactivex.Observable) Schedulers(io.reactivex.schedulers.Schedulers) UserRepository(se.zinokader.spotiq.repository.UserRepository) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) Empty(se.zinokader.spotiq.util.type.Empty)

Aggregations

Empty (se.zinokader.spotiq.util.type.Empty)2 Context (android.content.Context)1 Observable (io.reactivex.Observable)1 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)1 Schedulers (io.reactivex.schedulers.Schedulers)1 TimeUnit (java.util.concurrent.TimeUnit)1 Inject (javax.inject.Inject)1 ApplicationConstants (se.zinokader.spotiq.constant.ApplicationConstants)1 BasePresenter (se.zinokader.spotiq.feature.base.BasePresenter)1 Song (se.zinokader.spotiq.model.Song)1 UserRepository (se.zinokader.spotiq.repository.UserRepository)1