Search in sources :

Example 1 with NewsApiArg

use of net.iGap.model.news.NewsApiArg in project iGap-Android by KianIranian-STDG.

the class NewsGroupPagerFrag method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    Bundle arg = getArguments();
    String groupID = arg.getString("GroupID");
    HelperToolbar mHelperToolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLeftIcon(R.string.icon_back).setListener(new ToolbarListener() {

        @Override
        public void onLeftIconClickListener(View view) {
            popBackStackFragment();
        }
    }).setDefaultTitle(arg.getString("GroupTitle")).setRoundBackground(// cause of imageView below toolbar use flat toolbar is better than round
    false).setLogoShown(true);
    binding.Toolbar.addView(mHelperToolbar.getView());
    if (!arg.getString("GroupPic").equals(""))
        Glide.with(G.context).load(arg.getString("GroupPic")).placeholder(R.mipmap.news_temp_banner).into(binding.groupImage);
    ViewPager viewPager = binding.secondaryLayout.viewPager;
    tabLayout = binding.secondaryLayout.pagerTabLayout;
    // TabAdapter adapter = new TabAdapter(getFragmentManager());
    NewsListFrag frag = new NewsListFrag();
    frag.setApiArg(new NewsApiArg(1, 10, Integer.parseInt(groupID), NewsApiArg.NewsType.GROUP_NEWS));
    frag.setHandler(news -> {
        Glide.with(G.context).load(news.getImage()).into(binding.groupImage);
        binding.groupTitle.setText(news.getTitle());
        binding.headerNews.setOnClickListener(v -> {
            FragmentManager fragmentManager = getChildFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            Fragment fragment = fragmentManager.findFragmentByTag(NewsDetailFrag.class.getName());
            if (fragment == null) {
                fragment = NewsDetailFrag.newInstance();
                fragmentTransaction.addToBackStack(fragment.getClass().getName());
            }
            Bundle args = new Bundle();
            args.putString("NewsID", news.getId());
            fragment.setArguments(args);
            new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load();
        });
    });
    // adapter.addFragment(frag, getResources().getString(R.string.news_latest));
    NewsListFrag frag2 = new NewsListFrag();
    frag2.setApiArg(new NewsApiArg(1, 10, Integer.parseInt(groupID), NewsApiArg.NewsType.MOST_HITS));
    // adapter.addFragment(frag2, getResources().getString(R.string.news_MHits));
    NewsListFrag frag3 = new NewsListFrag();
    frag3.setApiArg(new NewsApiArg(1, 10, Integer.parseInt(groupID), NewsApiArg.NewsType.CONTROVERSIAL_NEWS));
    // adapter.addFragment(frag3, getResources().getString(R.string.news_ergent));
    // viewPager.setAdapter(adapter);
    tabLayout.setupWithViewPager(viewPager);
    updateFontTabLayout();
}
Also used : Bundle(android.os.Bundle) View(android.view.View) TextView(android.widget.TextView) ViewPager(androidx.viewpager.widget.ViewPager) Fragment(androidx.fragment.app.Fragment) HelperFragment(net.iGap.helper.HelperFragment) BaseFragment(net.iGap.fragments.BaseFragment) FragmentManager(androidx.fragment.app.FragmentManager) NewsApiArg(net.iGap.model.news.NewsApiArg) FragmentTransaction(androidx.fragment.app.FragmentTransaction) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) HelperToolbar(net.iGap.helper.HelperToolbar) HelperFragment(net.iGap.helper.HelperFragment)

Aggregations

Bundle (android.os.Bundle)1 View (android.view.View)1 TextView (android.widget.TextView)1 Fragment (androidx.fragment.app.Fragment)1 FragmentManager (androidx.fragment.app.FragmentManager)1 FragmentTransaction (androidx.fragment.app.FragmentTransaction)1 ViewPager (androidx.viewpager.widget.ViewPager)1 BaseFragment (net.iGap.fragments.BaseFragment)1 HelperFragment (net.iGap.helper.HelperFragment)1 HelperToolbar (net.iGap.helper.HelperToolbar)1 NewsApiArg (net.iGap.model.news.NewsApiArg)1 ToolbarListener (net.iGap.observers.interfaces.ToolbarListener)1