Android Open Source - android-weather-demo-application Date Display View






From Project

Back to project page android-weather-demo-application.

License

The source code is released under:

GNU General Public License

If you think the Android project android-weather-demo-application 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 org.openweathermap.view;
/*  ww w. ja va2  s.  c  o m*/
import org.openweathermap.utils.DateHelper;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ink.weather.R;

/**
 * Display the day, day of month and 3 letter month for the provided timestamp
 * @author samkirton
 */
public class DateDisplayView extends LinearLayout {
  private TextView uiDayOfWeekTextView;
  private TextView uiDayOfMonthTextView;
  private TextView uiMonthTextView;
  
  private int mPosition;
  
  public int getPosition() {
    return mPosition;
  }
  
  public DateDisplayView(Context context) {
    super(context);
    LayoutInflater layoutInflater = LayoutInflater.from(context);
    layoutInflater.inflate(R.layout.view_date_display, this, true);
    
    uiDayOfWeekTextView = (TextView)findViewById(R.id.view_date_display_day_of_week);
    uiDayOfMonthTextView = (TextView)findViewById(R.id.view_date_display_day_of_month);
    uiMonthTextView = (TextView)findViewById(R.id.view_date_display_month);
  }
  
  /**
   * Build the view based on the current timestamp
   * @param  timestamp  Determines the date values
   * @param  position  Saves a reference of the position in the ViewPager that the view relates to
   */
  public void init(long timestamp, int position) {
    mPosition = position;
    String dayOfWeek = DateHelper.getDayOfWeek(timestamp);
    String dayOfMonth = DateHelper.getDayOfMonth(timestamp);
    String month = DateHelper.getMonth(timestamp);
    
    uiDayOfWeekTextView.setText(dayOfWeek);
    uiDayOfMonthTextView.setText(dayOfMonth);
    uiMonthTextView.setText(month);
  }
  
  /**
   * Set a background highlight
   */
  public void selected() {
    this.setBackgroundColor(getResources().getColor(R.color.view_date_display_background));
    uiDayOfWeekTextView.setTextColor(getResources().getColor(R.color.view_date_display_select_foreground));
    uiDayOfMonthTextView.setTextColor(getResources().getColor(R.color.view_date_display_select_foreground));
    uiMonthTextView.setTextColor(getResources().getColor(R.color.view_date_display_select_foreground));
  }
  
  /**
   * Remove the background highlight
   */
  public void unSelected() {
    this.setBackgroundColor(Color.TRANSPARENT);
    uiDayOfWeekTextView.setTextColor(getResources().getColor(R.color.view_date_display_foreground));
    uiDayOfMonthTextView.setTextColor(getResources().getColor(R.color.view_date_display_foreground));
    uiMonthTextView.setTextColor(getResources().getColor(R.color.view_date_display_foreground));
  }
}




Java Source Code List

org.openweathermap.WeatherApplication.java
org.openweathermap.activity.MainActivity.java
org.openweathermap.activity.base.BaseActivity.java
org.openweathermap.adapter.CityAdapter.java
org.openweathermap.adapter.ForecastAdapter.java
org.openweathermap.asynctask.GetCitiesAsyncTask.java
org.openweathermap.asynctask.GetLastCityAsyncTask.java
org.openweathermap.asynctask.SaveForecastAsyncTask.java
org.openweathermap.asynctask.SearchCitiesAsyncTask.java
org.openweathermap.asynctask.base.BaseAsyncTask.java
org.openweathermap.asynctask.base.BaseResponse.java
org.openweathermap.asynctask.base.IParam.java
org.openweathermap.asynctask.param.SaveForecastParam.java
org.openweathermap.asynctask.param.SearchCitiesParam.java
org.openweathermap.asynctask.response.GetCitiesResponse.java
org.openweathermap.asynctask.response.GetLastCityResponse.java
org.openweathermap.asynctask.response.SaveForecastResponse.java
org.openweathermap.dto.CityDTO.java
org.openweathermap.dto.CoordDTO.java
org.openweathermap.dto.DayDTO.java
org.openweathermap.dto.ResultDTO.java
org.openweathermap.dto.TempDTO.java
org.openweathermap.dto.WeatherDTO.java
org.openweathermap.dto.base.IDTO.java
org.openweathermap.fragment.ForecastFragment.java
org.openweathermap.fragment.ModalDialogFragment.java
org.openweathermap.fragment.SelectCountryFragment.java
org.openweathermap.sql.SQLInitProvider.java
org.openweathermap.sql.model.CityModel.java
org.openweathermap.sql.model.IconModel.java
org.openweathermap.sql.model.WeatherModel.java
org.openweathermap.utils.DateHelper.java
org.openweathermap.utils.RESTProvider.java
org.openweathermap.utils.ReflectionHelper.java
org.openweathermap.utils.ResourceHelper.java
org.openweathermap.utils.StringHelper.java
org.openweathermap.view.CityListItemView.java
org.openweathermap.view.DateDisplayView.java
org.openweathermap.view.ViewPagerFade.java
org.openweathermap.view.ViewPagerIndicatorView.java
org.openweathermap.view.WeatherDataRowView.java
org.openweathermap.volley.callback.VolleyResponseCallback.java
org.openweathermap.volley.provider.VolleyImageLoader.java
org.openweathermap.volley.provider.VolleyRequest.java