Skip to content
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
8 changes: 5 additions & 3 deletions app/src/main/java/fr/wcs/blablacrade/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ protected void onCreate(Bundle savedInstanceState) {
setSupportActionBar(toolbar);

//bouton cherché
Button Search = (Button) findViewById(R.id.gogogo);
Button Search = (Button) findViewById(R.id.button_search_itinerary);
Search.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view){
Intent intent=new Intent(MainActivity.this, SearchItineraryActivity.class);startActivity(intent);
}});
Intent intent = new Intent(MainActivity.this, SearchItineraryActivity.class);
startActivity(intent);
}
});
}
}
61 changes: 31 additions & 30 deletions app/src/main/java/fr/wcs/blablacrade/SearchItineraryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,53 +21,54 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search_itinerary);

final EditText edit1 = (EditText) findViewById(R.id.editText1);
final EditText edit2 = (EditText) findViewById(R.id.editText2);
final EditText edit3 = (EditText) findViewById(R.id.editText3);
Button buttonSearch = (Button) findViewById(R.id.push);
final EditText editDeparture = (EditText) findViewById(R.id.editText_departure);
final EditText editDestination = (EditText) findViewById(R.id.editText_destination);
final EditText editDate = (EditText) findViewById(R.id.editText_date);
Button buttonSearch = (Button) findViewById(R.id.button_search);

// clicq action
buttonSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String text1 = edit1.getText().toString();
String text2 = edit2.getText().toString();
String texte = edit3.getText().toString();
String departure = editDeparture.getText().toString();
String destination = editDestination.getText().toString();
String date = editDate.getText().toString();

if (text1.isEmpty() || text2.isEmpty()
) {
if (departure.isEmpty() || destination.isEmpty()) {
Toast painGrillé = Toast.makeText(getApplicationContext(), getResources().getString(R.string.form_error), Toast.LENGTH_SHORT);
painGrillé.show();
}else {Intent intent = new Intent(SearchItineraryActivity.this, ViewSearchItineraryResultsListActivity.class);
SearchRequestModel searchRequest=new SearchRequestModel(text1, text2, texte); intent.putExtra("searchRequest", searchRequest);

SearchItineraryActivity.this.startActivity(intent);
}
else {
Intent intent = new Intent(SearchItineraryActivity.this, ViewSearchItineraryResultsListActivity.class);
SearchRequestModel searchRequest = new SearchRequestModel(departure, destination, date);
intent.putExtra("searchRequest", searchRequest);
SearchItineraryActivity.this.startActivity(intent);
}
}
});

final Calendar calandréi = Calendar.getInstance();
final Calendar calendar = Calendar.getInstance();
final DatePickerDialog.OnDateSetListener dateListener = new DatePickerDialog.OnDateSetListener() {

@Override
public void onDateSet(DatePicker view,int ané,int moi,int joure){
calandréi.set(Calendar.YEAR, ané);
calandréi.set(Calendar.MONTH, moi);
calandréi.set(Calendar.DAY_OF_MONTH, joure);
UpdateLabel(edit3, calandréi);
public void onDateSet(DatePicker view,int year,int month,int dayOfMonth){
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
UpdateLabel(editDate, calendar);
}};

edit3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new DatePickerDialog(SearchItineraryActivity.this,
dateListener,
calandréi.get(Calendar.YEAR),
calandréi.get(Calendar.MONTH),
calandréi.get(Calendar.DAY_OF_MONTH)
).show();
}
});
editDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new DatePickerDialog(SearchItineraryActivity.this,
dateListener,
calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH)
).show();
}
});
}

private void UpdateLabel(EditText editText, Calendar myCalendar) {
Expand Down
54 changes: 28 additions & 26 deletions app/src/main/java/fr/wcs/blablacrade/SearchRequestModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,39 @@

public class SearchRequestModel implements Parcelable {

private String depare;
private String oùilva;
private String quan;

public String getDepare() {
return depare;
}
private String departureModel;
private String destinationModel;
private String dateModel;

public String getOùilva() {
return oùilva;
//getters
public String getDepartureModel() {
return departureModel;
}
public String getDestinationModel() {
return destinationModel;
}
public String getDateModel() {
return dateModel;
}

public SearchRequestModel(String depare, String oùilva, String quan) {
this.depare = depare;
this.oùilva = oùilva;
this.quan = quan;
public SearchRequestModel(String departureModel, String destinationModel, String dateModel) {
this.departureModel = departureModel;
this.destinationModel = destinationModel;
this.dateModel = dateModel;
}

protected SearchRequestModel(Parcel in) {
depare = in.readString();
oùilva = in.readString();
quan = in.readString();
}
protected SearchRequestModel(Parcel in) {
departureModel = in.readString();
destinationModel = in.readString();
dateModel = in.readString();
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(depare);
dest.writeString(oùilva);
dest.writeString(quan);
dest.writeString(departureModel);
dest.writeString(destinationModel);
dest.writeString(dateModel);
}

@Override
Expand All @@ -46,9 +50,9 @@ public int describeContents() {
}

public static final Creator<SearchRequestModel> CREATOR = new Creator<SearchRequestModel>() {
@Override
public SearchRequestModel createFromParcel(Parcel in) {
return new SearchRequestModel(in);
@Override
public SearchRequestModel createFromParcel(Parcel in) {
return new SearchRequestModel(in);
}

@Override
Expand All @@ -57,7 +61,5 @@ public SearchRequestModel[] newArray(int size) {
}
};

public String getQuan() {
return quan;
}

}
30 changes: 15 additions & 15 deletions app/src/main/java/fr/wcs/blablacrade/TripResultAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,28 @@
* Created by wilder on 13/09/17.
*/

// This is the adapter lol
// This is the adapter
public class TripResultAdapter extends BaseAdapter {
private Context context; //context
private ArrayList<TripResultModel> items; //data source of the list adapter
private Context context;
//data source of the list adapter
private ArrayList<TripResultModel> items;

//public constructor
//public constructor
public TripResultAdapter(Context context, ArrayList<TripResultModel> items) {
this.context = context;
this.items = items;
}

@Override
//returns total of items in the list
public int getCount() {
return items.size(); //returns total of items in the list
return items.size();
}

@Override
//returns list item at the specified position
public Object getItem(int position) {
return items.get(position); //returns list item at the specified position
return items.get(position);
}

@Override
Expand All @@ -51,17 +54,14 @@ public View getView(int position, View convertView, ViewGroup parent) {
TripResultModel currentItem = (TripResultModel) getItem(position);

// get the TextView for item name and item description
TextView departure = (TextView)
convertView.findViewById(R.id.texteresu1);
TextView firstname = (TextView)
convertView.findViewById(R.id.textres2);
TextView price = (TextView)
convertView.findViewById(R.id.txt);
TextView departure = (TextView) convertView.findViewById(R.id.text_result_departure);
TextView firstname = (TextView) convertView.findViewById(R.id.text_result_firstname);
TextView price = (TextView) convertView.findViewById(R.id.text_result_price);

//sets the text for item name and item description from the current item object
departure.setText(currentItem.getDepare().toString());
firstname.setText(currentItem.getPrénom());
price.setText(String.valueOf(currentItem.getPri()));
departure.setText(currentItem.getdateDeparture().toString());
firstname.setText(currentItem.getFirstname());
price.setText(String.valueOf(currentItem.getPrice()));

// returns the view for the current row
return convertView;
Expand Down
27 changes: 17 additions & 10 deletions app/src/main/java/fr/wcs/blablacrade/TripResultModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,28 @@
*/

public class TripResultModel {
private String firstname;
private int price;
private Date dateDeparture;

public Date getDepare() {
return depare;
public Date getdateDeparture() {
return dateDeparture;
}

public int getPri() {
return pri;
public int getPrice() {
return price;
}
private String prénom;
private int pri;
public String getFirstname() {
return firstname;
}


public TripResultModel(String prénom, Date depare, int pri) {
this.prénom = prénom;this.depare = depare;this.pri = pri;
public TripResultModel(String firstname, Date dateDeparture, int price) {
this.firstname = firstname;
this.dateDeparture = dateDeparture;
this.price = price;
}
private Date depare;

public String getPrénom() {return prénom;}


}
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,26 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_view_search_itinerary_results_list);

SearchRequestModel truc = getIntent().getParcelableExtra("searchRequest");
String text1 = truc.getDepare();
String TEXTEDEUX = truc.getOùilva();
String texte3 = truc.getQuan();
String depature = truc.getDepartureModel();
String destination = truc.getDestinationModel();
String date = truc.getDateModel();

Toast.makeText(this, texte3, Toast.LENGTH_LONG).show();
Toast.makeText(this, date, Toast.LENGTH_LONG).show();

setTitle(text1 + " >> " + TEXTEDEUX);
setTitle(depature + " >> " + destination);

// TODO : add résult to tableau
ListView résultat = (ListView) findViewById(R.id.listViewSearchResults);
ListView result = (ListView) findViewById(R.id.listViewSearchResults);
ArrayList<TripResultModel> tableau = new ArrayList<>();SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy-hh:mm");

try {
tableau.add(new TripResultModel("Bernard", sdf.parse("21/02/2017-15:30"), 15));
tableau.add(new TripResultModel("Jean-Jacques", sdf.parse("21/02/2017-16:00"), 20));
tableau.add(new TripResultModel("Bertrand", sdf.parse("21/02/2017-16:30"), 16));
tableau.add(new TripResultModel("Gertrude", sdf.parse("21/02/2017-17:00"), 40));
} catch (ParseException e) {
}
TripResultAdapter adapteur = new TripResultAdapter(this, tableau);résultat.setAdapter(adapteur);
} catch (ParseException e) {
}

TripResultAdapter adapter = new TripResultAdapter(this, tableau);result.setAdapter(adapter);
}
}
12 changes: 6 additions & 6 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"/>

</android.support.design.widget.AppBarLayout>
</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_main" />

Expand Down
Loading