<commit_before>package edu.rutgers.css.Rutgers.fragments;

import org.jdeferred.DoneCallback;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import edu.rutgers.css.Rutgers.api.Places;
import edu.rutgers.css.Rutgers2.R;

/**
 * A simple {@link android.support.v4.app.Fragment} subclass.
 * 
 */
public class PlacesDisplay extends Fragment {

	private static final String TAG = "PlacesDisplay";
	
	/**
	 * Put JSON address object into readable string form
	 * @param address JSON address object from place data
	 * @return Address as a multi-line human-readable string
	 */
	private static String formatAddress(JSONObject address) {
		String result = "";
		
		try {
			result += address.getString("name") + "\n";
			result += address.getString("street") + "\n";
			result += address.getString("city") + ", " + address.getString("state_abbr") + " " + address.getString("postal_code");
		} catch (JSONException e) {
			Log.e(TAG, e.getMessage());
		}
		
		return result;
	}
	
	private static final String formatOffices(JSONArray offices) {
		String result = "";
		
		for(int i = 0; i < offices.length(); i++) {
			try {
				result += offices.getString(i) + "\n";
			} catch (JSONException e) {
				Log.e(TAG, e.getMessage());
			}
		}
		
		return result;
	}
	
	public PlacesDisplay() {
		// Required empty public constructor
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		final View v = inflater.inflate(R.layout.fragment_place_display, container, false);
		Bundle args = getArguments();
		
		final TextView addressTextView = (TextView) v.findViewById(R.id.addressTextView);
		final TextView buildingNoTextView = (TextView) v.findViewById(R.id.buildingNoTextView);
		final TextView descriptionTextView = (TextView) v.findViewById(R.id.descriptionTextView);
		final TextView campusNameTextView = (TextView) v.findViewById(R.id.campusTextView);
		final TextView officesTextView = (TextView) v.findViewById(R.id.officesTextView);
		
		if(args.get("placeJSON") != null) {
			JSONObject placeJSON;
			
			try {
				placeJSON = new JSONObject(args.getString("placeJSON"));
			} catch (JSONException e1) {
				Log.e(TAG, e1.getMessage());
				return v;
			}
			
			try {
				getActivity().setTitle(placeJSON.getString("placeName"));
			} catch (JSONException e) {
				getActivity().setTitle("Places");
			}
				

			try {
				
				if(placeJSON.has("location")) addressTextView.setText(formatAddress(placeJSON.getJSONObject("location")));
				if(placeJSON.has("building_number")) buildingNoTextView.setText(placeJSON.getString("building_number"));
				if(placeJSON.has("campus_name")) campusNameTextView.setText(placeJSON.getString("campus_name"));
				if(placeJSON.has("description")) descriptionTextView.setText(placeJSON.getString("description"));
				if(placeJSON.has("offices")) officesTextView.setText(formatOffices(placeJSON.getJSONArray("offices")));
				
			} catch (JSONException e) {
				Log.e(TAG, Log.getStackTraceString(e));
			}
			
		}					
		
		return v;
	}

}<commit_msg>Removed unnecessary checks & fixed title<commit_after>package edu.rutgers.css.Rutgers.fragments;

import org.jdeferred.DoneCallback;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import edu.rutgers.css.Rutgers.api.Places;
import edu.rutgers.css.Rutgers2.R;

/**
 * A simple {@link android.support.v4.app.Fragment} subclass.
 * 
 */
public class PlacesDisplay extends Fragment {

	private static final String TAG = "PlacesDisplay";
	
	/**
	 * Put JSON address object into readable string form
	 * @param address JSON address object from place data
	 * @return Address as a multi-line human-readable string
	 */
	private static String formatAddress(JSONObject address) {
		String result = "";
		
		try {
			result += address.getString("name") + "\n";
			result += address.getString("street") + "\n";
			result += address.getString("city") + ", " + address.getString("state_abbr") + " " + address.getString("postal_code");
		} catch (JSONException e) {
			Log.e(TAG, e.getMessage());
		}
		
		return result;
	}
	
	private static final String formatOffices(JSONArray offices) {
		String result = "";
		
		for(int i = 0; i < offices.length(); i++) {
			try {
				result += offices.getString(i) + "\n";
			} catch (JSONException e) {
				Log.e(TAG, e.getMessage());
			}
		}
		
		return result;
	}
	
	public PlacesDisplay() {
		// Required empty public constructor
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		final View v = inflater.inflate(R.layout.fragment_place_display, container, false);
		Bundle args = getArguments();
		
		final TextView addressTextView = (TextView) v.findViewById(R.id.addressTextView);
		final TextView buildingNoTextView = (TextView) v.findViewById(R.id.buildingNoTextView);
		final TextView descriptionTextView = (TextView) v.findViewById(R.id.descriptionTextView);
		final TextView campusNameTextView = (TextView) v.findViewById(R.id.campusTextView);
		final TextView officesTextView = (TextView) v.findViewById(R.id.officesTextView);
		
		if(args.get("placeJSON") != null) {
			JSONObject placeJSON;
			
			try {
				placeJSON = new JSONObject(args.getString("placeJSON"));
			} catch (JSONException e1) {
				Log.e(TAG, e1.getMessage());
				return v;
			}
			
			try {
				getActivity().setTitle(placeJSON.getString("title"));
			} catch (JSONException e) {
				Log.w(TAG, e.getMessage());
				getActivity().setTitle("Places");
			}

			try {
				
				addressTextView.setText(formatAddress(placeJSON.getJSONObject("location")));
				buildingNoTextView.setText(placeJSON.getString("building_number"));
				campusNameTextView.setText(placeJSON.getString("campus_name"));
				descriptionTextView.setText(placeJSON.getString("description"));
				officesTextView.setText(formatOffices(placeJSON.getJSONArray("offices")));
				
			} catch (JSONException e) {
				Log.w(TAG, e.getMessage());
			}
			
		}					
		
		return v;
	}

}
{'fraction_non_alphanumeric': 0.13105149552883133, 'fraction_numerical': 0.0018501387604070306, 'mean_word_length': 4.252631578947368, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3136239', 'n_tokens_mistral': 2251, 'n_tokens_neox': 1906, 'n_words': 411}