Search in sources :

Example 6 with User

use of com.instructure.canvasapi.model.User in project instructure-android by instructure.

the class GuessWhoStudentFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (container == null) {
        return null;
    }
    View view = inflater.inflate(R.layout.guess_who_student_fragment, container, false);
    rootView = (RelativeLayout) view.findViewById(R.id.rootView);
    rootView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            FlipAnimation flipAnimation = new FlipAnimation(cardFront, cardBack);
            if (cardFront.getVisibility() == View.GONE) {
                flipAnimation.reverse();
                hasFlipped = false;
            } else {
                hasFlipped = true;
            }
            rootView.startAnimation(flipAnimation);
        }
    });
    cardFront = (RelativeLayout) view.findViewById(R.id.cardFront);
    cardBack = (RelativeLayout) view.findViewById(R.id.cardBack);
    User user = this.getArguments().getParcelable(Const.USER);
    name = (TextView) view.findViewById(R.id.studentName);
    name.setText(user.getShortName());
    avatar = (ImageView) view.findViewById(R.id.avatar);
    Picasso.with(getActivity()).load(user.getAvatarURL()).into(avatar);
    // show the back view
    if (savedInstanceState != null && savedInstanceState.getBoolean(Const.GUESS_WHO_CARD_FLIPPED)) {
        // we want the card to flip, but we don't want the animation. So use the same logic but set the
        // duration to 0 so it happens instantly
        FlipAnimation flipAnimation = new FlipAnimation(cardFront, cardBack);
        flipAnimation.setDuration(0);
        rootView.startAnimation(flipAnimation);
        hasFlipped = true;
    }
    return view;
}
Also used : User(com.instructure.canvasapi.model.User) FlipAnimation(com.instructure.teacheraid.animation.FlipAnimation) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 7 with User

use of com.instructure.canvasapi.model.User in project instructure-android by instructure.

the class StudentChooserCarouselFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (container == null) {
        return null;
    }
    RelativeLayout l = (RelativeLayout) inflater.inflate(R.layout.user_fragment, container, false);
    User user = this.getArguments().getParcelable(Const.USER);
    TextView tv = (TextView) l.findViewById(R.id.viewID);
    tv.setText(user.getShortName());
    ImageView imageView = (ImageView) l.findViewById(R.id.content);
    Picasso.with(getActivity()).load(user.getAvatarURL()).into(imageView);
    return l;
}
Also used : User(com.instructure.canvasapi.model.User) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 8 with User

use of com.instructure.canvasapi.model.User in project instructure-android by instructure.

the class APIHelpers method setCachedShortName.

/**
 * setCachedShortName is a helper to set a value on the cached user.
 * @param context
 * @param shortName
 * @return
 */
public static boolean setCachedShortName(Context context, String shortName) {
    User user = getCacheUser(context);
    if (user == null) {
        return false;
    }
    user.setShortName(shortName);
    return setCacheUser(context, user);
}
Also used : User(com.instructure.canvasapi.model.User)

Example 9 with User

use of com.instructure.canvasapi.model.User in project instructure-android by instructure.

the class APIHelpers method setCachedEmail.

/**
 * setCachedEmail is a helper to set a value on the cached user.
 * @param context
 * @param email
 * @return
 */
public static boolean setCachedEmail(Context context, String email) {
    User user = getCacheUser(context);
    if (user == null) {
        return false;
    }
    user.setEmail(email);
    return setCacheUser(context, user);
}
Also used : User(com.instructure.canvasapi.model.User)

Example 10 with User

use of com.instructure.canvasapi.model.User in project instructure-android by instructure.

the class APIHelpers method setCachedAvatarURL.

/**
 * setCachedAvatarURL is a helper to set a value on the cached user.
 * @param context
 * @param avatarURL
 * @return
 */
public static boolean setCachedAvatarURL(Context context, String avatarURL) {
    User user = getCacheUser(context);
    if (user == null) {
        return false;
    }
    user.setAvatarURL(avatarURL);
    return setCacheUser(context, user);
}
Also used : User(com.instructure.canvasapi.model.User)

Aggregations

User (com.instructure.canvasapi.model.User)23 TextView (android.widget.TextView)4 Gson (com.google.gson.Gson)4 LinkHeaders (com.instructure.canvasapi.utilities.LinkHeaders)4 Response (retrofit.client.Response)4 Intent (android.content.Intent)3 View (android.view.View)3 ImageView (android.widget.ImageView)3 Test (org.junit.Test)3 RetrofitError (retrofit.RetrofitError)3 PackageInfo (android.content.pm.PackageInfo)2 PackageManager (android.content.pm.PackageManager)2 Bundle (android.os.Bundle)2 Course (com.instructure.canvasapi.model.Course)2 Section (com.instructure.canvasapi.model.Section)2 Submission (com.instructure.canvasapi.model.Submission)2 CanvasRestAdapter (com.instructure.canvasapi.utilities.CanvasRestAdapter)2 UserCallback (com.instructure.canvasapi.utilities.UserCallback)2 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)2 RestAdapter (retrofit.RestAdapter)2