use of android.widget.AutoCompleteTextView in project BloodHub by kazijehangir.
the class AddPatientActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
mAuth = FirebaseAuth.getInstance();
user = mAuth.getCurrentUser();
mEmail = user.getEmail();
// INITIALIZE FIREBASE DB
db = FirebaseDatabase.getInstance().getReference().child("patients");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_patient);
setTitle("Add Patient");
name = (AutoCompleteTextView) findViewById(R.id.name);
age = (EditText) findViewById(R.id.age);
bloodgroup = (Spinner) findViewById(R.id.spin);
number = (EditText) findViewById(R.id.contact_num);
diagnosis = (Spinner) findViewById(R.id.diagnosis);
Button submit = (Button) findViewById(R.id.add_patient);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Context context = getApplicationContext();
pname = name.getText().toString();
a = age.getText().toString();
bgroup = bloodgroup.getSelectedItem().toString();
diag = diagnosis.getSelectedItem().toString();
num = number.getText().toString();
Patient pat = new Patient(user.getUid(), pname, a, bgroup, num, diag);
try {
db.push().setValue(pat);
dialog = new Dialog(AddPatientActivity.this);
dialog.setTitle("Add Patient");
dialog.setContentView(R.layout.popup_patient);
dialog.show();
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
final Button submit = (Button) dialog.findViewById(R.id.button_ok);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(AddPatientActivity.this, MainActivityOrg.class);
startActivity(intent);
}
});
} catch (DatabaseException e) {
Toast.makeText(context, "Error occurred", Toast.LENGTH_SHORT).show();
}
}
});
}
use of android.widget.AutoCompleteTextView in project BloodHub by kazijehangir.
the class AddRequestActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
mAuth = FirebaseAuth.getInstance();
user = mAuth.getCurrentUser();
mEmail = user.getEmail();
// INITIALIZE FIREBASE DB
db = FirebaseDatabase.getInstance().getReference().child("bloodrequests");
mStorageRef = FirebaseStorage.getInstance().getReference().child("bloodrequests");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_request);
setTitle("Add Request");
name = (AutoCompleteTextView) findViewById(R.id.name);
bloodgroup = (Spinner) findViewById(R.id.spin);
quantity = (Spinner) findViewById(R.id.spin1);
number = (EditText) findViewById(R.id.contact_num);
location = (AutoCompleteTextView) findViewById(R.id.loc);
when = (EditText) findViewById(R.id.editText);
diagnosis = (Spinner) findViewById(R.id.diagnosis);
transport_group = (RadioGroup) findViewById(R.id.transport);
image = (TextView) findViewById(R.id.image_text);
String[] hospitals = getResources().getStringArray(R.array.organizations_array);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, hospitals);
location.setAdapter(adapter);
final EditText set = (EditText) findViewById(R.id.editText);
set.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog = new Dialog(AddRequestActivity.this);
dialog.setTitle("Set Date and Time");
dialog.setContentView(R.layout.set_date);
dialog.show();
final Button setDate = (Button) dialog.findViewById(R.id.set_date);
final DatePicker datePicker = (DatePicker) dialog.findViewById(R.id.datePicker);
datePicker.setMinDate(System.currentTimeMillis() - 1000);
setDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
date = datePicker.getDayOfMonth();
month = datePicker.getMonth();
year = datePicker.getYear();
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, date);
pdate = calendar.getTime();
String date = DateFormat.getDateInstance().format(pdate);
set.setText(date);
dialog.cancel();
}
});
}
});
Button image_btn = (Button) findViewById(R.id.upload_image_button);
image_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Context context = getApplicationContext();
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
startActivityForResult(intent, GALLERY_INTENT);
}
});
Button submit = (Button) findViewById(R.id.submit_button);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
pname = name.getText().toString();
bgroup = bloodgroup.getSelectedItem().toString();
quan = quantity.getSelectedItem().toString();
diag = diagnosis.getSelectedItem().toString();
num = number.getText().toString();
loc = location.getText().toString();
transport_btn = (RadioButton) findViewById(transport_group.getCheckedRadioButtonId());
String transport_text = (String) transport_btn.getText();
if (transport_text.equals("Available")) {
transport = true;
} else if (transport_text.equals("Not Available")) {
transport = false;
}
new_request = db.push();
String address = loc + ", Pakistan";
new GetCoordinates().execute(address.replace(" ", "+"));
if (image_file != null) {
mStorageRef.child(new_request.getKey()).putFile(image_file).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
// Toast.makeText(getApplicationContext(),"Image uploaded",
// Toast.LENGTH_SHORT).show();
String regToken = FirebaseInstanceId.getInstance().getToken();
BloodRequest request = new BloodRequest(user.getUid(), pname, bgroup, quan, num, loc, lat, lng, diag, pdate.getTime(), transport, regToken);
new_request.setValue(request);
request_added = true;
dialog = new Dialog(AddRequestActivity.this);
dialog.setContentView(R.layout.popup_submit);
dialog.show();
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
final Button submit = (Button) dialog.findViewById(R.id.button_ok);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(AddRequestActivity.this, MainActivity.class);
startActivity(intent);
}
});
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
Toast.makeText(getApplicationContext(), "Error uploading image", Toast.LENGTH_SHORT).show();
}
});
} else {
String regToken = FirebaseInstanceId.getInstance().getToken();
BloodRequest request = new BloodRequest(user.getUid(), pname, bgroup, quan, num, loc, lat, lng, diag, pdate.getTime(), transport, regToken);
new_request.setValue(request);
request_added = true;
dialog = new Dialog(AddRequestActivity.this);
dialog.setContentView(R.layout.popup_submit);
dialog.show();
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
final Button submit = (Button) dialog.findViewById(R.id.button_ok);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(AddRequestActivity.this, MainActivity.class);
startActivity(intent);
}
});
}
}
});
}
use of android.widget.AutoCompleteTextView in project BloodHub by kazijehangir.
the class AddRequestOrgActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
mAuth = FirebaseAuth.getInstance();
user = mAuth.getCurrentUser();
mEmail = user.getEmail();
// INITIALIZE FIREBASE DB
db = FirebaseDatabase.getInstance().getReference().child("bloodrequests");
mStorageRef = FirebaseStorage.getInstance().getReference().child("bloodrequests");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_request_org);
setTitle("Add Request for Patient");
location = (AutoCompleteTextView) findViewById(R.id.loc);
when = (EditText) findViewById(R.id.editText);
transport_group = (RadioGroup) findViewById(R.id.transport);
quantity = (Spinner) findViewById(R.id.spin1);
String[] hospitals = getResources().getStringArray(R.array.organizations_array);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, hospitals);
location.setAdapter(adapter);
if (savedInstanceState == null) {
Bundle extras = getIntent().getExtras();
if (extras == null) {
patient = null;
} else {
patient = extras.getString("patient");
}
}
final EditText set = (EditText) findViewById(R.id.editText);
set.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog = new Dialog(AddRequestOrgActivity.this);
dialog.setTitle("Set Date and Time");
dialog.setContentView(R.layout.set_date);
dialog.show();
final Button setDate = (Button) dialog.findViewById(R.id.set_date);
final DatePicker datePicker = (DatePicker) dialog.findViewById(R.id.datePicker);
datePicker.setMinDate(System.currentTimeMillis() - 1000);
setDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
date = datePicker.getDayOfMonth();
month = datePicker.getMonth();
year = datePicker.getYear();
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, date);
pdate = calendar.getTime();
String date = DateFormat.getDateInstance().format(pdate);
set.setText(date);
dialog.cancel();
}
});
}
});
// name = null;
// age = null;
// needs = null;
// when = null;
// diagnosis = null;
// gender = null;
// mEmail = null;
// } else {
// //
// name = extras.getString("name");
// age = extras.getString("age");
// needs = extras.getString("bgroup");
// when = extras.getString("lastRequest");
// diagnosis = extras.getString("diagnosis");
// gender = extras.getString("gender");
// mEmail = extras.getString("mEmail");
// Toast.makeText(this,gender,Toast.LENGTH_SHORT).show();
// }
// } else {
// // Toast.makeText(this, "getting strings from savedInstance",
// // Toast.LENGTH_SHORT).show();
// name = (String) savedInstanceState.getSerializable("name");
// age = (String) savedInstanceState.getSerializable("age");
// needs = (String) savedInstanceState.getSerializable("bgroup");
// when = (String) savedInstanceState.getSerializable("lastRequest");
// diagnosis = (String) savedInstanceState.getSerializable("diagnosis");
// gender = (String) savedInstanceState.getSerializable("gender");
// mEmail = (String) savedInstanceState.getSerializable("mEmail");
//
// }
//
// // TextView mName = (TextView) findViewById(R.id.name);
// // mName.setText("Name: "+name);
// // TextView mAge = (TextView) findViewById(R.id.age);
// // mName.setText("Age: "+age);
// // TextView mWhen = (TextView) findViewById(R.id.blood_g);
// // mWhen.setText("Blood Group: "+needs);
// // TextView mDiagnosis = (TextView) findViewById(R.id.con_num);
// // mDiagnosis.setText("Diagnosis: "+diagnosis);
// // TextView mTransport = (TextView) findViewById(R.id.last);
// mTransport.setText("Last Request: "+when);
// ImageView image = (ImageView) findViewById(R.id.image1);
// if (gender.equals("Female")){
// image.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.girl));
// }
// else {
// image.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.boy));
// }
// db = FirebaseDatabase.getInstance().getReference().child("patient details");
FirebaseDatabase.getInstance().getReference().child("patients").child(patient).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Patient data = dataSnapshot.getValue(Patient.class);
TextView mName = (TextView) findViewById(R.id.user_profile_name);
mName.setText(data.name);
pname = data.name;
TextView mAge = (TextView) findViewById(R.id.user_profile_age);
mAge.setText("Age: " + data.age);
TextView mCnumber = (TextView) findViewById(R.id.user_profile_number);
mCnumber.setText("Contact Number: " + data.cnumber);
num = data.cnumber;
TextView mBloodgroup = (TextView) findViewById(R.id.user_profile_bgroup);
mBloodgroup.setText("Blood Group: " + data.blood_group);
bgroup = data.blood_group;
TextView mDiagnosis = (TextView) findViewById(R.id.user_profile_Diagnosis);
mDiagnosis.setText("Diagnosis: " + data.diagnosis);
diag = data.diagnosis;
// Spinner mNeeds = (Spinner) findViewById(R.id.spin1);
// mNeeds.getSelectedItem().toString();
//
// TextView mLocation = (TextView) findViewById(R.id.request_detail_location);
// mLocation.setText(data.location);
// TextView mWhen = (TextView) findViewById(R.id.request_detail_when);
// String date = DateFormat.getDateInstance().format(new Date(data.date));
// mWhen.setText(date);
// if (date.equals(DateFormat.getDateInstance().format(new Date()))) {
// mWhen.setText("URGENT");
// mWhen.setTextColor(0xFFFF0000);
// }
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
Button add = (Button) findViewById(R.id.add_button);
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
loc = location.getText().toString();
transport_btn = (RadioButton) findViewById(transport_group.getCheckedRadioButtonId());
quan = quantity.getSelectedItem().toString();
String transport_text = (String) transport_btn.getText();
if (transport_text.equals("Available")) {
transport = true;
} else if (transport_text.equals("Not Available")) {
transport = false;
}
final Context context = getApplicationContext();
new_request = db.push();
String address = loc + ", Lahore, Pakistan";
new GetCoordinates().execute(address.replace(" ", "+"));
// BloodRequest request = new BloodRequest(user.getUid(), pname, bgroup, quan, num, loc, lat, lng, diag, pdate.getTime(), transport);
// new_request.setValue(request);
dialog = new Dialog(AddRequestOrgActivity.this);
dialog.setTitle("Add Request");
dialog.setContentView(R.layout.popup_submit);
dialog.show();
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
final Button add_request = (Button) dialog.findViewById(R.id.button_ok);
add_request.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(AddRequestOrgActivity.this, MainActivityOrg.class);
intent.putExtra("mEmail", mEmail);
startActivity(intent);
}
});
}
});
}
use of android.widget.AutoCompleteTextView in project Applozic-Android-SDK by AppLozic.
the class LoginActivity method onCreate.
// private LoginButton loginButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// FacebookSdk.sdkInitialize(this);
Applozic.init(this, getString(R.string.application_key));
setContentView(R.layout.activity_login);
setupUI(findViewById(R.id.layout));
layout = (LinearLayout) findViewById(R.id.footerSnack);
// Set up the login form.
mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
mPhoneNumberView = (EditText) findViewById(R.id.phoneNumber);
mUserIdView = (EditText) findViewById(R.id.userId);
mPasswordView = (EditText) findViewById(R.id.password);
mDisplayName = (EditText) findViewById(R.id.displayName);
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == R.id.login || id == EditorInfo.IME_NULL) {
attemptLogin(User.AuthenticationType.APPLOZIC);
return true;
}
return false;
}
});
mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
mEmailSignInButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Utils.toggleSoftKeyBoard(LoginActivity.this, true);
attemptLogin(User.AuthenticationType.APPLOZIC);
}
});
mLoginFormView = findViewById(R.id.login_form);
mProgressView = findViewById(R.id.login_progress);
// callbackManager = CallbackManager.Factory.create();
mSpinnerView = (Spinner) findViewById(R.id.spinner_for_url);
mSpinnerView.setVisibility(View.INVISIBLE);
mTitleView = (TextView) findViewById(R.id.textViewTitle);
mTitleView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
touchCount += 1;
if (touchCount == 5) {
mSpinnerView.setVisibility(View.VISIBLE);
touchCount = 0;
} else {
Toast.makeText(getApplicationContext(), getBaseContext().getString(R.string.click_more) + Integer.toString(5 - touchCount), Toast.LENGTH_SHORT).show();
}
}
});
mobiComUserPreference = MobiComUserPreference.getInstance(this);
mSpinnerView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
mobiComUserPreference.setUrl(adapterView.getItemAtPosition(i).toString());
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
}
use of android.widget.AutoCompleteTextView in project opacclient by opacapp.
the class SuggestLibraryActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_suggest_library);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
etCity = (AutoCompleteTextView) findViewById(R.id.etCity);
etName = (EditText) findViewById(R.id.etName);
etComment = (EditText) findViewById(R.id.etComment);
Button btnSend = (Button) findViewById(R.id.btnSend);
if (savedInstanceState != null) {
etCity.setText(savedInstanceState.getCharSequence("city"));
etName.setText(savedInstanceState.getCharSequence("name"));
etComment.setText(savedInstanceState.getCharSequence("comment"));
selectedCity = (City) savedInstanceState.getSerializable("selectedCity");
}
final PlacesAutoCompleteAdapter adapter = new PlacesAutoCompleteAdapter(this, android.R.layout.simple_dropdown_item_1line);
etCity.setAdapter(adapter);
etCity.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
selectedCity = adapter.getCity(position);
}
});
etCity.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
selectedCity = null;
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
});
btnSend.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent send = new Intent(Intent.ACTION_SENDTO);
String uriText = "mailto:" + Uri.encode("info@opacapp.de") + "?subject=" + Uri.encode(getResources().getString(R.string.library_suggestion) + " " + etCity.getText().toString() + " " + etName.getText().toString()) + "&body=" + Uri.encode(createMessage());
Uri uri = Uri.parse(uriText);
send.setData(uri);
startActivity(Intent.createChooser(send, getResources().getString(R.string.select_mail_app)));
supportFinishAfterTransition();
}
});
}
Aggregations