diff --git a/.idea/misc.xml b/.idea/misc.xml index 635999d..ba7052b 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -24,7 +24,7 @@ - + diff --git a/app/src/main/java/com/example/rhenigan/stormy/UI/DailyForecastActivity.java b/app/src/main/java/com/example/rhenigan/stormy/UI/DailyForecastActivity.java index 1165cfd..f1e4c63 100644 --- a/app/src/main/java/com/example/rhenigan/stormy/UI/DailyForecastActivity.java +++ b/app/src/main/java/com/example/rhenigan/stormy/UI/DailyForecastActivity.java @@ -6,6 +6,7 @@ import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.view.View; import com.example.rhenigan.stormy.R; import com.example.rhenigan.stormy.adapters.DayAdapter; @@ -33,7 +34,7 @@ protected void onCreate(Bundle savedInstanceState) { Parcelable[] parcelables = intent.getParcelableArrayExtra(MainActivity.DAILY_FORECAST); mDays = Arrays.copyOf(parcelables, parcelables.length, Day[].class); - DayAdapter adapter = new DayAdapter(mDays); + DayAdapter adapter = new DayAdapter(this, mDays); mRecyclerView.setAdapter(adapter); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this); diff --git a/app/src/main/java/com/example/rhenigan/stormy/UI/HourlyForecastActivity.java b/app/src/main/java/com/example/rhenigan/stormy/UI/HourlyForecastActivity.java index af6a182..d707b8a 100644 --- a/app/src/main/java/com/example/rhenigan/stormy/UI/HourlyForecastActivity.java +++ b/app/src/main/java/com/example/rhenigan/stormy/UI/HourlyForecastActivity.java @@ -34,7 +34,7 @@ protected void onCreate(Bundle savedInstanceState) { Parcelable[] parcelables = intent.getParcelableArrayExtra(MainActivity.HOURLY_FORECAST); mHours = Arrays.copyOf(parcelables, parcelables.length, Hour[].class); - HourAdapter adapter = new HourAdapter(mHours); + HourAdapter adapter = new HourAdapter(this, mHours); mRecyclerView.setAdapter(adapter); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this); diff --git a/app/src/main/java/com/example/rhenigan/stormy/adapters/DayAdapter.java b/app/src/main/java/com/example/rhenigan/stormy/adapters/DayAdapter.java index c26fe98..28e23c1 100644 --- a/app/src/main/java/com/example/rhenigan/stormy/adapters/DayAdapter.java +++ b/app/src/main/java/com/example/rhenigan/stormy/adapters/DayAdapter.java @@ -1,11 +1,13 @@ package com.example.rhenigan.stormy.adapters; +import android.content.Context; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; +import android.widget.Toast; import com.example.rhenigan.stormy.R; import com.example.rhenigan.stormy.weather.Day; @@ -17,12 +19,14 @@ public class DayAdapter extends RecyclerView.Adapter { private Day[] mDays; + private Context mContext; - public DayAdapter(Day[] days) { + public DayAdapter(Context context, Day[] days) { mDays = days; + mContext = context; } - public class DayViewHolder extends RecyclerView.ViewHolder { + public class DayViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ public TextView mDayNameLabel; public TextView mTempLabel; @@ -37,13 +41,23 @@ public DayViewHolder(View itemView) { mTempLabel = itemView.findViewById(R.id.tempLabel); mIconImageView = itemView.findViewById(R.id.iconImageView); mCircleImageView = itemView.findViewById(R.id.circleImageView); + + itemView.setOnClickListener(this); } public void bindDay(Day day) { mDayNameLabel.setText(day.getDay()); mTempLabel.setText(day.getTempMax() + ""); mIconImageView.setImageResource(day.getIconId()); - mCircleImageView.setImageResource(R.drawable.clear_day); + mCircleImageView.setImageResource(R.drawable.bg_temperature); + } + + @Override + public void onClick(View view) { + String Day = (String) mDayNameLabel.getText(); + String Temp = (String) mTempLabel.getText(); + String message = String.format("On %s it will be %s", Day, Temp); + Toast.makeText(mContext, message, Toast.LENGTH_LONG).show(); } } diff --git a/app/src/main/java/com/example/rhenigan/stormy/adapters/HourAdapter.java b/app/src/main/java/com/example/rhenigan/stormy/adapters/HourAdapter.java index a61ea58..c206d29 100644 --- a/app/src/main/java/com/example/rhenigan/stormy/adapters/HourAdapter.java +++ b/app/src/main/java/com/example/rhenigan/stormy/adapters/HourAdapter.java @@ -1,11 +1,13 @@ package com.example.rhenigan.stormy.adapters; +import android.content.Context; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; +import android.widget.Toast; import com.example.rhenigan.stormy.R; import com.example.rhenigan.stormy.weather.Hour; @@ -17,12 +19,14 @@ public class HourAdapter extends RecyclerView.Adapter { private Hour[] mHours; + private Context mContext; - public HourAdapter(Hour[] hours) { + public HourAdapter(Context context, Hour[] hours) { mHours = hours; + mContext = context; } - public class HourViewHolder extends RecyclerView.ViewHolder { + public class HourViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView mTimeLabel; public TextView mSummaryLabel; @@ -36,6 +40,8 @@ public HourViewHolder(View itemView) { mSummaryLabel = itemView.findViewById(R.id.summaryLabel); mTempLabel = itemView.findViewById(R.id.tempLabel); mIconImageView = itemView.findViewById(R.id.iconImageView); + + itemView.setOnClickListener(this); } public void bindHour(Hour hour) { @@ -44,6 +50,15 @@ public void bindHour(Hour hour) { mTempLabel.setText(hour.getTemp() + ""); mIconImageView.setImageResource(hour.getIconId()); } + + @Override + public void onClick(View view) { + String Time = (String) mTimeLabel.getText(); + String Temp = (String) mTempLabel.getText(); + String Summary = (String) mSummaryLabel.getText(); + String message = String.format("At %s it will be %s and %s", Time, Temp, Summary); + Toast.makeText(mContext, message, Toast.LENGTH_LONG).show(); + } } @Override diff --git a/app/src/main/java/com/example/rhenigan/stormy/weather/Day.java b/app/src/main/java/com/example/rhenigan/stormy/weather/Day.java index e7b08f6..63d1cc4 100644 --- a/app/src/main/java/com/example/rhenigan/stormy/weather/Day.java +++ b/app/src/main/java/com/example/rhenigan/stormy/weather/Day.java @@ -66,7 +66,7 @@ public int getIconId() { } public String getDay() { - SimpleDateFormat formatter = new SimpleDateFormat("E"); + SimpleDateFormat formatter = new SimpleDateFormat("EEEE"); Date date = new Date(mTime*1000); return formatter.format(date); }