<commit_before>package com.blstream.studybox;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.design.widget.Snackbar;
import android.view.View;

/**
 * If device loses network connection for unspecified reason user will be warned in form of snackbar
 * showing him proper message and enable him/her to perform action ("DISMISS" for now - when this
 * action is perform snackbar won't show again, unless device connect and disconnect again).
 * If network connection return by the time snackbar is shown, it (snackbar) will dismiss itself.
 */

public class SnackbarManager {
    private Snackbar snackbar;

    public SnackbarManager(Context context) {
        snackbar = createSnackbar(context);
    }

    private Snackbar createSnackbar(final Context context) {

        View rootView = ((Activity) context).getWindow().getDecorView().findViewById(android.R.id.content);
        View view = useCoordinatorLayoutIfPossible(rootView);

        return Snackbar
                .make(view, R.string.no_internet_connection, Snackbar.LENGTH_LONG)
                .setAction(R.string.open_options, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        ((Activity) context).startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
                    }
                });
    }

    private View useCoordinatorLayoutIfPossible(View rootView) {
        View view;
        if (rootView.findViewById(R.id.coordinatorLayout) != null) {
            view = rootView.findViewById(R.id.coordinatorLayout);
        } else {
            view = rootView;
        }
        return view;
    }

    public void networkAvailable() {
        if (snackbar.isShownOrQueued()) {
            snackbar.dismiss();
        }
    }

    public void networkUnavailable() {
        if (!(snackbar.isShown()))
            snackbar.show();
    }
}
<commit_msg>change snackbar show time to LENGTH_INDEFINITE<commit_after>package com.blstream.studybox;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.design.widget.Snackbar;
import android.view.View;

/**
 * If device loses network connection for unspecified reason user will be warned in form of snackbar
 * showing him proper message and enable him/her to perform action (open android settings).
 * If network connection return by the time snackbar is shown, it (snackbar) will dismiss itself.
 */

public class SnackbarManager {
    private Snackbar snackbar;

    public SnackbarManager(Context context) {
        snackbar = createSnackbar(context);
    }

    private Snackbar createSnackbar(final Context context) {

        View rootView = ((Activity) context).getWindow().getDecorView().findViewById(android.R.id.content);
        View view = useCoordinatorLayoutIfPossible(rootView);

        return Snackbar
                .make(view, R.string.no_internet_connection, Snackbar.LENGTH_INDEFINITE)
                .setAction(R.string.open_options, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        ((Activity) context).startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
                    }
                });
    }

    private View useCoordinatorLayoutIfPossible(View rootView) {
        View view;
        if (rootView.findViewById(R.id.coordinatorLayout) != null) {
            view = rootView.findViewById(R.id.coordinatorLayout);
        } else {
            view = rootView;
        }
        return view;
    }

    public void networkAvailable() {
        if (snackbar.isShownOrQueued()) {
            snackbar.dismiss();
        }
    }

    public void networkUnavailable() {
        if (!(snackbar.isShown()))
            snackbar.show();
    }
}

{'fraction_non_alphanumeric': 0.0898021308980213, 'fraction_numerical': 0.0005073566717402334, 'mean_word_length': 2.5812897366030882, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7389846', 'n_tokens_mistral': 1097, 'n_tokens_neox': 1033, 'n_words': 268}