use of net.iGap.observers.interfaces.ToolbarListener 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();
}
use of net.iGap.observers.interfaces.ToolbarListener in project iGap-Android by KianIranian-STDG.
the class NewsPublisherListFrag method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
HelperToolbar mHelperToolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLeftIcon(R.string.icon_back).setListener(new ToolbarListener() {
@Override
public void onLeftIconClickListener(View view) {
popBackStackFragment();
}
}).setLogoShown(true);
binding.toolbar.addView(mHelperToolbar.getView());
binding.pullToRefresh.setOnRefreshListener(() -> {
viewModel.getData();
binding.noItemInListError.setVisibility(View.GONE);
});
binding.rcGroup.setHasFixedSize(true);
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 3);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
binding.rcGroup.setLayoutManager(layoutManager);
viewModel.getData();
onErrorObserver();
onDataChanged();
onProgress();
}
use of net.iGap.observers.interfaces.ToolbarListener in project iGap-Android by KianIranian-STDG.
the class PollFragment method init.
private void init(View view) {
emptyRecycle = view.findViewById(R.id.emptyRecycle);
rcDiscovery = view.findViewById(R.id.rcDiscovery);
pollAdapter = new PollAdapter(getActivity(), new ArrayList<>());
swipeRefreshLayout = view.findViewById(R.id.pullToRefresh);
swipeRefreshLayout.setOnRefreshListener(() -> {
setRefreshing(true);
boolean isSend = updateOrFetchRecycleViewData();
if (!isSend) {
setRefreshing(false);
HelperError.showSnackMessage(getString(R.string.wallet_error_server), false);
}
});
emptyRecycle.setOnClickListener(v -> {
boolean isSend = updateOrFetchRecycleViewData();
if (!isSend) {
HelperError.showSnackMessage(getString(R.string.wallet_error_server), false);
}
});
rcDiscovery.setLayoutManager(new LinearLayoutManager(getContext()));
rcDiscovery.setAdapter(pollAdapter);
mHelperToolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLeftIcon(R.string.icon_back).setLogoShown(true).setListener(new ToolbarListener() {
@Override
public void onLeftIconClickListener(View view) {
popBackStackFragment();
}
});
ViewGroup viewGroup = view.findViewById(R.id.fd_layout_toolbar);
viewGroup.addView(mHelperToolbar.getView());
tryToUpdateOrFetchRecycleViewData(0);
}
use of net.iGap.observers.interfaces.ToolbarListener in project iGap-Android by KianIranian-STDG.
the class IGashtLocationDetailFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
binding.toolbar.addView(HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLogoShown(true).setLeftIcon(R.string.icon_back).setRightIcons(R.string.icon_time).setListener(new ToolbarListener() {
@Override
public void onLeftIconClickListener(View view) {
if (getActivity() != null) {
getActivity().onBackPressed();
}
}
@Override
public void onRightIconClickListener(View view) {
if (getActivity() != null) {
new HelperFragment(getActivity().getSupportFragmentManager(), new IGashtHistoryPlaceListFragment()).setReplace(false).load(true);
}
}
}).getView());
viewModel.getLoadBuyTicketView().observe(getViewLifecycleOwner(), loadBuyTicketView -> {
if (loadBuyTicketView != null) {
FragmentManager fragmentManager = getChildFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
Fragment fragment;
binding.buyTicket.setTextColor(G.themeColor == Theme.DARK ? getResources().getColor(R.color.white) : (loadBuyTicketView ? getResources().getColor(R.color.white) : getResources().getColor(R.color.black)));
binding.detail.setTextColor(G.themeColor == Theme.DARK ? getResources().getColor(R.color.white) : (loadBuyTicketView ? getResources().getColor(R.color.black) : getResources().getColor(R.color.white)));
if (loadBuyTicketView) {
fragment = fragmentManager.findFragmentByTag(IGashtBuyTicketFragment.class.getName());
if (fragment == null) {
fragment = new IGashtBuyTicketFragment();
fragmentTransaction.addToBackStack(fragment.getClass().getName());
}
} else {
fragment = fragmentManager.findFragmentByTag(IGashtLocationSubDetailFragment.class.getName());
if (fragment == null) {
fragment = new IGashtLocationSubDetailFragment();
fragmentTransaction.addToBackStack(fragment.getClass().getName());
}
}
fragmentTransaction.replace(R.id.detailFrame, fragment, fragment.getClass().getName()).commit();
}
});
viewModel.getGoHistoryPage().observe(getViewLifecycleOwner(), voucherNumber -> {
if (voucherNumber != null) {
goToHistoryListPage();
}
});
viewModel.getGoPayment().observe(getViewLifecycleOwner(), orderToken -> {
if (getActivity() != null && orderToken != null) {
new HelperFragment(getActivity().getSupportFragmentManager()).loadPayment(getString(R.string.igasht_title), orderToken, result -> {
if (result.isSuccess()) {
goToHistoryListPage();
}
});
}
});
viewModel.getPaymentError().observe(getViewLifecycleOwner(), isError -> {
if (getContext() != null && isError != null && isError) {
Toast.makeText(getContext(), R.string.error, Toast.LENGTH_SHORT).show();
}
});
}
use of net.iGap.observers.interfaces.ToolbarListener in project iGap-Android by KianIranian-STDG.
the class IGashtLocationListFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
binding.toolbar.addView(HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLeftIcon(R.string.icon_back).setRightIcons(R.string.icon_time).setLogoShown(true).setListener(new ToolbarListener() {
@Override
public void onLeftIconClickListener(View view) {
if (getActivity() != null) {
getActivity().onBackPressed();
}
}
@Override
public void onRightIconClickListener(View view) {
if (getActivity() != null) {
new HelperFragment(getActivity().getSupportFragmentManager(), new IGashtHistoryPlaceListFragment()).setReplace(false).load(true);
}
}
}).getView());
binding.locationListView.addItemDecoration(new DividerItemDecoration(binding.locationListView.getContext(), DividerItemDecoration.VERTICAL));
binding.locationListView.setAdapter(new IGashtLocationListAdapter(viewModel.getSelectedProvinceName(), new IGashtLocationListAdapter.onLocationItemClickListener() {
@Override
public void buyTicket(int position) {
viewModel.buyTicket(position);
}
@Override
public void onItem(int position) {
viewModel.buyTicket(position);
}
}));
viewModel.getLocationList().observe(getViewLifecycleOwner(), data -> {
if (binding.locationListView.getAdapter() instanceof IGashtLocationListAdapter && data != null) {
((IGashtLocationListAdapter) binding.locationListView.getAdapter()).setItems(data);
}
});
viewModel.getGoToLocationDetail().observe(getViewLifecycleOwner(), isGo -> {
if (getActivity() != null && isGo != null) {
if (isGo) {
new HelperFragment(getActivity().getSupportFragmentManager()).setFragment(new IGashtLocationDetailFragment()).setReplace(false).load(true);
} else {
Toast.makeText(getActivity(), R.string.error, Toast.LENGTH_SHORT).show();
}
}
});
}
Aggregations