Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit dc8aca0

Browse files
committed
JavaDocs for methods
1 parent 5ec7739 commit dc8aca0

File tree

4 files changed

+90
-2
lines changed

4 files changed

+90
-2
lines changed

app/src/main/java/com/zulip/android/ZulipApp.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ private void afterLogin() {
149149
setupEmoji();
150150
}
151151

152+
/**
153+
* Fills the Emoji Table with the existing emoticons saved in the assets folder.
154+
*/
152155
private void setupEmoji() {
153156
try {
154157
final RuntimeExceptionDao<Emoji, Object> dao = getDao(Emoji.class);

app/src/main/java/com/zulip/android/activities/RecyclerMessageAdapter.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ public void setContextItemSelectedPosition(int adapterPosition) {
164164
setupLists(messageList);
165165
}
166166

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

222+
/**
223+
* Add an old message to the current list and add those messages to the existing messageHeaders if no
224+
* messageHeader is found then create a new messageHeader
225+
* @param message Message to be added
226+
* @param messageAndHeadersCount Count of the (messages + messageHeaderParent) added in the loop from where this function is being called
227+
* @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.
228+
*/
218229
public boolean addMessage(Message message, int messageAndHeadersCount) {
219230

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

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

375+
/**
376+
* This is called when the Message is bind to the Holder and attached, displayed in the window.
377+
* @param message Mark this message read
378+
*/
360379
private void markThisMessageAsRead(Message message) {
361380
try {
362381
int mID = message.getID();
@@ -427,7 +446,11 @@ public Object getItem(int position) {
427446
return items.get(position);
428447
}
429448

430-
449+
/**
450+
* Return the size of the list with including or excluding footer
451+
* @param includeFooter true to return the size including footer or false to return size excluding footer.
452+
* @return
453+
*/
431454
public int getItemCount(boolean includeFooter) {
432455
if (includeFooter) return getItemCount();
433456
else return getItemCount() - 1;

app/src/main/java/com/zulip/android/activities/ZulipActivity.java

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,10 @@ public Cursor runQuery(CharSequence charSequence) {
494494
messageEt.setAdapter(combinedAdapter);
495495
}
496496

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

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

732+
/**
733+
* Initiates the streams Drawer if the streams in the drawer is 0.
734+
*/
725735
public void checkAndSetupStreamsDrawer() {
726736
try {
727737
if (streamsDrawer.getAdapter().getCount() != 0) {
@@ -801,6 +811,9 @@ public void onTaskFailure(String result) {
801811
sender.execute();
802812
}
803813

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

817830
private LinearLayout composeStatus;
818831

832+
/**
833+
* Setup adapter's for the {@link AutoCompleteTextView}
834+
*
835+
* These adapters are being intialized -
836+
*
837+
* {@link #streamActvAdapter} Adapter for suggesting all the stream names in this AutoCompleteTextView
838+
* {@link #emailActvAdapter} Adapter for suggesting all the person email's in this AutoCompleteTextView
839+
* {@link #subjectActvAdapter} Adapter for suggesting all the topic for the stream specified in the {@link #streamActv} in this AutoCompleteTextView
840+
*/
819841
private void setUpAdapter() {
820842
streamActvAdapter = new SimpleCursorAdapter(
821843
that, R.layout.stream_tile, null,
@@ -897,6 +919,10 @@ public Cursor runQuery(CharSequence charSequence) {
897919
sendingMessage(false);
898920
}
899921

922+
/**
923+
* Creates a cursor to get the streams saved in the database
924+
* @param streamName Filter out streams name containing this string
925+
*/
900926
private Cursor makeStreamCursor(CharSequence streamName)
901927
throws SQLException {
902928
if (streamName == null) {
@@ -915,6 +941,11 @@ private Cursor makeStreamCursor(CharSequence streamName)
915941
.closeableIterator().getRawResults()).getRawCursor();
916942
}
917943

944+
/**
945+
* Creates a cursor to get the topics in the stream in
946+
* @param stream
947+
* @param subject Filter out subject containing this string
948+
*/
918949
private Cursor makeSubjectCursor(CharSequence stream, CharSequence subject)
919950
throws SQLException {
920951
if (subject == null) {
@@ -941,6 +972,10 @@ private Cursor makeSubjectCursor(CharSequence stream, CharSequence subject)
941972
return results.getRawCursor();
942973
}
943974

975+
/**
976+
* Creates a cursor to get the E-Mails stored in the database
977+
* @param email Filter out emails containing this string
978+
*/
944979
private Cursor makePeopleCursor(CharSequence email) throws SQLException {
945980
if (email == null) {
946981
email = "";
@@ -990,6 +1025,9 @@ private void removeEditTextErrors() {
9901025
messageEt.setError(null);
9911026
}
9921027

1028+
/**
1029+
* Switch from Private to Stream or vice versa in chatBox
1030+
*/
9931031
private void switchView() {
9941032
if (isCurrentModeStream()) { //Person
9951033
togglePrivateStreamBtn.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_action_bullhorn));
@@ -1109,6 +1147,9 @@ private void setupTitleBar(String title, String subtitle) {
11091147
}
11101148
}
11111149

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

1178+
/**
1179+
* Fills the chatBox according to the {@link MessageType}
1180+
* @param openSoftKeyboard If true open's up the SoftKeyboard else not.
1181+
*/
11371182
@Override
11381183
public void onNarrowFillSendBox(Message message, boolean openSoftKeyboard) {
11391184
displayChatBox(true);
@@ -1155,6 +1200,12 @@ public void onNarrowFillSendBox(Message message, boolean openSoftKeyboard) {
11551200
}
11561201
}
11571202

1203+
/**
1204+
* Fills the chatBox with the stream name and the topic
1205+
* @param stream Stream name to be filled
1206+
* @param subject Subject to be filled
1207+
* @param openSoftKeyboard If true open's the softKeyboard else not
1208+
*/
11581209
public void onNarrowFillSendBoxStream(String stream, String subject, boolean openSoftKeyboard) {
11591210
displayChatBox(true);
11601211
displayFAB(false);
@@ -1292,6 +1343,10 @@ public void onClick(
12921343
return true;
12931344
}
12941345

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

@@ -1380,6 +1435,9 @@ protected void onDestroy() {
13801435
}
13811436
}
13821437

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

app/src/main/java/com/zulip/android/networking/AsyncGetEvents.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ private void processEvents(JSONArray events) {
306306
}
307307
}
308308

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

0 commit comments

Comments
 (0)