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


Java PluginUtils类代码示例

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


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

示例1: loadFromFile

import com.kanedias.vanilla.plugins.PluginUtils; //导入依赖的package包/类
private boolean loadFromFile() {
    if (!PluginUtils.havePermissions(this, WRITE_EXTERNAL_STORAGE)) {
        return false;
    }

    Uri fileUri = getIntent().getParcelableExtra(EXTRA_PARAM_URI);
    File media = new File(fileUri.getPath());
    File folderJpg = new File(media.getParentFile(), "folder.jpg");
    if (!folderJpg.exists()) {
        return false;
    }

    Bitmap raw = BitmapFactory.decodeFile(folderJpg.getPath());
    if (raw == null) {
        return false;
    }

    setCoverImage(raw);
    return true;
}
 
开发者ID:vanilla-music,项目名称:vanilla-music-cover-fetch,代码行数:21,代码来源:CoverShowActivity.java

示例2: onResume

import com.kanedias.vanilla.plugins.PluginUtils; //导入依赖的package包/类
/**
 * Handle Vanilla Music player intents. This will show activity window (in most cases) and load
 * all needed info from file.
 */
@Override
protected void onResume() {
    super.onResume();

    // onResume will fire both on first launch and on return from permission request
    if (!PluginUtils.checkAndRequestPermissions(this, WRITE_EXTERNAL_STORAGE)) {
        return;
    }

    if (getIntent().hasExtra(EXTRA_PARAM_P2P)) {
        // if we're here, then user didn't grant tag editor "write to SD" permission before
        // and service passed P2P intent to activity in hope that it will sort it out.
        // We need to pass this intent back to service as user had approved permission request
        Intent serviceStart = new Intent(this, PluginService.class);
        serviceStart.setAction(ACTION_LAUNCH_PLUGIN);
        serviceStart.putExtras(getIntent());
        startService(serviceStart); // pass intent back to the service
        finish();
    } else {
        // it's non-P2P intent, prepare interaction and fire full-blown activity window
        // we'll need service at hand while editing
        Intent bind = new Intent(this, PluginService.class);
        bindService(bind, mServiceConn, 0);
    }
}
 
开发者ID:vanilla-music,项目名称:vanilla-music-tag-editor,代码行数:30,代码来源:TagEditActivity.java

示例3: handleLaunchPlugin

import com.kanedias.vanilla.plugins.PluginUtils; //导入依赖的package包/类
private void handleLaunchPlugin() {
    if (mLaunchIntent.hasExtra(EXTRA_PARAM_SAF_P2P)) {
        // it's SAF intent that is returned from SAF activity, should have URI inside
        persistThroughSaf(mLaunchIntent);
        return;
    }

    // if it's P2P intent, just try to read/write file as requested
    if (PluginUtils.havePermissions(this, WRITE_EXTERNAL_STORAGE) && mLaunchIntent.hasExtra(EXTRA_PARAM_P2P)) {
        if(loadFile(false)) {
            handleP2pIntent();
        }
        stopSelf();
        return;
    }

    // either we have no permissions to write to SD and activity is requested
    // or this is normal user-requested operation (non-P2P)
    // start activity!
    Intent dialogIntent = new Intent(this, TagEditActivity.class);
    dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    dialogIntent.putExtras(mLaunchIntent);
    startActivity(dialogIntent);
}
 
开发者ID:vanilla-music,项目名称:vanilla-music-tag-editor,代码行数:25,代码来源:PluginService.java

示例4: loadFromFile

import com.kanedias.vanilla.plugins.PluginUtils; //导入依赖的package包/类
/**
 * Try to load lyrics tag from companion *.lrc file nearby
 * @return true if lyrics was loaded from file, false otherwise
 */
private boolean loadFromFile() {
    if (!PluginUtils.havePermissions(this, WRITE_EXTERNAL_STORAGE)) {
        return false;
    }

    Uri fileUri = getIntent().getParcelableExtra(EXTRA_PARAM_URI);
    File media = new File(fileUri.getPath());
    String lyricsFileName = lyricsForFile(media);
    File lyricsFile = new File(media.getParentFile(), lyricsFileName);
    if (!lyricsFile.exists()) {
        return false;
    }

    try {
        String lyricsText = LyricsWikiEngine.readIt(new FileInputStream(lyricsFile));
        showFetchedLyrics(lyricsText);
    } catch (IOException e) {
        Log.e(LOG_TAG, "Failed to read lyrics text from file!", e);
        return false;
    }
    return true;
}
 
开发者ID:vanilla-music,项目名称:vanilla-music-lyrics-search,代码行数:27,代码来源:LyricsShowActivity.java


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