CreatePostActivity¶
-
public class
CreatePostActivity
extends AppCompatActivity implements FormatManager.IconUpdateListener¶ Creates screen the user can use to create a new
Post
Fields¶
content¶
-
ListenableEditText
content
¶ Field the user uses to type the body of their
Post
formatManager¶
-
FormatManager
formatManager
¶ Handles markup of the body text
progressBar¶
-
ProgressBar
progressBar
¶ Displays progress as the post is being sent over the network
Methods¶
onCreate¶
-
protected void
onCreate
(Bundle savedInstanceState)¶ Create the screen from
R.layout.activity_create_post
, fillCreatePostActivity.networkLabel
with a description of theNetwork
fromAPI.Get.network(RequestQueue,long,Response.Listener)
, setupCreatePostActivity.formatManager
, and link a listener to the submission button that sends thePost
usingAPI.Post.post(RequestQueue,Post,SharedPreferences,Response.Listener)
Parameters: - savedInstanceState – {@inheritDoc}
onOptionsItemSelected¶
-
public boolean
onOptionsItemSelected
(MenuItem item)¶ This function handles what happens when our format toggle buttons are clicked. We want to update the content formatting when this happens as well with Spannables. Check out https://stackoverflow.com/questions/10828182/spannablestringbuilder-to-create-string-with-multiple-fonts-text-sizes-etc-examp for more info.
Parameters: - item – the MenuItem that was tapped.
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)
updateIconToggles¶
-
public void
updateIconToggles
(SparseBooleanArray formTogState, SparseArray<int[]> toggleIcons)¶ This fancy function uses our SparseArray’s to concisely iterate over our toggle icons and update their colors - white if untoggled, black if toggled.