Skip to content
This repository has been archived by the owner on Apr 20, 2019. It is now read-only.

submit #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ListViewActivity"
android:windowSoftInputMode="adjustPan" />
<activity android:name=".NetworkActivity" />
<activity android:name=".JSONActivity" />
<activity android:name=".NotificationActivity" />
<activity
android:name=".PaceCalculatorActivity"
android:label="@string/title_activity_pace_calculator"
Expand Down
66 changes: 66 additions & 0 deletions src/main/java/nyc/c4q/CustomAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package nyc.c4q;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;

/**
* Created by elvisboves on 8/30/15.
*/
public class CustomAdapter extends BaseAdapter {

ArrayList<Person> persons = new ArrayList<Person>();
LayoutInflater mInflater;
Context context;


public CustomAdapter(Context context, ArrayList<Person> persons) {
this.persons = persons;
this.context = context;
mInflater = LayoutInflater.from(this.context);
}

@Override
public int getCount() {
return persons.size();
}

@Override
public Person getItem(int position) {
return persons.get(position);
}

@Override
public long getItemId(int i) {
return 0;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {


if (convertView == null) {
convertView = mInflater.inflate(R.layout.listitem_member, parent, false);
}

Person personFinal = getItem(position);

TextView house = (TextView) convertView.findViewById(R.id.text_house);
TextView name = (TextView) convertView.findViewById(R.id.text_name);

name.setText(personFinal.firstName);
house.setText(personFinal.house.toString());


return convertView;
}



}
57 changes: 57 additions & 0 deletions src/main/java/nyc/c4q/ListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleAdapter;

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

import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;


public class ListActivity extends Activity {

public ListView list;
ArrayList<Person> mPersonArrayList = new ArrayList<Person>();

public static final Person[] PEOPLE = {
new Person("Hannah", "Abbott", House.Hufflepuff),
Expand Down Expand Up @@ -47,7 +61,50 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);

ArrayList<Person> arrayOfPersons = new ArrayList<Person>();
CustomAdapter adapter = new CustomAdapter(this, arrayOfPersons);
list = (ListView) findViewById(R.id.list);

list.setAdapter(adapter);


// try {
//
// JSONArray jsonArray= new JSONArray("");
// JSONObject jsonObjectb = (JSONObject)jsonArray.getJSONObject(0);
// JSONArray st = jsonObjectb.getJSONArray("name");
// for(int i=0;i<st.length();i++)
// {
// String street = st.getString(i);
// Log.d("MainActivity", "K lio " + street);
// }
// }catch(Exception e)
// {
// e.printStackTrace();
// }


}

private void getData() {



for (int i = 0; i < PEOPLE.length; i++) {

Person listData = new Person();
String finals;

finals = listData.firstName;





}
}




}
91 changes: 90 additions & 1 deletion src/main/java/nyc/c4q/PaceCalculatorActivity.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,103 @@
package nyc.c4q;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;

import java.io.IOException;
import java.math.BigDecimal;

public class PaceCalculatorActivity extends FragmentActivity {

EditText inputDistance;
EditText inputTimeMin;
EditText inputTimeSec;
EditText inputPaceMin;
EditText inputPaceSec;
Button buttonCalculate;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pace_calculator);
setContentView(R.layout.fragment_pace_calculator);

inputDistance = (EditText) findViewById(R.id.input_distance);
inputTimeMin = (EditText) findViewById(R.id.input_time_min);
inputTimeSec = (EditText) findViewById(R.id.input_time_sec);
inputPaceMin = (EditText) findViewById(R.id.input_pace_min);
inputPaceSec = (EditText) findViewById(R.id.input_pace_sec);
buttonCalculate = (Button) findViewById(R.id.button_calculate);





buttonCalculate.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View view) {


if ((inputPaceMin.getText().toString().trim().length() == 0) && (inputPaceSec.getText().toString().trim().length() == 0)) {

int timeMin;
int timeSec;
double distance;
double result;

timeMin = Integer.parseInt(inputTimeMin.getText().toString());
timeSec = Integer.parseInt(inputTimeSec.getText().toString());
distance = Double.valueOf(inputDistance.getText().toString());

result = ((timeMin + (timeSec / 60.0)) / distance);
int finalPaceMin = (int) result;
inputPaceMin.setText(finalPaceMin + "");
int finalPaceSec = (int) ((result - finalPaceMin) * 60);
inputPaceSec.setText( finalPaceSec + "");

} else if ((inputTimeMin.getText().toString().trim().length() == 0) && (inputTimeSec.getText().toString().trim().length() == 0)) {

int paceMin;
int paceSec;
double distance;
double result;

distance = Double.valueOf(inputDistance.getText().toString());
paceMin = Integer.parseInt(inputPaceMin.getText().toString());
paceSec = Integer.parseInt(inputPaceSec.getText().toString());

result = distance * (paceMin + (paceSec / 60.0));
int finalres = (int) result;
inputTimeMin.setText(finalres + "");
int finalSec = (int) ((result - finalres) * 60);
inputTimeSec.setText(finalSec + "");
}else {

int paceMin;
int paceSec;
int timeMin;
int timeSec;
double result;

timeMin = Integer.parseInt(inputTimeMin.getText().toString());
timeSec = Integer.parseInt(inputTimeSec.getText().toString());
paceMin = Integer.parseInt(inputPaceMin.getText().toString());
paceSec = Integer.parseInt((inputPaceSec.getText().toString()));

result = ((timeMin + (timeSec / 60.0)) / (paceMin + (paceSec / 60.0)));
inputDistance.setText(result + " ");
}
}

});

}

}
12 changes: 12 additions & 0 deletions src/main/java/nyc/c4q/Person.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package nyc.c4q;

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

import java.util.ArrayList;

public class Person {
public String firstName;
public String lastName;
Expand All @@ -10,4 +16,10 @@ public Person(String firstName, String lastName, House house) {
this.lastName = lastName;
this.house = house;
}

public Person(){

}


}
2 changes: 1 addition & 1 deletion src/main/res/raw/books.json
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@
"isbn": "0439554934",
"isbn13": "9780439554930",
"publisher": "Scholastic",
"publishyear": 2003.
"publishyear": 2003,
"checkedout": true,
"checkedoutby": 38,
"checkoutdateyear": 2015,
Expand Down