Commit ec6e6690 authored by ejcris's avatar ejcris

Searching bus schedules - Starting terminal and Destination only

parent a9b16be7
...@@ -166,7 +166,7 @@ public class ActionBarAttempt extends AppCompatActivity { ...@@ -166,7 +166,7 @@ public class ActionBarAttempt extends AppCompatActivity {
switch(position){ switch(position){
case 0: case 0:
Fragment fa = new SearchFragment(); fragment = new SearchFragment();
break; break;
case 1: case 1:
fragment = new Schedules(); fragment = new Schedules();
......
...@@ -48,7 +48,7 @@ public class Confirmation extends Dialog{ ...@@ -48,7 +48,7 @@ public class Confirmation extends Dialog{
t = busSchedule.getString("to", "").trim(); t = busSchedule.getString("to", "").trim();
dT = busSchedule.getString("depTime", "").trim(); dT = busSchedule.getString("depTime", "").trim();
sA = busSchedule.getString("seatsAvailable", "").trim(); sA = busSchedule.getString("seatsAvailable", "").trim();
//c = busSchedule.getString("cost", "").trim(); c = busSchedule.getString("cost", "").trim();
nOS = busSchedule.getString("noOfSeats", "").trim(); nOS = busSchedule.getString("noOfSeats", "").trim();
a = busSchedule.getString("arrival", "").trim(); a = busSchedule.getString("arrival", "").trim();
} }
...@@ -59,7 +59,6 @@ public class Confirmation extends Dialog{ ...@@ -59,7 +59,6 @@ public class Confirmation extends Dialog{
TextView from = (TextView) findViewById(R.id.from); TextView from = (TextView) findViewById(R.id.from);
TextView to = (TextView) findViewById(R.id.to); TextView to = (TextView) findViewById(R.id.to);
TextView depTime = (TextView) findViewById(R.id.depTime); TextView depTime = (TextView) findViewById(R.id.depTime);
TextView seatsAvailable = (TextView) findViewById(R.id.seatsAvailable);
TextView purchase = (TextView) findViewById(R.id.purchase); TextView purchase = (TextView) findViewById(R.id.purchase);
TextView noOfSeats =(TextView) findViewById(R.id.noOfSeats); TextView noOfSeats =(TextView) findViewById(R.id.noOfSeats);
TextView seatsPurchased =(TextView) findViewById(R.id.seatsPurchased); TextView seatsPurchased =(TextView) findViewById(R.id.seatsPurchased);
...@@ -70,7 +69,6 @@ public class Confirmation extends Dialog{ ...@@ -70,7 +69,6 @@ public class Confirmation extends Dialog{
from.setText(f); from.setText(f);
to.setText(t); to.setText(t);
depTime.setText(dT); depTime.setText(dT);
seatsAvailable.setText(sA);
arrival.setText(a); arrival.setText(a);
totalCost = Double.parseDouble(c)*Double.parseDouble(nOS); totalCost = Double.parseDouble(c)*Double.parseDouble(nOS);
purchase.setText(Double.toString(totalCost)); purchase.setText(Double.toString(totalCost));
...@@ -132,14 +130,14 @@ public class Confirmation extends Dialog{ ...@@ -132,14 +130,14 @@ public class Confirmation extends Dialog{
} }
}); });
Button cancel = (Button) findViewById(R.id.cancel); // Button cancel = (Button) findViewById(R.id.cancel);
cancel.setOnClickListener(new View.OnClickListener() { // cancel.setOnClickListener(new View.OnClickListener() {
//
@Override // @Override
public void onClick(View v) { // public void onClick(View v) {
cancel(); // cancel();
} // }
}); // });
} }
} }
package com.example.pearlsantos.project; package com.example.pearlsantos.project;
import android.app.ProgressDialog;
import android.content.Intent; import android.content.Intent;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
...@@ -19,6 +20,7 @@ import com.parse.ParseUser; ...@@ -19,6 +20,7 @@ import com.parse.ParseUser;
public class Login_Screen extends AppCompatActivity { public class Login_Screen extends AppCompatActivity {
//public final static String EXTRA_MESSAGE = ; //public final static String EXTRA_MESSAGE = ;
String name, password; String name, password;
ProgressDialog progress;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -35,29 +37,51 @@ public class Login_Screen extends AppCompatActivity { ...@@ -35,29 +37,51 @@ public class Login_Screen extends AppCompatActivity {
submit.setOnClickListener(new View.OnClickListener() { submit.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
EditText n = (EditText) findViewById(R.id.name); final ProgressDialog ringProgressDialog = ProgressDialog.show(Login_Screen.this,
name = n.getText().toString(); "Maaring maghintay lamang ...", "Logging in ...", true);
ringProgressDialog.setCancelable(true);
EditText p = (EditText) findViewById(R.id.password); new Thread(new Runnable() {
password = p.getText().toString(); @Override
public void run() {
ParseUser.logInInBackground(name, password, new LogInCallback() { try {
public void done(ParseUser user, ParseException e) { EditText n = (EditText) findViewById(R.id.name);
if (user != null) { name = n.getText().toString();
Intent intent = new Intent(Login_Screen.this, ActionBarAttempt.class);
//EditText editText = (EditText) findViewById(R.id.name); EditText p = (EditText) findViewById(R.id.password);
//String message = editText.getText().toString(); password = p.getText().toString();
//intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent); ParseUser.logInInBackground(name, password, new LogInCallback() {
finish(); public void done(ParseUser user, ParseException e) {
if (user != null) {
} else { Intent intent = new Intent(Login_Screen.this, ActionBarAttempt.class);
//Log.d(e, "What happened?"); //EditText editText = (EditText) findViewById(R.id.name);
Toast.makeText(Login_Screen.this, "Name and phone number combination " + //String message = editText.getText().toString();
"does not exist", Toast.LENGTH_LONG).show(); //intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
ringProgressDialog.dismiss();
finish();
} else {
//Log.d(e, "What happened?");
Toast.makeText(Login_Screen.this, "Name and phone number combination " +
"does not exist", Toast.LENGTH_LONG).show();
ringProgressDialog.dismiss();
}
}
});
Thread.sleep(10000);
} catch (Exception e) {
}
ringProgressDialog.dismiss();
} }
}
}); }).start();
} }
}); });
...@@ -94,4 +118,5 @@ public class Login_Screen extends AppCompatActivity { ...@@ -94,4 +118,5 @@ public class Login_Screen extends AppCompatActivity {
startActivity(intent); startActivity(intent);
} }
} }
...@@ -18,7 +18,8 @@ import android.widget.Toast; ...@@ -18,7 +18,8 @@ import android.widget.Toast;
public class ReservingSeats extends Dialog { public class ReservingSeats extends Dialog {
SharedPreferences busSchedule; SharedPreferences busSchedule;
EditText noOfSeats; EditText noOfSeats;
String bN, pN, f, t, dT, sA, c, nOS, a; String sA;
int nOS;
NumberPicker tens; NumberPicker tens;
NumberPicker ones; NumberPicker ones;
...@@ -31,6 +32,7 @@ public class ReservingSeats extends Dialog { ...@@ -31,6 +32,7 @@ public class ReservingSeats extends Dialog {
{ {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_reserving_seats);
busSchedule = getContext().getSharedPreferences("bus", Context.MODE_PRIVATE); busSchedule = getContext().getSharedPreferences("bus", Context.MODE_PRIVATE);
// if(busSchedule!=null){ // if(busSchedule!=null){
// bN = busSchedule.getString("busNum", "").trim(); // bN = busSchedule.getString("busNum", "").trim();
...@@ -38,7 +40,7 @@ public class ReservingSeats extends Dialog { ...@@ -38,7 +40,7 @@ public class ReservingSeats extends Dialog {
// f = busSchedule.getString("from", "").trim(); // f = busSchedule.getString("from", "").trim();
// t = busSchedule.getString("to", "").trim(); // t = busSchedule.getString("to", "").trim();
// dT = busSchedule.getString("depTime", "").trim(); // dT = busSchedule.getString("depTime", "").trim();
sA = busSchedule.getString("seatsAvailable", "").trim(); sA = busSchedule.getString("seatsAvailable", "").trim();
// c = busSchedule.getString("cost", "").trim(); // c = busSchedule.getString("cost", "").trim();
// a = busSchedule.getString("arrival", "").trim(); // a = busSchedule.getString("arrival", "").trim();
// } // }
...@@ -56,7 +58,6 @@ public class ReservingSeats extends Dialog { ...@@ -56,7 +58,6 @@ public class ReservingSeats extends Dialog {
ones.setWrapSelectorWheel(true); ones.setWrapSelectorWheel(true);
setContentView(R.layout.activity_reserving_seats);
// noOfSeats = (EditText) findViewById(R.id.noOfSeats); // noOfSeats = (EditText) findViewById(R.id.noOfSeats);
// noOfSeats.setText("1"); // noOfSeats.setText("1");
...@@ -69,12 +70,13 @@ public class ReservingSeats extends Dialog { ...@@ -69,12 +70,13 @@ public class ReservingSeats extends Dialog {
NumberPicker tensSeats = (NumberPicker) findViewById(R.id.numberPicker); NumberPicker tensSeats = (NumberPicker) findViewById(R.id.numberPicker);
NumberPicker unitSeats = (NumberPicker) findViewById(R.id.numberPicker2); NumberPicker unitSeats = (NumberPicker) findViewById(R.id.numberPicker2);
int nOS1 = (tensSeats.getValue()*10) + unitSeats.getValue(); nOS = (tensSeats.getValue()*10) + unitSeats.getValue();
int remainingSeats = Integer.parseInt(sA) - nOS1; int remainingSeats = Integer.parseInt(sA) - nOS;
if (remainingSeats > 0) { if (remainingSeats > 0) {
SharedPreferences.Editor edit = busSchedule.edit(); SharedPreferences.Editor edit = busSchedule.edit();
edit.putString("noOfSeats", noOfSeats.getText().toString().trim()); edit.putString("noOfSeats", Integer.toString(nOS).trim());
edit.putString("seatsAvailable", Integer.toString(remainingSeats).trim());
edit.commit(); edit.commit();
Confirmation confirm = new Confirmation(getContext()); Confirmation confirm = new Confirmation(getContext());
confirm.show(); confirm.show();
......
...@@ -107,5 +107,11 @@ ...@@ -107,5 +107,11 @@
</LinearLayout> </LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/schedule"
android:layout_gravity="center_horizontal" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment