use of ca.etsmtl.applets.etsmobile.model.applets_events.EvenementCommunaute in project ETSMobile-Android2 by ApplETS.
the class AppletsApiEvenementsRequest method loadDataFromNetwork.
@Override
public EvenementCommunauteList loadDataFromNetwork() throws Exception {
String eventsAddress = context.getString(R.string.applets_api_events, source.getKey());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(eventsAddress).get().build();
Response response = client.newCall(request).execute();
String result = response.body().string();
EvenementCommunauteList evenementList = new Gson().fromJson(result, EvenementCommunauteList.class);
for (EvenementCommunaute event : evenementList) {
event.setSourceEvenement(source);
}
return evenementList;
}
use of ca.etsmtl.applets.etsmobile.model.applets_events.EvenementCommunaute in project ETSMobile-Android2 by ApplETS.
the class EvenementCommunauteAdapter method getGroupView.
@Override
public View getGroupView(int listPosition, boolean isExpanded, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView != null) {
holder = (ViewHolder) convertView.getTag();
} else {
LayoutInflater layoutInflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.row_header_applets_events, parent, false);
holder = new ViewHolder();
holder.imageViewEvenement = (ImageView) convertView.findViewById(R.id.iv_evenement);
holder.textViewNomEvenement = (TextView) convertView.findViewById(R.id.tv_nom_evenement);
holder.textViewMois = (TextView) convertView.findViewById(R.id.tv_mois);
holder.textViewJour = (TextView) convertView.findViewById(R.id.tv_jour);
convertView.setTag(holder);
}
final EvenementCommunaute item = (EvenementCommunaute) getGroup(listPosition);
String urlImageEvenement = item.getImage();
final String urlImageOrganisateur = item.getSourceEvenement().getUrlImage();
if (!urlImageEvenement.isEmpty()) {
Picasso.with(context).load(urlImageEvenement).placeholder(R.drawable.event_header).into(holder.imageViewEvenement);
}
DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd");
DateTime date = dateTimeFormatter.parseDateTime(item.getDebut());
String monthString = date.toString("MMMM");
monthString = monthString.substring(0, 1).toUpperCase() + monthString.substring(1, 3);
holder.textViewMois.setText(monthString);
holder.textViewJour.setText(date.toString("dd", Locale.CANADA_FRENCH));
holder.textViewNomEvenement.setText(item.getNom());
return convertView;
}
use of ca.etsmtl.applets.etsmobile.model.applets_events.EvenementCommunaute in project ETSMobile-Android2 by ApplETS.
the class EvenementCommunauteAdapter method getRealChildView.
@Override
public View getRealChildView(final int listPosition, final int expandedListPosition, boolean isLastChild, View convertView, ViewGroup parent) {
final EvenementCommunaute item = (EvenementCommunaute) getChild(listPosition, expandedListPosition);
if (convertView == null) {
LayoutInflater layoutInflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.row_applets_events, null);
}
TextView textViewDescription = (TextView) convertView.findViewById(R.id.tv_description);
ImageView imageViewLogoOrganisateur = (ImageView) convertView.findViewById(R.id.iv_logo_organisateur);
TextView textViewNomOrganisateur = (TextView) convertView.findViewById(R.id.tv_nom_organisateur);
CircleButton buttonDetails = (CircleButton) convertView.findViewById(R.id.btn_details);
textViewDescription.setText(item.getDescription());
textViewNomOrganisateur.setText(item.getSourceEvenement().getName());
String urlImageOrganisateur = item.getSourceEvenement().getUrlImage();
if (!urlImageOrganisateur.isEmpty()) {
Picasso.with(convertView.getContext()).load(urlImageOrganisateur).into(imageViewLogoOrganisateur);
}
buttonDetails.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String url = getFacebookEventURL(item.getId());
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
// Verify if the link is one to use Facebook first. If not, open a webpage.
if (URLUtil.isHttpUrl(url) || URLUtil.isHttpsUrl(url)) {
Utility.openChromeCustomTabs(v.getContext(), url);
} else {
v.getContext().startActivity(intent);
}
}
});
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!(view instanceof Button)) {
expandableListView.collapseGroupWithAnimation(listPosition);
}
}
});
return convertView;
}
Aggregations