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();
}
Aggregations