当前位置: 首页>>代码示例>>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;未经允许,请勿转载。