Search in sources :

Example 1 with InvitationPayload

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);
        }
    });
}
Also used : EditText(android.widget.EditText) View(android.view.View) ListView(android.widget.ListView) WindowManager(android.view.WindowManager) Response(retrofit.Response) Retrofit(retrofit.Retrofit) Callback(retrofit.Callback) Button(android.widget.Button) Dialog(android.app.Dialog) InvitationPayload(com.eveningoutpost.dexdrip.ShareModels.Models.InvitationPayload)

Example 2 with InvitationPayload

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);
        }
    });
}
Also used : EditText(android.widget.EditText) View(android.view.View) ListView(android.widget.ListView) WindowManager(android.view.WindowManager) Response(retrofit.Response) Retrofit(retrofit.Retrofit) Callback(retrofit.Callback) Button(android.widget.Button) Dialog(android.app.Dialog) InvitationPayload(com.eveningoutpost.dexdrip.ShareModels.Models.InvitationPayload)

Aggregations

Dialog (android.app.Dialog)2 View (android.view.View)2 WindowManager (android.view.WindowManager)2 Button (android.widget.Button)2 EditText (android.widget.EditText)2 ListView (android.widget.ListView)2 InvitationPayload (com.eveningoutpost.dexdrip.ShareModels.Models.InvitationPayload)2 Callback (retrofit.Callback)2 Response (retrofit.Response)2 Retrofit (retrofit.Retrofit)2