<commit_before>package br.com.catbag.giffluxsample.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Toast;

import com.umaplay.fluxxan.Fluxxan;
import com.umaplay.fluxxan.ui.StateListenerActivity;
import com.umaplay.fluxxan.util.ThreadUtils;

import br.com.catbag.giffluxsample.App;
import br.com.catbag.giffluxsample.R;
import br.com.catbag.giffluxsample.actions.GifActionCreator;
import br.com.catbag.giffluxsample.models.AppState;
import br.com.catbag.giffluxsample.ui.wrappers.GlideWrapper;

public class GifListActivity extends StateListenerActivity<AppState> {

    private AppState mAppState = getFlux().getState();
    private GifActionCreator mActionCreator = GifActionCreator.getInstance();
    private ProgressBar mLoading;
    private GlideWrapper mGlideWrapper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gif_list);
        initializeGifView();
        mLoading = (ProgressBar) findViewById(R.id.loading);
        mActionCreator.gifDownloadStart(mAppState.getGifUrl(), mAppState.getGifTitle(), this);
    }

    @Override
    protected Fluxxan<AppState> getFlux() {
        return App.getFluxxan();
    }

    @Override
    public void onStateChanged(AppState appState) {
        mAppState = appState;
        switch (mAppState.getGifStatus()) {
            case NOT_DOWNLOADED:
                String errorMsg = appState.getGifDownloadFailureMsg();
                if (!errorMsg.isEmpty()) {
                    showToast(errorMsg);
                    mLoading.setVisibility(View.GONE);
                }
                break;
            case DOWNLOADING:
                setVisibilityLoading(View.VISIBLE);
                break;
            case DOWNLOADED:
                mGlideWrapper.load(appState.getGifLocalPath());
                break;
            case LOOPING:
                mGlideWrapper.play(appState.getGifLocalPath());
                break;
            case PAUSED:
                mGlideWrapper.stop();
                break;
            default:
        }
    }

    private void setVisibilityLoading(int visibility) {
        ThreadUtils.runOnMain(() -> mLoading.setVisibility(visibility));
    }

    private void showToast(String msg) {
        ThreadUtils.runOnMain(() -> {
            Toast.makeText(GifListActivity.this, msg, Toast.LENGTH_LONG).show();
        });
    }

    private void initializeGifView() {
        ImageView imageView = (ImageView) findViewById(R.id.gif_image);
        imageView.setOnClickListener(v -> mActionCreator.gifClick(mAppState.getGifStatus()));
        mGlideWrapper = new GlideWrapper(imageView)
                .onException((e) -> showToast(e.getLocalizedMessage()))
                .onLoaded(() -> setVisibilityLoading(View.GONE));
    }
}<commit_msg>Fixing wrong parameter in wrapper play inside GifListActivity class (#16)<commit_after>package br.com.catbag.giffluxsample.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Toast;

import com.umaplay.fluxxan.Fluxxan;
import com.umaplay.fluxxan.ui.StateListenerActivity;
import com.umaplay.fluxxan.util.ThreadUtils;

import br.com.catbag.giffluxsample.App;
import br.com.catbag.giffluxsample.R;
import br.com.catbag.giffluxsample.actions.GifActionCreator;
import br.com.catbag.giffluxsample.models.AppState;
import br.com.catbag.giffluxsample.ui.wrappers.GlideWrapper;

public class GifListActivity extends StateListenerActivity<AppState> {

    private AppState mAppState = getFlux().getState();
    private GifActionCreator mActionCreator = GifActionCreator.getInstance();
    private ProgressBar mLoading;
    private GlideWrapper mGlideWrapper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gif_list);
        initializeGifView();
        mLoading = (ProgressBar) findViewById(R.id.loading);
        mActionCreator.gifDownloadStart(mAppState.getGifUrl(), mAppState.getGifTitle(), this);
    }

    @Override
    protected Fluxxan<AppState> getFlux() {
        return App.getFluxxan();
    }

    @Override
    public void onStateChanged(AppState appState) {
        mAppState = appState;
        switch (mAppState.getGifStatus()) {
            case NOT_DOWNLOADED:
                String errorMsg = appState.getGifDownloadFailureMsg();
                if (!errorMsg.isEmpty()) {
                    showToast(errorMsg);
                    mLoading.setVisibility(View.GONE);
                }
                break;
            case DOWNLOADING:
                setVisibilityLoading(View.VISIBLE);
                break;
            case DOWNLOADED:
                mGlideWrapper.load(appState.getGifLocalPath());
                break;
            case LOOPING:
                mGlideWrapper.play();
                break;
            case PAUSED:
                mGlideWrapper.stop();
                break;
            default:
        }
    }

    private void setVisibilityLoading(int visibility) {
        ThreadUtils.runOnMain(() -> mLoading.setVisibility(visibility));
    }

    private void showToast(String msg) {
        ThreadUtils.runOnMain(() -> {
            Toast.makeText(GifListActivity.this, msg, Toast.LENGTH_LONG).show();
        });
    }

    private void initializeGifView() {
        ImageView imageView = (ImageView) findViewById(R.id.gif_image);
        imageView.setOnClickListener(v -> mActionCreator.gifClick(mAppState.getGifStatus()));
        mGlideWrapper = new GlideWrapper(imageView)
                .onException((e) -> showToast(e.getLocalizedMessage()))
                .onLoaded(() -> setVisibilityLoading(View.GONE));
    }
}
{'fraction_non_alphanumeric': 0.09800608313619466, 'fraction_numerical': 0.0003379520108144643, 'mean_word_length': 2.6290619251992644, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6890134', 'n_tokens_mistral': 1763, 'n_tokens_neox': 1662, 'n_words': 275}