<commit_before>/*
 * Copyright (c) 2017 CMPUT301F17T15. This project is distributed under the MIT license.
 */

package com.cmput301.cia.activities;

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

import com.cmput301.cia.R;
import com.cmput301.cia.models.HabitEvent;

/**
 * created by Tinghui.
 * on 11/8/2017.
 */

public class HabitEventViewActivity extends AppCompatActivity {

    public static final String ID_INDEX = "Index";
    public static final String RETURNED_INDEX = "Index", RETURNED_EVENT = "Event", RETURNED_DELETED = "Deleted";

    private TextView habitEventName;
    private TextView habitEventDate;
    private TextView habitEventLocation;
    private TextView habitEventPhoto;
    TextView habitEventComment;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_habit_event_view);
        /**
         * display habit event information.
         */
        habitEventName = (TextView) findViewById(R.id.EventName);
        habitEventDate = (TextView) findViewById(R.id.EventDate);
        habitEventLocation = (TextView) findViewById(R.id.EventLocation);
        habitEventPhoto = (TextView) findViewById(R.id.EventPhoto);
        habitEventComment = (TextView) findViewById(R.id.EventComment);

        HabitEvent habitevent = (HabitEvent) getIntent().getSerializableExtra("HabitEvent");

        habitEventName.setText(habitevent.getTittle());
        habitEventDate.setText(habitevent.getDate().toString());

        if (habitevent.getLocation() != null)
            habitEventLocation.setText(habitevent.getLocation().toString());
        habitEventPhoto.setText(habitevent.getBase64EncodedPhoto());
        habitEventComment.setText(habitevent.getComment());

    }

    /**
     * the following three function basic on createhabitEventActivity.
     * Handles the save button being clicked
     * @param view
     */
    public void onSaveClicked(View view){
        finishActivity(false);
    }

    /**
     * Handles the delete button being clicked
     * @param view
     */
    public void onDeleteClicked(View view){
        finishActivity(true);
    }

    /**
     * End this activity after the user clicks on either "Edit" or "Delete"
     * Adds data to the intent object if the user selects "Save"
     * @param deleted whether the Delete button was clicked or not
     */
    private void finishActivity(boolean deleted){
        Intent intent = new Intent();
        if (deleted) {

        }
        

        
    }
}<commit_msg>add control ability of delete and edit for habit event view<commit_after>/*
 * Copyright (c) 2017 CMPUT301F17T15. This project is distributed under the MIT license.
 */

package com.cmput301.cia.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.cmput301.cia.R;
import com.cmput301.cia.models.HabitEvent;

/**
 * created by Tinghui.
 * on 11/8/2017.
 */

public class HabitEventViewActivity extends AppCompatActivity {

    public static final String ID_INDEX = "Index";
    public static final String RETURNED_INDEX = "Index", RETURNED_EVENT = "Event", RETURNED_DELETED = "Deleted";

    private TextView habitEventName;
    private TextView habitEventDate;
    private TextView habitEventLocation;
    private TextView habitEventPhoto;
    private EditText habitEventComment;

    private String habitId;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_habit_event_view);
        /**
         * display habit event information.
         */
        Intent intent = getIntent();
        habitId = intent.getStringExtra(ID_INDEX);

        habitEventName = (TextView) findViewById(R.id.EventName);
        habitEventDate = (TextView) findViewById(R.id.EventDate);
        habitEventLocation = (TextView) findViewById(R.id.EventLocation);
        habitEventPhoto = (TextView) findViewById(R.id.EventPhoto);
        habitEventComment = (EditText) findViewById(R.id.EditComment);

        HabitEvent habitevent = (HabitEvent) getIntent().getSerializableExtra("HabitEvent");

        habitEventName.setText(habitevent.getTittle());
        habitEventDate.setText(habitevent.getDate().toString());

        if (habitevent.getLocation() != null)
            habitEventLocation.setText(habitevent.getLocation().toString());
        habitEventPhoto.setText(habitevent.getBase64EncodedPhoto());
        habitEventComment.setText(habitevent.getComment());

    }

    /**
     * the following three function basic on createhabitEventActivity.
     * Handles the save button being clicked
     * @param view
     */
    public void onSaveClicked(View view){
        finishActivity(false);
    }

    /**
     * Handles the delete button being clicked
     * @param view
     */
    public void onDeleteClicked(View view){
        finishActivity(true);
    }

    /**
     * End this activity after the user clicks on either "Edit" or "Delete"
     * Adds data to the intent object if the user selects "Save"
     * @param deleted whether the Delete button was clicked or not
     */
    private void finishActivity(boolean deleted){
        Intent intent = new Intent();
        if (deleted) {
            intent.putExtra("INDEX", ID_INDEX);
            setResult(RESULT_OK, intent);
            finish();
            return;
        }

        String comment = ((EditText)findViewById(R.id.EditComment)).getText().toString();
        HabitEvent event = new HabitEvent(comment);
        intent.putExtra(RETURNED_INDEX, event);
        intent.putExtra(ID_INDEX, habitId);
        setResult(Activity.RESULT_OK, intent);
        finish();
    }
}
{'fraction_non_alphanumeric': 0.0959244532803181, 'fraction_numerical': 0.009940357852882704, 'mean_word_length': 3.1406035665294922, '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': '6989301', 'n_tokens_mistral': 1712, 'n_tokens_neox': 1642, 'n_words': 409}