<commit_before>package uk.co.pilllogger.fragments;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.FragmentManager;
import android.content.Context;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.otto.Subscribe;

import hugo.weaving.DebugLog;
import uk.co.pilllogger.R;
import uk.co.pilllogger.activities.DialogActivity;
import uk.co.pilllogger.events.ConsumptionInfoDialogEvent;
import uk.co.pilllogger.events.DecreaseConsumptionEvent;
import uk.co.pilllogger.events.DeleteConsumptionEvent;
import uk.co.pilllogger.events.IncreaseConsumptionEvent;
import uk.co.pilllogger.models.Consumption;
import uk.co.pilllogger.services.IAddConsumptionService;
import uk.co.pilllogger.state.State;

/**
 * Created by Alex on 05/03/14.
 */
public class ConsumptionInfoDialogFragment extends InfoDialogFragment {
    private Consumption _consumption;
    private TextView _takeAgain;
    private TextView _quantityText;
    private TextView _takeAgainSummary;
    private TextView _quantity;
    private TextView _delete;
    private TextView _deleteSummary;
    private TextView _quantitySummary;
    private Activity _activity;

    public ConsumptionInfoDialogFragment(){
        super();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.consumption_info_dialog;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        _activity = getActivity();

        _takeAgain = (TextView) _activity.findViewById(R.id.info_dialog_take_again_title);
        _takeAgainSummary = (TextView) _activity.findViewById(R.id.info_dialog_take_again_summary);
        _quantityText = (TextView) _activity.findViewById(R.id.info_dialog_quantity_title);
        _quantity = (TextView) _activity.findViewById(R.id.consumption_info_quantity);
        _quantitySummary = (TextView) _activity.findViewById(R.id.info_dialog_quantity_summary);
        _delete = (TextView) _activity.findViewById(R.id.info_dialog_delete_title);
        _deleteSummary = (TextView) _activity.findViewById(R.id.info_dialog_delete_summary);

        ((DialogActivity) getActivity()).setTopInfoHidden(false);
    }

    private void setup() {
        View takeAgainContainer = _activity.findViewById(R.id.info_dialog_take_again);
        View increase = _activity.findViewById(R.id.consumption_info_dialog_increase);
        ImageView decrease = (ImageView) _activity.findViewById(R.id.consumption_info_dialog_decrease);
        View deleteContainer = _activity.findViewById(R.id.info_dialog_delete);

        if(decrease == null || increase == null){
            if(_activity != null){
                // close the dialog if these elements aren't visible
                _activity.finish();
            }
            return;
        }

        setTypeFace();

        _quantity.setText("" + _consumption.getQuantity());

        String takeAgainText =  _activity.getString(R.string.consumption_info_dialog_take_again_prefix);
        if(_consumption.getQuantity() > 1)
            takeAgainText += " " + _consumption.getQuantity();
        takeAgainText += String.format(" %s %s", _consumption.getPill().getName(), _activity.getString(R.string.consumption_info_dialog_take_again_suffix));
        _takeAgainSummary.setText(takeAgainText);

        if(_consumption.getQuantity() > 1){
            decrease.setClickable(true);<commit_msg>Fix crash for ConsumptionInfoDialog<commit_after>package uk.co.pilllogger.fragments;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.FragmentManager;
import android.content.Context;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.otto.Subscribe;

import hugo.weaving.DebugLog;
import uk.co.pilllogger.R;
import uk.co.pilllogger.activities.DialogActivity;
import uk.co.pilllogger.events.ConsumptionInfoDialogEvent;
import uk.co.pilllogger.events.DecreaseConsumptionEvent;
import uk.co.pilllogger.events.DeleteConsumptionEvent;
import uk.co.pilllogger.events.IncreaseConsumptionEvent;
import uk.co.pilllogger.models.Consumption;
import uk.co.pilllogger.services.IAddConsumptionService;
import uk.co.pilllogger.state.State;

/**
 * Created by Alex on 05/03/14.
 */
public class ConsumptionInfoDialogFragment extends InfoDialogFragment {
    private Consumption _consumption;
    private TextView _takeAgain;
    private TextView _quantityText;
    private TextView _takeAgainSummary;
    private TextView _quantity;
    private TextView _delete;
    private TextView _deleteSummary;
    private TextView _quantitySummary;
    private Activity _activity;

    public ConsumptionInfoDialogFragment(){
        super();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.consumption_info_dialog;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        _activity = getActivity();

        _takeAgain = (TextView) _activity.findViewById(R.id.info_dialog_take_again_title);
        _takeAgainSummary = (TextView) _activity.findViewById(R.id.info_dialog_take_again_summary);
        _quantityText = (TextView) _activity.findViewById(R.id.info_dialog_quantity_title);
        _quantity = (TextView) _activity.findViewById(R.id.consumption_info_quantity);
        _quantitySummary = (TextView) _activity.findViewById(R.id.info_dialog_quantity_summary);
        _delete = (TextView) _activity.findViewById(R.id.info_dialog_delete_title);
        _deleteSummary = (TextView) _activity.findViewById(R.id.info_dialog_delete_summary);

        ((DialogActivity) getActivity()).setTopInfoHidden(false);
    }

    private void setup() {
        if(_activity == null){
            _activity = getActivity();

            if(_activity == null){
                return;
            }
        }

        View takeAgainContainer = _activity.findViewById(R.id.info_dialog_take_again);
        View increase = _activity.findViewById(R.id.consumption_info_dialog_increase);
        ImageView decrease = (ImageView) _activity.findViewById(R.id.consumption_info_dialog_decrease);
        View deleteContainer = _activity.findViewById(R.id.info_dialog_delete);

        if(decrease == null || increase == null){
            if(_activity != null){
                // close the dialog if these elements aren't visible
                _activity.finish();
            }
            return;
        }

        setTypeFace();

        _quantity.setText("" + _consumption.getQuantity());

        String takeAgainText =  _activity.getString(R.string.consumption_info_dialog_take_again_prefix);
        if(_consumption.getQuantity() > 1)
            takeAgainText += " " + _consumption.getQuantity();
        takeAgainText += String.format(" %s %s", _consumption.getPill().getName(), _activity.getString(R.string.consumption_info_dialog_take_again_suffix));
        _takeAgainSummary.setText(takeAgainText);

        if(_consumption.getQuantity() > 1){
            decrease.setClickable(true);
{'fraction_non_alphanumeric': 0.09412248253185368, 'fraction_numerical': 0.002192081107000959, 'mean_word_length': 3.828042328042328, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4157054', 'n_tokens_mistral': 2141, 'n_tokens_neox': 2000, 'n_words': 351}