<commit_before>package cgeo.geocaching;

import cgeo.geocaching.LogTemplateProvider.LogTemplate;
import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.enumerations.LogTypeTrackable;
import cgeo.geocaching.enumerations.StatusCode;
import cgeo.geocaching.gcvote.GCVote;
import cgeo.geocaching.ui.DateDialog;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class VisitCacheActivity extends AbstractActivity implements DateDialog.DateDialogParent {
    static final String EXTRAS_FOUND = "found";
    static final String EXTRAS_TEXT = "text";
    static final String EXTRAS_GEOCODE = "geocode";
    static final String EXTRAS_ID = "id";

    private static final int MENU_SIGNATURE = 1;
    private static final int SUBMENU_VOTE = 2;

    private LayoutInflater inflater = null;
    private cgCache cache = null;
    private ProgressDialog waitDialog = null;
    private String cacheid = null;
    private String geocode = null;
    private String text = null;
    private boolean alreadyFound = false;
    private List<LogType> possibleLogTypes = new ArrayList<LogType>();
    private String[] viewstates = null;
    private boolean gettingViewstate = true;
    private List<cgTrackableLog> trackables = null;
    private Calendar date = Calendar.getInstance();
    private LogType typeSelected = LogType.LOG_UNKNOWN;
    private int attempts = 0;
    private Button postButton = null;
    private Button saveButton = null;
    private Button clearButton = null;
    private CheckBox tweetCheck = null;
    private LinearLayout tweetBox = null;
    private double rating = 0.0;
    private boolean tbChanged = false;

    // handlers
    private final Handler loadDataHandler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            if (!possibleLogTypes.contains(typeSelected)) {
                typeSelected = possibleLogTypes.get(0);
                setType(typeSelected);

                showToast(res.getString(R.string.info_log_type_changed));
            }

            if (cgBase.isEmpty(viewstates) && attempts < 2) {
                showToast(res.getString(R.string.err_log_load_data_again));

                final LoadDataThread thread;
                thread = new LoadDataThread();
                thread.start();

                return;
            } else if (cgBase.isEmpty(viewstates) && attempts >= 2) {
                showToast(res.getString(R.string.err_log_load_data));
                showProgress(false);

                return;
            }

            gettingViewstate = false; // we're done, user can post log

            enablePostButton(true);

            // add trackables
            if (CollectionUtils.isNotEmpty(trackables)) {<commit_msg>Don't show "can't load log data"-toast twice in VisitCacheActivity<commit_after>package cgeo.geocaching;

import cgeo.geocaching.LogTemplateProvider.LogTemplate;
import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.enumerations.LogTypeTrackable;
import cgeo.geocaching.enumerations.StatusCode;
import cgeo.geocaching.gcvote.GCVote;
import cgeo.geocaching.ui.DateDialog;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class VisitCacheActivity extends AbstractActivity implements DateDialog.DateDialogParent {
    static final String EXTRAS_FOUND = "found";
    static final String EXTRAS_TEXT = "text";
    static final String EXTRAS_GEOCODE = "geocode";
    static final String EXTRAS_ID = "id";

    private static final int MENU_SIGNATURE = 1;
    private static final int SUBMENU_VOTE = 2;

    private LayoutInflater inflater = null;
    private cgCache cache = null;
    private ProgressDialog waitDialog = null;
    private String cacheid = null;
    private String geocode = null;
    private String text = null;
    private boolean alreadyFound = false;
    private List<LogType> possibleLogTypes = new ArrayList<LogType>();
    private String[] viewstates = null;
    private boolean gettingViewstate = true;
    private List<cgTrackableLog> trackables = null;
    private Calendar date = Calendar.getInstance();
    private LogType typeSelected = LogType.LOG_UNKNOWN;
    private int attempts = 0;
    private Button postButton = null;
    private Button saveButton = null;
    private Button clearButton = null;
    private CheckBox tweetCheck = null;
    private LinearLayout tweetBox = null;
    private double rating = 0.0;
    private boolean tbChanged = false;

    // handlers
    private final Handler loadDataHandler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            if (!possibleLogTypes.contains(typeSelected)) {
                typeSelected = possibleLogTypes.get(0);
                setType(typeSelected);

                showToast(res.getString(R.string.info_log_type_changed));
            }

            if (cgBase.isEmpty(viewstates) && attempts < 2) {
                final LoadDataThread thread;
                thread = new LoadDataThread();
                thread.start();

                return;
            } else if (cgBase.isEmpty(viewstates) && attempts >= 2) {
                showToast(res.getString(R.string.err_log_load_data));
                showProgress(false);

                return;
            }

            gettingViewstate = false; // we're done, user can post log

            enablePostButton(true);

            // add trackables
            if (CollectionUtils.isNotEmpty(trackables)) {
{'fraction_non_alphanumeric': 0.08321479374110953, 'fraction_numerical': 0.0025604551920341396, 'mean_word_length': 3.29505192425168, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3218971', 'n_tokens_mistral': 1964, 'n_tokens_neox': 1882, 'n_words': 491}