Search in sources :

Example 1 with EvenementCommunaute

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;
}
Also used : Response(okhttp3.Response) EvenementCommunauteList(ca.etsmtl.applets.etsmobile.model.applets_events.EvenementCommunauteList) EvenementCommunaute(ca.etsmtl.applets.etsmobile.model.applets_events.EvenementCommunaute) OkHttpClient(okhttp3.OkHttpClient) Request(okhttp3.Request) SpringAndroidSpiceRequest(com.octo.android.robospice.request.springandroid.SpringAndroidSpiceRequest) Gson(com.google.gson.Gson)

Example 2 with EvenementCommunaute

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;
}
Also used : EvenementCommunaute(ca.etsmtl.applets.etsmobile.model.applets_events.EvenementCommunaute) LayoutInflater(android.view.LayoutInflater) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTime(org.joda.time.DateTime)

Example 3 with EvenementCommunaute

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;
}
Also used : CircleButton(at.markushi.ui.CircleButton) EvenementCommunaute(ca.etsmtl.applets.etsmobile.model.applets_events.EvenementCommunaute) CircleButton(at.markushi.ui.CircleButton) Button(android.widget.Button) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) Intent(android.content.Intent) ImageView(android.widget.ImageView) AnimatedExpandableListView(ca.etsmtl.applets.etsmobile.views.AnimatedExpandableListView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

EvenementCommunaute (ca.etsmtl.applets.etsmobile.model.applets_events.EvenementCommunaute)3 LayoutInflater (android.view.LayoutInflater)2 Intent (android.content.Intent)1 View (android.view.View)1 Button (android.widget.Button)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 CircleButton (at.markushi.ui.CircleButton)1 EvenementCommunauteList (ca.etsmtl.applets.etsmobile.model.applets_events.EvenementCommunauteList)1 AnimatedExpandableListView (ca.etsmtl.applets.etsmobile.views.AnimatedExpandableListView)1 Gson (com.google.gson.Gson)1 SpringAndroidSpiceRequest (com.octo.android.robospice.request.springandroid.SpringAndroidSpiceRequest)1 OkHttpClient (okhttp3.OkHttpClient)1 Request (okhttp3.Request)1 Response (okhttp3.Response)1 DateTime (org.joda.time.DateTime)1 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)1