Java Code Examples for org.telegram.ui.Components.EmptyTextProgressView#showTextView()

The following examples show how to use org.telegram.ui.Components.EmptyTextProgressView#showTextView() . 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: CommonGroupsActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 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("GroupsInCommonTitle", R.string.GroupsInCommonTitle));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick()
    {
        @Override
        public void onItemClick(int id)
        {
            if (id == -1)
            {
                finishFragment();
            }
        }
    });

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

    emptyView = new EmptyTextProgressView(context);
    emptyView.setText(LocaleController.getString("NoGroupsInCommon", R.string.NoGroupsInCommon));
    frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    listView = new RecyclerListView(context);
    listView.setEmptyView(emptyView);
    listView.setLayoutManager(layoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
    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) ->
    {
        if (position < 0 || position >= chats.size())
        {
            return;
        }
        TLRPC.Chat chat = chats.get(position);
        Bundle args = new Bundle();
        args.putInt("chat_id", chat.id);
        if (!MessagesController.getInstance(currentAccount).checkCanOpenChat(args, CommonGroupsActivity.this))
        {
            return;
        }
        NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats);
        presentFragment(new ChatActivity(args), true);
    });
    listView.setOnScrollListener(new RecyclerView.OnScrollListener()
    {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
            int visibleItemCount = firstVisibleItem == RecyclerView.NO_POSITION ? 0 : Math.abs(layoutManager.findLastVisibleItemPosition() - firstVisibleItem) + 1;
            if (visibleItemCount > 0)
            {
                int totalItemCount = listViewAdapter.getItemCount();
                if (!endReached && !loading && !chats.isEmpty() && firstVisibleItem + visibleItemCount >= totalItemCount - 5)
                {
                    getChats(chats.get(chats.size() - 1).id, 100);
                }
            }
        }
    });

    if (loading)
    {
        emptyView.showProgress();
    }
    else
    {
        emptyView.showTextView();
    }
    return fragmentView;
}
 
Example 2
Source File: CommonGroupsActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 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("GroupsInCommonTitle", R.string.GroupsInCommonTitle));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick()
    {
        @Override
        public void onItemClick(int id)
        {
            if (id == -1)
            {
                finishFragment();
            }
        }
    });

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

    emptyView = new EmptyTextProgressView(context);
    emptyView.setText(LocaleController.getString("NoGroupsInCommon", R.string.NoGroupsInCommon));
    frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    listView = new RecyclerListView(context);
    listView.setEmptyView(emptyView);
    listView.setLayoutManager(layoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
    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) ->
    {
        if (position < 0 || position >= chats.size())
        {
            return;
        }
        TLRPC.Chat chat = chats.get(position);
        Bundle args = new Bundle();
        args.putInt("chat_id", chat.id);
        if (!MessagesController.getInstance(currentAccount).checkCanOpenChat(args, CommonGroupsActivity.this))
        {
            return;
        }
        NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats);
        presentFragment(new ChatActivity(args), true);
    });
    listView.setOnScrollListener(new RecyclerView.OnScrollListener()
    {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
            int visibleItemCount = firstVisibleItem == RecyclerView.NO_POSITION ? 0 : Math.abs(layoutManager.findLastVisibleItemPosition() - firstVisibleItem) + 1;
            if (visibleItemCount > 0)
            {
                int totalItemCount = listViewAdapter.getItemCount();
                if (!endReached && !loading && !chats.isEmpty() && firstVisibleItem + visibleItemCount >= totalItemCount - 5)
                {
                    getChats(chats.get(chats.size() - 1).id, 100);
                }
            }
        }
    });

    if (loading)
    {
        emptyView.showProgress();
    }
    else
    {
        emptyView.showTextView();
    }
    return fragmentView;
}
 
Example 3
Source File: ArchivedStickersActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    if (currentType == MediaDataController.TYPE_IMAGE) {
        actionBar.setTitle(LocaleController.getString("ArchivedStickers", R.string.ArchivedStickers));
    } else {
        actionBar.setTitle(LocaleController.getString("ArchivedMasks", R.string.ArchivedMasks));
    }
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    listAdapter = new ListAdapter(context);

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

    emptyView = new EmptyTextProgressView(context);
    if (currentType == MediaDataController.TYPE_IMAGE) {
        emptyView.setText(LocaleController.getString("ArchivedStickersEmpty", R.string.ArchivedStickersEmpty));
    } else {
        emptyView.setText(LocaleController.getString("ArchivedMasksEmpty", R.string.ArchivedMasksEmpty));
    }
    frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    if (loadingStickers) {
        emptyView.showProgress();
    } else {
        emptyView.showTextView();
    }

    listView = new RecyclerListView(context);
    listView.setFocusable(true);
    listView.setEmptyView(emptyView);
    listView.setLayoutManager(layoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));

    frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    listView.setAdapter(listAdapter);
    listView.setOnItemClickListener((view, position) -> {
        if (position >= stickersStartRow && position < stickersEndRow && getParentActivity() != null) {
            final TLRPC.StickerSetCovered stickerSet = sets.get(position - stickersStartRow);
            TLRPC.InputStickerSet inputStickerSet;
            if (stickerSet.set.id != 0) {
                inputStickerSet = new TLRPC.TL_inputStickerSetID();
                inputStickerSet.id = stickerSet.set.id;
            } else {
                inputStickerSet = new TLRPC.TL_inputStickerSetShortName();
                inputStickerSet.short_name = stickerSet.set.short_name;
            }
            inputStickerSet.access_hash = stickerSet.set.access_hash;
            final StickersAlert stickersAlert = new StickersAlert(getParentActivity(), ArchivedStickersActivity.this, inputStickerSet, null, null);
            stickersAlert.setInstallDelegate(new StickersAlert.StickersAlertInstallDelegate() {
                @Override
                public void onStickerSetInstalled() {
                    ((ArchivedStickerSetCell) view).setDrawProgress(true, true);
                    installingStickerSets.put(stickerSet.set.id, stickerSet);
                }

                @Override
                public void onStickerSetUninstalled() {
                }
            });
            showDialog(stickersAlert);
        }
    });
    listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (!loadingStickers && !endReached && layoutManager.findLastVisibleItemPosition() > stickersLoadingRow - 2) {
                getStickers();
            }
        }
    });

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

    listAdapter = new ListAdapter(context);

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

    emptyView = new EmptyTextProgressView(context);
    if (currentType == MediaDataController.TYPE_IMAGE) {
        emptyView.setText(LocaleController.getString("ArchivedStickersEmpty", R.string.ArchivedStickersEmpty));
    } else {
        emptyView.setText(LocaleController.getString("ArchivedMasksEmpty", R.string.ArchivedMasksEmpty));
    }
    frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    if (loadingStickers) {
        emptyView.showProgress();
    } else {
        emptyView.showTextView();
    }

    listView = new RecyclerListView(context);
    listView.setFocusable(true);
    listView.setEmptyView(emptyView);
    listView.setLayoutManager(layoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));

    frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    listView.setAdapter(listAdapter);
    listView.setOnItemClickListener((view, position) -> {
        if (position >= stickersStartRow && position < stickersEndRow && getParentActivity() != null) {
            final TLRPC.StickerSetCovered stickerSet = sets.get(position - stickersStartRow);
            TLRPC.InputStickerSet inputStickerSet;
            if (stickerSet.set.id != 0) {
                inputStickerSet = new TLRPC.TL_inputStickerSetID();
                inputStickerSet.id = stickerSet.set.id;
            } else {
                inputStickerSet = new TLRPC.TL_inputStickerSetShortName();
                inputStickerSet.short_name = stickerSet.set.short_name;
            }
            inputStickerSet.access_hash = stickerSet.set.access_hash;
            final StickersAlert stickersAlert = new StickersAlert(getParentActivity(), ArchivedStickersActivity.this, inputStickerSet, null, null);
            stickersAlert.setInstallDelegate(new StickersAlert.StickersAlertInstallDelegate() {
                @Override
                public void onStickerSetInstalled() {
                    ((ArchivedStickerSetCell) view).setDrawProgress(true, true);
                    installingStickerSets.put(stickerSet.set.id, stickerSet);
                }

                @Override
                public void onStickerSetUninstalled() {
                }
            });
            showDialog(stickersAlert);
        }
    });
    listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (!loadingStickers && !endReached && layoutManager.findLastVisibleItemPosition() > stickersLoadingRow - 2) {
                getStickers();
            }
        }
    });

    return fragmentView;
}