本文整理汇总了Java中com.kanedias.vanilla.plugins.saf.SafRequestActivity类的典型用法代码示例。如果您正苦于以下问题:Java SafRequestActivity类的具体用法?Java SafRequestActivity怎么用?Java SafRequestActivity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SafRequestActivity类属于com.kanedias.vanilla.plugins.saf包,在下文中一共展示了SafRequestActivity类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeFile
import com.kanedias.vanilla.plugins.saf.SafRequestActivity; //导入依赖的package包/类
/**
* Writes file to backing filesystem provider, this may be either SAF-managed sdcard or internal storage.
*/
public void writeFile() {
if (SafUtils.isSafNeeded(mAudioFile.getFile(), this)) {
if (mPrefs.contains(PREF_SDCARD_URI)) {
// we already got the permission!
persistThroughSaf(null);
return;
}
// request SAF permissions in SAF activity
Intent safIntent = new Intent(this, SafRequestActivity.class);
safIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
safIntent.putExtra(PluginConstants.EXTRA_PARAM_PLUGIN_APP, getApplicationInfo());
safIntent.putExtras(mLaunchIntent);
startActivity(safIntent);
// it will pass us URI back after the work is done
} else {
persistThroughFile();
}
}
示例2: persistAsFolderJpg
import com.kanedias.vanilla.plugins.saf.SafRequestActivity; //导入依赖的package包/类
/**
* Click listener for handling writing tag as folder.jpg
*/
public void persistAsFolderJpg() {
Uri fileUri = getIntent().getParcelableExtra(EXTRA_PARAM_URI);
if (fileUri == null) {
// wrong intent passed?
return;
}
File mediaFile = new File(fileUri.getPath());
if (!mediaFile.exists()) {
// file deleted while launching intent or player db is not refreshed
return;
}
// image must be present because this button enables only after it's downloaded
Bitmap bitmap = ((BitmapDrawable) mCoverImage.getDrawable()).getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, stream);
byte[] imgData = stream.toByteArray();
File folderTarget = new File(mediaFile.getParent(), "folder.jpg");
if (isSafNeeded(mediaFile)) {
if (mPrefs.contains(PREF_SDCARD_URI)) {
// we already got the permission!
writeThroughSaf(imgData, mediaFile, folderTarget.getName());
return;
}
// request SAF permissions in SAF activity
Intent safIntent = new Intent(CoverShowActivity.this, SafRequestActivity.class);
safIntent.putExtra(PluginConstants.EXTRA_PARAM_PLUGIN_APP, getApplicationInfo());
safIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
safIntent.putExtras(getIntent());
startActivity(safIntent);
// it will pass us URI back after the work is done
} else {
writeThroughFile(imgData, mediaFile, folderTarget);
}
}
示例3: persistAsLrcFile
import com.kanedias.vanilla.plugins.saf.SafRequestActivity; //导入依赖的package包/类
/**
* Write lyrics as a *.lrc file - selects SAF/File routine based on target access.
* Resulting file should be placed in the same directory as media file but with *.lrc extension instead.
*/
private void persistAsLrcFile() {
Uri fileUri = getIntent().getParcelableExtra(EXTRA_PARAM_URI);
if (fileUri == null) {
// wrong intent passed?
return;
}
File mediaFile = new File(fileUri.getPath());
if (!mediaFile.exists()) {
// file deleted while launching intent or player db is not refreshed
return;
}
String lrcFilename = lyricsForFile(mediaFile);
File lrcTarget = new File(mediaFile.getParent(), lrcFilename);
byte[] data = mLyricsText.getText().toString().getBytes(Charset.forName("UTF-8"));
if (isSafNeeded(mediaFile, this)) {
if (mPrefs.contains(PREF_SDCARD_URI)) {
// we already got the permission!
writeThroughSaf(data, mediaFile, lrcTarget.getName());
return;
}
// request SAF permissions in SAF activity
Intent safIntent = new Intent(this, SafRequestActivity.class);
safIntent.putExtra(PluginConstants.EXTRA_PARAM_PLUGIN_APP, getApplicationInfo());
safIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
safIntent.putExtras(getIntent());
startActivity(safIntent);
// it will pass us URI back after the work is done
} else {
writeThroughFile(data, mediaFile, lrcTarget);
}
}