@@ -29,52 +29,52 @@ public class EditJob extends ListActivity {
29
29
MicroJobsDatabase db ;
30
30
31
31
private class Employer {
32
- public String employerName ;
33
- public long id ;
34
- Employer ( long id , String employerName ){
35
- this .id = id ;
36
- this .employerName = employerName ;
37
- }
38
- @ Override
39
- public String toString () {
40
- return this .employerName ;
41
- }
32
+ public String employerName ;
33
+ public long id ;
34
+ Employer ( long id , String employerName ){
35
+ this .id = id ;
36
+ this .employerName = employerName ;
37
+ }
38
+ @ Override
39
+ public String toString () {
40
+ return this .employerName ;
41
+ }
42
42
}
43
43
44
44
45
45
// Create a button click listener for the Update button.
46
46
private final Button .OnClickListener btnUpdateOnClick = new Button .OnClickListener () {
47
47
@ Override
48
48
public void onClick (View v ) {
49
- Employer employer = (Employer )spnEmployer .getSelectedItem ();
50
- // Toast.makeText(
51
- // EditJob.this,
52
- // String.format(
53
- // "Job: %d\nEmployer: %s (%d)\nTitle: %s\nDesc: %s",
54
- // job_id,
55
- // employer.employerName,
56
- // employer.id,
57
- // txtTitle.getText(),
58
- // txtDescription.getText()
59
- // ),
60
- // Toast.LENGTH_SHORT
61
- // ).show();
62
- if ((txtTitle .getText ().length ()==0 ) || (txtDescription .getText ().length ()==0 )){
63
- Toast .makeText (EditJob .this , "Fill out the form completely first." , Toast .LENGTH_LONG ).show ();
64
- } else {
65
- db .editJob (job_id .longValue (), employer .id , txtTitle .getText ().toString (), txtDescription .getText ().toString ());
66
- Toast .makeText (EditJob .this , "Job updated" , Toast .LENGTH_SHORT ).show ();
67
- finish ();
68
- }
49
+ Employer employer = (Employer )spnEmployer .getSelectedItem ();
50
+ // Toast.makeText(
51
+ // EditJob.this,
52
+ // String.format(
53
+ // "Job: %d\nEmployer: %s (%d)\nTitle: %s\nDesc: %s",
54
+ // job_id,
55
+ // employer.employerName,
56
+ // employer.id,
57
+ // txtTitle.getText(),
58
+ // txtDescription.getText()
59
+ // ),
60
+ // Toast.LENGTH_SHORT
61
+ // ).show();
62
+ if ((txtTitle .getText ().length ()==0 ) || (txtDescription .getText ().length ()==0 )){
63
+ Toast .makeText (EditJob .this , "Fill out the form completely first." , Toast .LENGTH_LONG ).show ();
64
+ } else {
65
+ db .editJob (job_id .longValue (), employer .id , txtTitle .getText ().toString (), txtDescription .getText ().toString ());
66
+ Toast .makeText (EditJob .this , "Job updated" , Toast .LENGTH_SHORT ).show ();
67
+ finish ();
68
+ }
69
69
}
70
70
};
71
71
72
72
// Create a button click listener for the Cancel button.
73
73
private final Button .OnClickListener btnCancelOnClick = new Button .OnClickListener () {
74
74
@ Override
75
75
public void onClick (View v ) {
76
- finish ();
77
- }
76
+ finish ();
77
+ }
78
78
};
79
79
80
80
/** Called when the activity is first created. */
@@ -107,15 +107,15 @@ public void onCreate(Bundle savedInstanceState) {
107
107
startManagingCursor (c );
108
108
int position =0 ;
109
109
for (int i =0 ; i <c .getCount (); i ++){
110
- c .moveToPosition (i );
111
- employersList .add (new Employer (c .getColId (),c .getColEmployerName ()));
112
- if (c .getColId ()==job .getColEmployersId ()) {
110
+ c .moveToPosition (i );
111
+ employersList .add (new Employer (c .getColId (),c .getColEmployerName ()));
112
+ if (c .getColId ()==job .getColEmployersId ()) {
113
113
position =i ;
114
114
}
115
115
}
116
116
117
117
ArrayAdapter <Employer > aspnEmployers = new ArrayAdapter <Employer >(
118
- this , android .R .layout .simple_spinner_item , employersList );
118
+ this , android .R .layout .simple_spinner_item , employersList );
119
119
aspnEmployers .setDropDownViewResource (android .R .layout .simple_spinner_dropdown_item );
120
120
spnEmployer .setAdapter (aspnEmployers );
121
121
spnEmployer .setSelection (position );
0 commit comments