use of org.telegram.ui.Components.FlickerLoadingView in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatUsersActivity method showItemsAnimated.
private void showItemsAnimated(int from) {
if (isPaused || !openTransitionStarted || (listView.getAdapter() == listViewAdapter && firstLoaded)) {
return;
}
View progressView = null;
for (int i = 0; i < listView.getChildCount(); i++) {
View child = listView.getChildAt(i);
if (child instanceof FlickerLoadingView) {
progressView = child;
}
}
final View finalProgressView = progressView;
if (progressView != null) {
listView.removeView(progressView);
from--;
}
int finalFrom = from;
listView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
listView.getViewTreeObserver().removeOnPreDrawListener(this);
int n = listView.getChildCount();
AnimatorSet animatorSet = new AnimatorSet();
for (int i = 0; i < n; i++) {
View child = listView.getChildAt(i);
if (child == finalProgressView || listView.getChildAdapterPosition(child) < finalFrom) {
continue;
}
child.setAlpha(0);
int s = Math.min(listView.getMeasuredHeight(), Math.max(0, child.getTop()));
int delay = (int) ((s / (float) listView.getMeasuredHeight()) * 100);
ObjectAnimator a = ObjectAnimator.ofFloat(child, View.ALPHA, 0, 1f);
a.setStartDelay(delay);
a.setDuration(200);
animatorSet.playTogether(a);
}
if (finalProgressView != null && finalProgressView.getParent() == null) {
listView.addView(finalProgressView);
RecyclerView.LayoutManager layoutManager = listView.getLayoutManager();
if (layoutManager != null) {
layoutManager.ignoreView(finalProgressView);
Animator animator = ObjectAnimator.ofFloat(finalProgressView, View.ALPHA, finalProgressView.getAlpha(), 0);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
finalProgressView.setAlpha(1f);
layoutManager.stopIgnoringView(finalProgressView);
listView.removeView(finalProgressView);
}
});
animator.start();
}
}
animatorSet.start();
return true;
}
});
}
use of org.telegram.ui.Components.FlickerLoadingView in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatUsersActivity method createView.
@Override
public View createView(Context context) {
searching = false;
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
if (type == TYPE_KICKED) {
actionBar.setTitle(LocaleController.getString("ChannelPermissions", R.string.ChannelPermissions));
} else if (type == TYPE_BANNED) {
actionBar.setTitle(LocaleController.getString("ChannelBlacklist", R.string.ChannelBlacklist));
} else if (type == TYPE_ADMIN) {
actionBar.setTitle(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators));
} else if (type == TYPE_USERS) {
if (selectType == SELECT_TYPE_MEMBERS) {
if (isChannel) {
actionBar.setTitle(LocaleController.getString("ChannelSubscribers", R.string.ChannelSubscribers));
} else {
actionBar.setTitle(LocaleController.getString("ChannelMembers", R.string.ChannelMembers));
}
} else {
if (selectType == SELECT_TYPE_ADMIN) {
actionBar.setTitle(LocaleController.getString("ChannelAddAdmin", R.string.ChannelAddAdmin));
} else if (selectType == SELECT_TYPE_BLOCK) {
actionBar.setTitle(LocaleController.getString("ChannelBlockUser", R.string.ChannelBlockUser));
} else if (selectType == SELECT_TYPE_EXCEPTION) {
actionBar.setTitle(LocaleController.getString("ChannelAddException", R.string.ChannelAddException));
}
}
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
if (checkDiscard()) {
finishFragment();
}
} else if (id == done_button) {
processDone();
}
}
});
if (selectType != SELECT_TYPE_MEMBERS || type == TYPE_USERS || type == TYPE_BANNED || type == TYPE_KICKED) {
searchListViewAdapter = new SearchAdapter(context);
ActionBarMenu menu = actionBar.createMenu();
searchItem = menu.addItem(search_button, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
@Override
public void onSearchExpand() {
searching = true;
if (doneItem != null) {
doneItem.setVisibility(View.GONE);
}
}
@Override
public void onSearchCollapse() {
searchListViewAdapter.searchUsers(null);
searching = false;
listView.setAnimateEmptyView(false, 0);
listView.setAdapter(listViewAdapter);
listViewAdapter.notifyDataSetChanged();
listView.setFastScrollVisible(true);
listView.setVerticalScrollBarEnabled(false);
if (doneItem != null) {
doneItem.setVisibility(View.VISIBLE);
}
}
@Override
public void onTextChanged(EditText editText) {
if (searchListViewAdapter == null) {
return;
}
String text = editText.getText().toString();
int oldItemsCount = listView.getAdapter() == null ? 0 : listView.getAdapter().getItemCount();
searchListViewAdapter.searchUsers(text);
if (TextUtils.isEmpty(text) && listView != null && listView.getAdapter() != listViewAdapter) {
listView.setAnimateEmptyView(false, 0);
listView.setAdapter(listViewAdapter);
if (oldItemsCount == 0) {
showItemsAnimated(0);
}
}
progressBar.setVisibility(View.GONE);
flickerLoadingView.setVisibility(View.VISIBLE);
}
});
if (type == TYPE_KICKED) {
searchItem.setSearchFieldHint(LocaleController.getString("ChannelSearchException", R.string.ChannelSearchException));
} else {
searchItem.setSearchFieldHint(LocaleController.getString("Search", R.string.Search));
}
if (!(ChatObject.isChannel(currentChat) || currentChat.creator)) {
searchItem.setVisibility(View.GONE);
}
if (type == TYPE_KICKED) {
doneItem = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56), LocaleController.getString("Done", R.string.Done));
}
}
fragmentView = new FrameLayout(context) {
@Override
protected void dispatchDraw(Canvas canvas) {
canvas.drawColor(Theme.getColor(listView.getAdapter() == searchListViewAdapter ? Theme.key_windowBackgroundWhite : Theme.key_windowBackgroundGray));
super.dispatchDraw(canvas);
}
};
FrameLayout frameLayout = (FrameLayout) fragmentView;
FrameLayout progressLayout = new FrameLayout(context);
flickerLoadingView = new FlickerLoadingView(context);
flickerLoadingView.setViewType(FlickerLoadingView.USERS_TYPE);
flickerLoadingView.showDate(false);
flickerLoadingView.setUseHeaderOffset(true);
progressLayout.addView(flickerLoadingView);
progressBar = new RadialProgressView(context);
progressLayout.addView(progressBar, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
flickerLoadingView.setVisibility(View.GONE);
progressBar.setVisibility(View.GONE);
emptyView = new StickerEmptyView(context, progressLayout, StickerEmptyView.STICKER_TYPE_SEARCH);
emptyView.title.setText(LocaleController.getString("NoResult", R.string.NoResult));
emptyView.subtitle.setText(LocaleController.getString("SearchEmptyViewFilteredSubtitle2", R.string.SearchEmptyViewFilteredSubtitle2));
emptyView.setVisibility(View.GONE);
emptyView.setAnimateLayoutChange(true);
emptyView.showProgress(true, false);
frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
emptyView.addView(progressLayout, 0);
listView = new RecyclerListView(context) {
@Override
public void invalidate() {
super.invalidate();
if (fragmentView != null) {
fragmentView.invalidate();
}
}
};
listView.setLayoutManager(layoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) {
@Override
public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
if (!firstLoaded && type == TYPE_BANNED && participants.size() == 0) {
return 0;
}
return super.scrollVerticallyBy(dy, recycler, state);
}
});
DefaultItemAnimator itemAnimator = new DefaultItemAnimator() {
@Override
protected long getAddAnimationDelay(long removeDuration, long moveDuration, long changeDuration) {
return 0;
}
@Override
protected long getMoveAnimationDelay() {
return 0;
}
@Override
public long getMoveDuration() {
return 220;
}
@Override
public long getRemoveDuration() {
return 220;
}
@Override
public long getAddDuration() {
return 220;
}
int animationIndex = -1;
@Override
protected void onAllAnimationsDone() {
super.onAllAnimationsDone();
getNotificationCenter().onAnimationFinish(animationIndex);
}
@Override
public void runPendingAnimations() {
boolean removalsPending = !mPendingRemovals.isEmpty();
boolean movesPending = !mPendingMoves.isEmpty();
boolean changesPending = !mPendingChanges.isEmpty();
boolean additionsPending = !mPendingAdditions.isEmpty();
if (removalsPending || movesPending || additionsPending || changesPending) {
animationIndex = getNotificationCenter().setAnimationInProgress(animationIndex, null);
}
super.runPendingAnimations();
}
};
listView.setItemAnimator(itemAnimator);
itemAnimator.setSupportsChangeAnimations(false);
listView.setAnimateEmptyView(true, 0);
listView.setAdapter(listViewAdapter = new ListAdapter(context));
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? RecyclerListView.SCROLLBAR_POSITION_LEFT : RecyclerListView.SCROLLBAR_POSITION_RIGHT);
frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
listView.setOnItemClickListener((view, position) -> {
boolean listAdapter = listView.getAdapter() == listViewAdapter;
if (listAdapter) {
if (position == addNewRow) {
if (type == TYPE_BANNED || type == TYPE_KICKED) {
Bundle bundle = new Bundle();
bundle.putLong("chat_id", chatId);
bundle.putInt("type", ChatUsersActivity.TYPE_USERS);
bundle.putInt("selectType", type == TYPE_BANNED ? ChatUsersActivity.SELECT_TYPE_BLOCK : ChatUsersActivity.SELECT_TYPE_EXCEPTION);
ChatUsersActivity fragment = new ChatUsersActivity(bundle);
fragment.setInfo(info);
fragment.setDelegate(new ChatUsersActivityDelegate() {
@Override
public void didAddParticipantToList(long uid, TLObject participant) {
if (participantsMap.get(uid) == null) {
DiffCallback diffCallback = saveState();
participants.add(participant);
participantsMap.put(uid, participant);
sortUsers(participants);
updateListAnimated(diffCallback);
}
}
@Override
public void didKickParticipant(long uid) {
if (participantsMap.get(uid) == null) {
DiffCallback diffCallback = saveState();
TLRPC.TL_channelParticipantBanned chatParticipant = new TLRPC.TL_channelParticipantBanned();
if (uid > 0) {
chatParticipant.peer = new TLRPC.TL_peerUser();
chatParticipant.peer.user_id = uid;
} else {
chatParticipant.peer = new TLRPC.TL_peerChannel();
chatParticipant.peer.channel_id = -uid;
}
chatParticipant.date = getConnectionsManager().getCurrentTime();
chatParticipant.kicked_by = getAccountInstance().getUserConfig().clientUserId;
info.kicked_count++;
participants.add(chatParticipant);
participantsMap.put(uid, chatParticipant);
sortUsers(participants);
updateListAnimated(diffCallback);
}
}
});
presentFragment(fragment);
} else if (type == TYPE_ADMIN) {
Bundle bundle = new Bundle();
bundle.putLong("chat_id", chatId);
bundle.putInt("type", ChatUsersActivity.TYPE_USERS);
bundle.putInt("selectType", ChatUsersActivity.SELECT_TYPE_ADMIN);
ChatUsersActivity fragment = new ChatUsersActivity(bundle);
fragment.setDelegate(new ChatUsersActivityDelegate() {
@Override
public void didAddParticipantToList(long uid, TLObject participant) {
if (participant != null && participantsMap.get(uid) == null) {
DiffCallback diffCallback = saveState();
participants.add(participant);
participantsMap.put(uid, participant);
sortAdmins(participants);
updateListAnimated(diffCallback);
}
}
@Override
public void didChangeOwner(TLRPC.User user) {
onOwnerChaged(user);
}
@Override
public void didSelectUser(long uid) {
final TLRPC.User user = getMessagesController().getUser(uid);
if (user != null) {
AndroidUtilities.runOnUIThread(() -> {
if (BulletinFactory.canShowBulletin(ChatUsersActivity.this)) {
BulletinFactory.createPromoteToAdminBulletin(ChatUsersActivity.this, user.first_name).show();
}
}, 200);
}
if (participantsMap.get(uid) == null) {
DiffCallback diffCallback = saveState();
TLRPC.TL_channelParticipantAdmin chatParticipant = new TLRPC.TL_channelParticipantAdmin();
chatParticipant.peer = new TLRPC.TL_peerUser();
chatParticipant.peer.user_id = user.id;
chatParticipant.date = getConnectionsManager().getCurrentTime();
chatParticipant.promoted_by = getAccountInstance().getUserConfig().clientUserId;
participants.add(chatParticipant);
participantsMap.put(user.id, chatParticipant);
sortAdmins(participants);
updateListAnimated(diffCallback);
}
}
});
fragment.setInfo(info);
presentFragment(fragment);
} else if (type == TYPE_USERS) {
Bundle args = new Bundle();
args.putBoolean("addToGroup", true);
args.putLong(isChannel ? "channelId" : "chatId", currentChat.id);
GroupCreateActivity fragment = new GroupCreateActivity(args);
fragment.setInfo(info);
fragment.setIgnoreUsers(contactsMap != null && contactsMap.size() != 0 ? contactsMap : participantsMap);
fragment.setDelegate(new GroupCreateActivity.ContactsAddActivityDelegate() {
@Override
public void didSelectUsers(ArrayList<TLRPC.User> users, int fwdCount) {
DiffCallback savedState = saveState();
ArrayList<TLObject> array = contactsMap != null && contactsMap.size() != 0 ? contacts : participants;
LongSparseArray<TLObject> map = contactsMap != null && contactsMap.size() != 0 ? contactsMap : participantsMap;
int k = 0;
for (int a = 0, N = users.size(); a < N; a++) {
TLRPC.User user = users.get(a);
getMessagesController().addUserToChat(chatId, user, fwdCount, null, ChatUsersActivity.this, null);
getMessagesController().putUser(user, false);
if (map.get(user.id) == null) {
if (ChatObject.isChannel(currentChat)) {
TLRPC.TL_channelParticipant channelParticipant1 = new TLRPC.TL_channelParticipant();
channelParticipant1.inviter_id = getUserConfig().getClientUserId();
channelParticipant1.peer = new TLRPC.TL_peerUser();
channelParticipant1.peer.user_id = user.id;
channelParticipant1.date = getConnectionsManager().getCurrentTime();
array.add(k, channelParticipant1);
k++;
map.put(user.id, channelParticipant1);
} else {
TLRPC.ChatParticipant participant = new TLRPC.TL_chatParticipant();
participant.user_id = user.id;
participant.inviter_id = getUserConfig().getClientUserId();
array.add(k, participant);
k++;
map.put(user.id, participant);
}
}
}
if (array == participants) {
sortAdmins(participants);
}
updateListAnimated(savedState);
}
@Override
public void needAddBot(TLRPC.User user) {
openRightsEdit(user.id, null, null, null, "", true, ChatRightsEditActivity.TYPE_ADMIN, false);
}
});
presentFragment(fragment);
}
return;
} else if (position == recentActionsRow) {
presentFragment(new ChannelAdminLogActivity(currentChat));
return;
} else if (position == removedUsersRow) {
Bundle args = new Bundle();
args.putLong("chat_id", chatId);
args.putInt("type", ChatUsersActivity.TYPE_BANNED);
ChatUsersActivity fragment = new ChatUsersActivity(args);
fragment.setInfo(info);
presentFragment(fragment);
return;
} else if (position == gigaConvertRow) {
showDialog(new GigagroupConvertAlert(getParentActivity(), ChatUsersActivity.this) {
@Override
protected void onCovert() {
getMessagesController().convertToGigaGroup(getParentActivity(), currentChat, ChatUsersActivity.this, (result) -> {
if (result && parentLayout != null) {
BaseFragment editActivity = parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 2);
if (editActivity instanceof ChatEditActivity) {
editActivity.removeSelfFromStack();
Bundle args = new Bundle();
args.putLong("chat_id", chatId);
ChatEditActivity fragment = new ChatEditActivity(args);
fragment.setInfo(info);
parentLayout.addFragmentToStack(fragment, parentLayout.fragmentsStack.size() - 1);
finishFragment();
fragment.showConvertTooltip();
} else {
finishFragment();
}
}
});
}
@Override
protected void onCancel() {
}
});
} else if (position == addNew2Row) {
ManageLinksActivity fragment = new ManageLinksActivity(chatId, 0, 0);
fragment.setInfo(info, info.exported_invite);
presentFragment(fragment);
return;
} else if (position > permissionsSectionRow && position <= changeInfoRow) {
TextCheckCell2 checkCell = (TextCheckCell2) view;
if (!checkCell.isEnabled()) {
return;
}
if (checkCell.hasIcon()) {
if (!TextUtils.isEmpty(currentChat.username) && (position == pinMessagesRow || position == changeInfoRow)) {
BulletinFactory.of(this).createErrorBulletin(LocaleController.getString("EditCantEditPermissionsPublic", R.string.EditCantEditPermissionsPublic)).show();
} else {
BulletinFactory.of(this).createErrorBulletin(LocaleController.getString("EditCantEditPermissions", R.string.EditCantEditPermissions)).show();
}
return;
}
checkCell.setChecked(!checkCell.isChecked());
if (position == changeInfoRow) {
defaultBannedRights.change_info = !defaultBannedRights.change_info;
} else if (position == addUsersRow) {
defaultBannedRights.invite_users = !defaultBannedRights.invite_users;
} else if (position == pinMessagesRow) {
defaultBannedRights.pin_messages = !defaultBannedRights.pin_messages;
} else {
boolean disabled = !checkCell.isChecked();
if (position == sendMessagesRow) {
defaultBannedRights.send_messages = !defaultBannedRights.send_messages;
} else if (position == sendMediaRow) {
defaultBannedRights.send_media = !defaultBannedRights.send_media;
} else if (position == sendStickersRow) {
defaultBannedRights.send_stickers = defaultBannedRights.send_games = defaultBannedRights.send_gifs = defaultBannedRights.send_inline = !defaultBannedRights.send_stickers;
} else if (position == embedLinksRow) {
defaultBannedRights.embed_links = !defaultBannedRights.embed_links;
} else if (position == sendPollsRow) {
defaultBannedRights.send_polls = !defaultBannedRights.send_polls;
}
if (disabled) {
if (defaultBannedRights.view_messages && !defaultBannedRights.send_messages) {
defaultBannedRights.send_messages = true;
RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(sendMessagesRow);
if (holder != null) {
((TextCheckCell2) holder.itemView).setChecked(false);
}
}
if ((defaultBannedRights.view_messages || defaultBannedRights.send_messages) && !defaultBannedRights.send_media) {
defaultBannedRights.send_media = true;
RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(sendMediaRow);
if (holder != null) {
((TextCheckCell2) holder.itemView).setChecked(false);
}
}
if ((defaultBannedRights.view_messages || defaultBannedRights.send_messages) && !defaultBannedRights.send_polls) {
defaultBannedRights.send_polls = true;
RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(sendPollsRow);
if (holder != null) {
((TextCheckCell2) holder.itemView).setChecked(false);
}
}
if ((defaultBannedRights.view_messages || defaultBannedRights.send_messages) && !defaultBannedRights.send_stickers) {
defaultBannedRights.send_stickers = defaultBannedRights.send_games = defaultBannedRights.send_gifs = defaultBannedRights.send_inline = true;
RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(sendStickersRow);
if (holder != null) {
((TextCheckCell2) holder.itemView).setChecked(false);
}
}
if ((defaultBannedRights.view_messages || defaultBannedRights.send_messages) && !defaultBannedRights.embed_links) {
defaultBannedRights.embed_links = true;
RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(embedLinksRow);
if (holder != null) {
((TextCheckCell2) holder.itemView).setChecked(false);
}
}
} else {
if ((!defaultBannedRights.embed_links || !defaultBannedRights.send_inline || !defaultBannedRights.send_media || !defaultBannedRights.send_polls) && defaultBannedRights.send_messages) {
defaultBannedRights.send_messages = false;
RecyclerListView.ViewHolder holder = listView.findViewHolderForAdapterPosition(sendMessagesRow);
if (holder != null) {
((TextCheckCell2) holder.itemView).setChecked(true);
}
}
}
}
return;
}
}
TLRPC.TL_chatBannedRights bannedRights = null;
TLRPC.TL_chatAdminRights adminRights = null;
String rank = "";
final TLObject participant;
long peerId = 0;
long promoted_by = 0;
boolean canEditAdmin = false;
if (listAdapter) {
participant = listViewAdapter.getItem(position);
if (participant instanceof TLRPC.ChannelParticipant) {
TLRPC.ChannelParticipant channelParticipant = (TLRPC.ChannelParticipant) participant;
peerId = MessageObject.getPeerId(channelParticipant.peer);
bannedRights = channelParticipant.banned_rights;
adminRights = channelParticipant.admin_rights;
rank = channelParticipant.rank;
canEditAdmin = !(channelParticipant instanceof TLRPC.TL_channelParticipantAdmin || channelParticipant instanceof TLRPC.TL_channelParticipantCreator) || channelParticipant.can_edit;
if (participant instanceof TLRPC.TL_channelParticipantCreator) {
adminRights = ((TLRPC.TL_channelParticipantCreator) participant).admin_rights;
if (adminRights == null) {
adminRights = new TLRPC.TL_chatAdminRights();
adminRights.change_info = adminRights.post_messages = adminRights.edit_messages = adminRights.delete_messages = adminRights.ban_users = adminRights.invite_users = adminRights.pin_messages = adminRights.add_admins = true;
if (!isChannel) {
adminRights.manage_call = true;
}
}
}
} else if (participant instanceof TLRPC.ChatParticipant) {
TLRPC.ChatParticipant chatParticipant = (TLRPC.ChatParticipant) participant;
peerId = chatParticipant.user_id;
canEditAdmin = currentChat.creator;
if (participant instanceof TLRPC.TL_chatParticipantCreator) {
adminRights = new TLRPC.TL_chatAdminRights();
adminRights.change_info = adminRights.post_messages = adminRights.edit_messages = adminRights.delete_messages = adminRights.ban_users = adminRights.invite_users = adminRights.pin_messages = adminRights.add_admins = true;
if (!isChannel) {
adminRights.manage_call = true;
}
}
}
} else {
TLObject object = searchListViewAdapter.getItem(position);
if (object instanceof TLRPC.User) {
TLRPC.User user = (TLRPC.User) object;
getMessagesController().putUser(user, false);
participant = getAnyParticipant(peerId = user.id);
} else if (object instanceof TLRPC.ChannelParticipant || object instanceof TLRPC.ChatParticipant) {
participant = object;
} else {
participant = null;
}
if (participant instanceof TLRPC.ChannelParticipant) {
TLRPC.ChannelParticipant channelParticipant = (TLRPC.ChannelParticipant) participant;
peerId = MessageObject.getPeerId(channelParticipant.peer);
canEditAdmin = !(channelParticipant instanceof TLRPC.TL_channelParticipantAdmin || channelParticipant instanceof TLRPC.TL_channelParticipantCreator) || channelParticipant.can_edit;
bannedRights = channelParticipant.banned_rights;
adminRights = channelParticipant.admin_rights;
rank = channelParticipant.rank;
} else if (participant instanceof TLRPC.ChatParticipant) {
TLRPC.ChatParticipant chatParticipant = (TLRPC.ChatParticipant) participant;
peerId = chatParticipant.user_id;
canEditAdmin = currentChat.creator;
bannedRights = null;
adminRights = null;
} else if (participant == null) {
canEditAdmin = true;
}
}
if (peerId != 0) {
if (selectType != SELECT_TYPE_MEMBERS) {
if (selectType == SELECT_TYPE_EXCEPTION || selectType == SELECT_TYPE_ADMIN) {
if (selectType != SELECT_TYPE_ADMIN && canEditAdmin && (participant instanceof TLRPC.TL_channelParticipantAdmin || participant instanceof TLRPC.TL_chatParticipantAdmin)) {
final TLRPC.User user = getMessagesController().getUser(peerId);
final TLRPC.TL_chatBannedRights br = bannedRights;
final TLRPC.TL_chatAdminRights ar = adminRights;
final boolean canEdit = canEditAdmin;
final String rankFinal = rank;
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setMessage(LocaleController.formatString("AdminWillBeRemoved", R.string.AdminWillBeRemoved, UserObject.getUserName(user)));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialog, which) -> openRightsEdit(user.id, participant, ar, br, rankFinal, canEdit, selectType == SELECT_TYPE_ADMIN ? 0 : 1, false));
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
} else {
openRightsEdit(peerId, participant, adminRights, bannedRights, rank, canEditAdmin, selectType == SELECT_TYPE_ADMIN ? 0 : 1, selectType == SELECT_TYPE_ADMIN || selectType == SELECT_TYPE_EXCEPTION);
}
} else {
removeParticipant(peerId);
}
} else {
boolean canEdit = false;
if (type == TYPE_ADMIN) {
canEdit = peerId != getUserConfig().getClientUserId() && (currentChat.creator || canEditAdmin);
} else if (type == TYPE_BANNED || type == TYPE_KICKED) {
canEdit = ChatObject.canBlockUsers(currentChat);
}
if (type == TYPE_BANNED || type != TYPE_ADMIN && isChannel || type == TYPE_USERS && selectType == SELECT_TYPE_MEMBERS) {
if (peerId == getUserConfig().getClientUserId()) {
return;
}
Bundle args = new Bundle();
if (peerId > 0) {
args.putLong("user_id", peerId);
} else {
args.putLong("chat_id", -peerId);
}
presentFragment(new ProfileActivity(args));
} else {
if (bannedRights == null) {
bannedRights = new TLRPC.TL_chatBannedRights();
bannedRights.view_messages = true;
bannedRights.send_stickers = true;
bannedRights.send_media = true;
bannedRights.embed_links = true;
bannedRights.send_messages = true;
bannedRights.send_games = true;
bannedRights.send_inline = true;
bannedRights.send_gifs = true;
bannedRights.pin_messages = true;
bannedRights.send_polls = true;
bannedRights.invite_users = true;
bannedRights.change_info = true;
}
ChatRightsEditActivity fragment = new ChatRightsEditActivity(peerId, chatId, adminRights, defaultBannedRights, bannedRights, rank, type == TYPE_ADMIN ? ChatRightsEditActivity.TYPE_ADMIN : ChatRightsEditActivity.TYPE_BANNED, canEdit, participant == null);
fragment.setDelegate(new ChatRightsEditActivity.ChatRightsEditActivityDelegate() {
@Override
public void didSetRights(int rights, TLRPC.TL_chatAdminRights rightsAdmin, TLRPC.TL_chatBannedRights rightsBanned, String rank) {
if (participant instanceof TLRPC.ChannelParticipant) {
TLRPC.ChannelParticipant channelParticipant = (TLRPC.ChannelParticipant) participant;
channelParticipant.admin_rights = rightsAdmin;
channelParticipant.banned_rights = rightsBanned;
channelParticipant.rank = rank;
updateParticipantWithRights(channelParticipant, rightsAdmin, rightsBanned, 0, false);
}
}
@Override
public void didChangeOwner(TLRPC.User user) {
onOwnerChaged(user);
}
});
presentFragment(fragment);
}
}
}
});
listView.setOnItemLongClickListener((view, position) -> !(getParentActivity() == null || listView.getAdapter() != listViewAdapter) && createMenuForParticipant(listViewAdapter.getItem(position), false));
if (searchItem != null) {
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
}
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
}
});
}
undoView = new UndoView(context);
frameLayout.addView(undoView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
updateRows();
listView.setEmptyView(emptyView);
listView.setAnimateEmptyView(false, 0);
if (needOpenSearch) {
searchItem.openSearch(false);
}
return fragmentView;
}
use of org.telegram.ui.Components.FlickerLoadingView in project Telegram-FOSS by Telegram-FOSS-Team.
the class ContactsActivity method createView.
@Override
public View createView(Context context) {
searching = false;
searchWas = false;
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
if (destroyAfterSelect) {
if (returnAsResult) {
actionBar.setTitle(LocaleController.getString("SelectContact", R.string.SelectContact));
} else {
if (createSecretChat) {
actionBar.setTitle(LocaleController.getString("NewSecretChat", R.string.NewSecretChat));
} else {
actionBar.setTitle(LocaleController.getString("NewMessageTitle", R.string.NewMessageTitle));
}
}
} else {
actionBar.setTitle(LocaleController.getString("Contacts", R.string.Contacts));
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
} else if (id == sort_button) {
SharedConfig.toggleSortContactsByName();
sortByName = SharedConfig.sortContactsByName;
listViewAdapter.setSortType(sortByName ? 1 : 2, false);
sortItem.setIcon(sortByName ? R.drawable.contacts_sort_time : R.drawable.contacts_sort_name);
}
}
});
ActionBarMenu menu = actionBar.createMenu();
ActionBarMenuItem item = menu.addItem(search_button, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
@Override
public void onSearchExpand() {
searching = true;
if (floatingButtonContainer != null) {
floatingButtonContainer.setVisibility(View.GONE);
}
if (sortItem != null) {
sortItem.setVisibility(View.GONE);
}
}
@Override
public void onSearchCollapse() {
searchListViewAdapter.searchDialogs(null);
searching = false;
searchWas = false;
listView.setAdapter(listViewAdapter);
listView.setSectionsType(1);
listViewAdapter.notifyDataSetChanged();
listView.setFastScrollVisible(true);
listView.setVerticalScrollBarEnabled(false);
// emptyView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
if (floatingButtonContainer != null) {
floatingButtonContainer.setVisibility(View.VISIBLE);
floatingHidden = true;
floatingButtonContainer.setTranslationY(AndroidUtilities.dp(100));
hideFloatingButton(false);
}
if (sortItem != null) {
sortItem.setVisibility(View.VISIBLE);
}
}
@Override
public void onTextChanged(EditText editText) {
if (searchListViewAdapter == null) {
return;
}
String text = editText.getText().toString();
if (text.length() != 0) {
searchWas = true;
if (listView != null) {
listView.setAdapter(searchListViewAdapter);
listView.setSectionsType(0);
searchListViewAdapter.notifyDataSetChanged();
listView.setFastScrollVisible(false);
listView.setVerticalScrollBarEnabled(true);
}
emptyView.showProgress(true, true);
searchListViewAdapter.searchDialogs(text);
} else {
if (listView != null) {
listView.setAdapter(listViewAdapter);
listView.setSectionsType(1);
}
}
}
});
item.setSearchFieldHint(LocaleController.getString("Search", R.string.Search));
item.setContentDescription(LocaleController.getString("Search", R.string.Search));
if (!createSecretChat && !returnAsResult) {
sortItem = menu.addItem(sort_button, sortByName ? R.drawable.contacts_sort_time : R.drawable.contacts_sort_name);
sortItem.setContentDescription(LocaleController.getString("AccDescrContactSorting", R.string.AccDescrContactSorting));
}
searchListViewAdapter = new SearchAdapter(context, ignoreUsers, allowUsernameSearch, false, false, allowBots, allowSelf, true, 0) {
@Override
protected void onSearchProgressChanged() {
if (!searchInProgress() && getItemCount() == 0) {
emptyView.showProgress(false, true);
}
showItemsAnimated();
}
};
int inviteViaLink;
if (chatId != 0) {
TLRPC.Chat chat = getMessagesController().getChat(chatId);
inviteViaLink = ChatObject.canUserDoAdminAction(chat, ChatObject.ACTION_INVITE) ? 1 : 0;
} else if (channelId != 0) {
TLRPC.Chat chat = getMessagesController().getChat(channelId);
inviteViaLink = ChatObject.canUserDoAdminAction(chat, ChatObject.ACTION_INVITE) && TextUtils.isEmpty(chat.username) ? 2 : 0;
} else {
inviteViaLink = 0;
}
try {
hasGps = ApplicationLoader.applicationContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS);
} catch (Throwable e) {
hasGps = false;
}
listViewAdapter = new ContactsAdapter(context, onlyUsers ? 1 : 0, needPhonebook, ignoreUsers, inviteViaLink, hasGps) {
@Override
public void notifyDataSetChanged() {
super.notifyDataSetChanged();
if (listView != null && listView.getAdapter() == this) {
int count = super.getItemCount();
if (needPhonebook) {
// emptyView.setVisibility(count == 2 ? View.VISIBLE : View.GONE);
listView.setFastScrollVisible(count != 2);
} else {
// emptyView.setVisibility(count == 0 ? View.VISIBLE : View.GONE);
listView.setFastScrollVisible(count != 0);
}
}
}
};
listViewAdapter.setSortType(sortItem != null ? (sortByName ? 1 : 2) : 0, false);
listViewAdapter.setDisableSections(disableSections);
fragmentView = new FrameLayout(context) {
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (listView.getAdapter() == listViewAdapter) {
if (emptyView.getVisibility() == VISIBLE) {
emptyView.setTranslationY(AndroidUtilities.dp(74));
}
} else {
emptyView.setTranslationY(AndroidUtilities.dp(0));
}
}
};
FrameLayout frameLayout = (FrameLayout) fragmentView;
FlickerLoadingView flickerLoadingView = new FlickerLoadingView(context);
flickerLoadingView.setViewType(FlickerLoadingView.USERS_TYPE);
flickerLoadingView.showDate(false);
emptyView = new StickerEmptyView(context, flickerLoadingView, StickerEmptyView.STICKER_TYPE_SEARCH);
emptyView.addView(flickerLoadingView, 0);
emptyView.setAnimateLayoutChange(true);
emptyView.showProgress(true, false);
emptyView.title.setText(LocaleController.getString("NoResult", R.string.NoResult));
emptyView.subtitle.setText(LocaleController.getString("SearchEmptyViewFilteredSubtitle2", R.string.SearchEmptyViewFilteredSubtitle2));
frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
listView = new RecyclerListView(context) {
@Override
public void setPadding(int left, int top, int right, int bottom) {
super.setPadding(left, top, right, bottom);
if (emptyView != null) {
emptyView.setPadding(left, top, right, bottom);
}
}
};
listView.setSectionsType(1);
listView.setVerticalScrollBarEnabled(false);
listView.setFastScrollEnabled(RecyclerListView.FastScroll.LETTER_TYPE);
listView.setLayoutManager(layoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
listView.setAdapter(listViewAdapter);
frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
listView.setEmptyView(emptyView);
listView.setAnimateEmptyView(true, 0);
listView.setOnItemClickListener((view, position) -> {
if (listView.getAdapter() == searchListViewAdapter) {
Object object = searchListViewAdapter.getItem(position);
if (object instanceof TLRPC.User) {
TLRPC.User user = (TLRPC.User) object;
if (searchListViewAdapter.isGlobalSearch(position)) {
ArrayList<TLRPC.User> users = new ArrayList<>();
users.add(user);
getMessagesController().putUsers(users, false);
MessagesStorage.getInstance(currentAccount).putUsersAndChats(users, null, false, true);
}
if (returnAsResult) {
if (ignoreUsers != null && ignoreUsers.indexOfKey(user.id) >= 0) {
return;
}
didSelectResult(user, true, null);
} else {
if (createSecretChat) {
if (user.id == UserConfig.getInstance(currentAccount).getClientUserId()) {
return;
}
creatingChat = true;
SecretChatHelper.getInstance(currentAccount).startSecretChat(getParentActivity(), user);
} else {
Bundle args = new Bundle();
args.putLong("user_id", user.id);
if (getMessagesController().checkCanOpenChat(args, ContactsActivity.this)) {
presentFragment(new ChatActivity(args), true);
}
}
}
} else if (object instanceof String) {
String str = (String) object;
if (!str.equals("section")) {
NewContactActivity activity = new NewContactActivity();
activity.setInitialPhoneNumber(str, true);
presentFragment(activity);
}
}
} else {
int section = listViewAdapter.getSectionForPosition(position);
int row = listViewAdapter.getPositionInSectionForPosition(position);
if (row < 0 || section < 0) {
return;
}
if ((!onlyUsers || inviteViaLink != 0) && section == 0) {
if (needPhonebook) {
if (row == 0) {
presentFragment(new InviteContactsActivity());
} else if (row == 1 && hasGps) {
if (Build.VERSION.SDK_INT >= 23) {
Activity activity = getParentActivity();
if (activity != null) {
if (activity.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
presentFragment(new ActionIntroActivity(ActionIntroActivity.ACTION_TYPE_NEARBY_LOCATION_ACCESS));
return;
}
}
}
boolean enabled = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
LocationManager lm = (LocationManager) ApplicationLoader.applicationContext.getSystemService(Context.LOCATION_SERVICE);
enabled = lm.isLocationEnabled();
} else if (Build.VERSION.SDK_INT >= 19) {
try {
int mode = Settings.Secure.getInt(ApplicationLoader.applicationContext.getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
enabled = (mode != Settings.Secure.LOCATION_MODE_OFF);
} catch (Throwable e) {
FileLog.e(e);
}
}
if (!enabled) {
presentFragment(new ActionIntroActivity(ActionIntroActivity.ACTION_TYPE_NEARBY_LOCATION_ENABLED));
return;
}
presentFragment(new PeopleNearbyActivity());
}
} else if (inviteViaLink != 0) {
if (row == 0) {
presentFragment(new GroupInviteActivity(chatId != 0 ? chatId : channelId));
}
} else {
if (row == 0) {
Bundle args = new Bundle();
presentFragment(new GroupCreateActivity(args), false);
} else if (row == 1) {
Bundle args = new Bundle();
args.putBoolean("onlyUsers", true);
args.putBoolean("destroyAfterSelect", true);
args.putBoolean("createSecretChat", true);
args.putBoolean("allowBots", false);
args.putBoolean("allowSelf", false);
presentFragment(new ContactsActivity(args), false);
} else if (row == 2) {
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
if (!BuildVars.DEBUG_VERSION && preferences.getBoolean("channel_intro", false)) {
Bundle args = new Bundle();
args.putInt("step", 0);
presentFragment(new ChannelCreateActivity(args));
} else {
presentFragment(new ActionIntroActivity(ActionIntroActivity.ACTION_TYPE_CHANNEL_CREATE));
preferences.edit().putBoolean("channel_intro", true).commit();
}
}
}
} else {
Object item1 = listViewAdapter.getItem(section, row);
if (item1 instanceof TLRPC.User) {
TLRPC.User user = (TLRPC.User) item1;
if (returnAsResult) {
if (ignoreUsers != null && ignoreUsers.indexOfKey(user.id) >= 0) {
return;
}
didSelectResult(user, true, null);
} else {
if (createSecretChat) {
creatingChat = true;
SecretChatHelper.getInstance(currentAccount).startSecretChat(getParentActivity(), user);
} else {
Bundle args = new Bundle();
args.putLong("user_id", user.id);
if (getMessagesController().checkCanOpenChat(args, ContactsActivity.this)) {
presentFragment(new ChatActivity(args), true);
}
}
}
} else if (item1 instanceof ContactsController.Contact) {
ContactsController.Contact contact = (ContactsController.Contact) item1;
String usePhone = null;
if (!contact.phones.isEmpty()) {
usePhone = contact.phones.get(0);
}
if (usePhone == null || getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("InviteUser", R.string.InviteUser));
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
final String arg1 = usePhone;
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialogInterface, i) -> {
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", arg1, null));
intent.putExtra("sms_body", ContactsController.getInstance(currentAccount).getInviteText(1));
getParentActivity().startActivityForResult(intent, 500);
} catch (Exception e) {
FileLog.e(e);
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
}
}
}
});
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
private boolean scrollingManually;
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
if (searching && searchWas) {
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
}
scrollingManually = true;
} else {
scrollingManually = false;
}
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (floatingButtonContainer != null && floatingButtonContainer.getVisibility() != View.GONE) {
int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
final View topChild = recyclerView.getChildAt(0);
int firstViewTop = 0;
if (topChild != null) {
firstViewTop = topChild.getTop();
}
boolean goingDown;
boolean changed = true;
if (prevPosition == firstVisibleItem) {
final int topDelta = prevTop - firstViewTop;
goingDown = firstViewTop < prevTop;
changed = Math.abs(topDelta) > 1;
} else {
goingDown = firstVisibleItem > prevPosition;
}
if (changed && scrollUpdated && (goingDown || scrollingManually)) {
hideFloatingButton(goingDown);
}
prevPosition = firstVisibleItem;
prevTop = firstViewTop;
scrollUpdated = true;
}
}
});
if (!createSecretChat && !returnAsResult) {
floatingButtonContainer = new FrameLayout(context);
frameLayout.addView(floatingButtonContainer, LayoutHelper.createFrame((Build.VERSION.SDK_INT >= 21 ? 56 : 60) + 20, (Build.VERSION.SDK_INT >= 21 ? 56 : 60) + 20, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, LocaleController.isRTL ? 4 : 0, 0, LocaleController.isRTL ? 0 : 4, 0));
floatingButtonContainer.setOnClickListener(v -> presentFragment(new NewContactActivity()));
floatingButton = new RLottieImageView(context);
floatingButton.setScaleType(ImageView.ScaleType.CENTER);
Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_chats_actionBackground), Theme.getColor(Theme.key_chats_actionPressedBackground));
if (Build.VERSION.SDK_INT < 21) {
Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow).mutate();
shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
drawable = combinedDrawable;
}
floatingButton.setBackgroundDrawable(drawable);
floatingButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.MULTIPLY));
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
boolean configAnimationsEnabled = preferences.getBoolean("view_animations", true);
floatingButton.setAnimation(configAnimationsEnabled ? R.raw.write_contacts_fab_icon : R.raw.write_contacts_fab_icon_reverse, 52, 52);
floatingButtonContainer.setContentDescription(LocaleController.getString("CreateNewContact", R.string.CreateNewContact));
if (Build.VERSION.SDK_INT >= 21) {
StateListAnimator animator = new StateListAnimator();
animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(floatingButton, View.TRANSLATION_Z, AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
animator.addState(new int[] {}, ObjectAnimator.ofFloat(floatingButton, View.TRANSLATION_Z, AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
floatingButton.setStateListAnimator(animator);
floatingButton.setOutlineProvider(new ViewOutlineProvider() {
@SuppressLint("NewApi")
@Override
public void getOutline(View view, Outline outline) {
outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
}
});
}
floatingButtonContainer.addView(floatingButton, LayoutHelper.createFrame((Build.VERSION.SDK_INT >= 21 ? 56 : 60), (Build.VERSION.SDK_INT >= 21 ? 56 : 60), Gravity.LEFT | Gravity.TOP, 10, 6, 10, 0));
}
if (initialSearchString != null) {
actionBar.openSearchField(initialSearchString, false);
initialSearchString = null;
}
return fragmentView;
}
use of org.telegram.ui.Components.FlickerLoadingView in project Telegram-FOSS by Telegram-FOSS-Team.
the class CallLogActivity method getThemeDescriptions.
@Override
public ArrayList<ThemeDescription> getThemeDescriptions() {
ArrayList<ThemeDescription> themeDescriptions = new ArrayList<>();
ThemeDescription.ThemeDescriptionDelegate cellDelegate = () -> {
if (listView != null) {
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof CallCell) {
CallCell cell = (CallCell) child;
cell.profileSearchCell.update(0);
}
}
}
};
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[] { LocationCell.class, CallCell.class, HeaderCell.class, GroupCallCell.class }, null, null, null, Theme.key_windowBackgroundWhite));
themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundGray));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { View.class }, Theme.dividerPaint, null, null, Theme.key_divider));
themeDescriptions.add(new ThemeDescription(emptyView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { EmptyTextProgressView.class }, new String[] { "emptyTextView1" }, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(emptyView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { EmptyTextProgressView.class }, new String[] { "emptyTextView2" }, null, null, null, Theme.key_emptyListPlaceholder));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { LoadingCell.class }, new String[] { "progressBar" }, null, null, null, Theme.key_progressCircle));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[] { TextInfoPrivacyCell.class }, null, null, null, Theme.key_windowBackgroundGrayShadow));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { TextInfoPrivacyCell.class }, new String[] { "textView" }, null, null, null, Theme.key_windowBackgroundWhiteGrayText4));
themeDescriptions.add(new ThemeDescription(floatingButton, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chats_actionIcon));
themeDescriptions.add(new ThemeDescription(floatingButton, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_chats_actionBackground));
themeDescriptions.add(new ThemeDescription(floatingButton, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_chats_actionPressedBackground));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { CallCell.class }, new String[] { "imageView" }, null, null, null, Theme.key_featuredStickers_addButton));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { CallCell.class }, null, new Drawable[] { Theme.dialogs_verifiedCheckDrawable }, null, Theme.key_chats_verifiedCheck));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { CallCell.class }, null, new Drawable[] { Theme.dialogs_verifiedDrawable }, null, Theme.key_chats_verifiedBackground));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { CallCell.class }, Theme.dialogs_offlinePaint, null, null, Theme.key_windowBackgroundWhiteGrayText3));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { CallCell.class }, Theme.dialogs_onlinePaint, null, null, Theme.key_windowBackgroundWhiteBlueText3));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { CallCell.class }, null, new Paint[] { Theme.dialogs_namePaint[0], Theme.dialogs_namePaint[1], Theme.dialogs_searchNamePaint }, null, null, Theme.key_chats_name));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { CallCell.class }, null, new Paint[] { Theme.dialogs_nameEncryptedPaint[0], Theme.dialogs_nameEncryptedPaint[1], Theme.dialogs_searchNameEncryptedPaint }, null, null, Theme.key_chats_secretName));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { CallCell.class }, null, Theme.avatarDrawables, null, Theme.key_avatar_text));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundRed));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundOrange));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundViolet));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundGreen));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundCyan));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundBlue));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundPink));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { View.class }, null, new Drawable[] { greenDrawable, greenDrawable2, Theme.calllog_msgCallUpRedDrawable, Theme.calllog_msgCallDownRedDrawable }, null, Theme.key_calls_callReceivedGreenIcon));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { View.class }, null, new Drawable[] { redDrawable, Theme.calllog_msgCallUpGreenDrawable, Theme.calllog_msgCallDownGreenDrawable }, null, Theme.key_calls_callReceivedRedIcon));
themeDescriptions.add(new ThemeDescription(flickerLoadingView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[] { ShadowSectionCell.class }, null, null, null, Theme.key_windowBackgroundGrayShadow));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { HeaderCell.class }, new String[] { "textView" }, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader));
return themeDescriptions;
}
use of org.telegram.ui.Components.FlickerLoadingView in project Telegram-FOSS by Telegram-FOSS-Team.
the class DialogsSearchAdapter method onCreateViewHolder.
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view;
switch(viewType) {
case 0:
view = new ProfileSearchCell(mContext);
break;
case 1:
view = new GraySectionCell(mContext);
break;
case 2:
view = new DialogCell(null, mContext, false, true);
break;
case 3:
FlickerLoadingView flickerLoadingView = new FlickerLoadingView(mContext);
flickerLoadingView.setViewType(FlickerLoadingView.DIALOG_TYPE);
flickerLoadingView.setIsSingleCell(true);
view = flickerLoadingView;
break;
case 4:
view = new HashtagSearchCell(mContext);
break;
case 5:
RecyclerListView horizontalListView = new RecyclerListView(mContext) {
@Override
public boolean onInterceptTouchEvent(MotionEvent e) {
if (getParent() != null && getParent().getParent() != null) {
getParent().getParent().requestDisallowInterceptTouchEvent(canScrollHorizontally(-1) || canScrollHorizontally(1));
}
return super.onInterceptTouchEvent(e);
}
};
horizontalListView.setSelectorRadius(AndroidUtilities.dp(4));
horizontalListView.setSelectorDrawableColor(Theme.getColor(Theme.key_listSelector));
horizontalListView.setTag(9);
horizontalListView.setItemAnimator(null);
horizontalListView.setLayoutAnimation(null);
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext) {
@Override
public boolean supportsPredictiveItemAnimations() {
return false;
}
};
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
horizontalListView.setLayoutManager(layoutManager);
// horizontalListView.setDisallowInterceptTouchEvents(true);
horizontalListView.setAdapter(new CategoryAdapterRecycler(mContext, currentAccount, false));
horizontalListView.setOnItemClickListener((view1, position) -> {
if (delegate != null) {
delegate.didPressedOnSubDialog((Long) view1.getTag());
}
});
horizontalListView.setOnItemLongClickListener((view12, position) -> {
if (delegate != null) {
delegate.needRemoveHint((Long) view12.getTag());
}
return true;
});
view = horizontalListView;
innerListView = horizontalListView;
break;
case 6:
default:
view = new TextCell(mContext, 16, false);
break;
}
if (viewType == 5) {
view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, AndroidUtilities.dp(86)));
} else {
view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT));
}
return new RecyclerListView.Holder(view);
}
Aggregations