Skip to content

Commit

Permalink
Fixed Temp icon on Daily
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Henigan committed Apr 18, 2018
1 parent 7511f78 commit 45eb82f
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,12 +19,14 @@
public class DayAdapter extends RecyclerView.Adapter<DayAdapter.DayViewHolder> {

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;
Expand All @@ -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();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,12 +19,14 @@
public class HourAdapter extends RecyclerView.Adapter<HourAdapter.HourViewHolder> {

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;
Expand All @@ -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) {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 45eb82f

Please sign in to comment.