Skip to content

Commit

Permalink
Added progress for the search screen. Removed unused code.| #793
Browse files Browse the repository at this point in the history
  • Loading branch information
DenBond7 committed Jan 10, 2020
1 parent 3bfdc54 commit 6150144
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ class ConnectionSyncRunnable(account: AccountDao, syncListener: SyncListener)

fun searchMsgs(ownerKey: String, requestCode: Int, localFolder: LocalFolder, alreadyLoadedMsgsCount: Int) {
try {
syncListener.onActionProgress(account, ownerKey, requestCode, R.id.progress_id_adding_task_to_queue)
removeOldTasks(SearchMessagesSyncTask::class.java, tasksQueue)
tasksQueue.put(SearchMessagesSyncTask(ownerKey, requestCode, localFolder, alreadyLoadedMsgsCount))
} catch (e: InterruptedException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package com.flowcrypt.email.api.email.sync.tasks

import android.content.Context
import com.flowcrypt.email.R
import com.flowcrypt.email.api.email.EmailUtil
import com.flowcrypt.email.api.email.JavaEmailConstants
import com.flowcrypt.email.api.email.model.LocalFolder
Expand Down Expand Up @@ -46,6 +47,7 @@ class SearchMessagesSyncTask(ownerKey: String,

override fun runIMAPAction(account: AccountDao, session: Session, store: Store, listener: SyncListener) {
super.runIMAPAction(account, session, store, listener)
listener.onActionProgress(account, ownerKey, requestCode, R.id.progress_id_opening_store)

val imapFolder = store.getFolder(localFolder.fullName) as IMAPFolder
imapFolder.open(Folder.READ_ONLY)
Expand All @@ -66,6 +68,8 @@ class SearchMessagesSyncTask(ownerKey: String,
else -> startCandidate
}

listener.onActionProgress(account, ownerKey, requestCode, R.id.progress_id_getting_list_of_emails)

if (end < 1) {
listener.onSearchMsgsReceived(account, localFolder, imapFolder, arrayOf(), ownerKey, requestCode)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,11 @@ abstract class BaseEmailListActivity : BaseSyncActivity(), EmailListFragment.OnM

override fun onProgressReplyReceived(requestCode: Int, resultCode: Int, obj: Any?) {
when (requestCode) {
R.id.syns_request_code_load_next_messages -> when (resultCode) {
R.id.syns_request_code_load_next_messages, R.id.sync_request_code_search_messages -> when (resultCode) {
R.id.progress_id_start_of_loading_new_messages -> updateActionProgressState(0, "Starting")

R.id.progress_id_adding_task_to_queue -> updateActionProgressState(10, "Queuing")

R.id.progress_id_queue_is_not_empty -> updateActionProgressState(15, "Queue is not empty")

R.id.progress_id_thread_is_cancelled_and_done -> updateActionProgressState(15, "Thread is cancelled and done")

R.id.progress_id_thread_is_done -> updateActionProgressState(15, "Thread is done")

R.id.progress_id_thread_is_cancelled -> updateActionProgressState(15, "Thread is cancelled")

R.id.progress_id_running_task -> updateActionProgressState(20, "Running task")

R.id.progress_id_resetting_connection -> updateActionProgressState(30, "Resetting connection")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ abstract class BaseSyncActivity : BaseNodeActivity() {
* @param alreadyLoadedMsgsCount The count of already loaded messages in the localFolder.
*/
fun searchNextMsgs(requestCode: Int, localFolder: LocalFolder, alreadyLoadedMsgsCount: Int) {
onProgressReplyReceived(requestCode, R.id.progress_id_start_of_loading_new_messages, Any())
if (checkServiceBound(isSyncServiceBound)) return

val action = BaseService.Action(replyMessengerName, requestCode, localFolder)
Expand Down
4 changes: 0 additions & 4 deletions FlowCrypt/src/main/res/values/ids.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@
<item name="progress_id_running_imap_action" type="id" />
<item name="progress_id_opening_store" type="id" />
<item name="progress_id_getting_list_of_emails" type="id" />
<item name="progress_id_queue_is_not_empty" type="id" />
<item name="progress_id_thread_is_cancelled_and_done" type="id" />
<item name="progress_id_thread_is_done" type="id" />
<item name="progress_id_thread_is_cancelled" type="id" />
<item name="progress_id_connecting" type="id" />
<item name="progress_id_fetching_message" type="id" />
<item name="progress_id_processing" type="id" />
Expand Down

0 comments on commit 6150144

Please sign in to comment.