Example usage for android.support.v4.internal.view SupportMenuItem getActionView

List of usage examples for android.support.v4.internal.view SupportMenuItem getActionView

Introduction

In this page you can find the example usage for android.support.v4.internal.view SupportMenuItem getActionView.

Prototype

View getActionView();

Source Link

Usage

From source file:org.telegram.ui.LoginActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.group_create_menu, menu);
    SupportMenuItem doneItem = (SupportMenuItem) menu.findItem(R.id.done_menu_item);
    TextView doneTextView = (TextView) doneItem.getActionView().findViewById(R.id.done_button);
    doneTextView.setOnClickListener(new View.OnClickListener() {
        @Override//w w w  .  j ava 2  s  .c o m
        public void onClick(View view) {
            onNextAction();
        }
    });
    return super.onCreateOptionsMenu(menu);
}

From source file:com.yahala.ui.LoginActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.group_create_menu, menu);
    SupportMenuItem doneItem = (SupportMenuItem) menu.findItem(R.id.done_menu_item);
    TextView doneTextView = (TextView) doneItem.getActionView().findViewById(R.id.done_button);
    doneTextView.setText(LocaleController.getString("Done", R.string.Done));
    doneTextView.setOnClickListener(new View.OnClickListener() {
        @Override//w  ww .j a  v a2s. co m
        public void onClick(View view) {
            onNextAction();
        }
    });
    return super.onCreateOptionsMenu(menu);
}

From source file:org.telegram.ui.GroupCreateFinalActivity.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.group_create_menu, menu);
    SupportMenuItem doneItem = (SupportMenuItem) menu.findItem(R.id.done_menu_item);
    TextView doneTextView = (TextView) doneItem.getActionView().findViewById(R.id.done_button);
    doneTextView.setOnClickListener(new View.OnClickListener() {
        @Override// w w w . j a  v a 2  s.  c o m
        public void onClick(View view) {
            if (donePressed) {
                return;
            }
            if (nameTextView.getText().length() == 0) {
                return;
            }
            donePressed = true;
            Utilities.ShowProgressDialog(parentActivity, getStringEntry(R.string.Loading));
            if (avatarUpdater.uploadingAvatar != null) {
                createAfterUpload = true;
            } else {
                MessagesController.Instance.createChat(nameTextView.getText().toString(), selectedContacts,
                        uploadedAvatar);
            }
        }
    });
}

From source file:com.yahala.ui.GroupCreateFinalActivity.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.group_create_menu, menu);
    SupportMenuItem doneItem = (SupportMenuItem) menu.findItem(R.id.done_menu_item);
    TextView doneTextView = (TextView) doneItem.getActionView().findViewById(R.id.done_button);
    doneTextView.setText(LocaleController.getString("Done", R.string.Done));
    doneTextView.setOnClickListener(new View.OnClickListener() {
        @Override/*  w w w  .  java2  s . c  o m*/
        public void onClick(View view) {
            /*   if (donePressed || parentActivity == null) {
            return;
               }
               if (nameTextView.getText().length() == 0) {
            return;
               }
               donePressed = true;
                    
               if (avatarUpdater.uploadingAvatar != null) {
            createAfterUpload = true;
               } else {
            progressDialog = new ProgressDialog(parentActivity);
            progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
            progressDialog.setCanceledOnTouchOutside(false);
            progressDialog.setCancelable(false);
                    
            final long reqId = MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, uploadedAvatar);
                    
            progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    ConnectionsManager.getInstance().cancelRpc(reqId, true);
                    donePressed = false;
                    try {
                        dialog.dismiss();
                    } catch (Exception e) {
                        FileLog.e("tmessages", e);
                    }
                }
            });
            progressDialog.show();
               }*/
        }
    });
}

From source file:org.telegram.ui.GroupCreateActivity.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.group_create_menu, menu);
    SupportMenuItem doneItem = (SupportMenuItem) menu.findItem(R.id.done_menu_item);
    doneTextView = (TextView) doneItem.getActionView().findViewById(R.id.done_button);
    doneTextView.setOnClickListener(new View.OnClickListener() {
        @Override/* w w  w.j  av a 2 s.c  o m*/
        public void onClick(View view) {
            if (!selectedContacts.isEmpty()) {
                ArrayList<Integer> result = new ArrayList<Integer>();
                result.addAll(selectedContacts.keySet());
                NotificationCenter.Instance.addToMemCache(2, result);
            } else {
                return;
            }
            ((ApplicationActivity) parentActivity).presentFragment(new GroupCreateFinalActivity(),
                    "group_craate_final", false);
        }
    });
}

From source file:com.yahala.ui.GroupCreateActivity.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.group_create_menu, menu);
    SupportMenuItem doneItem = (SupportMenuItem) menu.findItem(R.id.done_menu_item);
    TextView doneTextView = (TextView) doneItem.getActionView().findViewById(R.id.done_button);
    doneTextView.setText(LocaleController.getString("Next", R.string.Next));
    doneTextView.setOnClickListener(new View.OnClickListener() {
        @Override//  w ww.  ja v  a  2  s.c  om
        public void onClick(View view) {

            if (!selectedContacts.isEmpty()) {
                ArrayList<String> result = new ArrayList<String>();
                result.addAll(selectedContacts.keySet());
                Bundle args = new Bundle();
                args.putStringArrayList("result", result);
                FileLog.e("selectedContacts.size()", selectedContacts.size() + "");
                GroupCreateFinalActivity groupCreateFinalActivity = new GroupCreateFinalActivity();
                groupCreateFinalActivity.setArguments(args);
                ((LaunchActivity) parentActivity).presentFragment(groupCreateFinalActivity,
                        "group_create_final", false);

            } else {
                return;
            }

        }
    });
}

From source file:org.telegram.ui.ChatProfileActivity.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.group_profile_menu, menu);
    SupportMenuItem doneItem = (SupportMenuItem) menu.findItem(R.id.block_user);
    TextView doneTextView = (TextView) doneItem.getActionView().findViewById(R.id.done_button);
    doneTextView.setOnClickListener(new View.OnClickListener() {
        @Override/*from   w  ww.  ja va2  s  .co m*/
        public void onClick(View view) {
            openAddMenu();
        }
    });
}

From source file:org.telegram.ui.ChatActivity.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();/*from  ww  w.  j  av  a 2 s .  co m*/
    inflater.inflate(R.menu.chat_menu, menu);
    if (currentEncryptedChat != null && !(currentEncryptedChat instanceof TLRPC.TL_encryptedChat)
            || currentChat != null && (currentChat instanceof TLRPC.TL_chatForbidden || currentChat.left)) {
        SupportMenuItem item = (SupportMenuItem) menu.findItem(R.id.chat_menu_attach);
        item.setVisible(false);
    }

    SupportMenuItem avatarItem = (SupportMenuItem) menu.findItem(R.id.chat_menu_avatar);
    View avatarLayout = avatarItem.getActionView();
    avatarImageView = (BackupImageView) avatarLayout.findViewById(R.id.chat_avatar_image);

    avatarImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (parentActivity == null) {
                return;
            }
            if (currentUser != null) {
                UserProfileActivity fragment = new UserProfileActivity();
                Bundle args = new Bundle();
                args.putInt("user_id", currentUser.id);
                if (currentEncryptedChat != null) {
                    args.putLong("dialog_id", dialog_id);
                }
                fragment.setArguments(args);
                ((ApplicationActivity) parentActivity).presentFragment(fragment, "user_" + currentUser.id,
                        swipeOpening);
            } else if (currentChat != null) {
                if (info != null) {
                    if (info instanceof TLRPC.TL_chatParticipantsForbidden) {
                        return;
                    }
                    NotificationCenter.Instance.addToMemCache(5, info);
                }
                if (currentChat.participants_count == 0 || currentChat.left
                        || currentChat instanceof TLRPC.TL_chatForbidden) {
                    return;
                }
                ChatProfileActivity fragment = new ChatProfileActivity();
                Bundle args = new Bundle();
                args.putInt("chat_id", currentChat.id);
                fragment.setArguments(args);
                ((ApplicationActivity) parentActivity).presentFragment(fragment, "chat_" + currentChat.id,
                        swipeOpening);
            }
        }
    });

    TLRPC.FileLocation photo = null;
    int placeHolderId = 0;
    if (currentUser != null) {
        if (currentUser.photo != null) {
            photo = currentUser.photo.photo_small;
        }
        placeHolderId = Utilities.getUserAvatarForId(currentUser.id);
    } else if (currentChat != null) {
        if (currentChat.photo != null) {
            photo = currentChat.photo.photo_small;
        }
        placeHolderId = Utilities.getGroupAvatarForId(currentChat.id);
    }
    avatarImageView.setImage(photo, "50_50", placeHolderId);
}