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


Java Helpers类代码示例

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


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

示例1: RemoveOBBFile

import com.google.android.vending.expansion.downloader.Helpers; //导入依赖的package包/类
static private void RemoveOBBFile(int OBBToDelete) {
	
	for (OBBData.XAPKFile xf : OBBData.xAPKS) {
	    String fileName = Helpers.getExpansionAPKFileName(DownloaderActivity._download, xf.mIsMain, xf.mFileVersion);
		switch(OBBToDelete)
		{
		case 0:
			String fileForNewFile = Helpers.generateSaveFileName(DownloaderActivity._download, fileName);
			File srcFile = new File(fileForNewFile);
			srcFile.delete();
			break;
		case 1:
			String fileForDevFile = Helpers.generateSaveFileNameDevelopment(DownloaderActivity._download, fileName);
			File srcDevFile = new File(fileForDevFile);
			srcDevFile.delete();
			break;
		}
	}		
}
 
开发者ID:FallingUpGame,项目名称:FallingUp,代码行数:20,代码来源:DownloaderActivity.java

示例2: onDownloadProgress

import com.google.android.vending.expansion.downloader.Helpers; //导入依赖的package包/类
/**
 * Sets the state of the various controls based on the progressinfo object
 * sent from the downloader service.
 */
@Override
public void onDownloadProgress(DownloadProgressInfo progress) {
    mAverageSpeed.setText(getString(R.string.kilobytes_per_second,
            Helpers.getSpeedString(progress.mCurrentSpeed)));
    mTimeRemaining.setText(getString(R.string.time_remaining,
            Helpers.getTimeRemaining(progress.mTimeRemaining)));

    progress.mOverallTotal = progress.mOverallTotal;
    mPB.setMax((int) (progress.mOverallTotal >> 8));
    mPB.setProgress((int) (progress.mOverallProgress >> 8));
    mProgressPercent.setText(Long.toString(progress.mOverallProgress
            * 100 /
            progress.mOverallTotal) + "%");
    mProgressFraction.setText(Helpers.getDownloadProgressString
            (progress.mOverallProgress,
                    progress.mOverallTotal));
}
 
开发者ID:FallingUpGame,项目名称:FallingUp,代码行数:22,代码来源:DownloaderActivity.java

示例3: finalizeDestinationFile

import com.google.android.vending.expansion.downloader.Helpers; //导入依赖的package包/类
/**
 * Called after a successful completion to take any necessary action on the
 * downloaded file.
 */
private void finalizeDestinationFile(State state) throws StopRequest {
    syncDestination(state);
    String tempFilename = state.mFilename;
    String finalFilename = Helpers.generateSaveFileName(mService, mInfo.mFileName);
    if (!state.mFilename.equals(finalFilename)) {
        File startFile = new File(tempFilename);
        File destFile = new File(finalFilename);
        if (mInfo.mTotalBytes != -1 && mInfo.mCurrentBytes == mInfo.mTotalBytes) {
            if (!startFile.renameTo(destFile)) {
                throw new StopRequest(DownloaderService.STATUS_FILE_ERROR,
                        "unable to finalize destination file");
            }
        } else {
            throw new StopRequest(DownloaderService.STATUS_FILE_DELIVERED_INCORRECTLY,
                    "file delivered with incorrect size. probably due to network not browser configured");
        }
    }
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:23,代码来源:DownloadThread.java

示例4: onDownloadProgress

import com.google.android.vending.expansion.downloader.Helpers; //导入依赖的package包/类
@Override
public void onDownloadProgress(DownloadProgressInfo progress) {
    mProgressInfo = progress;
    if (null != mClientProxy) {
        mClientProxy.onDownloadProgress(progress);
    }
    if (progress.mOverallTotal <= 0) {
        // we just show the text
        mBuilder.setTicker(mCurrentTitle);
        mBuilder.setSmallIcon(android.R.drawable.stat_sys_download);
        mBuilder.setContentTitle(mCurrentTitle);
        mBuilder.setContentText(mCurrentText);
        mCurrentBuilder = mBuilder;
    } else {
        mActiveDownloadBuilder.setProgress((int) progress.mOverallTotal, (int) progress.mOverallProgress, false);
        mActiveDownloadBuilder.setContentText(Helpers.getDownloadProgressString(progress.mOverallProgress, progress.mOverallTotal));
        mActiveDownloadBuilder.setSmallIcon(android.R.drawable.stat_sys_download);
        mActiveDownloadBuilder.setTicker(mLabel + ": " + mCurrentText);
        mActiveDownloadBuilder.setContentTitle(mLabel);
        mActiveDownloadBuilder.setContentInfo(mContext.getString(Helpers.getStringResource(mContext, "time_remaining_notification"),
                Helpers.getTimeRemaining(progress.mTimeRemaining)));
        mCurrentBuilder = mActiveDownloadBuilder;
    }
    mNotificationManager.notify(NOTIFICATION_ID, mCurrentBuilder.build());
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:26,代码来源:DownloadNotification.java

示例5: handleFileUpdated

import com.google.android.vending.expansion.downloader.Helpers; //导入依赖的package包/类
/**
 * The APK has been updated and a filename has been sent down from the
 * Market call. If the file has the same name as the previous file, we do
 * nothing as the file is guaranteed to be the same. If the file does not
 * have the same name, we download it if it hasn't already been delivered by
 * Market.
 *
 * @param index the index of the file from market (0 = main, 1 = patch)
 * @param filename the name of the new file
 * @param fileSize the size of the new file
 * @return
 */
public boolean handleFileUpdated(DownloadsDB db, int index,
        String filename, long fileSize) {
    DownloadInfo di = db.getDownloadInfoByFileName(filename);
    if (null != di) {
        String oldFile = di.mFileName;
        // cleanup
        if (null != oldFile) {
            if (filename.equals(oldFile)) {
                return false;
            }

            // remove partially downloaded file if it is there
            String deleteFile = Helpers.generateSaveFileName(this, oldFile);
            File f = new File(deleteFile);
            if (f.exists())
                f.delete();
        }
    }
    return !Helpers.doesFileExist(this, filename, fileSize, true);
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:33,代码来源:DownloaderService.java

示例6: generateSaveFile

import com.google.android.vending.expansion.downloader.Helpers; //导入依赖的package包/类
/**
 * Creates a filename (where the file should be saved) from info about a
 * download.
 */
public String generateSaveFile(String filename, long filesize)
        throws GenerateSaveFileError {
    String path = generateTempSaveFileName(filename);
    File expPath = new File(path);
    if (!Helpers.isExternalMediaMounted()) {
        Log.d(Constants.TAG, "External media not mounted: " + path);
        throw new GenerateSaveFileError(STATUS_DEVICE_NOT_FOUND_ERROR,
                "external media is not yet mounted");

    }
    if (expPath.exists()) {
        Log.d(Constants.TAG, "File already exists: " + path);
        throw new GenerateSaveFileError(STATUS_FILE_ALREADY_EXISTS_ERROR,
                "requested destination file already exists");
    }
    if (Helpers.getAvailableBytes(Helpers.getFilesystemRoot(path)) < filesize) {
        throw new GenerateSaveFileError(STATUS_INSUFFICIENT_SPACE_ERROR,
                "insufficient space on external storage");
    }
    return path;
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:26,代码来源:DownloaderService.java

示例7: updateNotification

import com.google.android.vending.expansion.downloader.Helpers; //导入依赖的package包/类
@Override
public Notification updateNotification(Context c) {
    Notification.Builder builder = new Notification.Builder(c);
    builder.setContentTitle(mTitle);
    if (mTotalKB > 0 && -1 != mCurrentKB) {
        builder.setProgress((int) (mTotalKB >> 8), (int) (mCurrentKB >> 8), false);
    } else {
        builder.setProgress(0, 0, true);
    }
    builder.setContentText(Helpers.getDownloadProgressString(mCurrentKB, mTotalKB));
    builder.setContentInfo(c.getString(R.string.time_remaining_notification,
            Helpers.getTimeRemaining(mTimeRemaining)));
    if (mIcon != 0) {
        builder.setSmallIcon(mIcon);
    } else {
        int iconResource = android.R.drawable.stat_sys_download;
        builder.setSmallIcon(iconResource);
    }
    builder.setOngoing(true);
    builder.setTicker(mTicker);
    builder.setContentIntent(mPendingIntent);
    builder.setOnlyAlertOnce(true);

    return builder.getNotification();
}
 
开发者ID:SlotNSlot,项目名称:SlotNSlot_Android,代码行数:26,代码来源:V14CustomNotification.java

示例8: handleFileUpdated

import com.google.android.vending.expansion.downloader.Helpers; //导入依赖的package包/类
/**
 * The APK has been updated and a filename has been sent down from the
 * Market call. If the file has the same name as the previous file, we do
 * nothing as the file is guaranteed to be the same. If the file does not
 * have the same name, we download it if it hasn't already been delivered by
 * Market.
 * 
 * @param index the index of the file from market (0 = main, 1 = patch)
 * @param filename the name of the new file
 * @param fileSize the size of the new file
 * @return
 */
public boolean handleFileUpdated(DownloadsDB db, int index,
        String filename, long fileSize) {
    DownloadInfo di = db.getDownloadInfoByFileName(filename);
    if (null != di) {
        String oldFile = di.mFileName;
        // cleanup
        if (null != oldFile) {
            if (filename.equals(oldFile)) {
                return false;
            }

            // remove partially downloaded file if it is there
            String deleteFile = Helpers.generateSaveFileName(this, oldFile);
            File f = new File(deleteFile);
            if (f.exists())
                f.delete();
        }
    }
    return !Helpers.doesFileExist(this, filename, fileSize, true);
}
 
开发者ID:SlotNSlot,项目名称:SlotNSlot_Android,代码行数:33,代码来源:DownloaderService.java

示例9: onDownloadProgress

import com.google.android.vending.expansion.downloader.Helpers; //导入依赖的package包/类
@Override
public void onDownloadProgress(DownloadProgressInfo progress) {
    mProgressInfo = progress;
    if (null != mClientProxy) {
        mClientProxy.onDownloadProgress(progress);
    }
    if (progress.mOverallTotal <= 0) {
        // we just show the text
        mBuilder.setTicker(mCurrentTitle);
        mBuilder.setSmallIcon(android.R.drawable.stat_sys_download);
        mBuilder.setContentTitle(mCurrentTitle);
        mBuilder.setContentText(mCurrentText);
        mCurrentBuilder = mBuilder;
    } else {
        mActiveDownloadBuilder.setProgress((int) progress.mOverallTotal, (int) progress.mOverallProgress, false);
        mActiveDownloadBuilder.setContentText(Helpers.getDownloadProgressString(progress.mOverallProgress, progress.mOverallTotal));
        mActiveDownloadBuilder.setSmallIcon(android.R.drawable.stat_sys_download);
        mActiveDownloadBuilder.setTicker(mLabel + ": " + mCurrentText);
        mActiveDownloadBuilder.setContentTitle(mLabel);
        mActiveDownloadBuilder.setContentInfo(mContext.getString(R.string.time_remaining_notification,
                Helpers.getTimeRemaining(progress.mTimeRemaining)));
        mCurrentBuilder = mActiveDownloadBuilder;
    }
    mNotificationManager.notify(NOTIFICATION_ID, mCurrentBuilder.build());
}
 
开发者ID:google,项目名称:play-apk-expansion,代码行数:26,代码来源:DownloadNotification.java

示例10: doInBackground

import com.google.android.vending.expansion.downloader.Helpers; //导入依赖的package包/类
@Override
protected Boolean doInBackground(Void... params) {
    try {
        for (XAPKFile xFile : mXFiles) {
            String fileName = Helpers.getExpansionAPKFileName(mContext, xFile.mIsMain, xFile.mFileVersion);
            String srcFileName = Helpers.generateSaveFileName(mContext, fileName);
            File srcFile = new File(srcFileName);
            if (!unzip(srcFile, mDestFolder)) {
                return false;
            }
        }
        return true;
    } catch (Exception e) {
        return false;
    }
}
 
开发者ID:cclink,项目名称:ObbDownloadHelper,代码行数:17,代码来源:ObbUnzipHelper.java

示例11: expansionFilesDelivered

import com.google.android.vending.expansion.downloader.Helpers; //导入依赖的package包/类
/**
 * Go through each of the Expansion APK files defined in the project and
 * determine if the files are present and match the required size. Free
 * applications should definitely consider doing this, as this allows the
 * application to be launched for the first time without having a network
 * connection present. Paid applications that use LVL should probably do at
 * least one LVL check that requires the network to be present, so this is
 * not as necessary.
 * 
 * @return true if they are present.
 */
public boolean expansionFilesDelivered() {
    // Determine whether the apk expansion files exist, and the file size is
    // correct
    for (XAPKFile xf : xAPKS) {
        String fileName = Helpers.getExpansionAPKFileName(mContext, xf.mIsMain, xf.mFileVersion);
        if (!Helpers.doesFileExist(mContext, fileName, xf.mFileSize, false)) {
            if (xf.mIsMain) {
                Log.i("APKExpansionDownloader", "Expansion files are not delivered: main obb does not exist");
            } else {
                Log.i("APKExpansionDownloader", "Expansion files are not delivered: patch obb does not exist");
            }
            return false;
        }
    }
    Log.i("APKExpansionDownloader", "Expansion files are already delivered");
    return true;
}
 
开发者ID:cclink,项目名称:ObbDownloadHelper,代码行数:29,代码来源:ObbDownloadHelper.java

示例12: copy

import com.google.android.vending.expansion.downloader.Helpers; //导入依赖的package包/类
private void copy(XAPKFile[] xfs, String folder, ObbCopyListener listener) {
    if (!XAPKFileUitl.checkXAPKs(mContext, xfs)) {
        Log.w("APKExpansionCopy", "Copy failed, obb file check failed");
        if (listener != null) {
            listener.onCopyFailed();
        }
    }
    // run the copy task
    else {
        String filePath = Helpers.getSaveFilePath(mContext);
        // if the target folder is the same as the obb files path, we do nothing and just call onCopyComplete()
        if (filePath.equals(folder)) {
            listener.onCopyComplete();
        } else {
            mListener = listener;
            new CopyTask(xAPKS, folder).execute();
        }
    }
}
 
开发者ID:cclink,项目名称:ObbDownloadHelper,代码行数:20,代码来源:ObbCopyHelper.java

示例13: doInBackground

import com.google.android.vending.expansion.downloader.Helpers; //导入依赖的package包/类
@Override
protected Boolean doInBackground(Void... params) {
    try {
        for (XAPKFile xFile : mXFiles) {
            String fileName = Helpers.getExpansionAPKFileName(mContext, xFile.mIsMain, xFile.mFileVersion);
            String srcFileName = Helpers.generateSaveFileName(mContext, fileName);
            File srcFile = new File(srcFileName);
            if (!copy(srcFile, mDestFolder)) {
                return false;
            }
        }
        return true;
    } catch (Exception e) {
        return false;
    }
}
 
开发者ID:cclink,项目名称:ObbDownloadHelper,代码行数:17,代码来源:ObbCopyHelper.java


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