Skip to content

Commit

Permalink
Merge pull request #116 in MOB/climate-android from ~KBAYGAN/climate-…
Browse files Browse the repository at this point in the history
…android:workspace to master

Squashed commit of the following:

commit 6a9e6cd168518223deca02f26638f3d1152a6d23
Author: Kaz Baygan <kazb@baygan.com>
Date:   Tue Jan 27 18:43:52 2015 -0800

    removed workability from forecast

commit 8073b10aff75c1899705d88ea54a0d24b5c168d1
Author: Kaz Baygan <kazb@baygan.com>
Date:   Tue Jan 27 14:31:45 2015 -0800

    Basic-541 - Android: Replace workability with windspeed and direction on the field card
  • Loading branch information
Kaz Baygan committed Jan 29, 2015
1 parent 8a23b54 commit e3f36c2
Show file tree
Hide file tree
Showing 18 changed files with 124 additions and 166 deletions.
4 changes: 2 additions & 2 deletions ClimateGrowersProject/ClimateGrowersApp/ClimateGrowersApp.iml
Expand Up @@ -90,11 +90,11 @@
<orderEntry type="library" exported="" name="library-1.2.3" level="project" />
<orderEntry type="library" exported="" name="okhttp-2.0.0" level="project" />
<orderEntry type="library" exported="" name="httpclient-android-4.3.3" level="project" />
<orderEntry type="library" exported="" name="notifications-android-1.3.8" level="project" />
<orderEntry type="library" exported="" name="okio-1.0.0" level="project" />
<orderEntry type="library" exported="" name="notifications-android-1.3.7" level="project" />
<orderEntry type="library" exported="" name="library-0.9.9" level="project" />
<orderEntry type="library" exported="" name="lolay-investigo-10" level="project" />
<orderEntry type="library" exported="" name="eventbus-2.2.1" level="project" />
<orderEntry type="library" exported="" name="eventbus-2.4.0" level="project" />
<orderEntry type="library" exported="" name="httpclientandroidlib-1.2.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.0" level="project" />
<orderEntry type="library" exported="" name="lolay-strands-2" level="project" />
Expand Down
2 changes: 1 addition & 1 deletion ClimateGrowersProject/ClimateGrowersApp/build.gradle
Expand Up @@ -194,7 +194,7 @@ dependencies {
//compile 'org.lucasr.twowayview:twowayview:0.1.4'
compile 'com.climate.android.notificationlib:notifications-android:1.3.8@aar'
//compile 'com.climate:notificationlib:1@aar'
compile 'de.greenrobot:eventbus:2.2.1'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.google.code.gson:gson:2.3'
compile 'com.squareup.retrofit:retrofit:1.6.1'
compile 'com.squareup.okhttp:okhttp:2.0.0'
Expand Down
Expand Up @@ -86,13 +86,6 @@ public void onBindViewHolder(Holder holder, int position) {
holder.time.setText(hour + "");
}


// WORKABILITY
int workability = forecast.getWorkability();
int iconRes = AssetUtil.getWorkabilityIcoNotchRes(this.context, workability);
if (holder.workability!=null)
holder.workability.setImageResource(iconRes);

if(holder.precip!=null)
holder.precip.setText(PrecipUtil.getFormattedPercent(this.context, forecast.getPrecipitation()));

Expand Down Expand Up @@ -144,15 +137,14 @@ public void onBindViewHolder(Holder holder, int position) {

public static class Holder extends RecyclerView.ViewHolder {
private TextView time, precip, windSpeed;
private ImageView workability, vector, precipGraph;
private ImageView vector, precipGraph;
private int viewType;

public Holder(View view, int viewType) {
super(view);
this.time = (TextView)view.findViewById(R.id.time);
this.precip = (TextView)view.findViewById(R.id.precip);
this.windSpeed = (TextView)view.findViewById(R.id.windSpeed);
this.workability = (ImageView)view.findViewById(R.id.workabilityColor);
this.vector = (ImageView)view.findViewById(R.id.vector);
this.precipGraph = (ImageView)view.findViewById(R.id.precipGraph);
this.viewType = viewType;
Expand Down
Expand Up @@ -119,6 +119,11 @@ public static FieldLazyDetails parseFieldLazyDetails(Map<String, Object> parsed)
field.setClus(CLUParser.parseCLUs(clus));
}

if (parsed.containsKey("wind")) {
Map<String, Object> w = (Map<String, Object>)parsed.get("wind");
field.setWind( WindParser.parseWind(w) );
}

return field;
}

Expand Down
Expand Up @@ -16,6 +16,7 @@ public class FieldLazyDetails extends BaseObject {
private String weatherCondition;
private LatLong centroid;
private ArrayList<CLU> clus;
private Wind wind;

public long getId() {
return id;
Expand Down Expand Up @@ -131,4 +132,12 @@ public float totalClusArea() {
}
return area;
}

public void setWind(Wind wind) {
this.wind = wind;
}

public Wind getWind() {
return wind;
}
}
Expand Up @@ -25,9 +25,9 @@

public class FieldDetailCardRenderer extends RelativeLayout {

private TextView last24Precip, last72Precip, next24Precip, fieldCondition;
private TextView last24Precip, last72Precip, next24Precip, windSpeed;
private TextView moisture, growth, fieldName, fieldLocation;
private ImageView map, workIcon;
private ImageView map, windIcon;
private DetailedField fieldDetails;
private View toggleBtn, bottomRow;

Expand All @@ -42,7 +42,6 @@ public FieldDetailCardRenderer(Context context, AttributeSet attrs, int defStyle

public void setLazyDetails(FieldLazyDetails lazyDetails, ImageViewBinder binder) {
if (lazyDetails == null) {
fieldCondition.setText("");
next24Precip.setText("");
return;
}
Expand Down Expand Up @@ -70,19 +69,24 @@ public void setLazyDetails(FieldLazyDetails lazyDetails, ImageViewBinder binder)

last24Precip.setText(PrecipUtil.getFormattedInches(getContext(),
lazyDetails.getLastTwentyFourHours()));
// last72Precip.setText(PrecipUtil.getFormattedInches(getContext(),
// lazyDetails.getPrecepLast72()));
next24Precip.setText(PrecipUtil.getFormattedPercent(getContext(),
lazyDetails.getNextTwentyFourHours()));


int work = lazyDetails.getWorkability();
fieldCondition.setText(AssetUtil.getWorkabilityLabelFromInt(getContext(),
work));
fieldCondition.setTextColor(AssetUtil.getWorkabilityLabelColorFromInt(
getContext(), work));
workIcon.setImageResource(AssetUtil.getWorkabilityIconRes(getContext(),
work));

if (lazyDetails.getWind() != null) {
windSpeed.setText(lazyDetails.getWind().getMphSpeed() + " mph");
if (lazyDetails.getWind().getMphSpeedAsFloat() > 30f) {
windIcon.setImageResource(R.drawable.ic_arrow_up_red);
} else {
windIcon.setImageResource(R.drawable.ic_arrow_up);
}
windIcon.setRotation( lazyDetails.getWind().getDegreesAsFloat() );
} else {
windSpeed.setText("");
windIcon.setVisibility(View.INVISIBLE);
}


binder.load(map, lazyDetails.getThumbnail());
}
Expand All @@ -100,13 +104,13 @@ protected void onFinishInflate() {
last24Precip = (TextView)findViewById(R.id.last24);
last72Precip = (TextView)findViewById(R.id.last72);
next24Precip = (TextView)findViewById(R.id.next24);
fieldCondition = (TextView)findViewById(R.id.condition);
windSpeed = (TextView)findViewById(R.id.windSpeed);
moisture = (TextView)findViewById(R.id.moisture);
growth = (TextView)findViewById(R.id.growth);
fieldName = (TextView)findViewById(R.id.fieldName);
fieldLocation = (TextView)findViewById(R.id.fieldLoc);
map = (ImageView)findViewById(R.id.map);
workIcon = (ImageView)findViewById(R.id.workIcon);
windIcon = (ImageView)findViewById(R.id.windIcon);
toggleBtn = findViewById(R.id.toggleBtn);
bottomRow = findViewById(R.id.row2);

Expand Down Expand Up @@ -212,13 +216,5 @@ private void bindTextLabels() {
}
growth.setText(fieldDetails.getGrowthStage());
}


fieldCondition.setText(AssetUtil.getWorkabilityLabelFromInt(getContext(),
fieldDetails.getWorkability()));
fieldCondition.setTextColor(AssetUtil.getWorkabilityLabelColorFromInt(
getContext(), fieldDetails.getWorkability()));
workIcon.setImageResource(AssetUtil.getWorkabilityIconRes(getContext(),
fieldDetails.getWorkability()));
}
}
Expand Up @@ -35,9 +35,8 @@ public static interface OnExpandListener {
}

private View header;
private TextView dayField, workabilityField, plusPrecipField, hourlyMsg;
private TextView dayField, plusPrecipField, hourlyMsg;
private TextView tMax, tMin;
private ImageView workIcon;
private String[] weekDays;
private View expandingLayout;
private TwoWayView hourlyContainer;
Expand Down Expand Up @@ -81,14 +80,13 @@ public void expand(boolean doExpand, boolean doAnimate) {
header.setSelected(true);
precipIcon.setVisibility(View.INVISIBLE);
plusPrecipField.setVisibility(View.INVISIBLE);
workIcon.setVisibility(View.INVISIBLE);
workabilityField.setVisibility(View.INVISIBLE);

tMax.setVisibility(View.INVISIBLE);
tMin.setVisibility(View.INVISIBLE);

if (animator != null && animator.isRunning()) animator.cancel();
int widthSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
int size = PxUtil.toPx(getContext(), hasHourlyData ? 160 : 30);
int size = PxUtil.toPx(getContext(), hasHourlyData ? 110 : 30);
int heightSpec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
expandingLayout.measure(widthSpec, heightSpec);

Expand All @@ -105,8 +103,7 @@ public void expand(boolean doExpand, boolean doAnimate) {
header.setSelected(false);
precipIcon.setVisibility(View.VISIBLE);
plusPrecipField.setVisibility(View.VISIBLE);
workIcon.setVisibility(View.VISIBLE);
workabilityField.setVisibility(View.VISIBLE);

tMax.setVisibility(View.VISIBLE);
tMin.setVisibility(View.VISIBLE);

Expand All @@ -131,20 +128,6 @@ public void onAnimationEnd(Animator animation) {

if (onExpandListener != null) onExpandListener.onExpand(this, doExpand);

// int from;
// int to;
// if (doExpand) {
// to = expandedColor;
// from = collapsedColor;
// } else {
// to = collapsedColor;
// from = expandedColor;
// }
//
// ObjectAnimator oa = ObjectAnimator.ofInt(header, "backgroundColor", from, to);
// oa.setEvaluator(new ArgbEvaluator());
// oa.start();

}

public void setCalendars(Calendar today, Calendar tomorrow) {
Expand Down Expand Up @@ -194,15 +177,6 @@ public void setDailyForecast(Forecast dailyForecast) {
// PRECIP
Precipitation precip = dailyForecast.getPrecipitation();
plusPrecipField.setText(PrecipUtil.getFormattedPercent(getContext(), precip));


// WORKABILITY
workabilityField.setText(AssetUtil.getWorkabilityLabelFromInt(getContext(),
dailyForecast.getWorkability()));
workabilityField.setTextColor(AssetUtil.getWorkabilityLabelColorFromInt(
getContext(), dailyForecast.getWorkability()));
workIcon.setImageResource(AssetUtil.getWorkabilityIconRes(getContext(),
dailyForecast.getWorkability()));
}

public void setHourlyForecasts(List<Forecast> forecasts, int listPosition) {
Expand Down Expand Up @@ -234,9 +208,7 @@ protected void onFinishInflate() {
header = findViewById(R.id.header);
dayField = (TextView)findViewById(R.id.dateLabel);
plusPrecipField = (TextView)findViewById(R.id.plusPrecip);
workabilityField = (TextView)findViewById(R.id.condition);
hourlyMsg = (TextView)findViewById(R.id.hourlyMsg);
workIcon = (ImageView)findViewById(R.id.workIcon);
expandingLayout = findViewById(R.id.expanding_layout);
hourlyContainer = (TwoWayView)findViewById(R.id.horizontalListView);
precipIcon = findViewById(R.id.plusPrecipIcon);
Expand Down
Expand Up @@ -22,9 +22,9 @@

public class FieldStatRenderer extends RelativeLayout {

private ImageView map, workIcon;
private ImageView map, windIcon;
private TextView fieldName, fieldLocation, degrees, weatherStatus;
private TextView minusPrecip, plusPrecip, fieldCondition;
private TextView minusPrecip, plusPrecip, windSpeed;
private View alertSym;
private Resources res;
private FieldLazyDetails field;
Expand Down Expand Up @@ -103,12 +103,19 @@ public void setData(FieldLazyDetails details, GroupViewBinder<ImageView> binder)

binder.build(map, details.getThumbnail()).load();

fieldCondition.setText(AssetUtil.getWorkabilityLabelFromInt(getContext(),
details.getWorkability()));
fieldCondition.setTextColor(AssetUtil.getWorkabilityLabelColorFromInt(
getContext(), details.getWorkability()));
workIcon.setImageResource(AssetUtil.getWorkabilityIconRes(getContext(),
details.getWorkability()));

if (details.getWind() != null) {
windSpeed.setText(details.getWind().getMphSpeed() + " mph");
if (details.getWind().getMphSpeedAsFloat() > 30f) {
windIcon.setImageResource(R.drawable.ic_arrow_up_red);
} else {
windIcon.setImageResource(R.drawable.ic_arrow_up);
}
windIcon.setRotation( details.getWind().getDegreesAsFloat() );
} else {
windSpeed.setText("");
windIcon.setVisibility(View.INVISIBLE);
}
}

@Override
Expand All @@ -118,9 +125,9 @@ protected void onFinishInflate() {
fieldLocation = (TextView)findViewById(R.id.fieldLoc);
minusPrecip = (TextView)findViewById(R.id.last24);
plusPrecip = (TextView)findViewById(R.id.next24);
fieldCondition = (TextView)findViewById(R.id.condition);
windSpeed = (TextView)findViewById(R.id.windSpeed);
map = (ImageView)findViewById(R.id.map);
workIcon = (ImageView)findViewById(R.id.workIcon);
windIcon = (ImageView)findViewById(R.id.windIcon);
alertSym = findViewById(R.id.alertSym);
}
}
Expand Up @@ -169,26 +169,6 @@ public void onItemSelected(int itemId) {
EventBus.getDefault().register(this);
}

public BitmapDrawable writeOnDrawable(int drawableId, String text){

Bitmap bm = BitmapFactory.decodeResource(getResources(), drawableId).copy(Bitmap.Config.ARGB_8888, true);

Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL_AND_STROKE);
paint.setColor(Color.WHITE);
paint.setTextSize(12);

Paint paint2 = new Paint();
paint2.setStyle(Paint.Style.FILL_AND_STROKE);
paint2.setColor(Color.RED);


Canvas canvas = new Canvas(bm);
canvas.drawCircle(16, 7, 7, paint2);
canvas.drawText(text, 12, bm.getHeight()-9, paint);

return new BitmapDrawable(getResources(), bm);
}

@Override
protected void onNewIntent(Intent intent) {
Expand Down
Expand Up @@ -32,7 +32,7 @@
android:layout_centerVertical="true"
>

<include layout="@layout/view_workability" android:visibility="invisible"/>


<FrameLayout
android:layout_width="0dp"
Expand Down
Expand Up @@ -110,7 +110,7 @@
android:gravity="bottom"
android:weightSum="2" >

<include layout="@layout/view_workability"/>
<include layout="@layout/view_wind"/>

<FrameLayout
android:layout_width="0dp"
Expand Down
Expand Up @@ -67,37 +67,9 @@
android:layout_weight="1"
/>

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>

<ImageView
android:id="@+id/workIcon"
android:layout_width="18dp"
android:layout_height="18dp"
android:src="@drawable/ic_work_good"
/>

<TextView
android:id="@+id/condition"
style="@style/TextAppearance.Card.Work"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/workIcon"
android:text="GOOD"
/>
</RelativeLayout>

<Space
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1"
/>

<RelativeLayout
<RelativeLayout
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_marginRight="7dp">
Expand Down

0 comments on commit e3f36c2

Please sign in to comment.