Android Open Source - TuentiTV Agenda






From Project

Back to project page TuentiTV.

License

The source code is released under:

Apache License

If you think the Android project TuentiTV listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright (C) 2014 Pedro Vicente Gmez Snchez.
 */*from w ww  .j  av  a 2  s .  co m*/
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.pedrovgs.tuentitv.model;

import java.util.LinkedList;
import java.util.List;
import javax.inject.Inject;

/**
 * Main class related to contacts feature. This class contains the responsibility to return user
 * logged contacts and favorite contacts. It also perform contact searches by name. All the data
 * this class returns is mocked for this sample.
 *
 * @author Pedro Vicente Gmez Snchez.
 */
public class Agenda {

  private final List<Contact> contacts;
  private final List<Contact> favoriteContacts;

  @Inject public Agenda() {
    contacts = new LinkedList<Contact>();
    favoriteContacts = new LinkedList<Contact>();
    loadContacts();
    loadFavoriteContacts();
  }

  /**
   * @return every contact associated to the user logged sorted by name.
   */
  public List<Contact> getContacts() {
    return contacts;
  }

  /**
   * @return contacts marked by the logged user as favorite contacts. Returns this information
   * sorted by name.
   */
  public List<Contact> getFavorites() {
    return favoriteContacts;
  }

  /**
   * @return a list of contacts that matches with a name passed as parameter.
   */
  public List<Contact> getContactsWithName(String name) {
    List<Contact> searchResult = new LinkedList<Contact>();
    for (Contact contact : contacts) {
      String contactName = contact.getName().toLowerCase();
      if (contactName.contains(name)) {
        searchResult.add(contact);
      }
    }
    return searchResult;
  }

  /**
   * @return a Contact that matches with the id passed as parameter.
   */
  public Contact getContactById(String id) {
    Contact contactWithId = null;
    for (Contact contact : contacts) {
      if (id.equals(contact.getId())) {
        contactWithId = contact;
        break;
      }
    }
    return contactWithId;
  }

  private void loadContacts() {
    contacts.add(new Contact("Aarn", "https://imrl.tuenti.net/MexmzwOwyK_qaPXpAA",
        "https://imrl.tuenti.net/MeuEFQOwyK9ZMUl8AA"));
    contacts.add(new Contact("Andu Fratu", "https://imrl.tuenti.net/MewKTgRZKByd5oZ9AA",
        "https://imrl.tuenti.net/Mex2FgRZKBxFZQWKAA"));
    contacts.add(new Contact("Blanca Daz", "https://imrl.tuenti.net/MexmsQOUyDnTABlnAA",
        "https://imrl.tuenti.net/Mer_-gRUXxq_3yZqAA"));
    contacts.add(new Contact("Carmen Barroso", "https://imrl.tuenti.net/MexNAAOXqRoOXZcYAA",
        "https://imrl.tuenti.net/MepPIQS-zo5ircngAA"));
    contacts.add(new Contact("Carlos Perez", "https://imrl.tuenti.net/ILQtUgOLW18w1mHaAA",
        "https://imrl.tuenti.net/MeOI0gOLW19UOvNpAA"));
    contacts.add(new Contact("Cesar Estbanez", "https://imrl.tuenti.net/MeqsBwSymhO82EB9AA",
        "https://imrl.tuenti.net/MeoZRgOOOk3wInOMAA"));
    contacts.add(new Contact("Diana Hernndez", "https://imrl.tuenti.net/MeUzdwP0dhA6dQhWAA",
        "https://imrl.tuenti.net/MehaCQP0dhAyjmn_AA"));
    contacts.add(new Contact("Eduardo Ramirez", "https://imrl.tuenti.net/Mef8vgRt9SHKr5U0AA",
        "https://imrl.tuenti.net/MelqgQS-zo7D2jUkAA"));
    contacts.add(new Contact("Eduardo Gonzalez", "https://imrl.tuenti.net/MeHopQQgmSi7GQGdAA",
        "https://imrl.tuenti.net/MeoZRAOOOk07kA8MAA"));
    contacts.add(new Contact("Fina Perez", "https://imrl.tuenti.net/Mev9lAPPtkUlXKrgAA",
        "https://imrl.tuenti.net/Me4jFwTDI0SJxk1fAA"));
    contacts.add(new Contact("Fernando Cejas", "https://imrl.tuenti.net/MeyKggSu6c3B22wiAA",
        "https://imrl.tuenti.net/Meo-kQTBiDZBKnC9AA"));
    contacts.add(new Contact("Ivn Mosquera", "https://imrl.tuenti.net/Mek7iQPYc565Wkj7AA",
        "https://imrl.tuenti.net/MepPAQS-zo6Lc9gnAA"));
    contacts.add(new Contact("Joaquin Engelmo", "https://imrl.tuenti.net/MeqNvwQ3IFNBDGnUAA",
        "https://imrl.tuenti.net/MexxswOZ9UAkEFn6AA"));
    contacts.add(new Contact("Juanjo Torroglosa", "https://imrl.tuenti.net/IMwzMQOv3yxSsLLxAA",
        "https://imrl.tuenti.net/Mevl_gS9EGaDmKQ7AA"));
    contacts.add(new Contact("Laura Rus", "https://imrl.tuenti.net/MefvswOREWiM7ehEAA",
        "https://imrl.tuenti.net/MeOW2gOREWgfCrI-AA"));
    contacts.add(new Contact("Manolo Vera", "https://imrl.tuenti.net/MeskMwOsS3aHCO-fAA",
        "https://imrl.tuenti.net/MehZuwOTKRmei3V-AA"));
    contacts.add(new Contact("Sebas Muriel", "https://imrl.tuenti.net/CZ-M0wOhf0IbHVN2AA",
        "https://imrl.tuenti.net/MePi1gOhf0LH0aG8AA"));
    contacts.add(new Contact("Vctor Corugedo", "https://imrl.tuenti.net/MczWnAPlHhALIiljAA",
        "https://imrl.tuenti.net/MejiHgP0dhCo4kjrAA"));
  }

  private void loadFavoriteContacts() {
    favoriteContacts.add(new Contact("Fina Perez", "https://imrl.tuenti.net/Mev9lAPPtkUlXKrgAA",
        "https://imrl.tuenti.net/Me4jFwTDI0SJxk1fAA"));
    favoriteContacts.add(
        new Contact("Joaquin Engelmo", "https://imrl.tuenti.net/MeqNvwQ3IFNBDGnUAA",
            "https://imrl.tuenti.net/MejJ5wRt9SGPKzF-AA"));
    favoriteContacts.add(new Contact("Laura Rus", "https://imrl.tuenti.net/MefvswOREWiM7ehEAA",
        "https://imrl.tuenti.net/MeOW2gOREWgfCrI-AA"));
    favoriteContacts.add(
        new Contact("Juanjo Torroglosa", "https://imrl.tuenti.net/IMwzMQOv3yxSsLLxAA",
            "https://imrl.tuenti.net/Mevl_gS9EGaDmKQ7AA"));
    favoriteContacts.add(
        new Contact("Vctor Corugedo", "https://imrl.tuenti.net/MczWnAPlHhALIiljAA",
            "https://imrl.tuenti.net/MejiHgP0dhCo4kjrAA"));
    favoriteContacts.add(new Contact("Ivn Mosquera", "https://imrl.tuenti.net/Mek7iQPYc565Wkj7AA",
        "https://imrl.tuenti.net/MepPAQS-zo6Lc9gnAA"));
    favoriteContacts.add(new Contact("Carmen Barroso", "https://imrl.tuenti.net/MexNAAOXqRoOXZcYAA",
        "https://imrl.tuenti.net/MepPIQS-zo5ircngAA"));
  }
}




Java Source Code List

com.github.pedrovgs.tuentitv.TuentiTvApplication.java
com.github.pedrovgs.tuentitv.di.ActivityContext.java
com.github.pedrovgs.tuentitv.di.ActivityModule.java
com.github.pedrovgs.tuentitv.di.ApplicationContext.java
com.github.pedrovgs.tuentitv.di.RootModule.java
com.github.pedrovgs.tuentitv.di.TuentiTvApplicationModule.java
com.github.pedrovgs.tuentitv.model.Account.java
com.github.pedrovgs.tuentitv.model.Accounts.java
com.github.pedrovgs.tuentitv.model.Agenda.java
com.github.pedrovgs.tuentitv.model.Chat.java
com.github.pedrovgs.tuentitv.model.Contact.java
com.github.pedrovgs.tuentitv.model.ConversationSummary.java
com.github.pedrovgs.tuentitv.model.MediaElement.java
com.github.pedrovgs.tuentitv.model.MediaGallery.java
com.github.pedrovgs.tuentitv.presenter.DetailPresenter.java
com.github.pedrovgs.tuentitv.presenter.EnterPasswordPresenter.java
com.github.pedrovgs.tuentitv.presenter.LoginPresenter.java
com.github.pedrovgs.tuentitv.presenter.MainPresenter.java
com.github.pedrovgs.tuentitv.presenter.SearchPresenter.java
com.github.pedrovgs.tuentitv.recommendation.builder.RecommendationBuilder.java
com.github.pedrovgs.tuentitv.recommendation.service.BaseIntentService.java
com.github.pedrovgs.tuentitv.recommendation.service.RecommendationService.java
com.github.pedrovgs.tuentitv.ui.activity.BaseActivity.java
com.github.pedrovgs.tuentitv.ui.activity.DetailActivity.java
com.github.pedrovgs.tuentitv.ui.activity.EnterPasswordActivity.java
com.github.pedrovgs.tuentitv.ui.activity.LoadingActivity.java
com.github.pedrovgs.tuentitv.ui.activity.LoginActivity.java
com.github.pedrovgs.tuentitv.ui.activity.MainActivity.java
com.github.pedrovgs.tuentitv.ui.activity.SearchActivity.java
com.github.pedrovgs.tuentitv.ui.activity.ShowImageActivity.java
com.github.pedrovgs.tuentitv.ui.data.CardInfo.java
com.github.pedrovgs.tuentitv.ui.data.IconInfo.java
com.github.pedrovgs.tuentitv.ui.data.ImageInfo.java
com.github.pedrovgs.tuentitv.ui.fragment.BrowseBaseFragment.java
com.github.pedrovgs.tuentitv.ui.fragment.DetailBaseFragment.java
com.github.pedrovgs.tuentitv.ui.fragment.DetailFragment.java
com.github.pedrovgs.tuentitv.ui.fragment.MainFragment.java
com.github.pedrovgs.tuentitv.ui.fragment.SearchBaseFragment.java
com.github.pedrovgs.tuentitv.ui.fragment.SearchFragment.java
com.github.pedrovgs.tuentitv.ui.navigator.Navigator.java
com.github.pedrovgs.tuentitv.ui.picasso.PicassoBackgroundManagerTarget.java
com.github.pedrovgs.tuentitv.ui.picasso.PicassoImageCardViewTarget.java
com.github.pedrovgs.tuentitv.ui.picasso.transformation.BlurTransformation.java
com.github.pedrovgs.tuentitv.ui.picasso.transformation.CircleTransform.java
com.github.pedrovgs.tuentitv.ui.picasso.transformation.GrayScaleTransformation.java
com.github.pedrovgs.tuentitv.ui.util.Util.java
com.github.pedrovgs.tuentitv.ui.viewpresenter.CardPresenter.java
com.github.pedrovgs.tuentitv.ui.viewpresenter.DetailsDescriptionPresenter.java
com.github.pedrovgs.tuentitv.ui.viewpresenter.IconPresenter.java
com.github.pedrovgs.tuentitv.ui.viewpresenter.ImagePresenter.java