org.telegram.ui.Components.RecyclerListView Java Examples

The following examples show how to use org.telegram.ui.Components.RecyclerListView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProfileActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void checkListViewScroll()
{
    if (listView.getChildCount() <= 0 || openAnimationInProgress)
        return;

    View child = listView.getChildAt(0);
    RecyclerListView.Holder holder = (RecyclerListView.Holder) listView.findContainingViewHolder(child);
    int top = child.getTop();
    int newOffset = 0;
    if (top >= 0 && holder != null && holder.getAdapterPosition() == 0)
        newOffset = top;

    if (extraHeight != newOffset)
    {
        extraHeight = newOffset;
        topView.invalidate();
        if (playProfileAnimation)
            allowProfileAnimation = extraHeight != 0;

        needLayout();
    }
}
 
Example #2
Source File: SettingsActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void checkListViewScroll() {
    if (listView.getVisibility() != View.VISIBLE || listView.getChildCount() <= 0 || openAnimationInProgress || writeButton.getVisibility() != View.VISIBLE) {
        return;
    }

    View child = listView.getChildAt(0);
    RecyclerListView.Holder holder = (RecyclerListView.Holder) listView.findContainingViewHolder(child);
    int top = child.getTop();
    int newOffset = 0;
    if (top >= 0 && holder != null && holder.getAdapterPosition() == 0) {
        newOffset = top;
    }
    if (extraHeight != newOffset) {
        extraHeight = newOffset;
        topView.invalidate();
        needLayout();
    }
}
 
Example #3
Source File: SettingsActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void checkListViewScroll() {
    if (listView.getVisibility() != View.VISIBLE || listView.getChildCount() <= 0 || openAnimationInProgress || writeButton.getVisibility() != View.VISIBLE) {
        return;
    }

    View child = listView.getChildAt(0);
    RecyclerListView.Holder holder = (RecyclerListView.Holder) listView.findContainingViewHolder(child);
    int top = child.getTop();
    int newOffset = 0;
    if (top >= 0 && holder != null && holder.getAdapterPosition() == 0) {
        newOffset = top;
    }
    if (extraHeight != newOffset) {
        extraHeight = newOffset;
        topView.invalidate();
        needLayout();
    }
}
 
Example #4
Source File: ProfileActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void checkListViewScroll()
{
    if (listView.getChildCount() <= 0 || openAnimationInProgress)
        return;

    View child = listView.getChildAt(0);
    RecyclerListView.Holder holder = (RecyclerListView.Holder) listView.findContainingViewHolder(child);
    int top = child.getTop();
    int newOffset = 0;
    if (top >= 0 && holder != null && holder.getAdapterPosition() == 0)
        newOffset = top;

    if (extraHeight != newOffset)
    {
        extraHeight = newOffset;
        topView.invalidate();
        if (playProfileAnimation)
            allowProfileAnimation = extraHeight != 0;

        needLayout();
    }
}
 
Example #5
Source File: ThemeActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    switch (viewType) {
        case 0: {
            return new RecyclerListView.Holder(new InnerAccentView(mContext));
        }
        case 1:
        default: {
            return new RecyclerListView.Holder(new InnerCustomAccentView(mContext));
        }
    }
}
 
Example #6
Source File: FeaturedStickerSetInfoCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public static void createThemeDescriptions(List<ThemeDescription> descriptions, RecyclerListView listView, ThemeDescription.ThemeDescriptionDelegate delegate) {
    descriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{FeaturedStickerSetInfoCell.class}, new String[]{"nameTextView"}, null, null, null, Theme.key_chat_emojiPanelTrendingTitle));
    descriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{FeaturedStickerSetInfoCell.class}, new String[]{"infoTextView"}, null, null, null, Theme.key_chat_emojiPanelTrendingDescription));
    descriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{FeaturedStickerSetInfoCell.class}, new String[]{"addButton"}, null, null, null, Theme.key_featuredStickers_buttonText));
    descriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{FeaturedStickerSetInfoCell.class}, new String[]{"delButton"}, null, null, null, Theme.key_featuredStickers_removeButtonText));
    descriptions.add(new ThemeDescription(listView, 0, new Class[]{FeaturedStickerSetInfoCell.class}, null, null, null, Theme.key_featuredStickers_unread));
    descriptions.add(new ThemeDescription(listView, 0, new Class[]{FeaturedStickerSetInfoCell.class}, Theme.dividerPaint, null, null, Theme.key_divider));
    descriptions.add(new ThemeDescription(null, 0, null, null, null, delegate, Theme.key_featuredStickers_buttonProgress));
    descriptions.add(new ThemeDescription(null, 0, null, null, null, delegate, Theme.key_featuredStickers_addButton));
    descriptions.add(new ThemeDescription(null, 0, null, null, null, delegate, Theme.key_featuredStickers_addButtonPressed));
    descriptions.add(new ThemeDescription(null, 0, null, null, null, delegate, Theme.key_windowBackgroundWhiteBlueText4));
    descriptions.add(new ThemeDescription(null, 0, null, null, null, delegate, Theme.key_chat_emojiPanelTrendingDescription));
}
 
Example #7
Source File: AudioSelectActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    AudioCell view = new AudioCell(mContext);
    view.setDelegate(new AudioCell.AudioCellDelegate() {
        @Override
        public void startedPlayingAudio(MessageObject messageObject) {
            playingAudio = messageObject;
        }
    });
    return new RecyclerListView.Holder(view);
}
 
Example #8
Source File: StickersSearchAdapter.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void updateColors(RecyclerListView listView) {
    for (int i = 0, size = listView.getChildCount(); i < size; i++) {
        final View child = listView.getChildAt(i);
        if (child instanceof FeaturedStickerSetInfoCell) {
            ((FeaturedStickerSetInfoCell) child).updateColors();
        } else if (child instanceof StickerSetNameCell) {
            ((StickerSetNameCell) child).updateColors();
        }
    }
}
 
Example #9
Source File: FeaturedStickerSetCell2.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public static void createThemeDescriptions(List<ThemeDescription> descriptions, RecyclerListView listView, ThemeDescription.ThemeDescriptionDelegate delegate) {
    descriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{FeaturedStickerSetCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
    descriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{FeaturedStickerSetCell.class}, new String[]{"valueTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
    descriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{FeaturedStickerSetCell.class}, new String[]{"addButton"}, null, null, null, Theme.key_featuredStickers_buttonText));
    descriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{FeaturedStickerSetCell.class}, new String[]{"delButton"}, null, null, null, Theme.key_featuredStickers_removeButtonText));
    descriptions.add(new ThemeDescription(listView, 0, new Class[]{FeaturedStickerSetCell.class}, Theme.dividerPaint, null, null, Theme.key_divider));
    descriptions.add(new ThemeDescription(null, 0, null, null, null, delegate, Theme.key_featuredStickers_buttonProgress));
    descriptions.add(new ThemeDescription(null, 0, null, null, null, delegate, Theme.key_featuredStickers_addButtonPressed));
}
 
Example #10
Source File: QuickRepliesSettingsActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public View createView(Context context) {
	actionBar.setBackButtonImage(R.drawable.ic_ab_back);
	actionBar.setTitle(LocaleController.getString("VoipQuickReplies", R.string.VoipQuickReplies));
	if (AndroidUtilities.isTablet()) {
		actionBar.setOccupyStatusBar(false);
	}
	actionBar.setAllowOverlayTitle(true);
	actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
		@Override
		public void onItemClick(int id) {
			if (id == -1) {
				finishFragment();
			}
		}
	});

	listAdapter = new ListAdapter(context);

	fragmentView = new FrameLayout(context);
	fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
	FrameLayout frameLayout = (FrameLayout) fragmentView;

	listView = new RecyclerListView(context);
	listView.setVerticalScrollBarEnabled(false);
	listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
	frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
	listView.setAdapter(listAdapter);
	listView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() {
		@Override
		public void onItemClick(View view, final int position) {
		}
	});

	frameLayout.addView(actionBar);

	return fragmentView;
}
 
Example #11
Source File: ChatListItemAnimator.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public ChatListItemAnimator(ChatActivity activity, RecyclerListView listView) {
    this.activity = activity;
    this.recyclerListView = listView;
    translationInterpolator = CubicBezierInterpolator.DEFAULT;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        listView.getElevation();
    }
}
 
Example #12
Source File: ThemeActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    switch (viewType) {
        case 0: {
            return new RecyclerListView.Holder(new InnerAccentView(mContext));
        }
        case 1:
        default: {
            return new RecyclerListView.Holder(new InnerCustomAccentView(mContext));
        }
    }
}
 
Example #13
Source File: DialogsSearchAdapter.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
    View view = new HintDialogCell(mContext);
    view.setLayoutParams(new RecyclerView.LayoutParams(AndroidUtilities.dp(80), AndroidUtilities.dp(100)));
    return new RecyclerListView.Holder(view);
}
 
Example #14
Source File: ChatUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = new ManageChatUserCell(mContext, 2, true);
    view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
    ((ManageChatUserCell) view).setDelegate((cell, click) -> {
        TLObject object = getItem((Integer) cell.getTag());
        if (object instanceof TLRPC.ChatParticipant) {
            TLRPC.ChatParticipant participant = (TLRPC.ChatParticipant) getItem((Integer) cell.getTag());
            return createMenuForParticipant(participant, !click);
        } else {
            return false;
        }
    });
    return new RecyclerListView.Holder(view);
}
 
Example #15
Source File: StickerSetNameCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public static void createThemeDescriptions(List<ThemeDescription> descriptions, RecyclerListView listView, ThemeDescription.ThemeDescriptionDelegate delegate) {
    descriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{StickerSetNameCell.class}, new String[]{"textView"}, null, null, null, Theme.key_chat_emojiPanelStickerSetName));
    descriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{StickerSetNameCell.class}, new String[]{"urlTextView"}, null, null, null, Theme.key_chat_emojiPanelStickerSetName));
    descriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{StickerSetNameCell.class}, new String[]{"buttonView"}, null, null, null, Theme.key_chat_emojiPanelStickerSetNameIcon));
    descriptions.add(new ThemeDescription(null, 0, null, null, null, delegate, Theme.key_chat_emojiPanelStickerSetNameHighlight));
    descriptions.add(new ThemeDescription(null, 0, null, null, null, delegate, Theme.key_chat_emojiPanelStickerSetName));
}
 
Example #16
Source File: ChannelEditActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = new ManageChatUserCell(mContext, 8, true);
    view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
    ((ManageChatUserCell) view).setDelegate((cell, click) -> createMenuForParticipant(null, getItem((Integer) cell.getTag()), !click));
    return new RecyclerListView.Holder(view);
}
 
Example #17
Source File: MediaActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void fixScrollOffset() {
    if (actionBar.getTranslationY() != 0f) {
        final RecyclerListView listView = mediaPages[0].listView;
        final View child = listView.getChildAt(0);
        if (child != null) {
            final int offset = (int) (child.getY() - (actionBar.getMeasuredHeight() + actionBar.getTranslationY() + additionalPadding));
            if (offset > 0) {
                scrollWithoutActionBar(listView, offset);
            }
        }
    }
}
 
Example #18
Source File: QuickRepliesSettingsActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public View createView(Context context) {
	actionBar.setBackButtonImage(R.drawable.ic_ab_back);
	actionBar.setTitle(LocaleController.getString("VoipQuickReplies", R.string.VoipQuickReplies));
	if (AndroidUtilities.isTablet()) {
		actionBar.setOccupyStatusBar(false);
	}
	actionBar.setAllowOverlayTitle(true);
	actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
		@Override
		public void onItemClick(int id) {
			if (id == -1) {
				finishFragment();
			}
		}
	});

	listAdapter = new ListAdapter(context);

	fragmentView = new FrameLayout(context);
	fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
	FrameLayout frameLayout = (FrameLayout) fragmentView;

	listView = new RecyclerListView(context);
	listView.setVerticalScrollBarEnabled(false);
	listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
	frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
	listView.setAdapter(listAdapter);
	listView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() {
		@Override
		public void onItemClick(View view, final int position) {
		}
	});

	frameLayout.addView(actionBar);

	return fragmentView;
}
 
Example #19
Source File: DialogsSearchAdapter.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
    View view = new HintDialogCell(mContext);
    view.setLayoutParams(new RecyclerView.LayoutParams(AndroidUtilities.dp(80), AndroidUtilities.dp(100)));
    return new RecyclerListView.Holder(view);
}
 
Example #20
Source File: StickersSearchAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void updateColors(RecyclerListView listView) {
    for (int i = 0, size = listView.getChildCount(); i < size; i++) {
        final View child = listView.getChildAt(i);
        if (child instanceof FeaturedStickerSetInfoCell) {
            ((FeaturedStickerSetInfoCell) child).updateColors();
        } else if (child instanceof StickerSetNameCell) {
            ((StickerSetNameCell) child).updateColors();
        }
    }
}
 
Example #21
Source File: MediaActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void fixScrollOffset() {
    if (actionBar.getTranslationY() != 0f) {
        final RecyclerListView listView = mediaPages[0].listView;
        final View child = listView.getChildAt(0);
        if (child != null) {
            final int offset = (int) (child.getY() - (actionBar.getMeasuredHeight() + actionBar.getTranslationY() + additionalPadding));
            if (offset > 0) {
                scrollWithoutActionBar(listView, offset);
            }
        }
    }
}
 
Example #22
Source File: AudioSelectActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    AudioCell view = new AudioCell(mContext);
    view.setDelegate(new AudioCell.AudioCellDelegate() {
        @Override
        public void startedPlayingAudio(MessageObject messageObject) {
            playingAudio = messageObject;
        }
    });
    return new RecyclerListView.Holder(view);
}
 
Example #23
Source File: ChatUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = new ManageChatUserCell(mContext, 2, true);
    view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
    ((ManageChatUserCell) view).setDelegate((cell, click) -> {
        TLObject object = getItem((Integer) cell.getTag());
        if (object instanceof TLRPC.ChatParticipant) {
            TLRPC.ChatParticipant participant = (TLRPC.ChatParticipant) getItem((Integer) cell.getTag());
            return createMenuForParticipant(participant, !click);
        } else {
            return false;
        }
    });
    return new RecyclerListView.Holder(view);
}
 
Example #24
Source File: QuickRepliesSettingsActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public View createView(Context context) {
	actionBar.setBackButtonImage(R.drawable.ic_ab_back);
	actionBar.setTitle(LocaleController.getString("VoipQuickReplies", R.string.VoipQuickReplies));
	if (AndroidUtilities.isTablet()) {
		actionBar.setOccupyStatusBar(false);
	}
	actionBar.setAllowOverlayTitle(true);
	actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
		@Override
		public void onItemClick(int id) {
			if (id == -1) {
				finishFragment();
			}
		}
	});

	listAdapter = new ListAdapter(context);

	fragmentView = new FrameLayout(context);
	fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
	FrameLayout frameLayout = (FrameLayout) fragmentView;

	listView = new RecyclerListView(context);
	listView.setVerticalScrollBarEnabled(false);
	listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
	frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
	listView.setAdapter(listAdapter);

	return fragmentView;
}
 
Example #25
Source File: FiltersSetupActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("Filters", R.string.Filters));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));

    listView = new RecyclerListView(context);
    ((DefaultItemAnimator) listView.getItemAnimator()).setDelayAnimations(false);
    listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
    listView.setVerticalScrollBarEnabled(false);
    itemTouchHelper = new ItemTouchHelper(new TouchHelperCallback());
    itemTouchHelper.attachToRecyclerView(listView);
    frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    listView.setAdapter(adapter = new ListAdapter(context));
    listView.setOnItemClickListener((view, position, x, y) -> {
        if (position >= filtersStartRow && position < filtersEndRow) {
            presentFragment(new FilterCreateActivity(getMessagesController().dialogFilters.get(position - filtersStartRow)));
        } else if (position == createFilterRow) {
            presentFragment(new FilterCreateActivity());
        }
    });

    return fragmentView;
}
 
Example #26
Source File: ChannelEditActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = new ManageChatUserCell(mContext, 8, true);
    view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
    ((ManageChatUserCell) view).setDelegate((cell, click) -> createMenuForParticipant(null, getItem((Integer) cell.getTag()), !click));
    return new RecyclerListView.Holder(view);
}
 
Example #27
Source File: ChatListItemAnimator.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public ChatListItemAnimator(ChatActivity activity, RecyclerListView listView) {
    this.activity = activity;
    this.recyclerListView = listView;
    translationInterpolator = CubicBezierInterpolator.DEFAULT;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        listView.getElevation();
    }
}
 
Example #28
Source File: FiltersSetupActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("Filters", R.string.Filters));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));

    listView = new RecyclerListView(context);
    ((DefaultItemAnimator) listView.getItemAnimator()).setDelayAnimations(false);
    listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
    listView.setVerticalScrollBarEnabled(false);
    itemTouchHelper = new ItemTouchHelper(new TouchHelperCallback());
    itemTouchHelper.attachToRecyclerView(listView);
    frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    listView.setAdapter(adapter = new ListAdapter(context));
    listView.setOnItemClickListener((view, position, x, y) -> {
        if (position >= filtersStartRow && position < filtersEndRow) {
            presentFragment(new FilterCreateActivity(getMessagesController().dialogFilters.get(position - filtersStartRow)));
        } else if (position == createFilterRow) {
            presentFragment(new FilterCreateActivity());
        }
    });

    return fragmentView;
}
 
Example #29
Source File: QuickRepliesSettingsActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public View createView(Context context) {
	actionBar.setBackButtonImage(R.drawable.ic_ab_back);
	actionBar.setTitle(LocaleController.getString("VoipQuickReplies", R.string.VoipQuickReplies));
	if (AndroidUtilities.isTablet()) {
		actionBar.setOccupyStatusBar(false);
	}
	actionBar.setAllowOverlayTitle(true);
	actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
		@Override
		public void onItemClick(int id) {
			if (id == -1) {
				finishFragment();
			}
		}
	});

	listAdapter = new ListAdapter(context);

	fragmentView = new FrameLayout(context);
	fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
	FrameLayout frameLayout = (FrameLayout) fragmentView;

	listView = new RecyclerListView(context);
	listView.setVerticalScrollBarEnabled(false);
	listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
	frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
	listView.setAdapter(listAdapter);

	return fragmentView;
}
 
Example #30
Source File: ThemePreviewActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    PatternCell view = new PatternCell(mContext, maxWallpaperSize, new PatternCell.PatternCellDelegate() {
        @Override
        public TLRPC.TL_wallPaper getSelectedPattern() {
            return selectedPattern;
        }

        @Override
        public int getPatternColor() {
            return patternColor;
        }

        @Override
        public int getBackgroundColor() {
            if (screenType == SCREEN_TYPE_CHANGE_BACKGROUND) {
                return backgroundColor;
            }
            int defaultBackground = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper);
            int backgroundOverrideColor = (int) accent.backgroundOverrideColor;
            return backgroundOverrideColor != 0 ? backgroundOverrideColor : defaultBackground;
        }

        @Override
        public int getBackgroundGradientColor() {
            if (screenType == SCREEN_TYPE_CHANGE_BACKGROUND) {
                return backgroundGradientColor;
            }
            int defaultBackgroundGradient = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to);
            int backgroundGradientOverrideColor = (int) accent.backgroundGradientOverrideColor;
            return backgroundGradientOverrideColor != 0 ? backgroundGradientOverrideColor : defaultBackgroundGradient;
        }

        @Override
        public int getBackgroundGradientAngle() {
            if (screenType == SCREEN_TYPE_CHANGE_BACKGROUND) {
                return backgroundRotation;
            }
            return accent.backgroundRotation;
        }
    });
    return new RecyclerListView.Holder(view);
}