Search in sources :

Example 6 with RoundedTransformation

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);
            }
        });
    }
}
Also used : ProfileAct(br.ufrj.caronae.acts.ProfileAct) User(br.ufrj.caronae.models.User) RoundedTransformation(br.ufrj.caronae.RoundedTransformation) Gson(com.google.gson.Gson) Intent(android.content.Intent) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 7 with RoundedTransformation

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);
}
Also used : UrlForJson(br.ufrj.caronae.models.modelsforjson.UrlForJson) User(br.ufrj.caronae.models.User) DialogFragment(com.rey.material.app.DialogFragment) CaretString(com.redmadrobot.inputmask.model.CaretString) Profile(com.facebook.Profile) SimpleDialog(com.rey.material.app.SimpleDialog) RoundedTransformation(br.ufrj.caronae.RoundedTransformation) OnClick(butterknife.OnClick)

Example 8 with RoundedTransformation

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);
}
Also used : RoundedTransformation(br.ufrj.caronae.RoundedTransformation) CaretString(com.redmadrobot.inputmask.model.CaretString)

Example 9 with RoundedTransformation

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;
}
Also used : User(br.ufrj.caronae.models.User) RoundedTransformation(br.ufrj.caronae.RoundedTransformation) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView)

Example 10 with RoundedTransformation

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);
}
Also used : LayoutInflater(android.view.LayoutInflater) RoundedTransformation(br.ufrj.caronae.RoundedTransformation) TextView(android.widget.TextView) ImageView(android.widget.ImageView) SpannableString(android.text.SpannableString) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView)

Aggregations

RoundedTransformation (br.ufrj.caronae.RoundedTransformation)14 View (android.view.View)11 ImageView (android.widget.ImageView)11 TextView (android.widget.TextView)11 User (br.ufrj.caronae.models.User)8 Intent (android.content.Intent)7 RecyclerView (android.support.v7.widget.RecyclerView)7 Gson (com.google.gson.Gson)6 CardView (android.support.v7.widget.CardView)4 BindView (butterknife.BindView)4 ProgressDialog (android.app.ProgressDialog)3 ActionBar (android.support.v7.app.ActionBar)3 Toolbar (android.support.v7.widget.Toolbar)3 RideForJson (br.ufrj.caronae.models.modelsforjson.RideForJson)3 SimpleDialog (com.rey.material.app.SimpleDialog)3 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)3 NavigationView (android.support.design.widget.NavigationView)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 SpannableString (android.text.SpannableString)2 ActiveRideAct (br.ufrj.caronae.acts.ActiveRideAct)2