<commit_before>package com.bfd.note;

import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;

import com.bfd.note.store.Container;
import com.bfd.note.store.ContainerImpl;
import com.bfd.note.util.Note;

import jp.wasabeef.richeditor.RichEditor;

public class EditorActivity extends AppCompatActivity {
    public static final String RESULT_ID = "result_id";
    public static final String RESULT_CONTENT = "result content";

    public final static String EDIT_CONTENT = "edit_content";
    public final static String EDIT_ID = "edit_index";
    public final static String IS_ADD = "is_add";

    private RichEditor mEditor;
    private long id;
    private Container container;
    private boolean isAdd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_editor);
        id = getIntent().getLongExtra(EDIT_ID, -1);
        isAdd = getIntent().getBooleanExtra(IS_ADD, false);
        container = ContainerImpl.getContainer();
        setUpEditor(getIntent().getStringExtra(EDIT_CONTENT));
    }

    @Override
    public void onBackPressed() {
        Intent intent = new Intent()
                .putExtra(RESULT_ID, id)
                .putExtra(RESULT_CONTENT, mEditor.getHtml());
        if (isAdd) {
            container.addNote(new Note( mEditor.getHtml()));
        } else {
            container.resetNote(id,  mEditor.getHtml());
        }
        setResult(RESULT_OK, intent);
        finish();
    }<commit_msg>避免空日记的直接创建<commit_after>package com.bfd.note;

import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;

import com.bfd.note.store.Container;
import com.bfd.note.store.ContainerImpl;
import com.bfd.note.util.Note;

import jp.wasabeef.richeditor.RichEditor;

public class EditorActivity extends AppCompatActivity {
    public static final String RESULT_ID = "result_id";
    public static final String RESULT_CONTENT = "result content";

    public final static String EDIT_CONTENT = "edit_content";
    public final static String EDIT_ID = "edit_index";
    public final static String IS_ADD = "is_add";

    private RichEditor mEditor;
    private long id;
    private Container container;
    private boolean isAdd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_editor);
        id = getIntent().getLongExtra(EDIT_ID, -1);
        isAdd = getIntent().getBooleanExtra(IS_ADD, false);
        container = ContainerImpl.getContainer();
        setUpEditor(getIntent().getStringExtra(EDIT_CONTENT));
    }

    @Override
    public void onBackPressed() {
        Intent intent = new Intent()
                .putExtra(RESULT_ID, id)
                .putExtra(RESULT_CONTENT, mEditor.getHtml());
        if (isAdd) {
            if(!mEditor.getHtml().isEmpty())
                container.addNote(new Note( mEditor.getHtml()));
        } else {
            container.resetNote(id,  mEditor.getHtml());
        }
        setResult(RESULT_OK, intent);
        finish();
    }
{'fraction_non_alphanumeric': 0.09965136548518304, 'fraction_numerical': 0.0011621150493898896, 'mean_word_length': 3.22972972972973, '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': '4663411', 'n_tokens_mistral': 991, 'n_tokens_neox': 974, 'n_words': 223}