public class CreatePostActivity extends AppCompatActivity implements FormatManager.IconUpdateListener
Post
Modifier and Type | Field and Description |
---|---|
(package private) ListenableEditText |
content
Field the user uses to type the body of their
Post |
(package private) FormatManager |
formatManager
Handles markup of the body text
|
(package private) android.util.SparseArray<android.view.MenuItem> |
menuItems
All the items in the formatting menu
|
(package private) android.widget.TextView |
networkLabel
Displays the
Network the user's Post will be added to |
(package private) android.widget.ProgressBar |
progressBar
Displays progress as the post is being sent over the network
|
private RequestQueue |
queue
Queue for asynchronous tasks
|
Constructor and Description |
---|
CreatePostActivity() |
Modifier and Type | Method and Description |
---|---|
protected void |
onCreate(android.os.Bundle savedInstanceState)
Create the screen from
R.layout#activity_create_post , fill
networkLabel with a description of the Network
from API.Get#network(RequestQueue, long, Response.Listener) , setup
formatManager , and link a listener to the submission button that
sends the Post using
API.Post#post(RequestQueue, Post, SharedPreferences, Response.Listener) |
boolean |
onCreateOptionsMenu(android.view.Menu menu)
Populate the options menu with controls to make text bold, italic, or a link
|
boolean |
onOptionsItemSelected(android.view.MenuItem item)
This function handles what happens when our format toggle buttons are clicked.
|
void |
onStop()
This ensures that we are canceling all network requests if the user is leaving this activity.
|
void |
updateIconToggles(android.util.SparseBooleanArray formTogState,
android.util.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.
|
ListenableEditText content
Post
android.util.SparseArray<android.view.MenuItem> menuItems
android.widget.TextView networkLabel
Network
the user's Post
will be added toprivate RequestQueue queue
android.widget.ProgressBar progressBar
FormatManager formatManager
protected void onCreate(android.os.Bundle savedInstanceState)
R.layout#activity_create_post
, fill
networkLabel
with a description of the Network
from API.Get#network(RequestQueue, long, Response.Listener)
, setup
formatManager
, and link a listener to the submission button that
sends the Post
using
API.Post#post(RequestQueue, Post, SharedPreferences, Response.Listener)
savedInstanceState
- public boolean onCreateOptionsMenu(android.view.Menu menu)
menu
- Menu to populate with optionstrue
public boolean onOptionsItemSelected(android.view.MenuItem item)
item
- the MenuItem that was tapped.public void updateIconToggles(android.util.SparseBooleanArray formTogState, android.util.SparseArray<int[]> toggleIcons)
updateIconToggles
in interface FormatManager.IconUpdateListener
formTogState
- a SparseBooleanArray (HashMap) with int as key and boolean as value
key: int id of toggleButton View we are using.
value: true if toggled, false if not toggled.toggleIcons
- a SparseArray (HashMap) with int as key and int[] as value.
key: int id of toggleButton View we are using.
value: int[0] being untoggled icon, int[1] being toggled icon.public void onStop()