Skip to content

Commit

Permalink
Absence Activity
Browse files Browse the repository at this point in the history
#5
- set value dmxa at absences by ArrayString at xml resources
  • Loading branch information
eurosecom committed Jan 20, 2017
1 parent d5e1f14 commit 302488f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
29 changes: 27 additions & 2 deletions app/src/main/java/com/eusecom/attendance/NewAbsenceActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public class NewAbsenceActivity extends BaseDatabaseActivity {
protected int mPos;
protected String mSelection;
Toolbar mActionBarToolbar;
Spinner spinner;
int spinposition=0;

String dmaxx, dmnxx;
String[] AbsIdm, AbsIname;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -98,14 +103,28 @@ public void onClick(View v) {
}
});

Spinner spinner = (Spinner) findViewById(R.id.spinner01);
spinner = (Spinner) findViewById(R.id.spinner01);
this.mAdapter = ArrayAdapter.createFromResource(this, R.array.AbsenceSpinnerArray,
android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(this.mAdapter);


AdapterView.OnItemSelectedListener spinnerListener = new myOnItemSelectedListener(this,this.mAdapter);
spinner.setOnItemSelectedListener(spinnerListener);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

public void onItemSelected(AdapterView<?> parentView,
View selectedItemView, int position, long id) {
spinposition=position;

}

public void onNothingSelected(AdapterView<?> arg0) {// do nothing
}

});



CalendarView simpleCalendarView = (CalendarView) findViewById(R.id.calview); // get the reference of CalendarView
simpleCalendarView.setFocusedMonthDateColor(getResources().getColor(R.color.primary_dark)); // set yellow color for the dates of focused month
Expand Down Expand Up @@ -270,7 +289,13 @@ private void submitPost() {
final String hodinyx = hodiny.getText().toString();
final String dateodlx = dateodl.getText().toString();
final String datedolx = datedol.getText().toString();
AbsIdm = getResources().getStringArray(R.array.AbsenceSpinnerArrayIdm);
AbsIname = getResources().getStringArray(R.array.AbsenceSpinnerArrayIname);
dmaxx = "506";
dmnxx = "Holliday";

dmaxx = AbsIdm[spinposition];
dmnxx = AbsIname[spinposition];

// [START single_value_read]
final String userId = getUid();
Expand All @@ -294,7 +319,7 @@ public void onDataChange(DataSnapshot dataSnapshot) {
Long tsLong = System.currentTimeMillis() / 1000;
String ts = tsLong.toString();

writeAbsence(icox, userId, "0", "506","Holliday", dateodlx, datedolx, "0", hodinyx, "0", "0", ts);
writeAbsence(icox, userId, "0", dmaxx, dmnxx, dateodlx, datedolx, "0", hodinyx, "0", "0", ts);

}

Expand Down
17 changes: 17 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,23 @@
<string-array name="AbsenceSpinnerArray">
<item>506 Holliday</item>
<item>510 Bank holliday</item>
<item>518 Visit Doctor</item>
<item>520 Other</item>
<item>801 Illness</item>
</string-array>
<string-array name="AbsenceSpinnerArrayIdm">
<item>506</item>
<item>510</item>
<item>518</item>
<item>520</item>
<item>801</item>
</string-array>
<string-array name="AbsenceSpinnerArrayIname">
<item>Holliday</item>
<item>Bank holliday</item>
<item>Visit Doctor</item>
<item>Other</item>
<item>Illness</item>
</string-array>
<string name="select_absence">Select a absence</string>

Expand Down

0 comments on commit 302488f

Please sign in to comment.