Search in sources :

Example 1 with NewsFPList

use of net.iGap.model.news.NewsFPList 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 NewsFPList

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

the class NewsMainFrag method initMainRecycler.

private void initMainRecycler(List<NewsFirstPage> data) {
    List<NewsFirstPage> temp = new ArrayList<>(data);
    NewsFirstPageAdapter adapter = new NewsFirstPageAdapter(temp);
    adapter.setCallBack(new NewsFirstPageAdapter.onClickListener() {

        @Override
        public void onButtonClick(NewsMainBTN btn) {
            // open deepLink
            if (btn.getLink() == null || btn.getLink().equals(""))
                return;
            if (btn.getLink().startsWith("igap")) {
                BottomNavigationFragment navigationFragment = (BottomNavigationFragment) getFragmentManager().findFragmentByTag(BottomNavigationFragment.class.getName());
                if (navigationFragment != null)
                    navigationFragment.autoLinkCrawler(btn.getLink().replace("igap://", ""), new DiscoveryFragment.CrawlerStruct.OnDeepValidLink() {

                        @Override
                        public void linkValid(String link) {
                            popBackStackFragment();
                        }

                        @Override
                        public void linkInvalid(String link) {
                            HelperError.showSnackMessage(link + " " + getResources().getString(R.string.link_not_valid), false);
                        }
                    });
            } else {
                // open Link
                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(btn.getLink())) {
                    HelperUrl.openBrowser(btn.getLink());
                } else {
                    HelperUrl.openWithoutBrowser(btn.getLink());
                }
            }
        }

        @Override
        public void onNewsCategoryClick(NewsFPList group) {
            openGroupNews(group);
        }

        @Override
        public void onSliderClick(NewsFPList.NewsContent slide) {
            openNewsDetail(slide.getId());
        }
    });
    binding.rcMain.setAdapter(adapter);
}
Also used : NewsFirstPage(net.iGap.model.news.NewsFirstPage) SharedPreferences(android.content.SharedPreferences) ArrayList(java.util.ArrayList) NewsFPList(net.iGap.model.news.NewsFPList) NewsMainBTN(net.iGap.model.news.NewsMainBTN) BottomNavigationFragment(net.iGap.fragments.BottomNavigationFragment) NewsFirstPageAdapter(net.iGap.adapter.news.NewsFirstPageAdapter)

Aggregations

NewsFPList (net.iGap.model.news.NewsFPList)2 SharedPreferences (android.content.SharedPreferences)1 LinearLayout (android.widget.LinearLayout)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 ArrayList (java.util.ArrayList)1 NewsFirstPageAdapter (net.iGap.adapter.news.NewsFirstPageAdapter)1 BottomNavigationFragment (net.iGap.fragments.BottomNavigationFragment)1 HelperToolbar (net.iGap.helper.HelperToolbar)1 BackDrawable (net.iGap.messenger.ui.toolBar.BackDrawable)1 Toolbar (net.iGap.messenger.ui.toolBar.Toolbar)1 NewsFirstPage (net.iGap.model.news.NewsFirstPage)1 NewsMainBTN (net.iGap.model.news.NewsMainBTN)1