use of app.insti.api.model.User in project IITB-App by wncc.
the class SettingsFragment method toggleShowContact.
private void toggleShowContact(final SwitchPreferenceCompat showContactPref, Object option) {
final boolean isChecked = (boolean) option;
showContactPref.setEnabled(false);
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.patchUserMe(Utils.getSessionIDHeader(), new UserShowContactPatchRequest(isChecked)).enqueue(new Callback<User>() {
@Override
public void onResponse(Call<User> call, Response<User> response) {
if (getActivity() == null || getView() == null)
return;
if (response.isSuccessful()) {
showContactPref.setChecked(response.body().getShowContactNumber());
showContactPref.setEnabled(true);
Utils.currentUserCache = response.body();
} else {
showContactPref.setChecked(!isChecked);
showContactPref.setEnabled(true);
}
}
@Override
public void onFailure(Call<User> call, Throwable t) {
if (getActivity() == null || getView() == null)
return;
showContactPref.setChecked(!isChecked);
showContactPref.setEnabled(true);
}
});
}
use of app.insti.api.model.User in project IITB-App by wncc.
the class SettingsFragment method onStart.
@Override
public void onStart() {
super.onStart();
// Set toolbar title
Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("Settings");
Utils.setSelectedMenuItem(getActivity(), R.id.nav_settings);
if (Utils.currentUserCache == null) {
// Get the user id
Bundle bundle = getArguments();
String userID = bundle.getString(Constants.USER_ID);
// Fill in the user
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 user = response.body();
showContactPref.setChecked(user.getShowContactNumber());
showContactPref.setEnabled(true);
Utils.currentUserCache = user;
}
}
});
} else {
showContactPref.setChecked(Utils.currentUserCache.getShowContactNumber());
showContactPref.setEnabled(true);
}
}
use of app.insti.api.model.User in project IITB-App by wncc.
the class ComplaintDetailsFragment method addVotesToView.
public void addVotesToView(Venter.Complaint detailedComplaint) {
upVotesList.clear();
for (User users : detailedComplaint.getUsersUpVoted()) {
upVotesList.add(users);
}
upVotesAdapter.setList(upVotesList);
upVotesAdapter.notifyDataSetChanged();
textViewVoteUpLabel.setText("Up Votes (" + detailedComplaint.getUsersUpVoted().size() + ")");
}
use of app.insti.api.model.User in project IITB-App by wncc.
the class ExploreFragment method onStart.
@Override
public void onStart() {
super.onStart();
// Initialize
sessionId = Utils.getSessionIDHeader();
initRecyclerView();
Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("Explore");
Utils.setSelectedMenuItem(getActivity(), R.id.nav_explore);
final EditText searchEditText = getView().findViewById(R.id.explore_search);
// Get all bodies
if (allBodies.size() == 0) {
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getAllBodies(sessionId).enqueue(new EmptyCallback<List<Body>>() {
@Override
public void onResponse(Call<List<Body>> call, Response<List<Body>> response) {
allBodies = response.body();
bodies = allBodies;
updateAdapter(allBodies, new ArrayList<Event>(), new ArrayList<User>());
}
});
} else {
// Check if search box is not empty
if (searchEditText.getText() != null && !searchEditText.getText().toString().equals("")) {
updateAdapter(bodies, events, users);
} else {
updateAdapter(allBodies, new ArrayList<Event>(), new ArrayList<User>());
}
getView().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
}
// Close keyboard on search click
searchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
MainActivity.hideKeyboard(getActivity());
return true;
}
return false;
}
});
// Search on text change in search
searchEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// Do nothing
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// Do nothing
}
@Override
public void afterTextChanged(Editable s) {
currentQuery = s.toString();
if (currentQuery.length() >= 3) {
doSearch(searchEditText.getText().toString());
} else if (currentQuery.length() == 0) {
updateAdapter(allBodies, new ArrayList<Event>(), new ArrayList<User>());
}
}
});
}
use of app.insti.api.model.User 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);
}
});
}
}
Aggregations