use of br.ufrj.caronae.RoundedTransformation in project caronae-android by caronae.
the class RidersAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final User user = users.get(position);
String profilePicUrl = user.getProfilePicUrl();
if (profilePicUrl != null && !profilePicUrl.isEmpty())
Picasso.with(activity).load(profilePicUrl).placeholder(R.drawable.user_pic).error(R.drawable.user_pic).transform(new RoundedTransformation()).into(holder.photo_iv);
holder.name_tv.setText(user.getName().split(" ")[0]);
if (user.getDbId() != App.getUser().getDbId()) {
// dont allow user to open own profile
holder.photo_iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(activity, ProfileAct.class);
intent.putExtra("user", new Gson().toJson(user));
Class openScreenClass = activity.getClass();
String riders = openScreenClass == ActiveRideAct.class ? "activeRides" : openScreenClass.getSimpleName();
intent.putExtra("from", riders);
activity.startActivity(intent);
}
});
}
}
use of br.ufrj.caronae.RoundedTransformation in project caronae-android by caronae.
the class MyProfileFrag method userPic.
@OnClick(R.id.user_pic)
public void userPic() {
SimpleDialog.Builder builder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
final User user = App.getUser();
if (getSelectedValue().toString().equals(getString(R.string.frag_myprofile_facePicChoice))) {
Profile profile = Profile.getCurrentProfile();
if (profile != null) {
String faceId = profile.getId();
String profilePicUrl = "https://graph.facebook.com/" + faceId + "/picture?type=large";
// if (user.getProfilePicUrl() == null || !user.getProfilePicUrl().equals(profilePicUrl)) {
user.setProfilePicUrl(profilePicUrl);
Picasso.with(getContext()).load(profilePicUrl).error(R.drawable.auth_bg).transform(new RoundedTransformation()).into(user_pic);
saveProfilePicUrl(profilePicUrl);
// }
} else {
Util.toast(R.string.frag_myprofile_facePickChoiceNotOnFace);
}
} else {
CaronaeAPI.service(getContext()).getIntranetPhotoUrl().enqueue(new Callback<UrlForJson>() {
@Override
public void onResponse(Call<UrlForJson> call, Response<UrlForJson> response) {
if (response.isSuccessful()) {
UrlForJson urlForJson = response.body();
if (urlForJson == null)
return;
String profilePicUrl = urlForJson.getUrl();
if (profilePicUrl != null && !profilePicUrl.isEmpty()) {
user.setProfilePicUrl(profilePicUrl);
Picasso.with(getContext()).load(profilePicUrl).error(R.drawable.user_pic).transform(new RoundedTransformation()).into(user_pic);
saveProfilePicUrl(profilePicUrl);
}
} else {
Util.treatResponseFromServer(response);
Util.toast(R.string.frag_myprofile_errorGetIntranetPhoto);
Log.e("getIntranetPhotoUrl", response.message());
}
}
@Override
public void onFailure(Call<UrlForJson> call, Throwable t) {
Util.toast(R.string.frag_myprofile_errorGetIntranetPhoto);
Log.e("getIntranetPhotoUrl", t.getMessage());
}
});
}
super.onPositiveActionClicked(fragment);
}
@Override
public void onNegativeActionClicked(DialogFragment fragment) {
super.onNegativeActionClicked(fragment);
}
};
builder.items(new String[] { getString(R.string.frag_myprofile_facePicChoice) }, 0).title("Usar foto do Facebook?").positiveAction(getString(R.string.ok)).negativeAction(getString(R.string.cancel));
DialogFragment fragment = DialogFragment.newInstance(builder);
fragment.show(getFragmentManager(), null);
}
use of br.ufrj.caronae.RoundedTransformation in project caronae-android by caronae.
the class MyProfileFrag method fillUserFields.
private void fillUserFields(User user) {
car_lay.setVisibility(user.isCarOwner() ? View.VISIBLE : View.GONE);
name_tv.setText(user.getName());
profile_tv.setText(user.getProfile());
course_tv.setText(user.getCourse());
System.out.println("PhoneNumber:" + user.getPhoneNumber());
if (!TextUtils.isEmpty(user.getPhoneNumber())) {
phoneNumber_et.setText(getFormatedNumber(user.getPhoneNumber()));
}
email_et.setText(user.getEmail());
location_et.setText(user.getLocation());
carOwner_sw.setChecked(user.isCarOwner());
carModel_et.setText(user.getCarModel());
carColor_et.setText(user.getCarColor());
if (!TextUtils.isEmpty(user.getCarPlate())) {
carPlate_et.setText(getFormatedPlate(user.getCarPlate()));
}
String date = user.getCreatedAt().split(" ")[0];
date = Util.formatBadDateWithYear(date).substring(3);
createdAt_tv.setText(date);
String notifOn = SharedPref.getNotifPref();
notif_sw.setChecked(notifOn.equals("true"));
if (user.getProfilePicUrl() != null && !user.getProfilePicUrl().isEmpty())
Picasso.with(getContext()).load(user.getProfilePicUrl()).placeholder(R.drawable.user_pic).error(R.drawable.user_pic).transform(new RoundedTransformation()).into(user_pic);
}
use of br.ufrj.caronae.RoundedTransformation in project caronae-android by caronae.
the class FalaeFrag method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_falae, container, false);
ButterKnife.bind(this, view);
User user = App.getUser();
name_tv.setText(user.getName());
profile_tv.setText(user.getProfile());
course_tv.setText(user.getCourse());
String profilePicUrl = user.getProfilePicUrl();
if (profilePicUrl != null && !profilePicUrl.isEmpty())
Picasso.with(getContext()).load(profilePicUrl).placeholder(R.drawable.user_pic).error(R.drawable.user_pic).transform(new RoundedTransformation()).into(user_pic_iv);
return view;
}
use of br.ufrj.caronae.RoundedTransformation in project caronae-android by caronae.
the class MainAct method getHeaderView.
private void getHeaderView(NavigationView nvDrawer) {
LayoutInflater inflater = LayoutInflater.from(this);
View nvHeader = inflater.inflate(R.layout.nav_header, null, false);
TextView name_tv = (TextView) nvHeader.findViewById(R.id.name_tv);
name_tv.setText(App.getUser().getName());
TextView course_tv = (TextView) nvHeader.findViewById(R.id.course_tv);
course_tv.setText(App.getUser().getCourse());
ImageView user_pic = (ImageView) nvHeader.findViewById(R.id.user_pic);
String profilePicUrl = App.getUser().getProfilePicUrl();
if (profilePicUrl != null && !profilePicUrl.isEmpty())
Picasso.with(this).load(profilePicUrl).placeholder(R.drawable.user_pic).error(R.drawable.user_pic).transform(new RoundedTransformation()).into(user_pic);
nvDrawer.addHeaderView(nvHeader);
}
Aggregations