本文整理汇总了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;
}
}
}
示例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));
}
示例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");
}
}
}
示例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());
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
示例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());
}
示例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;
}
}
示例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;
}
示例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();
}
}
}
示例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;
}
}