本文整理汇总了Java中org.telegram.tgnet.TLRPC.TL_game方法的典型用法代码示例。如果您正苦于以下问题:Java TLRPC.TL_game方法的具体用法?Java TLRPC.TL_game怎么用?Java TLRPC.TL_game使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.telegram.tgnet.TLRPC
的用法示例。
在下文中一共展示了TLRPC.TL_game方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateGameMessageText
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public void generateGameMessageText(TLRPC.User fromUser) {
if (fromUser == null) {
if (messageOwner.from_id > 0) {
fromUser = MessagesController.getInstance().getUser(messageOwner.from_id);
}
}
TLRPC.TL_game game = null;
if (replyMessageObject != null && replyMessageObject.messageOwner.media != null && replyMessageObject.messageOwner.media.game != null) {
game = replyMessageObject.messageOwner.media.game;
}
if (game == null) {
if (fromUser != null && fromUser.id == UserConfig.getClientUserId()) {
messageText = LocaleController.formatString("ActionYouScored", R.string.ActionYouScored, LocaleController.formatPluralString("Points", messageOwner.action.score));
} else {
messageText = replaceWithLink(LocaleController.formatString("ActionUserScored", R.string.ActionUserScored, LocaleController.formatPluralString("Points", messageOwner.action.score)), "un1", fromUser);
}
} else {
if (fromUser != null && fromUser.id == UserConfig.getClientUserId()) {
messageText = LocaleController.formatString("ActionYouScoredInGame", R.string.ActionYouScoredInGame, LocaleController.formatPluralString("Points", messageOwner.action.score));
} else {
messageText = replaceWithLink(LocaleController.formatString("ActionUserScoredInGame", R.string.ActionUserScoredInGame, LocaleController.formatPluralString("Points", messageOwner.action.score)), "un1", fromUser);
}
messageText = replaceWithLink(messageText, "un2", game);
}
}
示例2: replaceWithLink
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public CharSequence replaceWithLink(CharSequence source, String param, TLObject object) {
int start = TextUtils.indexOf(source, param);
if (start >= 0) {
String name;
String id;
if (object instanceof TLRPC.User) {
name = UserObject.getUserName((TLRPC.User) object);
id = "" + ((TLRPC.User) object).id;
} else if (object instanceof TLRPC.Chat) {
name = ((TLRPC.Chat) object).title;
id = "" + -((TLRPC.Chat) object).id;
} else if (object instanceof TLRPC.TL_game) {
TLRPC.TL_game game = (TLRPC.TL_game) object;
name = game.title;
id = "game";
} else {
name = "";
id = "0";
}
SpannableStringBuilder builder = new SpannableStringBuilder(TextUtils.replace(source, new String[]{param}, new String[]{name}));
builder.setSpan(new URLSpanNoUnderlineBold("" + id), start, start + name.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
return builder;
}
return source;
}
示例3: showOpenGameAlert
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public void showOpenGameAlert(final TLRPC.TL_game game, final MessageObject messageObject, final String urlStr, boolean ask, final int uid) {
TLRPC.User user = MessagesController.getInstance().getUser(uid);
if (ask) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
String name;
if (user != null) {
name = ContactsController.formatName(user.first_name, user.last_name);
} else {
name = "";
}
builder.setMessage(LocaleController.formatString("BotPermissionGameAlert", R.string.BotPermissionGameAlert, name));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
showOpenGameAlert(game, messageObject, urlStr, false, uid);
ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE).edit().putBoolean("askgame_" + uid, false).commit();
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
} else {
if (Build.VERSION.SDK_INT >= 21 && !AndroidUtilities.isTablet() && WebviewActivity.supportWebview()) {
if (parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 1) == this) {
presentFragment(new WebviewActivity(urlStr, user != null && !TextUtils.isEmpty(user.username) ? user.username : "", game.title, game.short_name, messageObject));
}
} else {
WebviewActivity.openGameInBrowser(urlStr, messageObject, getParentActivity(), game.short_name, user != null && user.username != null ? user.username : "");
}
}
}
示例4: sendMessage
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public void sendMessage(TLRPC.TL_game game, long peer, TLRPC.ReplyMarkup replyMarkup, HashMap<String, String> params) {
sendMessage(null, null, null, null, null, null, game, peer, null, null, null, true, null, null, replyMarkup, params);
}