use of androidx.core.widget.NestedScrollView in project IITB-App by wncc.
the class EventFragment method inflateViews.
private void inflateViews(final Event event) {
if (getActivity() == null || getView() == null)
return;
eventPicture = (ImageView) getActivity().findViewById(R.id.event_picture_2);
final TextView eventTitle = (TextView) getActivity().findViewById(R.id.event_page_title);
final TextView eventDate = (TextView) getActivity().findViewById(R.id.event_page_date);
final TextView eventDescription = (TextView) getActivity().findViewById(R.id.event_page_description);
goingButton = getActivity().findViewById(R.id.going_button);
interestedButton = getActivity().findViewById(R.id.interested_button);
final ImageButton navigateButton = getActivity().findViewById(R.id.navigate_button);
final ImageButton webEventButton = getActivity().findViewById(R.id.web_event_button);
final ImageButton shareEventButton = getActivity().findViewById(R.id.share_event_button);
if (event.isEventBigImage() || !creatingView) {
Picasso.get().load(event.getEventImageURL()).into(eventPicture);
} else {
Picasso.get().load(Utils.resizeImageUrl(event.getEventImageURL())).into(eventPicture);
}
eventTitle.setText(event.getEventName());
Timestamp timestamp = event.getEventStartTime();
Date Date = new Date(timestamp.getTime());
SimpleDateFormat simpleDateFormatDate = new SimpleDateFormat("dd MMM");
SimpleDateFormat simpleDateFormatTime = new SimpleDateFormat("HH:mm");
// Check for minimal event
if (event.getEventDescription() == null) {
refreshEvent(event);
return;
}
Utils.getMarkwon().setMarkdown(eventDescription, event.getEventDescription());
final List<CardInterface> cardList = new ArrayList<>(event.getEventOfferedAchievements());
cardList.addAll(event.getEventBodies());
final RecyclerView bodyRecyclerView = getActivity().findViewById(R.id.body_card_recycler_view);
GenericAdapter genericAdapter = new GenericAdapter(cardList, this);
bodyRecyclerView.setAdapter(genericAdapter);
bodyRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
// Common
final String timing = simpleDateFormatDate.format(Date) + " | " + simpleDateFormatTime.format(Date);
StringBuilder eventVenueName = new StringBuilder();
for (Venue venue : event.getEventVenues()) {
eventVenueName.append(", ").append(venue.getVenueShortName());
}
// Make the venues clickable
if (eventVenueName.length() > 0) {
// Get the whole string
SpannableString ss = new SpannableString(eventVenueName.toString().substring(2));
// Make each venue clickable
int i = 0;
for (final Venue venue : event.getEventVenues()) {
int length = venue.getVenueShortName().length();
ClickableSpan cs = new ClickableSpan() {
@Override
public void onClick(@NonNull View widget) {
MapFragment mapFragment = MapFragment.newInstance(MapFragment.getPassableName(venue.getVenueShortName()));
((MainActivity) getActivity()).updateFragment(mapFragment);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
if (getActivity() == null || !isAdded())
return;
ds.setColor(getResources().getColor(R.color.primaryTextColor));
ds.setUnderlineText(false);
}
};
ss.setSpan(cs, i, i + length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
i += length + 2;
}
// Setup the text view
eventDate.setText(TextUtils.concat(timing + " | ", ss));
eventDate.setMovementMethod(LinkMovementMethod.getInstance());
} else {
eventDate.setText(TextUtils.concat(timing));
}
interestedButton.setOnClickListener(getInterestedButtonOnClickListener());
goingButton.setOnClickListener(getGoingButtonOnClickListener());
updateGoingInterestedButtonsAppearance(event.getEventUserUes());
if (!event.getEventVenues().isEmpty()) {
if (event.getEventVenues().get(0).getVenueLatitude() == 0) {
navigateButton.setVisibility(View.GONE);
} else {
navigateButton.setOnClickListener(v -> {
Venue primaryVenue = event.getEventVenues().get(0);
Uri gmmIntentUri = Uri.parse("google.navigation:q=" + primaryVenue.getVenueLatitude() + "," + primaryVenue.getVenueLongitude() + "(" + primaryVenue.getVenueName() + ")");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
});
}
} else {
navigateButton.setVisibility(View.GONE);
}
shareEventButton.setOnClickListener(new View.OnClickListener() {
String shareUrl = ShareURLMaker.getEventURL(event);
@Override
public void onClick(View view) {
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_SUBJECT, "Sharing URL");
i.putExtra(Intent.EXTRA_TEXT, shareUrl);
startActivity(Intent.createChooser(i, "Share URL"));
}
});
if (event.getEventWebsiteURL() != null && !event.getEventWebsiteURL().isEmpty()) {
webEventButton.setVisibility(View.VISIBLE);
webEventButton.setOnClickListener(new View.OnClickListener() {
String eventwebURL = event.getEventWebsiteURL();
@Override
public void onClick(View view) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(eventwebURL));
startActivity(browserIntent);
}
});
}
eventPicture.setOnClickListener(v -> zoomImageFromThumb(eventPicture));
mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);
final FloatingActionButton fab = getView().findViewById(R.id.edit_fab);
if (((MainActivity) getActivity()).editEventAccess(event)) {
fab.show();
NestedScrollView nsv = getView().findViewById(R.id.event_scrollview);
nsv.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
if (scrollY > oldScrollY)
fab.hide();
else
fab.show();
});
}
fab.setOnClickListener(v -> {
WebViewFragment webViewFragment = new WebViewFragment();
Bundle bundle = new Bundle();
bundle.putString(Constants.WV_TYPE, Constants.WV_TYPE_UPDATE_EVENT);
bundle.putString(Constants.WV_ID, event.getEventID());
webViewFragment.setArguments(bundle);
((MainActivity) getActivity()).updateFragment(webViewFragment);
});
}
use of androidx.core.widget.NestedScrollView in project IITB-App by wncc.
the class CalendarFragment method showFab.
/**
* Show the fab if we can make events
*/
private void showFab() {
if (((MainActivity) getActivity()).createEventAccess()) {
fab.show();
NestedScrollView nsv = view.findViewById(R.id.calendar_nsv);
nsv.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
if (scrollY > oldScrollY)
fab.hide();
else
fab.show();
}
});
// Handle fab click
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CalendarDay day = ((MaterialCalendarView) view.findViewById(R.id.simpleCalendarView)).getSelectedDate();
String date = day.getYear() + "-" + day.getMonth() + "-" + day.getDay();
WebViewFragment webViewFragment = (new WebViewFragment()).withDate(date);
Bundle bundle = new Bundle();
bundle.putString(Constants.WV_TYPE, Constants.WV_TYPE_ADD_EVENT);
webViewFragment.setArguments(bundle);
((MainActivity) getActivity()).updateFragment(webViewFragment);
}
});
}
}
Aggregations