Android Open Source - umbrella.alert Precipitation Card






From Project

Back to project page umbrella.alert.

License

The source code is released under:

GNU General Public License

If you think the Android project umbrella.alert 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

package macbury.umbrella.cards;
//ww  w  . j a va2  s . c  o  m
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

import com.androidquery.AQuery;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import it.gmariotti.cardslib.library.internal.Card;
import it.gmariotti.cardslib.library.internal.CardHeader;
import it.gmariotti.cardslib.library.prototypes.CardWithList;
import macbury.umbrella.R;
import macbury.umbrella.model.Forecast;
import macbury.umbrella.model.RainData;

/**
 * Created by macbury on 27.08.14.
 */
public class PrecipitationCard extends CardWithList {
  private final Forecast currentForecast;

  public PrecipitationCard(Context context, Forecast currentForecast) {
    super(context);
    this.currentForecast = currentForecast;
    init();
  }

  @Override
  protected CardHeader initCardHeader() {
    CardHeader cardHeader = new CardHeader(getContext());
    cardHeader.setTitle(getContext().getString(R.string.precipitation_card_title));
    return cardHeader;
  }

  @Override
  protected void initCard() {

  }

  @Override
  protected List<ListObject> initChildren() {
    ArrayList<ListObject> objects = new ArrayList<ListObject>();

    for (RainData rd : currentForecast.getRainData()) {
      PrecipitationListObject listObject = new PrecipitationListObject(this, rd);
      objects.add(listObject);
    }

    return objects;
  }

  @Override
  public View setupChildView(int i, ListObject listObject, View view, ViewGroup viewGroup) {
    AQuery query                  = new AQuery(view);
    PrecipitationListObject item  = (PrecipitationListObject)listObject;
    SimpleDateFormat format       = new SimpleDateFormat("hh:mm a");
    query.id(R.id.timeTextView).text(format.format(item.data.getAt()));
    query.id(R.id.humidityTextView).text("Humidity: "+ item.data.getHumidity()+" %");

    if (item.data.isRaining()) {
      query.id(R.id.weatherImageView).image(R.drawable.status_raining);
    } else {
      query.id(R.id.weatherImageView).image(R.drawable.status_sun);
    }

    return view;
  }

  @Override
  public int getChildLayoutId() {
    return R.layout.card_precipitation_list_view;
  }

  public class PrecipitationListObject extends DefaultListObject {
    private final RainData data;

    public PrecipitationListObject(Card parentCard, RainData data) {
      super(parentCard);
      this.data = data;
    }
  }
}




Java Source Code List

macbury.umbrella.ApplicationTest.java
macbury.umbrella.ForecastTest.java
macbury.umbrella.UmbrellaApplication.java
macbury.umbrella.activity.ForecastActivity.java
macbury.umbrella.activity.SettingsActivity.java
macbury.umbrella.cards.AboutCard.java
macbury.umbrella.cards.CityCard.java
macbury.umbrella.cards.PrecipitationCard.java
macbury.umbrella.factories.WeatherForecastFactory.java
macbury.umbrella.fragments.ForecastFragment.java
macbury.umbrella.fragments.LoadingFragment.java
macbury.umbrella.fragments.SettingsFragment.java
macbury.umbrella.managers.AlarmsManager.java
macbury.umbrella.managers.IntentsManager.java
macbury.umbrella.managers.NotificationsManager.java
macbury.umbrella.managers.ServicesManager.java
macbury.umbrella.managers.StoreManager.java
macbury.umbrella.model.Forecast.java
macbury.umbrella.model.RainData.java
macbury.umbrella.providers.ForecastProviderError.java
macbury.umbrella.providers.ForecastProviderListener.java
macbury.umbrella.providers.ForecastProvider.java
macbury.umbrella.receiver.CheckWeatherReceiver.java
macbury.umbrella.receiver.DissmisedTakeUmbrellaNotificationReceiver.java
macbury.umbrella.receiver.SyncStatusBroadcastReceiver.java
macbury.umbrella.service.CheckWeatherService.java