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
6 changes: 4 additions & 2 deletions README
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## BLA BLA CRADE

Paske c notre projé !


The application start on a activity which name is "Activity_Main". On this activity, we have a button which send us on a new activity which name is "Activity_Search_Itinerary". In this new page we can see a formulaire, where we can fill "The Departure, The Destination and the date. The goal of these informations is to find out, a driver at the date that we will decide it to go in a trip.
Afterwards, we arrive in the last activity which name is "Activity_view_search_itinerary_results" there we got the results from the search. We can see a list with several drivers ans several hours, than the user can decide when It's the better time for him to go.
6 changes: 4 additions & 2 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);
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);

}});

}
}
89 changes: 49 additions & 40 deletions app/src/main/java/fr/wcs/blablacrade/SearchItineraryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,61 +21,70 @@ 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);

// clicq action


// Here, I translate the Variables in English and I change the Indentation.

final EditText editDepartureValue = (EditText) findViewById(R.id.edit_departure);
final EditText editDestinationValue = (EditText) findViewById(R.id.edit_destination);
final EditText editDateValue = (EditText) findViewById(R.id.edit_date);
Button buttonSearch = (Button) findViewById(R.id.button_search);

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();

if (text1.isEmpty() || text2.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);
String textDepartureValue = editDepartureValue.getText().toString();
String textDestinationValue = editDestinationValue.getText().toString();
String textDateValue = editDateValue.getText().toString();

if (textDepartureValue.isEmpty() || textDestinationValue.isEmpty()) {
Toast breadGrilled = Toast.makeText(getApplicationContext(),
getResources().getString(R.string.form_error), Toast.LENGTH_SHORT);
breadGrilled.show();
}else {
Intent intent = new Intent(SearchItineraryActivity.this,
ViewSearchItineraryResultsListActivity.class);
SearchRequestModel searchRequest=new SearchRequestModel(textDepartureValue, textDestinationValue, textDateValue);
intent.putExtra("searchRequest", searchRequest);
SearchItineraryActivity.this.startActivity(intent);
}
}
});

final Calendar calandréi = Calendar.getInstance();


final Calendar calandar = 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);
}};

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();
public void onDateSet(DatePicker view,int year,int month,int day){

calandar.set(Calendar.YEAR, year);
calandar.set(Calendar.MONTH, month);
calandar.set(Calendar.DAY_OF_MONTH, day);
UpdateLabel(editDateValue, calandar);
}
});
}

private void UpdateLabel(EditText editText, Calendar myCalendar) {
private void UpdateLabel(EditText editDateValue, Calendar calendar) {
String myFormat = "dd/MM/yyyy";
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE);
editDateValue.setText(sdf.format(calendar.getTime()));
}


SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE);
};

editText.setText(sdf.format(myCalendar.getTime()));
editDateValue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new DatePickerDialog(SearchItineraryActivity.this,dateListener,
calandar.get(Calendar.YEAR),
calandar.get(Calendar.MONTH),
calandar.get(Calendar.DAY_OF_MONTH)).show();
}
}
});


}
}
60 changes: 35 additions & 25 deletions app/src/main/java/fr/wcs/blablacrade/SearchRequestModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,65 @@

public class SearchRequestModel implements Parcelable {

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

public String getDepare() {
return depare;
// here I corrected the Indentation and I translate the Strings
private String departure;
private String destination;
private String date;

public String getDeparture() {
return departure;
}

public String getOùilva() {
return oùilva;
public String getDestination() {

return destination;
}

public SearchRequestModel(String depare, String oùilva, String quan) {
this.depare = depare;
this.oùilva = oùilva;
this.quan = quan;
public String getDate() {
return date;
}

protected SearchRequestModel(Parcel in) {
depare = in.readString();
oùilva = in.readString();
quan = in.readString();
}
public SearchRequestModel(String departure, String destination, String date) {
this.departure = departure;
this.destination = destination;
this.date = date;
}

protected SearchRequestModel(Parcel in) {
departure = in.readString();
destination = in.readString();
date = in.readString();
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(depare);
dest.writeString(oùilva);
dest.writeString(quan);
dest.writeString(departure);
dest.writeString(destination);
dest.writeString(date);
}

@Override
public int describeContents() {

return 0;
}

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


@Override
public SearchRequestModel[] newArray(int size) {
return new SearchRequestModel[size];

return new SearchRequestModel[size];

}

};

public String getQuan() {
return quan;
}

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

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

//public constructor
public class TripResultAdapter extends BaseAdapter {
private Context context;
private ArrayList<TripResultModel> items;


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

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

return items.size();
}

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

return items.get(position);
}

@Override
public long getItemId(int position) {

return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
// inflate the layout for each list row

if (convertView == null) {
convertView = LayoutInflater.from(context).
inflate(R.layout.trip_item, parent, false);
}

// get current item to be displayed

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);

//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()));
TextView departure = (TextView) convertView.findViewById(R.id.text_departure);
TextView firstName = (TextView) convertView.findViewById(R.id.text_firstname);
TextView price = (TextView) convertView.findViewById(R.id.text_price);

departure.setText(currentItem.getDeparture().toString());
firstName.setText(currentItem.getFirstName());
price.setText(String.valueOf(currentItem.getPrice()));


// returns the view for the current row
return convertView;
}
}
33 changes: 22 additions & 11 deletions app/src/main/java/fr/wcs/blablacrade/TripResultModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,34 @@
/**
* Created by wilder on 13/09/17.
*/

// I tranlate in English all the Variables and correct the constructors structure.
public class TripResultModel {

public Date getDepare() {
return depare;

private String firstName;
private int price;
private Date departure;

public Date getDeparture() {

return departure;
}

public int getPri() {
return pri;
public int getPrice() {

return price;
}
private String prénom;
private int pri;

public TripResultModel(String prénom, Date depare, int pri) {
this.prénom = prénom;this.depare = depare;this.pri = pri;
public String getFirstName() {

return firstName;
}

public TripResultModel(String firstName, Date departure, int price) {
this.firstName = firstName;
this.departure = departure;
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 @@ -16,23 +16,22 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(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();
SearchRequestModel searchRequest= getIntent().getParcelableExtra("searchRequest");
String departure = searchRequest.getDeparture();
String destination = searchRequest.getDestination();
String date = searchRequest.getDate();

Toast.makeText(this, texte3, Toast.LENGTH_LONG).show();
Toast.makeText(this,date, Toast.LENGTH_LONG).show();
setTitle( departure + " >> " + destination);

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

// TODO : add résult to tableau
ListView résultat = (ListView) findViewById(R.id.listViewSearchResults);
ListView résultat = (ListView) findViewById(R.id.list_results);
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));
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);
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
android:background="?attr/colorPrimary"/>

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

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

</android.support.design.widget.CoordinatorLayout>
</android.support.design.widget.CoordinatorLayout>
Loading