Search in sources :

Example 1 with Toolbar

use of net.iGap.messenger.ui.toolBar.Toolbar in project iGap-Android by KianIranian-STDG.

the class NewsMainFrag method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    if (specificGroupID != null && !specificGroupID.equals("") && !specificGroupID.equals("showDetail"))
        openGroupNews(new NewsFPList(getResources().getString(R.string.news_mainTitle), specificGroupID, null));
    else if (specificNewsID != null && !specificNewsID.equals(""))
        openNewsDetail(specificNewsID);
    Toolbar newsMainToolbar = new Toolbar(getContext());
    newsMainToolbar.setTitle(getString(R.string.news_mainTitle));
    newsMainToolbar.setBackIcon(new BackDrawable(false));
    newsMainToolbar.setListener(i -> {
        if (i == -1) {
            popBackStackFragment();
        }
    });
    LinearLayout toolbarLayout = binding.Toolbar;
    toolbarLayout.addView(newsMainToolbar);
    binding.rcMain.setHasFixedSize(true);
    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    binding.rcMain.setLayoutManager(layoutManager);
    binding.pullToRefresh.setOnRefreshListener(() -> {
        viewModel.getNews();
        binding.noItemInListError.setVisibility(View.GONE);
    });
    viewModel.getNews();
    onErrorObserver();
    onDataChanged();
    onProgress();
}
Also used : BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) NewsFPList(net.iGap.model.news.NewsFPList) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) LinearLayout(android.widget.LinearLayout) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) HelperToolbar(net.iGap.helper.HelperToolbar)

Example 2 with Toolbar

use of net.iGap.messenger.ui.toolBar.Toolbar in project iGap-Android by KianIranian-STDG.

the class PopularChannelHomeFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    RecyclerView recyclerView = view.findViewById(R.id.rv_popularChannel_home);
    swipeRefreshLayout = view.findViewById(R.id.sr_popularChannel_home);
    epmtyView = view.findViewById(R.id.emptyRecycle);
    Toolbar popularChannelsToolbar = new Toolbar(getContext());
    popularChannelsToolbar.setBackIcon(new BackDrawable(false));
    popularChannelsToolbar.setTitle(getString(R.string.popular_channel));
    popularChannelsToolbar.setListener(i -> {
        if (i == -1) {
            if (getActivity() != null)
                getActivity().onBackPressed();
        }
    });
    recyclerView.setAdapter(new PopularChannelHomeAdapter(viewModel.getRecyclerItemClick()));
    ((ViewGroup) view.findViewById(R.id.ll_popularChannel_toolBar)).addView(popularChannelsToolbar);
    viewModel.getFirstPageMutableLiveData().observe(getViewLifecycleOwner(), parentChannel -> {
        if (recyclerView.getAdapter() instanceof PopularChannelHomeAdapter && parentChannel != null) {
            ((PopularChannelHomeAdapter) recyclerView.getAdapter()).setData(parentChannel.getData());
        }
    });
    viewModel.getProgressMutableLiveData().observe(getViewLifecycleOwner(), progress -> {
        if (progress != null && progress)
            swipeRefreshLayout.setRefreshing(true);
        else
            swipeRefreshLayout.setRefreshing(false);
    });
    swipeRefreshLayout.setOnRefreshListener(() -> {
        viewModel.getFirstPage();
    });
    viewModel.getEmptyViewMutableLiveData().observe(getViewLifecycleOwner(), visibility -> {
        if (visibility != null)
            epmtyView.setVisibility(visibility);
    });
    viewModel.getGoToMorePage().observe(getViewLifecycleOwner(), data -> {
        if (getActivity() != null && data != null) {
            PopularMoreChannelFragment moreChannelFragment = new PopularMoreChannelFragment();
            Bundle bundle = new Bundle();
            bundle.putString("id", data.getId());
            bundle.putString("title", G.isAppRtl ? data.getTitle() : data.getTitleEn());
            moreChannelFragment.setArguments(bundle);
            new HelperFragment(getActivity().getSupportFragmentManager(), moreChannelFragment).setReplace(false).load(true);
        }
    });
    viewModel.getGoToRoom().observe(getViewLifecycleOwner(), link -> {
        if (getActivity() != null && link != null) {
            HelperUrl.checkUsernameAndGoToRoom(getActivity(), link, HelperUrl.ChatEntry.chat);
        }
    });
    viewModel.getGoToChannel().observe(getViewLifecycleOwner(), data -> {
        if (getActivity() != null && data != null) {
            if (data.isPrivate()) {
                HelperUrl.checkAndJoinToRoom(getActivity(), data.getSlug());
            } else {
                HelperUrl.checkUsernameAndGoToRoom(getActivity(), data.getSlug(), HelperUrl.ChatEntry.chat);
            }
        }
    });
    viewModel.getGoToWebViewPage().observe(getViewLifecycleOwner(), link -> {
        if (getActivity() != null && link != null) {
            new HelperFragment(getActivity().getSupportFragmentManager(), FragmentWebView.newInstance(link, false, null)).setReplace(false).load();
        }
    });
    viewModel.getOpenBrowser().observe(getViewLifecycleOwner(), link -> {
        if (getActivity() != null && link != null) {
            SharedPreferences sharedPreferences = getActivity().getSharedPreferences(SHP_SETTING.FILE_NAME, Context.MODE_PRIVATE);
            int checkedInAppBrowser = sharedPreferences.getInt(SHP_SETTING.KEY_IN_APP_BROWSER, 1);
            if (checkedInAppBrowser == 1 && !HelperUrl.isNeedOpenWithoutBrowser(link)) {
                HelperUrl.openBrowser(link);
            } else {
                HelperUrl.openWithoutBrowser(link);
            }
        }
    });
    epmtyView.setOnClickListener(v -> viewModel.getFirstPage());
}
Also used : PopularChannelHomeAdapter(net.iGap.adapter.items.popularChannel.PopularChannelHomeAdapter) SharedPreferences(android.content.SharedPreferences) ViewGroup(android.view.ViewGroup) Bundle(android.os.Bundle) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) RecyclerView(androidx.recyclerview.widget.RecyclerView) HelperFragment(net.iGap.helper.HelperFragment) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) HelperToolbar(net.iGap.helper.HelperToolbar)

Example 3 with Toolbar

use of net.iGap.messenger.ui.toolBar.Toolbar in project iGap-Android by KianIranian-STDG.

the class EnterCodeQRCodePaymentFragment method initToolbar.

@SuppressLint("ResourceType")
private void initToolbar() {
    mToolbar = new Toolbar(getActivity());
    mToolbar.setTitle(G.isAppRtl ? R.string.logo_igap_fa : R.string.logo_igap_en);
    mToolbar.setBackIcon(new BackDrawable(false));
    mToolbar.setListener(new Toolbar.ToolbarListener() {

        @Override
        public void onItemClick(int i) {
            if (i == -1) {
                getActivity().onBackPressed();
            }
        }
    });
    mBinding.toolbarContainer.addView(mToolbar, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, 64, Gravity.TOP));
}
Also used : BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) SuppressLint(android.annotation.SuppressLint) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) SuppressLint(android.annotation.SuppressLint)

Example 4 with Toolbar

use of net.iGap.messenger.ui.toolBar.Toolbar in project iGap-Android by KianIranian-STDG.

the class ScanCodeQRCodePaymentFragment method initToolbar.

@SuppressLint("ResourceType")
private void initToolbar() {
    mToolbar = new Toolbar(getActivity());
    mToolbar.setTitle(G.isAppRtl ? R.string.logo_igap_fa : R.string.logo_igap_en);
    mToolbar.setBackIcon(new BackDrawable(false));
    mToolbar.setListener(new Toolbar.ToolbarListener() {

        @Override
        public void onItemClick(int i) {
            if (i == -1) {
                getActivity().onBackPressed();
            }
        }
    });
    mBinding.toolbarContainer.addView(mToolbar, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, 64, Gravity.TOP));
}
Also used : BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) SuppressLint(android.annotation.SuppressLint) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) SuppressLint(android.annotation.SuppressLint)

Example 5 with Toolbar

use of net.iGap.messenger.ui.toolBar.Toolbar in project iGap-Android by KianIranian-STDG.

the class MyStatusStoryListFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    if (getContext() == null)
        return super.onCreateView(inflater, container, savedInstanceState);
    Toolbar myStoryToolbar = new Toolbar(getContext());
    myStoryToolbar.setTitle(getString(R.string.my_status));
    myStoryToolbar.setBackIcon(new BackDrawable(false));
    myStoryToolbar.setListener(i -> {
        switch(i) {
            case -1:
                requireActivity().onBackPressed();
                break;
        }
    });
    FrameLayout rootView = new FrameLayout(new ContextThemeWrapper(context, R.style.IGapRootViewStyle));
    rootView.addView(myStoryToolbar, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.TOP));
    recyclerListView = new RecyclerListView(getContext());
    adapter = new ListAdapter();
    recyclerListView.setAdapter(adapter);
    recyclerListView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false));
    recyclerListView.setClipToPadding(false);
    recyclerListView.setVisibility(View.GONE);
    recyclerListView.setPadding(0, 0, 0, LayoutCreator.dp(30));
    rootView.addView(recyclerListView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT, Gravity.TOP, 0, LayoutCreator.getDimen(R.dimen.toolbar_height), 0, 0));
    progressBar = new ProgressBar(context);
    progressBar.setVisibility(View.GONE);
    rootView.addView(progressBar, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER));
    actionButtonsRootView = new LinearLayout(context);
    actionButtonsRootView.setOrientation(LinearLayout.VERTICAL);
    rootView.addView(actionButtonsRootView, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, (isAppRtl ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, 16, 0, 16, 16));
    customStatusActionLayout = new FrameLayout(context);
    Drawable customStatusDrawable = Theme.createSimpleSelectorCircleDrawable(LayoutCreator.dp(56), Theme.getInstance().getToolbarBackgroundColor(context), Theme.getInstance().getAccentColor(context));
    customStatusActionLayout.setBackground(customStatusDrawable);
    IconView customStatusAddButton = new IconView(context);
    customStatusAddButton.setIcon(R.string.icon_edit);
    customStatusAddButton.setIconColor(Color.WHITE);
    customStatusActionLayout.addView(customStatusAddButton);
    actionButtonsRootView.addView(customStatusActionLayout, LayoutCreator.createLinear(42, 42, Gravity.CENTER, 0, 0, 0, 0));
    floatActionLayout = new FrameLayout(context);
    Drawable drawable = Theme.createSimpleSelectorCircleDrawable(LayoutCreator.dp(56), Theme.getInstance().getToolbarBackgroundColor(context), Theme.getInstance().getAccentColor(context));
    floatActionLayout.setBackground(drawable);
    IconView addButton = new IconView(context);
    addButton.setIcon(R.string.icon_camera);
    addButton.setIconColor(Color.WHITE);
    floatActionLayout.addView(addButton);
    actionButtonsRootView.addView(floatActionLayout, LayoutCreator.createLinear(52, 52, Gravity.CENTER, 0, 10, 0, 0));
    return rootView;
}
Also used : IconView(net.iGap.messenger.ui.components.IconView) ContextThemeWrapper(android.view.ContextThemeWrapper) FrameLayout(android.widget.FrameLayout) Drawable(android.graphics.drawable.Drawable) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) RecyclerListView(net.iGap.module.customView.RecyclerListView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ProgressBar(android.widget.ProgressBar) LinearLayout(android.widget.LinearLayout) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) Nullable(androidx.annotation.Nullable)

Aggregations

Toolbar (net.iGap.messenger.ui.toolBar.Toolbar)30 BackDrawable (net.iGap.messenger.ui.toolBar.BackDrawable)29 ViewGroup (android.view.ViewGroup)11 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)11 HelperFragment (net.iGap.helper.HelperFragment)10 Bundle (android.os.Bundle)8 RecyclerView (androidx.recyclerview.widget.RecyclerView)8 Intent (android.content.Intent)7 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)7 FrameLayout (android.widget.FrameLayout)6 Nullable (androidx.annotation.Nullable)6 Fragment (androidx.fragment.app.Fragment)6 View (android.view.View)5 NonNull (androidx.annotation.NonNull)5 DialogAction (com.afollestad.materialdialogs.DialogAction)5 ToolbarItem (net.iGap.messenger.ui.toolBar.ToolbarItem)5 ToolbarItems (net.iGap.messenger.ui.toolBar.ToolbarItems)5 Theme (net.iGap.module.Theme)5 SuppressLint (android.annotation.SuppressLint)4 Gravity (android.view.Gravity)4