Small improvement

pull/162/head
M66B 6 years ago
parent 603ff53786
commit 3e080e0c9c

@ -659,17 +659,18 @@ public class FragmentRule extends FragmentBase {
int type = jaction.getInt("type"); int type = jaction.getInt("type");
switch (type) { switch (type) {
case EntityRule.TYPE_SNOOZE: case EntityRule.TYPE_SNOOZE:
npDuration.setValue(jaction.getInt("duration")); npDuration.setValue(jaction.optInt("duration", 0));
cbScheduleEnd.setChecked(jaction.optBoolean("schedule_end", false)); cbScheduleEnd.setChecked(jaction.optBoolean("schedule_end", false));
break; break;
case EntityRule.TYPE_FLAG: case EntityRule.TYPE_FLAG:
onSelectColor(jaction.isNull("color") ? Color.TRANSPARENT : jaction.getInt("color")); onSelectColor(jaction.isNull("color")
? Color.TRANSPARENT : jaction.optInt("color", 0));
break; break;
case EntityRule.TYPE_MOVE: case EntityRule.TYPE_MOVE:
case EntityRule.TYPE_COPY: case EntityRule.TYPE_COPY:
long target = jaction.getLong("target"); long target = jaction.optLong("target", -1);
for (int pos = 0; pos < adapterTarget.getCount(); pos++) for (int pos = 0; pos < adapterTarget.getCount(); pos++)
if (adapterTarget.getItem(pos).id.equals(target)) { if (adapterTarget.getItem(pos).id.equals(target)) {
spTarget.setSelection(pos); spTarget.setSelection(pos);
@ -682,14 +683,14 @@ public class FragmentRule extends FragmentBase {
break; break;
case EntityRule.TYPE_ANSWER: case EntityRule.TYPE_ANSWER:
long identity = jaction.getLong("identity"); long identity = jaction.optLong("identity", -1);
for (int pos = 0; pos < adapterIdentity.getCount(); pos++) for (int pos = 0; pos < adapterIdentity.getCount(); pos++)
if (adapterIdentity.getItem(pos).id.equals(identity)) { if (adapterIdentity.getItem(pos).id.equals(identity)) {
spIdent.setSelection(pos); spIdent.setSelection(pos);
break; break;
} }
long answer = jaction.getLong("answer"); long answer = jaction.optLong("answer", -1);
for (int pos = 0; pos < adapterAnswer.getCount(); pos++) for (int pos = 0; pos < adapterAnswer.getCount(); pos++)
if (adapterAnswer.getItem(pos).id.equals(answer)) { if (adapterAnswer.getItem(pos).id.equals(answer)) {
spAnswer.setSelection(pos); spAnswer.setSelection(pos);
@ -709,13 +710,13 @@ public class FragmentRule extends FragmentBase {
showActionParameters(type); showActionParameters(type);
} }
} catch (Throwable ex) {
Log.e(ex);
} finally {
grpReady.setVisibility(View.VISIBLE); grpReady.setVisibility(View.VISIBLE);
bottom_navigation.findViewById(R.id.action_delete).setVisibility(rule == null ? View.GONE : View.VISIBLE); bottom_navigation.findViewById(R.id.action_delete).setVisibility(rule == null ? View.GONE : View.VISIBLE);
bottom_navigation.setVisibility(View.VISIBLE); bottom_navigation.setVisibility(View.VISIBLE);
pbWait.setVisibility(View.GONE); pbWait.setVisibility(View.GONE);
} catch (JSONException ex) {
Log.e(ex);
} }
} }

Loading…
Cancel
Save