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