当前位置: 首页>>代码示例>>Java>>正文


Java FileDownloadHelper类代码示例

本文整理汇总了Java中com.liulishuo.filedownloader.util.FileDownloadHelper的典型用法代码示例。如果您正苦于以下问题:Java FileDownloadHelper类的具体用法?Java FileDownloadHelper怎么用?Java FileDownloadHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FileDownloadHelper类属于com.liulishuo.filedownloader.util包,在下文中一共展示了FileDownloadHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: NotificationItem

import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
private NotificationItem(int id, String title, String desc) {
    super(id, title, desc);
    Intent[] intents = new Intent[2];
    intents[0] = Intent.makeMainActivity(new ComponentName(DemoApplication.CONTEXT,
            MainActivity.class));
    intents[1] = new Intent(DemoApplication.CONTEXT, NotificationSampleActivity.class);

    this.pendingIntent = PendingIntent.getActivities(DemoApplication.CONTEXT, 0, intents,
            PendingIntent.FLAG_UPDATE_CURRENT);

    builder = new NotificationCompat.
            Builder(FileDownloadHelper.getAppContext());

    builder.setDefaults(Notification.DEFAULT_LIGHTS)
            .setOngoing(true)
            .setPriority(NotificationCompat.PRIORITY_MIN)
            .setContentTitle(getTitle())
            .setContentText(desc)
            .setContentIntent(pendingIntent)
            .setSmallIcon(R.mipmap.ic_launcher);

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:NotificationMinSetActivity.java

示例2: pauseAll

import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
/**
 * Pause all tasks running in FileDownloader.
 */
public void pauseAll() {
    FileDownloadTaskLauncher.getImpl().expireAll();
    final BaseDownloadTask.IRunningTask[] downloadList = FileDownloadList.getImpl().copy();
    for (BaseDownloadTask.IRunningTask task : downloadList) {
        task.getOrigin().pause();
    }
    // double check, for case: File Download progress alive but ui progress has died and relived,
    // so FileDownloadList not always contain all running task exactly.
    if (FileDownloadServiceProxy.getImpl().isConnected()) {
        FileDownloadServiceProxy.getImpl().pauseAllTasks();
    } else {
        if (pauseAllRunnable == null) {
            pauseAllRunnable = new Runnable() {
                @Override
                public void run() {
                    FileDownloadServiceProxy.getImpl().pauseAllTasks();
                }
            };
        }
        FileDownloadServiceProxy.getImpl().bindStartByContext(FileDownloadHelper.getAppContext(), pauseAllRunnable);
    }

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:FileDownloader.java

示例3: getStatus

import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
/**
 * @param id   The downloadId.
 * @param path The target file path.
 * @return the downloading status.
 * @see FileDownloadStatus
 * @see #getStatus(String, String)
 * @see #getStatusIgnoreCompleted(int)
 */
public byte getStatus(final int id, final String path) {
    byte status;
    BaseDownloadTask.IRunningTask task = FileDownloadList.getImpl().get(id);
    if (task == null) {
        status = FileDownloadServiceProxy.getImpl().getStatus(id);
    } else {
        status = task.getOrigin().getStatus();
    }

    if (path != null && status == FileDownloadStatus.INVALID_STATUS) {
        if (FileDownloadUtils.isFilenameConverted(FileDownloadHelper.getAppContext()) &&
                new File(path).exists()) {
            status = FileDownloadStatus.completed;
        }
    }

    return status;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:FileDownloader.java

示例4: sendCompletedBroadcast

import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
public static void sendCompletedBroadcast(FileDownloadModel model) {
    if (model == null) throw new IllegalArgumentException();
    if (model.getStatus() != FileDownloadStatus.completed) throw new IllegalStateException();

    final Intent intent = new Intent(ACTION_COMPLETED);
    intent.putExtra(KEY_MODEL, model);

    FileDownloadHelper.getAppContext().sendBroadcast(intent);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:FileDownloadBroadcastHandler.java

示例5: onCreate

import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    FileDownloadHelper.holdContext(this);

    try {
        FileDownloadUtils.setMinProgressStep(FileDownloadProperties.getImpl().DOWNLOAD_MIN_PROGRESS_STEP);
        FileDownloadUtils.setMinProgressTime(FileDownloadProperties.getImpl().DOWNLOAD_MIN_PROGRESS_TIME);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

    final FileDownloadManager manager = new FileDownloadManager();

    if (FileDownloadProperties.getImpl().PROCESS_NON_SEPARATE) {
        handler = new FDServiceSharedHandler(new WeakReference<>(this), manager);
    } else {
        handler = new FDServiceSeparateHandler(new WeakReference<>(this), manager);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:FileDownloadService.java

示例6: createOutputStreamCreator

import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
public FileDownloadHelper.OutputStreamCreator createOutputStreamCreator() {
    if (mMaker == null) {
        return createDefaultOutputStreamCreator();
    }

    final FileDownloadHelper.OutputStreamCreator outputStreamCreator = mMaker.mOutputStreamCreator;
    if (outputStreamCreator != null) {
        if (FileDownloadLog.NEED_LOG) {
            FileDownloadLog.d(this, "initial FileDownloader manager with the customize " +
                    "output stream: %s", outputStreamCreator);
        }
        return outputStreamCreator;
    } else {
        return createDefaultOutputStreamCreator();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:DownloadMgrInitialParams.java

示例7: createConnectionCreator

import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
public FileDownloadHelper.ConnectionCreator createConnectionCreator() {
    if (mMaker == null) {
        return createDefaultConnectionCreator();
    }

    final FileDownloadHelper.ConnectionCreator connectionCreator = mMaker.mConnectionCreator;

    if (connectionCreator != null) {
        if (FileDownloadLog.NEED_LOG) {
            FileDownloadLog.d(this, "initial FileDownloader manager with the customize " +
                    "connection creator: %s", connectionCreator);
        }
        return connectionCreator;
    } else {
        return createDefaultConnectionCreator();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:DownloadMgrInitialParams.java

示例8: createConnectionCountAdapter

import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
public FileDownloadHelper.ConnectionCountAdapter createConnectionCountAdapter() {
    if (mMaker == null) {
        return createDefaultConnectionCountAdapter();
    }

    final FileDownloadHelper.ConnectionCountAdapter adapter = mMaker.mConnectionCountAdapter;
    if (adapter != null) {
        if (FileDownloadLog.NEED_LOG) {
            FileDownloadLog.d(this, "initial FileDownloader manager with the customize " +
                    "connection count adapter: %s", adapter);
        }
        return adapter;
    } else {
        return createDefaultConnectionCountAdapter();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:DownloadMgrInitialParams.java

示例9: createIdGenerator

import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
public FileDownloadHelper.IdGenerator createIdGenerator() {
    if (mMaker == null) {
        return createDefaultIdGenerator();
    }

    final FileDownloadHelper.IdGenerator idGenerator = mMaker.mIdGenerator;
    if (idGenerator != null) {
        if (FileDownloadLog.NEED_LOG) {
            FileDownloadLog.d(this, "initial FileDownloader manager with the customize " +
                    "id generator: %s", idGenerator);
        }

        return idGenerator;
    } else {
        return createDefaultIdGenerator();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:DownloadMgrInitialParams.java

示例10: outputStreamCreator

import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
/**
 * Customize the output stream component.
 * <p>
 * If you don't customize the output stream component, we use the result of
 * {@link #createDefaultOutputStreamCreator()} as the default one.
 *
 * @param creator The output stream creator is used for creating {@link FileDownloadOutputStream}
 *                which is used to write the input stream to the file for downloading.
 */
public InitCustomMaker outputStreamCreator(FileDownloadHelper.OutputStreamCreator creator) {
    this.mOutputStreamCreator = creator;
    if (mOutputStreamCreator != null && !mOutputStreamCreator.supportSeek()) {
        if (!FileDownloadProperties.getImpl().FILE_NON_PRE_ALLOCATION) {
            throw new IllegalArgumentException("Since the provided FileDownloadOutputStream " +
                    "does not support the seek function, if FileDownloader pre-allocates " +
                    "file size at the beginning of the download, it will can not be resumed" +
                    " from the breakpoint. If you need to ensure that the resumption is" +
                    " available, please add and set the value of 'file.non-pre-allocation' " +
                    "field to 'true' in the 'filedownloader.properties' file which is in your" +
                    " application assets folder manually for resolving this problem.");
        }
    }
    return this;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:DownloadMgrInitialParams.java

示例11: dispatchTaskStart

import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
@Override
public boolean dispatchTaskStart(BaseDownloadTask.IRunningTask task) {
    if (!FileDownloader.getImpl().isServiceConnected()) {
        synchronized (mWaitingList) {
            if (!FileDownloader.getImpl().isServiceConnected()) {
                if (FileDownloadLog.NEED_LOG) {
                    FileDownloadLog.d(this, "Waiting for connecting with the downloader " +
                            "service... %d", task.getOrigin().getId());
                }
                FileDownloadServiceProxy.getImpl().
                        bindStartByContext(FileDownloadHelper.getAppContext());
                if (!mWaitingList.contains(task)) {
                    task.free();
                    mWaitingList.add(task);
                }
                return true;
            }
        }
    }

    taskWorkFine(task);

    return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:LostServiceConnectedHandler.java

示例12: init

import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
/**
 * @deprecated please using {@link #setupOnApplicationOnCreate(Application)} instead.
 */
public static void init(final Context context,
                        final DownloadMgrInitialParams.InitCustomMaker maker) {
    if (FileDownloadLog.NEED_LOG) {
        FileDownloadLog.d(FileDownloader.class, "init Downloader with params: %s %s",
                context, maker);
    }

    if (context == null) {
        throw new IllegalArgumentException("the provided context must not be null!");
    }

    FileDownloadHelper.holdContext(context.getApplicationContext());

    CustomComponentHolder.getImpl().setInitCustomMaker(maker);
}
 
开发者ID:lingochamp,项目名称:FileDownloader,代码行数:19,代码来源:FileDownloader.java

示例13: pauseAll

import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
/**
 * Pause all tasks running in FileDownloader.
 */
public void pauseAll() {
    FileDownloadTaskLauncher.getImpl().expireAll();
    final BaseDownloadTask.IRunningTask[] downloadList = FileDownloadList.getImpl().copy();
    for (BaseDownloadTask.IRunningTask task : downloadList) {
        task.getOrigin().pause();
    }
    // double check, for case: File Download progress alive but ui progress has died and relived
    // so FileDownloadList not always contain all running task exactly.
    if (FileDownloadServiceProxy.getImpl().isConnected()) {
        FileDownloadServiceProxy.getImpl().pauseAllTasks();
    } else {
        if (pauseAllRunnable == null) {
            pauseAllRunnable = new Runnable() {
                @Override
                public void run() {
                    FileDownloadServiceProxy.getImpl().pauseAllTasks();
                }
            };
        }
        FileDownloadServiceProxy.getImpl()
                .bindStartByContext(FileDownloadHelper.getAppContext(), pauseAllRunnable);
    }

}
 
开发者ID:lingochamp,项目名称:FileDownloader,代码行数:28,代码来源:FileDownloader.java

示例14: getStatus

import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
/**
 * @param id   The downloadId.
 * @param path The target file path.
 * @return the downloading status.
 * @see FileDownloadStatus
 * @see #getStatus(String, String)
 * @see #getStatusIgnoreCompleted(int)
 */
public byte getStatus(final int id, final String path) {
    byte status;
    BaseDownloadTask.IRunningTask task = FileDownloadList.getImpl().get(id);
    if (task == null) {
        status = FileDownloadServiceProxy.getImpl().getStatus(id);
    } else {
        status = task.getOrigin().getStatus();
    }

    if (path != null && status == FileDownloadStatus.INVALID_STATUS) {
        if (FileDownloadUtils.isFilenameConverted(FileDownloadHelper.getAppContext())
                && new File(path).exists()) {
            status = FileDownloadStatus.completed;
        }
    }

    return status;
}
 
开发者ID:lingochamp,项目名称:FileDownloader,代码行数:27,代码来源:FileDownloader.java

示例15: onCreate

import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    FileDownloadHelper.holdContext(this);

    try {
        FileDownloadUtils.setMinProgressStep(
                FileDownloadProperties.getImpl().downloadMinProgressStep);
        FileDownloadUtils.setMinProgressTime(
                FileDownloadProperties.getImpl().downloadMinProgressTime);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

    final FileDownloadManager manager = new FileDownloadManager();

    if (FileDownloadProperties.getImpl().processNonSeparate) {
        handler = new FDServiceSharedHandler(new WeakReference<>(this), manager);
    } else {
        handler = new FDServiceSeparateHandler(new WeakReference<>(this), manager);
    }
}
 
开发者ID:lingochamp,项目名称:FileDownloader,代码行数:23,代码来源:FileDownloadService.java


注:本文中的com.liulishuo.filedownloader.util.FileDownloadHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。