Commit 4d10ccda authored by Lucas Braz Cunha's avatar Lucas Braz Cunha

Issue AGILE#152: Added hint to spinner on SchedulingActivity

Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent 989fd6b2
......@@ -19,10 +19,16 @@ import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
import java.util.List;
import java.util.Objects;
import br.ufpr.c3sl.agendador.agendador.helpers.HintAdapter;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.UserPhotoHelper;
import br.ufpr.c3sl.agendador.agendador.models.UserUpdate;
......@@ -46,6 +52,8 @@ public class SchedulingActivity extends AppCompatActivity implements Scheduling
private ProgressBar pb_scheduling;
private Spinner spnr_citizen;
//TODO: create class "ConfirmationDialog"
private ConfirmationDialog confirmationDialog;
......@@ -73,6 +81,9 @@ public class SchedulingActivity extends AppCompatActivity implements Scheduling
}
});
spnr_citizen = (Spinner) findViewById(R.id.spnr_scheduling_citizen);
osb = ObscuredSharedPreferences.getPrefs(this, "Agendador", Context.MODE_PRIVATE);
String citizenName = osb.getString("name", null);
String citizenCity = osb.getString("city.name", null);
......@@ -112,6 +123,14 @@ public class SchedulingActivity extends AppCompatActivity implements Scheduling
navigationView.setNavigationItemSelectedListener(this);
// TODO: 17/04/17 example on how to set hint to spinner
String[] citizes = {"Lucas","Selecione um cidadão"};
HintAdapter hintAdapter= new HintAdapter(this, android.R.layout.simple_list_item_1, citizes);
spnr_citizen.setAdapter(hintAdapter);
// show hint
spnr_citizen.setSelection(hintAdapter.getCount());
}
......@@ -202,4 +221,6 @@ public class SchedulingActivity extends AppCompatActivity implements Scheduling
}
}
}
package br.ufpr.c3sl.agendador.agendador.helpers;
import android.content.Context;
import android.widget.ArrayAdapter;
import java.util.List;
/**
*
* Thanks to Ranjith Kumar at http://stackoverflow.com/questions/37019941/how-to-add-a-hint-in-spinner-in-xml
*/
public class HintAdapter extends ArrayAdapter<String>{
public HintAdapter(Context context, int resource) {
super(context, resource);
}
public HintAdapter(Context context, int resource, int textViewResourceId) {
super(context, resource, textViewResourceId);
}
public HintAdapter(Context context, int resource, String[] objects) {
super(context, resource, objects);
}
public HintAdapter(Context context, int resource, int textViewResourceId, String[] objects) {
super(context, resource, textViewResourceId, objects);
}
public HintAdapter(Context context, int resource, List<String> objects) {
super(context, resource, objects);
}
public HintAdapter(Context context, int resource, int textViewResourceId, List<String> objects) {
super(context, resource, textViewResourceId, objects);
}
@Override
public int getCount() {
// don't display last item. It is used as hint.
int count = super.getCount();
return count > 0 ? count - 1 : count;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment