@Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { case OVERSCROLLED_MSG: if (!mOverHandleInterval) { break; } mOverHandleInterval = false; Logging.d( "NonLockingScrollView handleMessage toggling loading actually !!! spend " + (System.currentTimeMillis() - mElapsedOverScrolled) + " ms"); mOnOverScrollListener.onOverScrolled(); mToggleLoading = false; mElapsedOverScrolled = 0; mHandler.postDelayed( new Runnable() { @Override public void run() { mOverHandleInterval = true; } }, 1000); break; default: break; } }
public void run() { try { final Folder remoteFolder = mRemoteStoreInner.getFolder(mToMailboxInner.mServerId); remoteFolder.open(OpenMode.READ_WRITE); while ((mUnsyncedMessageInner = getUnsyncedMessage()) != null) { ArrayList<Message> messages = new ArrayList<Message>(); messages.add(mUnsyncedMessageInner); loadUnsyncedMessages(mContext, mAccountInner, remoteFolder, messages, mToMailboxInner); } remoteFolder.close(false); } catch (MessagingException me) { Logging.d("LoadUnsyncMessageAsyncTask", me); /** M: Save MessagingException to send exception out */ mMessagingException = me; } finally { synchronized (mUnsyncedMessages) { mRunningSyncThreadCount--; if (mRunningSyncThreadCount == 0) { mUnsyncedMessages.notify(); } } } }
public void sendMessage() throws IOException { Logging.d(TAG, "Start send message ... for Uri " + mUri); // Initialize return value int resultType = EmailExternalConstants.TYPE_SEND; int result = EmailExternalConstants.RESULT_SUCCESS; mInputStream = mContentResolver.openInputStream(mUri); if (null == mInputStream) { Logging.w( TAG, "Send Message Failed in sendMessage() method , " + "Can't get InputStream from the given uri: " + mUri); result = EmailExternalConstants.RESULT_FAIL; sendCallback(result, resultType); return; } // Write the output to a temporary file File cacheDir = mContext.getCacheDir(); File tmpFile = File.createTempFile("eas_", "tmp", cacheDir); writToFile(mInputStream, tmpFile); try { mInputStream.close(); } catch (Exception e) { Logging.e(TAG, "Closes inputstream fail.", e); } try { // Get an input stream to our temporary file and create an entity with it FileInputStream fileInputStream = new FileInputStream(tmpFile); InputStreamEntity inputEntity = new InputStreamEntity(fileInputStream, tmpFile.length()); // Create the appropriate command and POST it to the server String cmd = "SendMail&SaveInSent=F"; if (mSaveInSent) { cmd = "SendMail&SaveInSent=T"; } // if (smartSend) { // cmd = reply ? "SmartReply" : "SmartForward"; // cmd += "&ItemId=" + itemId + "&CollectionId=" + collectionId + // "&SaveInSent=T"; // } Logging.d(TAG, "Send cmd: " + cmd); EasResponse resp = sendHttpClientPost(cmd, inputEntity, EasOutboxService.SEND_MAIL_TIMEOUT); fileInputStream.close(); // Send feedback // sendCallback(result, resultType); // TODO:How to define the Deliver complete. // resultType = EmailExternalConstants.TYPE_DELIVER; int code = resp.getStatus(); if (code == HttpStatus.SC_OK) { Logging.d(TAG, "EAS Message sending success, code:" + code); result = EmailExternalConstants.RESULT_SUCCESS; sendCallback(result, resultType); return; } else { Logging.d(TAG, "EAS Message sending failed, code:" + code); result = EmailExternalConstants.RESULT_FAIL; } } catch (FileNotFoundException e) { Logging.e(TAG, "EAS SendMessage FileNotFoundException " + e.getMessage()); result = EmailExternalConstants.RESULT_FAIL; } catch (IOException e) { Logging.e(TAG, "EAS SendMessage Exception " + e.getMessage()); result = EmailExternalConstants.RESULT_FAIL; } finally { // Clean up the temporary file if (tmpFile.exists()) { tmpFile.delete(); } } Logging.d(TAG, "EAS send Message feedback result = " + result + " resultType = " + resultType); sendCallback(result, resultType); }