导航菜单

页面标题

页面副标题

xDrip+ v04633772025.07.16 - FollowerManagementActivity.java 源代码

正在查看: xDrip+ v04633772025.07.16 应用的 FollowerManagementActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.eveningoutpost.dexdrip;

import android.app.Dialog;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.eveningoutpost.dexdrip.sharemodels.ShareRest;
import com.eveningoutpost.dexdrip.sharemodels.models.ExistingFollower;
import com.eveningoutpost.dexdrip.sharemodels.models.InvitationPayload;
import com.eveningoutpost.dexdrip.utils.ActivityWithMenu;
import java.util.List;
import retrofit.Callback;
import retrofit.Response;
import retrofit.Retrofit;

public class FollowerManagementActivity extends ActivityWithMenu {
    private static final String TAG = Home.class.getName();
    private Button addFollowerButton;
    private List<ExistingFollower> existingFollowerList;
    private Callback<List<ExistingFollower>> existingFollowerListener;
    private ListView existingFollowersView;
    private FollowerListAdapter followerListAdapter;
    private ShareRest shareRest;

    @Override
    public String getMenuName() {
        return "Follower Management";
    }

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(2131492914);
        this.existingFollowersView = (ListView) findViewById(2131296625);
        this.addFollowerButton = (Button) findViewById(2131296685);
        this.shareRest = new ShareRest(this, null);
    }

    @Override
    protected void onResume() {
        super.onResume();
        PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
        populateFollowerList();
        setInviteListener();
    }

    public void populateFollowerList() {
        Callback<List<ExistingFollower>> callback = new Callback<List<ExistingFollower>>() {
            public void onFailure(Throwable th) {
            }

            public void onResponse(Response<List<ExistingFollower>> response, Retrofit retrofit) {
                List list = (List) response.body();
                if (FollowerManagementActivity.this.followerListAdapter != null) {
                    FollowerManagementActivity.this.existingFollowerList.clear();
                    if (list != null && list.size() > 0) {
                        FollowerManagementActivity.this.existingFollowerList.addAll(list);
                    }
                    FollowerManagementActivity.this.followerListAdapter.notifyDataSetChanged();
                    return;
                }
                if (list == null || list.size() <= 0) {
                    return;
                }
                FollowerManagementActivity.this.existingFollowerList = list;
                FollowerManagementActivity.this.followerListAdapter = new FollowerListAdapter(FollowerManagementActivity.this.getApplicationContext(), FollowerManagementActivity.this.shareRest, FollowerManagementActivity.this.existingFollowerList);
                FollowerManagementActivity.this.existingFollowersView.setAdapter((ListAdapter) FollowerManagementActivity.this.followerListAdapter);
            }
        };
        this.existingFollowerListener = callback;
        this.shareRest.getContacts(callback);
    }

    class AnonymousClass2 implements View.OnClickListener {
        AnonymousClass2() {
        }

        @Override
        public void onClick(View view) {
            final Dialog dialog = new Dialog(FollowerManagementActivity.this);
            dialog.setContentView(2131492976);
            dialog.setTitle("Invite a Follower");
            Button button = (Button) dialog.findViewById(2131296923);
            Button button2 = (Button) dialog.findViewById(2131296479);
            button.setOnClickListener(new AnonymousClass1((EditText) dialog.findViewById(2131296627), (EditText) dialog.findViewById(2131296623), (EditText) dialog.findViewById(2131296624), dialog));
            button2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view2) {
                    dialog.dismiss();
                }
            });
            WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
            layoutParams.copyFrom(dialog.getWindow().getAttributes());
            layoutParams.width = -1;
            dialog.show();
            dialog.getWindow().setAttributes(layoutParams);
        }

        class AnonymousClass1 implements View.OnClickListener {
            final Dialog val$dialog;
            final EditText val$followerEmail;
            final EditText val$followerName;
            final EditText val$followerNicName;

            AnonymousClass1(EditText editText, EditText editText2, EditText editText3, Dialog dialog) {
                this.val$followerName = editText;
                this.val$followerNicName = editText2;
                this.val$followerEmail = editText3;
                this.val$dialog = dialog;
            }

            @Override
            public void onClick(View view) {
                if (!TextUtils.isEmpty(this.val$followerName.getText()) && !TextUtils.isEmpty(this.val$followerNicName.getText()) && !TextUtils.isEmpty(this.val$followerEmail.getText())) {
                    FollowerManagementActivity.this.shareRest.createContact(this.val$followerName.getText().toString().trim(), this.val$followerEmail.getText().toString().trim(), new Callback<String>() {
                        public void onResponse(Response<String> response, Retrofit retrofit) {
                            if (response.isSuccess()) {
                                FollowerManagementActivity.this.shareRest.createInvitationForContact((String) response.body(), new InvitationPayload(AnonymousClass1.this.val$followerNicName.getText().toString().trim()), new Callback<String>() {
                                    public void onResponse(Response<String> response2, Retrofit retrofit2) {
                                        if (response2.isSuccess()) {
                                            FollowerManagementActivity.this.populateFollowerList();
                                            Toast.makeText(FollowerManagementActivity.this.getApplicationContext(), "Follower invite sent succesfully", 1).show();
                                        } else {
                                            Toast.makeText(FollowerManagementActivity.this.getApplicationContext(), "Failed to invite follower", 1).show();
                                        }
                                    }

                                    public void onFailure(Throwable th) {
                                        Toast.makeText(FollowerManagementActivity.this.getApplicationContext(), "Failed to invite follower", 1).show();
                                    }
                                });
                            } else {
                                Toast.makeText(FollowerManagementActivity.this.getApplicationContext(), "Failed to invite follower", 1).show();
                            }
                        }

                        public void onFailure(Throwable th) {
                            Toast.makeText(FollowerManagementActivity.this.getApplicationContext(), "Failed to invite follower", 1).show();
                        }
                    });
                }
                this.val$dialog.dismiss();
            }
        }
    }

    private void setInviteListener() {
        this.addFollowerButton.setOnClickListener(new AnonymousClass2());
    }
}