use of com.eveningoutpost.dexdrip.ShareModels.Models.InvitationPayload in project xDrip by NightscoutFoundation.
the class FollowerManagementActivity method setInviteListener.
private void setInviteListener() {
addFollowerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Dialog dialog = new Dialog(FollowerManagementActivity.this);
dialog.setContentView(R.layout.dialog_invite_follower);
dialog.setTitle("Invite a Follower");
Button saveButton = (Button) dialog.findViewById(R.id.saveButton);
Button cancelButton = (Button) dialog.findViewById(R.id.cancelButton);
final EditText followerName = (EditText) dialog.findViewById(R.id.followerNameField);
final EditText followerNicName = (EditText) dialog.findViewById(R.id.followerDisplayNameField);
final EditText followerEmail = (EditText) dialog.findViewById(R.id.followerEmailField);
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!TextUtils.isEmpty(followerName.getText()) && !TextUtils.isEmpty(followerNicName.getText()) && !TextUtils.isEmpty(followerEmail.getText())) {
shareRest.createContact(followerName.getText().toString().trim(), followerEmail.getText().toString().trim(), new Callback<String>() {
@Override
public void onResponse(Response<String> response, Retrofit retrofit) {
if (response.isSuccess()) {
shareRest.createInvitationForContact(response.body(), new InvitationPayload(followerNicName.getText().toString().trim()), new Callback<String>() {
@Override
public void onResponse(Response<String> response, Retrofit retrofit) {
if (response.isSuccess()) {
populateFollowerList();
Toast.makeText(getApplicationContext(), "Follower invite sent succesfully", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), "Failed to invite follower", Toast.LENGTH_LONG).show();
}
}
@Override
public void onFailure(Throwable t) {
Toast.makeText(getApplicationContext(), "Failed to invite follower", Toast.LENGTH_LONG).show();
}
});
} else {
Toast.makeText(getApplicationContext(), "Failed to invite follower", Toast.LENGTH_LONG).show();
}
}
@Override
public void onFailure(Throwable t) {
Toast.makeText(getApplicationContext(), "Failed to invite follower", Toast.LENGTH_LONG).show();
}
});
}
dialog.dismiss();
}
});
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
dialog.show();
dialog.getWindow().setAttributes(lp);
}
});
}
use of com.eveningoutpost.dexdrip.ShareModels.Models.InvitationPayload in project xDrip-plus by jamorham.
the class FollowerManagementActivity method setInviteListener.
private void setInviteListener() {
addFollowerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Dialog dialog = new Dialog(FollowerManagementActivity.this);
dialog.setContentView(R.layout.dialog_invite_follower);
dialog.setTitle("Invite a Follower");
Button saveButton = (Button) dialog.findViewById(R.id.saveButton);
Button cancelButton = (Button) dialog.findViewById(R.id.cancelButton);
final EditText followerName = (EditText) dialog.findViewById(R.id.followerNameField);
final EditText followerNicName = (EditText) dialog.findViewById(R.id.followerDisplayNameField);
final EditText followerEmail = (EditText) dialog.findViewById(R.id.followerEmailField);
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!TextUtils.isEmpty(followerName.getText()) && !TextUtils.isEmpty(followerNicName.getText()) && !TextUtils.isEmpty(followerEmail.getText())) {
shareRest.createContact(followerName.getText().toString().trim(), followerEmail.getText().toString().trim(), new Callback<String>() {
@Override
public void onResponse(Response<String> response, Retrofit retrofit) {
if (response.isSuccess()) {
shareRest.createInvitationForContact(response.body(), new InvitationPayload(followerNicName.getText().toString().trim()), new Callback<String>() {
@Override
public void onResponse(Response<String> response, Retrofit retrofit) {
if (response.isSuccess()) {
populateFollowerList();
Toast.makeText(getApplicationContext(), "Follower invite sent succesfully", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), "Failed to invite follower", Toast.LENGTH_LONG).show();
}
}
@Override
public void onFailure(Throwable t) {
Toast.makeText(getApplicationContext(), "Failed to invite follower", Toast.LENGTH_LONG).show();
}
});
} else {
Toast.makeText(getApplicationContext(), "Failed to invite follower", Toast.LENGTH_LONG).show();
}
}
@Override
public void onFailure(Throwable t) {
Toast.makeText(getApplicationContext(), "Failed to invite follower", Toast.LENGTH_LONG).show();
}
});
}
dialog.dismiss();
}
});
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
dialog.show();
dialog.getWindow().setAttributes(lp);
}
});
}
Aggregations