Search in sources :

Example 6 with User

use of app.insti.api.model.User in project IITB-App by wncc.

the class GenericAdapter method onClick.

@Override
public void onClick(CardInterface cardInterface, Fragment fragment, View view) {
    if (cardInterface instanceof Event) {
        Utils.openEventFragment((Event) cardInterface, fragment, view.findViewById(R.id.object_picture));
    } else if (cardInterface instanceof Body) {
        Utils.openBodyFragment((Body) cardInterface, fragment, view.findViewById(R.id.object_picture));
    } else if (cardInterface instanceof User) {
        Utils.openUserFragment((User) cardInterface, fragment, view.findViewById(R.id.object_picture));
    } else if (cardInterface instanceof Role) {
        Utils.openBodyFragment(((Role) cardInterface).getRoleBodyDetails(), fragment, view.findViewById(R.id.object_picture));
    } else if (cardInterface instanceof Achievement) {
        Achievement a = (Achievement) cardInterface;
        if (a.getAchievementEvent() != null) {
            a.getAchievementEvent().setEventBodies(new ArrayList<>());
            a.getAchievementEvent().getEventBodies().add(a.getAchievementBody());
            Utils.openEventFragment(a.getAchievementEvent(), fragment, view.findViewById(R.id.object_picture));
        } else {
            Utils.openBodyFragment(a.getAchievementBody(), fragment, view.findViewById(R.id.object_picture));
        }
    } else if (cardInterface instanceof OfferedAchievement) {
        WebViewFragment webViewFragment = new WebViewFragment();
        Bundle bundle = new Bundle();
        bundle.putString(Constants.WV_TYPE, Constants.WV_TYPE_NEW_OFFERED_ACHIEVEMENT);
        bundle.putString(Constants.WV_ID, ((OfferedAchievement) cardInterface).getAchievementID());
        webViewFragment.setArguments(bundle);
        Utils.updateFragment(webViewFragment, fragment.getActivity());
    }
}
Also used : Role(app.insti.api.model.Role) WebViewFragment(app.insti.fragment.WebViewFragment) User(app.insti.api.model.User) OfferedAchievement(app.insti.api.model.OfferedAchievement) Bundle(android.os.Bundle) Event(app.insti.api.model.Event) Achievement(app.insti.api.model.Achievement) OfferedAchievement(app.insti.api.model.OfferedAchievement) Body(app.insti.api.model.Body)

Example 7 with User

use of app.insti.api.model.User in project IITB-App by wncc.

the class UserFragment method loadUser.

public void loadUser(String userID) {
    RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
    retrofitInterface.getUser(Utils.getSessionIDHeader(), userID).enqueue(new EmptyCallback<User>() {

        @Override
        public void onResponse(Call<User> call, Response<User> response) {
            if (response.isSuccessful()) {
                if (getActivity() == null || getView() == null)
                    return;
                user = response.body();
                populateViews();
            }
        }
    });
}
Also used : User(app.insti.api.model.User) RetrofitInterface(app.insti.api.RetrofitInterface)

Example 8 with User

use of app.insti.api.model.User in project IITB-App by wncc.

the class UserFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
    toolbar.setTitle("Profile");
    Bundle bundle = getArguments();
    String userID = bundle.getString(Constants.USER_ID);
    String userJson = bundle.getString(Constants.USER_JSON);
    if (user != null) {
        populateViews();
    } else if (userID != null) {
        loadUser(userID);
    } else if (userJson != null) {
        user = Utils.gson.fromJson(userJson, User.class);
        showingMin = true;
        populateViews();
    }
}
Also used : User(app.insti.api.model.User) Bundle(android.os.Bundle) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

User (app.insti.api.model.User)8 Bundle (android.os.Bundle)4 RetrofitInterface (app.insti.api.RetrofitInterface)4 Toolbar (androidx.appcompat.widget.Toolbar)3 Event (app.insti.api.model.Event)2 Role (app.insti.api.model.Role)2 ArrayList (java.util.ArrayList)2 Point (android.graphics.Point)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 KeyEvent (android.view.KeyEvent)1 View (android.view.View)1 EditText (android.widget.EditText)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 MainActivity (app.insti.activity.MainActivity)1 GenericAdapter (app.insti.adapter.GenericAdapter)1 Achievement (app.insti.api.model.Achievement)1