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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# BlaBlaWild

Application Android qui permet de chercher un covoiturage.
15 changes: 10 additions & 5 deletions app/src/main/java/fr/wcs/blablacrade/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ protected void onCreate(Bundle savedInstanceState) {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

//bouton cherché
Button Search = (Button) findViewById(R.id.gogogo);
Search.setOnClickListener(new View.OnClickListener() {

Button mSearch = (Button) findViewById(R.id.btn_search_itinerary);

/** Action sur le bouton search pour accéder à la page SearchItinerary */

mSearch.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);
MainActivity.this.startActivity(intent);
}
});
}
}
69 changes: 34 additions & 35 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,60 @@ 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 mEditDeparture = (EditText) findViewById(R.id.edit_departure);
final EditText mEditDestination = (EditText) findViewById(R.id.edit_destination);
final EditText mEditDate = (EditText) findViewById(R.id.edit_date);
Button mBtnSearch = (Button) findViewById(R.id.btn_search);

// clicq action
buttonSearch.setOnClickListener(new View.OnClickListener() {
mBtnSearch.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 strDeparture = mEditDeparture.getText().toString();
String strDestination = mEditDestination.getText().toString();
String strDate = mEditDate.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);
if (strDeparture.isEmpty() || strDestination.isEmpty()) {
Toast toast = Toast.makeText(getApplicationContext(), getResources().getString(R.string.form_error), Toast.LENGTH_SHORT);
toast.show();
} else {
Intent intent = new Intent(SearchItineraryActivity.this, ViewSearchItineraryResultsListActivity.class);
SearchRequestModel searchRequest = new SearchRequestModel(strDeparture, strDestination, strDate);
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 day){
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DAY_OF_MONTH, day);
UpdateLabel(mEditDate, calendar);
}
};

edit3.setOnClickListener(new View.OnClickListener() {
mEditDate.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();
dateListener,
calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH)).show();
}
});
}

private void UpdateLabel(EditText editText, Calendar myCalendar) {
String myFormat = "dd/MM/yyyy";
private void UpdateLabel(EditText editText, Calendar myCalendar) {
String myFormat = "dd/MM/yyyy";


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

editText.setText(sdf.format(myCalendar.getTime()));
}
editText.setText(sdf.format(myCalendar.getTime()));
}
}
45 changes: 23 additions & 22 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;
private String departure;
private String destination;
private String date;

public String getDepare() {
return depare;
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;
}

public SearchRequestModel(String departure, String destination, String date) {
this.departure = departure;
this.destination = destination;
this.date = date;
}

protected SearchRequestModel(Parcel in) {
depare = in.readString();
oùilva = in.readString();
quan = in.readString();
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
Expand All @@ -46,8 +50,8 @@ public int describeContents() {
}

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

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

public String getQuan() {
return quan;
}
}
28 changes: 11 additions & 17 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,23 @@
* 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
private Context context;
private ArrayList<TripResultModel> items;

//public constructor
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
Expand All @@ -41,27 +39,23 @@ public long getItemId(int 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);
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);
TextView mTripDeparture = (TextView) convertView.findViewById(R.id.text_trip_departure);
TextView mFirstname = (TextView) convertView.findViewById(R.id.text_firstname);
TextView mPrice = (TextView) convertView.findViewById(R.id.text_trip_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()));
mTripDeparture.setText(currentItem.getTripDeparture().toString());
mFirstname.setText(currentItem.getFirstname());
mPrice.setText(String.valueOf(currentItem.getPrice()));

// returns the view for the current row
return convertView;
Expand Down
25 changes: 14 additions & 11 deletions app/src/main/java/fr/wcs/blablacrade/TripResultModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@

public class TripResultModel {

public Date getDepare() {
return depare;
}
private Date tripDeparture;
private String firstname;
private int price;

public int getPri() {
return pri;
public TripResultModel(String firstname, Date tripDeparture, int price) {
this.firstname = firstname;
this.tripDeparture = tripDeparture;
this.price = 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 Date getTripDeparture() {
return tripDeparture;
}
private Date depare;

public String getPrénom() {return prénom;}
public int getPrice() {
return price;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,31 @@ 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();

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

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

// TODO : add résult to tableau
ListView résultat = (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);
/** On récupère les données envoyées depuis SearchItinerary */

SearchRequestModel searchRequestModel = getIntent().getParcelableExtra("searchRequest");
String strDeparture = searchRequestModel.getDeparture();
String strDestination = searchRequestModel.getDestination();
String strDate = searchRequestModel.getDate();

Toast.makeText(this, strDate, Toast.LENGTH_LONG).show();

setTitle(strDeparture + " >> " + strDestination);

ListView listView = (ListView) findViewById(R.id.listViewSearchResults);
ArrayList<TripResultModel> tripResult = new ArrayList<>();
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy-hh:mm");


try {
tripResult.add(new TripResultModel("Bernard", sdf.parse("21/02/2017-15:30"), 15));
tripResult.add(new TripResultModel("Jean-Jacques", sdf.parse("21/02/2017-16:00"), 20));
tripResult.add(new TripResultModel("Bertrand", sdf.parse("21/02/2017-16:30"), 16));
tripResult.add(new TripResultModel("Gertrude", sdf.parse("21/02/2017-17:00"), 40));
} catch (ParseException e) {
}

TripResultAdapter adapter = new TripResultAdapter(this, tripResult);
listView.setAdapter(adapter);
}
}
Loading