com.google.android.apps.muzei.api.RemoteMuzeiArtSource Java Examples

The following examples show how to use com.google.android.apps.muzei.api.RemoteMuzeiArtSource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WallpaperBoardMuzeiService.java    From wallpaperboard with Apache License 2.0 5 votes vote down vote up
@Override
protected void onTryUpdate(int reason) throws RemoteMuzeiArtSource.RetryException {
    try {
        if (Preferences.get(this).isConnectedAsPreferred()) {
            Wallpaper wallpaper = MuzeiHelper.getRandomWallpaper(this);

            if (wallpaper != null) {
                Uri uri = Uri.parse(wallpaper.getUrl());

                Intent intent = new Intent(this, WallpaperBoardPreviewActivity.class);
                intent.putExtra(Extras.EXTRA_URL, wallpaper.getUrl());
                intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

                publishArtwork(new Artwork.Builder()
                        .title(wallpaper.getName())
                        .byline(wallpaper.getAuthor())
                        .imageUri(uri)
                        .viewIntent(intent)
                        .build());

                scheduleUpdate(System.currentTimeMillis() +
                        Preferences.get(this).getRotateTime());
            }

            Database.get(this).closeDatabase();
        }
    } catch (Exception e) {
        LogUtil.e(Log.getStackTraceString(e));
    }
}