Skip to content

Commit

Permalink
Merge pull request #74 from galadril/icon-action
Browse files Browse the repository at this point in the history
Icons now show on/off statusses
  • Loading branch information
galadril committed Dec 7, 2015
2 parents 6a8c6af + f27f4f1 commit 37142c5
Show file tree
Hide file tree
Showing 36 changed files with 198 additions and 243 deletions.
85 changes: 33 additions & 52 deletions app/src/main/java/nl/hnogames/domoticz/Adapters/DevicesAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public class DevicesAdapter extends BaseAdapter implements Filterable {

public final int ID_SCENE_SWITCH = 2000;

Domoticz domoticz;
private Domoticz domoticz;
private Context context;
private ArrayList<DevicesInfo> filteredData = null;
public ArrayList<DevicesInfo> filteredData = null;
private ArrayList<DevicesInfo> data = null;
private switchesClickListener listener;
private int layoutResourceId;
Expand Down Expand Up @@ -87,6 +87,7 @@ public int compare(DevicesInfo left, DevicesInfo right) {
this.listener = listener;
}


@Override
public int getCount() {
return filteredData.size();
Expand Down Expand Up @@ -137,8 +138,7 @@ private View setSwitchRowId(DevicesInfo mExtendedStatusInfo, ViewHolder holder)
row = setDefaultRowId(holder);
break;
}
}
else {
} else {
boolean switchFound = true;
switch (mExtendedStatusInfo.getSwitchTypeVal()) {
case Domoticz.Device.Type.Value.ON_OFF:
Expand Down Expand Up @@ -171,7 +171,7 @@ private View setSwitchRowId(DevicesInfo mExtendedStatusInfo, ViewHolder holder)
break;

default:
switchFound=false;
switchFound = false;
break;
}
}
Expand Down Expand Up @@ -329,8 +329,7 @@ private void setSwitchRowData(DevicesInfo mExtendedStatusInfo,
setDefaultRowData(mExtendedStatusInfo, holder);
break;
}
}
else
} else
switch (mExtendedStatusInfo.getSwitchTypeVal()) {
case Domoticz.Device.Type.Value.ON_OFF:
case Domoticz.Device.Type.Value.MEDIAPLAYER:
Expand Down Expand Up @@ -383,20 +382,16 @@ private void setDefaultRowData(DevicesInfo mExtendedStatusInfo,
if (holder.switch_battery_level != null)
holder.switch_battery_level.setText(text);


Picasso.with(context).load(domoticz.getDrawableIcon(mExtendedStatusInfo.getTypeImg(), mExtendedStatusInfo.getSwitchType(), mExtendedStatusInfo.getStatusBoolean())).into(holder.iconRow);
if(!mExtendedStatusInfo.getStatusBoolean())
holder.iconRow.setAlpha(0.5f);
else
holder.iconRow.setAlpha(1f);
if(!mExtendedStatusInfo.getStatusBoolean())
holder.iconRow.setAlpha(1f);
if (!mExtendedStatusInfo.getStatusBoolean())
holder.iconRow.setAlpha(0.5f);
else
holder.iconRow.setAlpha(1f);
}

private void setOnOffSwitchRowData(DevicesInfo mExtendedStatusInfo,
ViewHolder holder) {
private void setOnOffSwitchRowData(final DevicesInfo mExtendedStatusInfo,
final ViewHolder holder) {

holder.isProtected = mExtendedStatusInfo.isProtected();
if (holder.switch_name != null)
Expand All @@ -415,21 +410,15 @@ private void setOnOffSwitchRowData(DevicesInfo mExtendedStatusInfo,
if (holder.isProtected)
holder.onOffSwitch.setEnabled(false);



Picasso.with(context).load(domoticz.getDrawableIcon(mExtendedStatusInfo.getTypeImg(), mExtendedStatusInfo.getSwitchType(), mExtendedStatusInfo.getStatusBoolean())).into(holder.iconRow);
if(!mExtendedStatusInfo.getStatusBoolean())
holder.iconRow.setAlpha(0.5f);
else
holder.iconRow.setAlpha(1f);
if(!mExtendedStatusInfo.getStatusBoolean())
if (!mExtendedStatusInfo.getStatusBoolean())
holder.iconRow.setAlpha(0.5f);
else
holder.iconRow.setAlpha(1f);

if (holder.onOffSwitch != null) {
if(mExtendedStatusInfo.getType().equals(Domoticz.Scene.Type.GROUP) || mExtendedStatusInfo.getType().equals(Domoticz.Scene.Type.SCENE))
holder.onOffSwitch.setId(mExtendedStatusInfo.getIdx()+this.ID_SCENE_SWITCH);
if (mExtendedStatusInfo.getType().equals(Domoticz.Scene.Type.GROUP) || mExtendedStatusInfo.getType().equals(Domoticz.Scene.Type.SCENE))
holder.onOffSwitch.setId(mExtendedStatusInfo.getIdx() + this.ID_SCENE_SWITCH);
else
holder.onOffSwitch.setId(mExtendedStatusInfo.getIdx());

Expand All @@ -438,13 +427,18 @@ private void setOnOffSwitchRowData(DevicesInfo mExtendedStatusInfo,
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
handleOnOffSwitchClick(compoundButton.getId(), checked);
mExtendedStatusInfo.setStatusBoolean(checked);
if (!checked)
holder.iconRow.setAlpha(0.5f);
else
holder.iconRow.setAlpha(1f);
}
});
}

if (holder.buttonLog != null) {
if(mExtendedStatusInfo.getType().equals(Domoticz.Scene.Type.GROUP) || mExtendedStatusInfo.getType().equals(Domoticz.Scene.Type.SCENE))
holder.buttonLog.setId(mExtendedStatusInfo.getIdx()+this.ID_SCENE_SWITCH);
if (mExtendedStatusInfo.getType().equals(Domoticz.Scene.Type.GROUP) || mExtendedStatusInfo.getType().equals(Domoticz.Scene.Type.SCENE))
holder.buttonLog.setId(mExtendedStatusInfo.getIdx() + this.ID_SCENE_SWITCH);
else
holder.buttonLog.setId(mExtendedStatusInfo.getIdx());

Expand Down Expand Up @@ -475,20 +469,14 @@ private void setPushOnOffSwitchRowData(DevicesInfo mExtendedStatusInfo, ViewHold
if (holder.isProtected)
holder.buttonOn.setEnabled(false);



Picasso.with(context).load(domoticz.getDrawableIcon(mExtendedStatusInfo.getTypeImg(), mExtendedStatusInfo.getSwitchType(), mExtendedStatusInfo.getStatusBoolean())).into(holder.iconRow);
if(!mExtendedStatusInfo.getStatusBoolean())
holder.iconRow.setAlpha(0.5f);
else
holder.iconRow.setAlpha(1f);
if(!mExtendedStatusInfo.getStatusBoolean())
if (!mExtendedStatusInfo.getStatusBoolean())
holder.iconRow.setAlpha(0.5f);
else
holder.iconRow.setAlpha(1f);

if(mExtendedStatusInfo.getType().equals(Domoticz.Scene.Type.GROUP) || mExtendedStatusInfo.getType().equals(Domoticz.Scene.Type.SCENE))
holder.buttonOn.setId(mExtendedStatusInfo.getIdx()+this.ID_SCENE_SWITCH);
if (mExtendedStatusInfo.getType().equals(Domoticz.Scene.Type.GROUP) || mExtendedStatusInfo.getType().equals(Domoticz.Scene.Type.SCENE))
holder.buttonOn.setId(mExtendedStatusInfo.getIdx() + this.ID_SCENE_SWITCH);
else
holder.buttonOn.setId(mExtendedStatusInfo.getIdx());

Expand All @@ -512,8 +500,8 @@ public void onClick(View v) {
});

if (holder.buttonLog != null) {
if(mExtendedStatusInfo.getType().equals(Domoticz.Scene.Type.GROUP) || mExtendedStatusInfo.getType().equals(Domoticz.Scene.Type.SCENE))
holder.buttonLog.setId(mExtendedStatusInfo.getIdx()+this.ID_SCENE_SWITCH);
if (mExtendedStatusInfo.getType().equals(Domoticz.Scene.Type.GROUP) || mExtendedStatusInfo.getType().equals(Domoticz.Scene.Type.SCENE))
holder.buttonLog.setId(mExtendedStatusInfo.getIdx() + this.ID_SCENE_SWITCH);
else
holder.buttonLog.setId(mExtendedStatusInfo.getIdx());

Expand Down Expand Up @@ -548,7 +536,6 @@ private void setBlindsRowData(DevicesInfo mExtendedStatusInfo,
if (holder.switch_battery_level != null)
holder.switch_battery_level.setText(text);


if (holder.isProtected) holder.buttonUp.setEnabled(false);
holder.buttonUp.setId(mExtendedStatusInfo.getIdx());
holder.buttonUp.setOnClickListener(new View.OnClickListener() {
Expand All @@ -567,14 +554,8 @@ public void onClick(View view) {
}
});



Picasso.with(context).load(domoticz.getDrawableIcon(mExtendedStatusInfo.getTypeImg(), mExtendedStatusInfo.getSwitchType(), mExtendedStatusInfo.getStatusBoolean())).into(holder.iconRow);
if(!mExtendedStatusInfo.getStatusBoolean())
holder.iconRow.setAlpha(0.5f);
else
holder.iconRow.setAlpha(1f);
if(!mExtendedStatusInfo.getStatusBoolean())
if (!mExtendedStatusInfo.getStatusBoolean())
holder.iconRow.setAlpha(0.5f);
else
holder.iconRow.setAlpha(1f);
Expand Down Expand Up @@ -612,15 +593,12 @@ private void setDimmerRowData(final DevicesInfo mExtendedStatusInfo,
mExtendedStatusInfo.getMaxDimLevel(), mExtendedStatusInfo.getLevel());
holder.switch_dimmer_level.setText(percentage);

Picasso.with(context).load(domoticz.getDrawableIcon(mExtendedStatusInfo.getTypeImg(), mExtendedStatusInfo.getSwitchType(), mExtendedStatusInfo.getStatusBoolean())).into(holder.iconRow);
if(!mExtendedStatusInfo.getStatusBoolean())
holder.iconRow.setAlpha(0.5f);
else
holder.iconRow.setAlpha(1f);
if(!mExtendedStatusInfo.getStatusBoolean())
Picasso.with(context).load(domoticz.getDrawableIcon(mExtendedStatusInfo.getTypeImg(), mExtendedStatusInfo.getSubType(), mExtendedStatusInfo.getStatusBoolean())).into(holder.iconRow);
if (!mExtendedStatusInfo.getStatusBoolean())
holder.iconRow.setAlpha(0.5f);
else
holder.iconRow.setAlpha(1f);

holder.dimmerOnOffSwitch.setId(mExtendedStatusInfo.getIdx());

if (holder.isProtected)
Expand All @@ -639,6 +617,10 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
holder.switch_dimmer_level.setVisibility(View.GONE);
holder.dimmer.setVisibility(View.GONE);
}
if (!checked)
holder.iconRow.setAlpha(0.5f);
else
holder.iconRow.setAlpha(1f);
}
});

Expand Down Expand Up @@ -674,7 +656,6 @@ public void onStopTrackingTouch(SeekBar seekBar) {
}
});


if (!mExtendedStatusInfo.getStatusBoolean()) {
holder.switch_dimmer_level.setVisibility(View.GONE);
holder.dimmer.setVisibility(View.GONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public class EventsAdapter extends BaseAdapter implements Filterable {

private static final String TAG = EventsAdapter.class.getSimpleName();
private final EventsClickListener listener;
Context context;
ArrayList<EventInfo> filteredData = null;
ArrayList<EventInfo> data = null;
Domoticz domoticz;
public Context context;
private ArrayList<EventInfo> filteredData = null;
private ArrayList<EventInfo> data = null;
private Domoticz domoticz;
private ItemFilter mFilter = new ItemFilter();

public EventsAdapter(Context context,
Expand All @@ -70,6 +70,7 @@ public EventsAdapter(Context context,
this.listener = listener;
}


@Override
public int getCount() {
return filteredData.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class LocationAdapter extends BaseAdapter {

private static final String TAG = LocationAdapter.class.getSimpleName();
public ArrayList<LocationInfo> data = null;
Context context;
private Context context;
private SharedPrefUtil prefs;

private LocationClickListener listener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public LogAdapter(Context context,
this.filteredData = data;
}


@Override
public int getCount() {
return filteredData.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ public class SceneAdapter extends BaseAdapter implements Filterable {
private static final String TAG = SceneAdapter.class.getSimpleName();

private final ScenesClickListener listener;
Context context;
ArrayList<SceneInfo> filteredData = null;
ArrayList<SceneInfo> data = null;
Domoticz domoticz;
private Context context;
public ArrayList<SceneInfo> filteredData = null;
private ArrayList<SceneInfo> data = null;
private Domoticz domoticz;

ItemFilter mFilter = new ItemFilter();
private ItemFilter mFilter = new ItemFilter();

public SceneAdapter(Context context,
ArrayList<SceneInfo> data,
Expand All @@ -79,6 +79,7 @@ public int compare(SceneInfo left, SceneInfo right) {
this.listener = listener;
}


@Override
public int getCount() {
return filteredData.size();
Expand Down Expand Up @@ -173,7 +174,7 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
}

Picasso.with(context).load(domoticz.getDrawableIcon(Domoticz.Scene.Type.GROUP.toLowerCase(), "", mSceneInfo.getStatusInBoolean())).into(holder.iconRow);
if(!mSceneInfo.getStatusInBoolean())
if (!mSceneInfo.getStatusInBoolean())
holder.iconRow.setAlpha(0.5f);
else
holder.iconRow.setAlpha(1f);
Expand Down
Loading

0 comments on commit 37142c5

Please sign in to comment.