<commit_before>package io.pivotal.arca.fragments;

import android.database.Cursor;
import android.view.View;
import android.widget.Toast;

import io.pivotal.arca.dispatcher.Error;
import io.pivotal.arca.dispatcher.QueryResult;

public class ArcaViewManager {

    private final View mView;

    private int mProgressId = android.R.id.progress;
    private int mEmptyId = android.R.id.empty;
    private int mContentId = android.R.id.content;
    private int mListId = android.R.id.list;

    public ArcaViewManager(final View view) {
        mView = view;
    }

    public void setProgressId(final int id) {
        mProgressId = id;
    }

    public void setEmptyId(final int id) {
        mEmptyId = id;
    }

    public void setContentId(final int id) {
        mContentId = id;
    }

    private View getView() {
        return mView;
    }

    private View getProgressView() {
        return getView().findViewById(mProgressId);
    }

    private View getEmptyView() {
        return getView().findViewById(mEmptyId);
    }

    private View getContentView() {
        final View content = getView().findViewById(mContentId);
        return content != null ? content : getView().findViewById(mListId);
    }

    public void showProgressView() {
        getContentView().setVisibility(View.INVISIBLE);
        getProgressView().setVisibility(View.VISIBLE);
        getEmptyView().setVisibility(View.INVISIBLE);
    }

    public void showContentView() {
        getContentView().setVisibility(View.VISIBLE);
        getProgressView().setVisibility(View.INVISIBLE);
        getEmptyView().setVisibility(View.INVISIBLE);
    }

    public void showEmptyView() {
        getContentView().setVisibility(View.INVISIBLE);
        getProgressView().setVisibility(View.INVISIBLE);
        getEmptyView().setVisibility(View.VISIBLE);
    }

    public void toastError(final Error error) {
        final String message = String.format("%s", error.getMessage());
        Toast.makeText(mView.getContext(), message, Toast.LENGTH_SHORT).show();
    }

    public void checkResult(final QueryResult result) {
        final Cursor data = result.getData();

        if (data != null && data.getCount() > 0) {
            showContentView();
        } else if (!result.isSyncing()) {
            showEmptyView();
        }
    }

    public void checkError(final Error error) {
        if (error != null) {
            showEmptyView();
            toastError(error);
        }
    }
}<commit_msg>Update view manager to ignore null views<commit_after>package io.pivotal.arca.fragments;

import android.database.Cursor;
import android.view.View;
import android.widget.Toast;

import io.pivotal.arca.dispatcher.Error;
import io.pivotal.arca.dispatcher.QueryResult;

public class ArcaViewManager {

    private final View mView;

    private int mContentId = android.R.id.content;
    private int mProgressId = android.R.id.progress;
    private int mEmptyId = android.R.id.empty;
    private int mListId = android.R.id.list;

    public ArcaViewManager(final View view) {
        mView = view;
    }

    public void setContentId(final int id) {
        mContentId = id;
    }

    public void setProgressId(final int id) {
        mProgressId = id;
    }

    public void setEmptyId(final int id) {
        mEmptyId = id;
    }

    private View getView() {
        return mView;
    }

    private View getContentView() {
        final View content = getView().findViewById(mContentId);
        return content != null ? content : getView().findViewById(mListId);
    }

    private View getProgressView() {
        return getView().findViewById(mProgressId);
    }

    private View getEmptyView() {
        return getView().findViewById(mEmptyId);
    }

    public void showContentView() {
        if (getContentView() != null) getContentView().setVisibility(View.VISIBLE);
        if (getProgressView() != null) getProgressView().setVisibility(View.INVISIBLE);
        if (getEmptyView() != null) getEmptyView().setVisibility(View.INVISIBLE);
    }

    public void showProgressView() {
        if (getContentView() != null) getContentView().setVisibility(View.INVISIBLE);
        if (getProgressView() != null) getProgressView().setVisibility(View.VISIBLE);
        if (getEmptyView() != null) getEmptyView().setVisibility(View.INVISIBLE);
    }

    public void showEmptyView() {
        if (getContentView() != null) getContentView().setVisibility(View.INVISIBLE);
        if (getProgressView() != null) getProgressView().setVisibility(View.INVISIBLE);
        if (getEmptyView() != null) getEmptyView().setVisibility(View.VISIBLE);
    }

    public void showError(final Error error) {
        final String message = String.format("%s", error.getMessage());
        Toast.makeText(mView.getContext(), message, Toast.LENGTH_SHORT).show();
    }

    public void checkResult(final QueryResult result) {
        final Cursor data = result.getData();

        if (data != null && data.getCount() > 0) {
            showContentView();
        } else if (!result.isSyncing()) {
            showEmptyView();
        }
    }

    public void checkError(final Error error) {
        if (error != null) {
            showEmptyView();
            showError(error);
        }
    }
}
{'fraction_non_alphanumeric': 0.11423149905123339, 'fraction_numerical': 0.0003795066413662239, 'mean_word_length': 2.811279826464208, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6747545', 'n_tokens_mistral': 1560, 'n_tokens_neox': 1499, 'n_words': 331}