Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
JavaDocs for methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kunall17 committed Aug 22, 2016
1 parent 5ec7739 commit dc8aca0
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/src/main/java/com/zulip/android/ZulipApp.java
Expand Up @@ -149,6 +149,9 @@ private void afterLogin() {
setupEmoji();
}

/**
* Fills the Emoji Table with the existing emoticons saved in the assets folder.
*/
private void setupEmoji() {
try {
final RuntimeExceptionDao<Emoji, Object> dao = getDao(Emoji.class);
Expand Down
Expand Up @@ -164,6 +164,10 @@ public void setContextItemSelectedPosition(int adapterPosition) {
setupLists(messageList);
}

/**
* Add's a placeHolder value for Header and footer loading with values of 3-{@link #VIEWTYPE_HEADER} and 4-{@link #VIEWTYPE_FOOTER} respectively.
* So that for these placeHolder can be created a ViewHolder in {@link #onCreateViewHolder(ViewGroup, int)}
*/
private void setupHeaderAndFooterViews() {
items.add(0, VIEWTYPE_HEADER); //Placeholder for header
items.add(VIEWTYPE_FOOTER); //Placeholder for footer
Expand Down Expand Up @@ -215,6 +219,13 @@ else if (getItem(position) instanceof Integer && (Integer) getItem(position) ==
}
}

/**
* Add an old message to the current list and add those messages to the existing messageHeaders if no
* messageHeader is found then create a new messageHeader
* @param message Message to be added
* @param messageAndHeadersCount Count of the (messages + messageHeaderParent) added in the loop from where this function is being called
* @return returns true if a new messageHeaderParent is created for this message so as to increment the count by where this function is being called.
*/
public boolean addMessage(Message message, int messageAndHeadersCount) {

int[] index = getHeaderAndNextIndex(message.getIdForHolder());
Expand All @@ -240,7 +251,11 @@ public boolean addMessage(Message message, int messageAndHeadersCount) {
}
}


/**
* Add a new message to the bottom of the list and create a new messageHeaderParent if last did not match this message
* Stream/subject or private recipients.
* @param message Message to be added
*/
public void addNewMessage(Message message) {
MessageHeaderParent item = null;
for (int i = getItemCount(false) - 1; i > 1; i--) {
Expand Down Expand Up @@ -357,6 +372,10 @@ public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
markThisMessageAsRead((Message) getItem(holder.getAdapterPosition()));
}

/**
* This is called when the Message is bind to the Holder and attached, displayed in the window.
* @param message Mark this message read
*/
private void markThisMessageAsRead(Message message) {
try {
int mID = message.getID();
Expand Down Expand Up @@ -427,7 +446,11 @@ public Object getItem(int position) {
return items.get(position);
}


/**
* Return the size of the list with including or excluding footer
* @param includeFooter true to return the size including footer or false to return size excluding footer.
* @return
*/
public int getItemCount(boolean includeFooter) {
if (includeFooter) return getItemCount();
else return getItemCount() - 1;
Expand Down
58 changes: 58 additions & 0 deletions app/src/main/java/com/zulip/android/activities/ZulipActivity.java
Expand Up @@ -494,6 +494,10 @@ public Cursor runQuery(CharSequence charSequence) {
messageEt.setAdapter(combinedAdapter);
}

/**
* Returns a cursor for the combinedAdapter used to suggest Emoji when ':' is typed in the {@link #messageEt}
* @param emoji A string to search in the existing database
*/
private Cursor makeEmojiCursor(CharSequence emoji)
throws SQLException {
if (emoji == null) {
Expand Down Expand Up @@ -620,6 +624,9 @@ public void onAnimationRepeat(Animator animator) {
animator.start();
}

/**
* Setup the streams Drawer which has a {@link ExpandableListView} categorizes the stream and subject
*/
private void setupListViewAdapter() {
ExpandableStreamDrawerAdapter streamsDrawerAdapter = null;
Callable<Cursor> streamsGenerator = new Callable<Cursor>() {
Expand Down Expand Up @@ -722,6 +729,9 @@ public void onClick(View v) {
streamsDrawer.setAdapter(streamsDrawerAdapter);
}

/**
* Initiates the streams Drawer if the streams in the drawer is 0.
*/
public void checkAndSetupStreamsDrawer() {
try {
if (streamsDrawer.getAdapter().getCount() != 0) {
Expand Down Expand Up @@ -801,6 +811,9 @@ public void onTaskFailure(String result) {
sender.execute();
}

/**
* Disable chatBox and show a loading footer while sending the message.
*/
private void sendingMessage(boolean isSending) {
streamActv.setEnabled(!isSending);
textView.setEnabled(!isSending);
Expand All @@ -816,6 +829,15 @@ private void sendingMessage(boolean isSending) {

private LinearLayout composeStatus;

/**
* Setup adapter's for the {@link AutoCompleteTextView}
*
* These adapters are being intialized -
*
* {@link #streamActvAdapter} Adapter for suggesting all the stream names in this AutoCompleteTextView
* {@link #emailActvAdapter} Adapter for suggesting all the person email's in this AutoCompleteTextView
* {@link #subjectActvAdapter} Adapter for suggesting all the topic for the stream specified in the {@link #streamActv} in this AutoCompleteTextView
*/
private void setUpAdapter() {
streamActvAdapter = new SimpleCursorAdapter(
that, R.layout.stream_tile, null,
Expand Down Expand Up @@ -897,6 +919,10 @@ public Cursor runQuery(CharSequence charSequence) {
sendingMessage(false);
}

/**
* Creates a cursor to get the streams saved in the database
* @param streamName Filter out streams name containing this string
*/
private Cursor makeStreamCursor(CharSequence streamName)
throws SQLException {
if (streamName == null) {
Expand All @@ -915,6 +941,11 @@ private Cursor makeStreamCursor(CharSequence streamName)
.closeableIterator().getRawResults()).getRawCursor();
}

/**
* Creates a cursor to get the topics in the stream in
* @param stream
* @param subject Filter out subject containing this string
*/
private Cursor makeSubjectCursor(CharSequence stream, CharSequence subject)
throws SQLException {
if (subject == null) {
Expand All @@ -941,6 +972,10 @@ private Cursor makeSubjectCursor(CharSequence stream, CharSequence subject)
return results.getRawCursor();
}

/**
* Creates a cursor to get the E-Mails stored in the database
* @param email Filter out emails containing this string
*/
private Cursor makePeopleCursor(CharSequence email) throws SQLException {
if (email == null) {
email = "";
Expand Down Expand Up @@ -990,6 +1025,9 @@ private void removeEditTextErrors() {
messageEt.setError(null);
}

/**
* Switch from Private to Stream or vice versa in chatBox
*/
private void switchView() {
if (isCurrentModeStream()) { //Person
togglePrivateStreamBtn.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_action_bullhorn));
Expand Down Expand Up @@ -1109,6 +1147,9 @@ private void setupTitleBar(String title, String subtitle) {
}
}

/**
* This method creates a new Instance of the MessageListFragment and displays it with the filter.
*/
private void doNarrow(NarrowFilter filter) {
narrowedList = MessageListFragment.newInstance(filter);
// Push to the back stack if we are not already narrowed
Expand All @@ -1134,6 +1175,10 @@ public void onNarrowFillSendBoxPrivate(Person peopleList[], boolean openSoftKeyb
}
}

/**
* Fills the chatBox according to the {@link MessageType}
* @param openSoftKeyboard If true open's up the SoftKeyboard else not.
*/
@Override
public void onNarrowFillSendBox(Message message, boolean openSoftKeyboard) {
displayChatBox(true);
Expand All @@ -1155,6 +1200,12 @@ public void onNarrowFillSendBox(Message message, boolean openSoftKeyboard) {
}
}

/**
* Fills the chatBox with the stream name and the topic
* @param stream Stream name to be filled
* @param subject Subject to be filled
* @param openSoftKeyboard If true open's the softKeyboard else not
*/
public void onNarrowFillSendBoxStream(String stream, String subject, boolean openSoftKeyboard) {
displayChatBox(true);
displayFAB(false);
Expand Down Expand Up @@ -1292,6 +1343,10 @@ public void onClick(
return true;
}

/**
* Switches the current Day/Night mode to Night/Day mode
* @param nightMode which Mode {@link android.support.v7.app.AppCompatDelegate.NightMode}
*/
private void setNightMode(@AppCompatDelegate.NightMode int nightMode) {
AppCompatDelegate.setDefaultNightMode(nightMode);

Expand Down Expand Up @@ -1380,6 +1435,9 @@ protected void onDestroy() {
}
}

/**
* Refresh the current user profile, removes all the tables from the database and reloads them from the server, reset the queue.
*/
private void onRefresh() {
super.onResume();

Expand Down
Expand Up @@ -306,6 +306,10 @@ private void processEvents(JSONArray events) {
}
}

/**
* Add messages to the list {@link com.zulip.android.activities.MessageListFragment} which are already added to the database
* @param messages List of messages to be added
*/
private void processMessages(final ArrayList<Message> messages) {
// In task thread
int lastMessageId = messages.get(messages.size() - 1).getID();
Expand Down

0 comments on commit dc8aca0

Please sign in to comment.