SettingsActivity¶
-
public class
SettingsActivity
extends DrawerActivity implements NetworkSummaryAdapter.OnNetworkTapListener¶ Screen that displays the current user’s profile and let’s them update it
Fields¶
MAX_PIXELS¶
-
final long
MAX_PIXELS
¶ The max number of pixels for an image given the image. Each pixel is 8 bytes large (according to RGBA_F16), and a MB is 2^20 bytes
emptyText¶
rv¶
scrollView¶
-
ScrollView
scrollView
¶ The user whose profile is displayed and being edited
updateProfile¶
Methods¶
onActivityResult¶
-
protected void
onActivityResult
(int requestCode, int resultCode, Intent data)¶ This function is overridden to handle image selection. Inspiration from http://www.tauntaunwonton.com/blog/2015/1/21/simple-posting-of-multipartform-data-from-android
Parameters: - requestCode – PICK_IMAGE if we asked them to choose an image from the gallery.
- resultCode – {@inheritDoc}
- data – Hopefully, the URI.
onCreate¶
-
protected void
onCreate
(Bundle savedInstanceState)¶ Setup the user interface with the layout defined in
R.layout.activity_settings
. Also initialize instance fields for UI fields with the elements defined in the layout file. Fill the fields with the current profile (fetched usingAPI.Get.user(RequestQueue,long,Response.Listener)
). Link listeners to buttons and the displays ofNetwork
s to handle interactions.Parameters: - savedInstanceState – {@inheritDoc}
onItemClick¶
-
public void
onItemClick
(View v, Network network)¶ Handle what happens when a user clicks on a
Network
. Right now, nothing is done.Parameters: - v – {@inheritDoc}
- network – {@inheritDoc}
onStop¶
-
public void
onStop
()¶ This ensures that we are canceling all network requests if the user is leaving this activity. We use a RequestFilter that accepts all requests (meaning it cancels all requests)
resetAdapter¶
-
void
resetAdapter
()¶ Reset the adapter by clearing it and then populating it with new information from
API.Get.userNetworks(RequestQueue,long,Response.Listener)
,API.Get.networkPostCount(RequestQueue,long,Response.Listener)
, andAPI.Get.networkUserCount(RequestQueue,long,Response.Listener)
.
updateUser¶
Updates user info via PUT request to server.
Parameters: - settings – SharedPreferences instance to save email.