當前位置: 首頁>>代碼示例>>Java>>正文


Java SyncRunnable類代碼示例

本文整理匯總了Java中com.android.ddmuilib.SyncProgressHelper.SyncRunnable的典型用法代碼示例。如果您正苦於以下問題:Java SyncRunnable類的具體用法?Java SyncRunnable怎麽用?Java SyncRunnable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SyncRunnable類屬於com.android.ddmuilib.SyncProgressHelper包,在下文中一共展示了SyncRunnable類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: promptAndPull

import com.android.ddmuilib.SyncProgressHelper.SyncRunnable; //導入依賴的package包/類
/**
 * Prompts the user for a save location and pulls the remote files into this location.
 * <p/>This <strong>must</strong> be called from the UI Thread.
 * @param sync the {@link SyncService} to use to pull the file from the device
 * @param localFileName The default local name
 * @param remoteFilePath The name of the file to pull off of the device
 * @param title The title of the File Save dialog.
 * @return The result of the pull as a {@link SyncResult} object, or null if the sync
 * didn't happen (canceled by the user).
 * @throws InvocationTargetException
 * @throws InterruptedException
 * @throws SyncException if an error happens during the push of the package on the device.
 * @throws IOException
 */
protected void promptAndPull(final SyncService sync,
        String localFileName, final String remoteFilePath, String title)
        throws InvocationTargetException, InterruptedException, SyncException, TimeoutException,
        IOException {
    FileDialog fileDialog = new FileDialog(mParentShell, SWT.SAVE);

    fileDialog.setText(title);
    fileDialog.setFileName(localFileName);

    final String localFilePath = fileDialog.open();
    if (localFilePath != null) {
        SyncProgressHelper.run(new SyncRunnable() {
            @Override
            public void run(ISyncProgressMonitor monitor) throws SyncException, IOException,
                    TimeoutException {
                sync.pullFile(remoteFilePath, localFilePath, monitor);
            }

            @Override
            public void close() {
                sync.close();
            }
        },
        String.format("Pulling %1$s from the device", remoteFilePath), mParentShell);
    }
}
 
開發者ID:utds3lab,項目名稱:SMVHunter,代碼行數:41,代碼來源:BaseFileHandler.java

示例2: pull

import com.android.ddmuilib.SyncProgressHelper.SyncRunnable; //導入依賴的package包/類
/**
 * Pulls a file from a device.
 * 
 * @param remote
 *            the remote file on the device
 * @param local
 *            the destination filepath
 */
public void pull(final String local, Shell parent, final Runnable callBack) {
    final SyncService sync;

    try {
        sync = sv.mDevice.getSyncService();

        if (sync != null) {
            SyncProgressHelper.run(new SyncRunnable() {
                @Override
                public void run(ISyncProgressMonitor monitor) throws SyncException,
                        IOException, TimeoutException {
                    sync.pullFile(getPath(), mEntry.getSizeValue(), local, monitor);
                }

                @Override
                public void close() {
                    sync.close();
                    if (callBack != null) {
                        callBack.run();
                    }
                }
            }, String.format("Pulling %1$s from the device", getName()), parent);
        }
    } catch (Exception e) {
        e.printStackTrace();
        MessageBox msg = new MessageBox(parent);
        if (e.getMessage() != null) {
            msg.setMessage(e.getMessage());
        }
        msg.setText("Error!!");
        msg.open();
    }
}
 
開發者ID:lrscp,項目名稱:AndroidFileExplorer,代碼行數:42,代碼來源:File.java

示例3: pullFiles

import com.android.ddmuilib.SyncProgressHelper.SyncRunnable; //導入依賴的package包/類
public void pullFiles(final File[] files, final String local, Shell parent,
        final Runnable callBack) {
    try {
        final SyncService sync = sv.mDevice.getSyncService();
        if (sync != null) {
            SyncProgressHelper.run(new SyncRunnable() {
                @Override
                public void run(ISyncProgressMonitor monitor) throws SyncException,
                        IOException, TimeoutException {
                    monitor.start(getTotalRemoteFileSize(files));
                    doPullFiles(files, local, monitor, sync);
                    monitor.stop();
                }

                @Override
                public void close() {
                    sync.close();
                    if (callBack != null) {
                        callBack.run();
                    }
                }
            }, String.format("Pulling %1$s from the device", getName()), parent);
        }
    } catch (Exception e) {
        e.printStackTrace();
        MessageBox msg = new MessageBox(parent);
        if (e.getMessage() != null) {
            msg.setMessage(e.getMessage());
        }
        msg.setText("Error!!");
        msg.open();
    }
}
 
開發者ID:lrscp,項目名稱:AndroidFileExplorer,代碼行數:34,代碼來源:File.java

示例4: pushFiles

import com.android.ddmuilib.SyncProgressHelper.SyncRunnable; //導入依賴的package包/類
public void pushFiles(Shell parent, final String[] local, final File remote,
        final Runnable callBack) {
    try {
        final SyncService sync = sv.mDevice.getSyncService();
        if (sync != null) {
            SyncProgressHelper.run(new SyncRunnable() {
                @Override
                public void run(ISyncProgressMonitor monitor) throws SyncException,
                        IOException, TimeoutException {
                    if (remote.isDirectory() == false) {
                        throw new SyncException(SyncError.REMOTE_IS_FILE);
                    }

                    // make a list of File from the list of String
                    ArrayList<java.io.File> files = new ArrayList<java.io.File>();
                    for (String path : local) {
                        files.add(new java.io.File(path));
                    }

                    // get the total count of the bytes to transfer
                    java.io.File[] fileArray = files.toArray(new java.io.File[files.size()]);
                    int total = sync.getTotalLocalFileSize(fileArray);

                    monitor.start(total);

                    sync.doPush(fileArray, remote.getPath(), monitor);

                    monitor.stop();
                }

                @Override
                public void close() {
                    sync.close();
                    if (callBack != null) {
                        callBack.run();
                    }
                }
            }, String.format("Push to the device %1$s", getName()), parent);
        }
    } catch (Exception e) {
        e.printStackTrace();
        notifyError(e.getMessage());
    }
}
 
開發者ID:lrscp,項目名稱:AndroidFileExplorer,代碼行數:45,代碼來源:File.java


注:本文中的com.android.ddmuilib.SyncProgressHelper.SyncRunnable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。