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

MAX_QUALITY

final int MAX_QUALITY

Constant that clarifies that quality 100 means no compression.

MAX_SIDE

final double MAX_SIDE

The maximum number of pixels allowed on a single side of an image

bio

EditText bio

Editable text fields that make up parts of the User’s profile

emptyText

TextView emptyText

Text field that displays R.string.no_networks if the user has not joined any Networks

profilePicture

ImageView profilePicture

The field for the User’s profile picture

queue

RequestQueue queue

Queue for asynchronous tasks

scrollView

ScrollView scrollView

The user whose profile is displayed and being edited

updateProfile

Button updateProfile

Button for updating the User’s profile on the server with the one currently displayed

user

User user

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 using API.Get.user(RequestQueue,long,Response.Listener)). Link listeners to buttons and the displays of Networks to handle interactions.

Parameters:

onItemClick

public void onItemClick(View v, Network network)

Handle what happens when a user clicks on a Network. Right now, nothing is done.

Parameters:

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), and API.Get.networkUserCount(RequestQueue,long,Response.Listener).

updateUser

public void updateUser(SharedPreferences settings)

Updates user info via PUT request to server.

Parameters:
  • settings – SharedPreferences instance to save email.