Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
- import org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons.InlineKeyboardButton;
- import java.util.ArrayList;
- import java.util.List;
- /**
- *
- * @author Mouamle H. Hameed
- */
- public class InlineKeyboardBuilder {
- private List<List<InlineKeyboardButton>> mKeyboard = new ArrayList<>();
- private List<InlineKeyboardButton> row = null;
- private InlineKeyboardBuilder() { }
- public static InlineKeyboardBuilder create() {
- return new InlineKeyboardBuilder();
- }
- public InlineKeyboardBuilder row() {
- this.row = new ArrayList<>();
- return this;
- }
- public InlineKeyboardBuilder button(String text, String callbackData) {
- row.add(new InlineKeyboardButton().setText(text).setCallbackData(callbackData));
- return this;
- }
- public InlineKeyboardBuilder button(InlineKeyboardButton button) {
- row.add(button);
- return this;
- }
- public InlineKeyboardBuilder endRow() {
- this.mKeyboard.add(this.row);
- this.row = null;
- return this;
- }
- public InlineKeyboardMarkup build() {
- return new InlineKeyboardMarkup().setKeyboard(mKeyboard);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement