<commit_before>package com.punventure.punadventure;

import roboguice.fragment.RoboFragment;
import roboguice.inject.InjectView;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.location.Location;
import android.os.Bundle;
import android.os.IBinder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.punventure.punadventure.model.Note;
import com.punventure.punadventure.svc.LocationService;
import com.punventure.punadventure.svc.LocationService.LocationServiceBinder;
import com.punventure.punadventure.svc.NoteRetrievalService;
import com.punventure.punadventure.svc.NoteRetrievalService.NoteRetrievalServiceBinder;

/**
 * A fragment representing a single Note detail screen. This fragment is either
 * contained in a {@link NoteListActivity} in two-pane mode (on tablets) or a
 * {@link NoteDetailActivity} on handsets.
 */
public class NoteDetailFragment extends RoboFragment implements ServiceConnection {
	
    @InjectView(R.id.play_audio_button) ImageView audioButton;
    @InjectView(R.id.show_photo_button) ImageView photoButton;
    @InjectView(R.id.latitude_display) TextView latView;
    @InjectView(R.id.longitude_display) TextView lonView;

    /**
     * The fragment argument representing the item ID that this fragment
     * represents.
     */
    public static final String ARG_ITEM_ID = "item_id";
    private Note note;
    private long mNoteId;

    /**
     * Mandatory empty constructor for the fragment manager to instantiate the
     * fragment (e.g. upon screen orientation changes).
     */
    public NoteDetailFragment() {
        this.note = new Note();
    }

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

        Intent service = new Intent(this.getActivity(), NoteRetrievalService.class);
        this.getActivity().bindService(service, this, Context.BIND_AUTO_CREATE);
        getActivity().bindService(new Intent(getActivity(), LocationService.class), this, Context.BIND_AUTO_CREATE);

        if (getArguments().containsKey(ARG_ITEM_ID)) {
            mNoteId = getArguments().getLong(ARG_ITEM_ID);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_note_detail,
                container, false);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        
        audioButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
            	Intent intent = new Intent(getActivity(), SoundPlayActivity.class);
            	intent.putExtra("audioPath", note.getAudio_path());
            	startActivity(intent);
            }
        }); 
        
        photoButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
            	Intent intent = new Intent(getActivity(), PhotoViewActivity.class);
            	intent.putExtra("imagePath", note.getImage_path());
            	startActivity(intent);
            }
        }); 
    }

    @Override
    public void onServiceConnected(ComponentName name, IBinder service) {
        if (name.toString().contains("NoteRetrievalService")) {
            this.note = ((NoteRetrievalServiceBinder)service).getService().findNoteById(mNoteId);
            // Show the dummy content as text in a TextView.
            if (this.note != null) {
                ((TextView) getView().findViewById(R.id.title_display))
                        .setText(note.getTitle());
                if (note.getAudio_path() == null || note.getAudio_path().isEmpty()) {
                    audioButton.setVisibility(View.INVISIBLE);
                }
                if (note.getImage_path() == null || note.getImage_path().isEmpty()) {
                    photoButton.setVisibility(View.INVISIBLE);
                }
            }
        } else {
            Location location = ((LocationServiceBinder)service).getService().getCurrentLocation();
            if (this.latView != null) {
                this.latView.setText((location.getLatitude() >= 0 ? "N" : "S")
                        + formatLatLon(Math.abs(location.getLatitude())));<commit_msg>Implmented back button in not details<commit_after>package com.punventure.punadventure;

import roboguice.fragment.RoboFragment;
import roboguice.inject.InjectView;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.location.Location;
import android.os.Bundle;
import android.os.IBinder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.punventure.punadventure.model.Note;
import com.punventure.punadventure.svc.LocationService;
import com.punventure.punadventure.svc.LocationService.LocationServiceBinder;
import com.punventure.punadventure.svc.NoteRetrievalService;
import com.punventure.punadventure.svc.NoteRetrievalService.NoteRetrievalServiceBinder;

/**
 * A fragment representing a single Note detail screen. This fragment is either
 * contained in a {@link NoteListActivity} in two-pane mode (on tablets) or a
 * {@link NoteDetailActivity} on handsets.
 */
public class NoteDetailFragment extends RoboFragment implements ServiceConnection {
	
    @InjectView(R.id.play_audio_button) ImageView audioButton;
    @InjectView(R.id.show_photo_button) ImageView photoButton;
    @InjectView(R.id.latitude_display) TextView latView;
    @InjectView(R.id.longitude_display) TextView lonView;
    @InjectView(R.id.back_button) TextView backButton;

    /**
     * The fragment argument representing the item ID that this fragment
     * represents.
     */
    public static final String ARG_ITEM_ID = "item_id";
    private Note note;
    private long mNoteId;

    /**
     * Mandatory empty constructor for the fragment manager to instantiate the
     * fragment (e.g. upon screen orientation changes).
     */
    public NoteDetailFragment() {
        this.note = new Note();
    }

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

        Intent service = new Intent(this.getActivity(), NoteRetrievalService.class);
        this.getActivity().bindService(service, this, Context.BIND_AUTO_CREATE);
        getActivity().bindService(new Intent(getActivity(), LocationService.class), this, Context.BIND_AUTO_CREATE);

        if (getArguments().containsKey(ARG_ITEM_ID)) {
            mNoteId = getArguments().getLong(ARG_ITEM_ID);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_note_detail,
                container, false);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        
        audioButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
            	Intent intent = new Intent(getActivity(), SoundPlayActivity.class);
            	intent.putExtra("audioPath", note.getAudio_path());
            	startActivity(intent);
            }
        }); 
        
        photoButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
            	Intent intent = new Intent(getActivity(), PhotoViewActivity.class);
            	intent.putExtra("imagePath", note.getImage_path());
            	startActivity(intent);
            }
        });
        
        backButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
            	getActivity().finish();
            }
        });
        
        
    }

    @Override
    public void onServiceConnected(ComponentName name, IBinder service) {
        if (name.toString().contains("NoteRetrievalService")) {
            this.note = ((NoteRetrievalServiceBinder)service).getService().findNoteById(mNoteId);
            // Show the dummy content as text in a TextView.
            if (this.note != null) {
                ((TextView) getView().findViewById(R.id.title_display))
                        .setText(note.getTitle());
                if (note.getAudio_path() == null || note.getAudio_path().isEmpty()) {
                    audioButton.setVisibility(View.INVISIBLE);
                }
                if (note.getImage_path() == null || note.getImage_path().isEmpty()) {
                    photoButton.setVisibility(View.INVISIBLE);
                }
            }
        } else {
            Location location = ((LocationServiceBinder)service).getService().getCurrentLocation();
            if (this.latView != null) {
                this.latView.setText((location.getLatitude() >= 0 ? "N" : "S")
                        + formatLatLon(Math.abs(location.getLatitude())));
{'fraction_non_alphanumeric': 0.09920050494424575, 'fraction_numerical': 0.00021039343572480537, 'mean_word_length': 2.8646341463414635, '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': '5449229', 'n_tokens_mistral': 2604, 'n_tokens_neox': 2501, 'n_words': 527}