SpecificPostActivity

public class SpecificPostActivity extends AppCompatActivity implements FormatManager.IconUpdateListener

Displays a particular Post along with its comments (PostReply). Also allows the user to add comments.

Fields

boldButton

ImageButton boldButton

Buttons for inline markup of the text of the reply

commentField

ListenableEditText commentField

Field for the user to enter a comment

content

TextView content

Body of the Post

cv

CardView cv

The View that holds the UI elements that make up the displayed Post

editTextOpened

boolean editTextOpened

Whether the “window” to write a reply is open. Starts off false

formatManager

FormatManager formatManager

Manages markup of the text of the reply

images

ImageView[] images

Array of images associated with the Post

loadingOverlay

FrameLayout loadingOverlay

personName

TextView personName

Name of the creator of the Post

personPhoto

ImageView personPhoto

Profile photo of the author of the Post

postButton

Button postButton

Button to submit a comment on the Post

postTypePhoto

ImageView postTypePhoto

Other photo associated with the Post

progressBar

ProgressBar progressBar

Progress bar for displaying the progress of network operations

queue

RequestQueue queue

Queue for asynchronous tasks

timestamp

TextView timestamp

When the Post was created

toggleButtons

SparseArray<ImageButton> toggleButtons

Tracks whether the inline markup buttons have been toggled to “on”

username

TextView username

Unique display name of the creator of the Post

writeReplyView

ConstraintLayout writeReplyView

Layout within which the compose reply UI elements are arranged

Methods

closeEditTextView

void closeEditTextView()

When the user selects out of the text field, the view will shrink back to its original position.

genResizeAnimation

void genResizeAnimation(int oldSize, int newSize, ConstraintLayout layout)

This little helper handles the animation involved in changing the size of the write reply view.

Parameters:
  • oldSize – start height, in pixels.
  • newSize – final height, in pixels.
  • layout – writeReplyView

onCreate

protected void onCreate(Bundle savedInstanceState)

Create the user interface from the layout defined by R.layout.activity_specific_post. Initialize instance fields with the UI elements defined in the layout. Setup listeners to handle loading more comments, clicks to post replies, and load the Post to display.

Parameters:

onStop

protected 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)

openEditTextView

void openEditTextView()

This function animates the bottom view to expand up, allowing for a greater text field as well as toggle buttons.

updateIconToggles

public void updateIconToggles(SparseBooleanArray formTogState, SparseArray<int[]> toggleIcons)

Update whether an icon has been “toggled”, or selected

Parameters:
  • 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.