use of app.insti.utils.BodyHeadCard in project IITB-App by wncc.
the class BodyFragment method displayBody.
private void displayBody() {
/* Skip if we're already destroyed */
if (getActivity() == null || getView() == null)
return;
if (body != min_body)
bodyDisplayed = true;
bodyPicture = (ImageView) getActivity().findViewById(R.id.body_picture);
/* Load only low res image if transition is not completed */
if (transitionEnded) {
Utils.loadImageWithPlaceholder(bodyPicture, body.getBodyImageURL());
} else {
Picasso.get().load(Utils.resizeImageUrl(body.getBodyImageURL())).into(bodyPicture);
}
/* Skip for min body */
if (body == min_body) {
return;
}
bodyPicture.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
zoomImageFromThumb(bodyPicture);
final FloatingActionButton fab = getView().findViewById(R.id.edit_fab);
fab.hide();
}
});
mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);
final List<Role> roles = body.getBodyRoles();
final List<User> users = new ArrayList<>();
for (Role role : roles) {
if (role.getRoleUsersDetail() != null) {
for (User user : role.getRoleUsersDetail()) {
user.setCurrentRole(role.getRoleName());
users.add(user);
}
}
}
final List<CardInterface> cards = new ArrayList<>();
cards.add(new BodyHeadCard(body));
addWithTitleCard(cards, body.getBodyEvents(), "Events");
addWithTitleCard(cards, users, "People");
addWithTitleCard(cards, body.getBodyChildren(), "Organizations");
addWithTitleCard(cards, body.getBodyParents(), "Part of");
final RecyclerView recyclerView = (RecyclerView) getActivity().findViewById(R.id.body_recycler_view);
GenericAdapter genericAdapter = new GenericAdapter(cards, this);
recyclerView.setAdapter(genericAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
/* Show update button if role */
if (((MainActivity) getActivity()).editBodyAccess(body)) {
final FloatingActionButton fab = getView().findViewById(R.id.edit_fab);
fab.show();
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (dy > 0)
fab.hide();
else
fab.show();
}
});
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
WebViewFragment webViewFragment = new WebViewFragment();
Bundle bundle = new Bundle();
bundle.putString(Constants.WV_TYPE, Constants.WV_TYPE_UPDATE_BODY);
bundle.putString(Constants.WV_ID, body.getBodyID());
webViewFragment.setArguments(bundle);
((MainActivity) getActivity()).updateFragment(webViewFragment);
}
});
}
}
use of app.insti.utils.BodyHeadCard in project IITB-App by wncc.
the class CardAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int i) {
switch(holder.getItemViewType()) {
case 0:
CardViewHolder viewHolder = (CardViewHolder) holder;
T t = tList.get(i);
viewHolder.title.setText(t.getTitle());
viewHolder.subtitle.setText(t.getSubtitle());
// Set transition names
viewHolder.avatar.setTransitionName(uid + Integer.toString((int) t.getId()) + "_sharedAvatar");
// Set badge if wanted
if (t.getBadge() != 0) {
Picasso.get().load(t.getBadge()).into(viewHolder.badge);
viewHolder.badge.setVisibility(View.VISIBLE);
} else {
viewHolder.badge.setVisibility(View.GONE);
}
if (getBigImageUrl(t) != null) {
// Show big image, hide avatar
viewHolder.bigPicture.setVisibility(View.VISIBLE);
viewHolder.bigPicture.setTransitionName(uid + Integer.toString((int) t.getId()) + "_sharedBigPicture");
viewHolder.avatar.setVisibility(View.GONE);
// Load big image with low resolution as avatar
Utils.loadImageWithPlaceholder(viewHolder.bigPicture, getBigImageUrl(t));
} else {
// Make sure avatar is visible for recycled views
viewHolder.bigPicture.setVisibility(View.GONE);
viewHolder.avatar.setVisibility(View.VISIBLE);
// Build basic request
RequestCreator requestCreator;
if (t.getAvatarUrl() != null && !t.getAvatarUrl().equals(""))
requestCreator = Picasso.get().load(Utils.resizeImageUrl(t.getAvatarUrl()));
else if (getAvatarPlaceholder(t) != 0) {
requestCreator = Picasso.get().load(getAvatarPlaceholder(t));
} else {
return;
}
// Check if we have a placeholder
if (getAvatarPlaceholder(t) != 0) {
requestCreator.placeholder(getAvatarPlaceholder(t));
}
// Load the image
requestCreator.into(viewHolder.avatar);
}
return;
case 2:
TitleViewHolder titleViewHolder = (TitleViewHolder) holder;
titleViewHolder.title.setText(tList.get(i).getTitle());
return;
case 4:
((BodyHeadCard) tList.get(i)).bindView((BodyHeadViewHolder) holder, mFragment);
return;
default:
return;
}
}
Aggregations