本文整理匯總了Java中com.google.android.apps.muzei.api.Artwork類的典型用法代碼示例。如果您正苦於以下問題:Java Artwork類的具體用法?Java Artwork怎麽用?Java Artwork使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Artwork類屬於com.google.android.apps.muzei.api包,在下文中一共展示了Artwork類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onUpdate
import com.google.android.apps.muzei.api.Artwork; //導入依賴的package包/類
@Override
protected void onUpdate(int reason) {
String location = Utility.getPreferredLocation(this);
Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(
location, System.currentTimeMillis());
Cursor cursor = getContentResolver().query(weatherForLocationUri, FORECAST_COLUMNS, null,
null, WeatherContract.WeatherEntry.COLUMN_DATE + " ASC");
if (cursor.moveToFirst()) {
int weatherId = cursor.getInt(INDEX_WEATHER_ID);
String desc = cursor.getString(INDEX_SHORT_DESC);
String imageUrl = Utility.getImageUrlForWeatherCondition(weatherId);
// Only publish a new wallpaper if we have a valid image
if (imageUrl != null) {
publishArtwork(new Artwork.Builder()
.imageUri(Uri.parse(imageUrl))
.title(desc)
.byline(location)
.viewIntent(new Intent(this, MainActivity.class))
.build());
}
}
cursor.close();
}
示例2: onTryUpdate
import com.google.android.apps.muzei.api.Artwork; //導入依賴的package包/類
@Override
protected void onTryUpdate(int reason) throws RetryException {
try {
if (!URLUtil.isValidUrl(getString(R.string.wallpaper_json)))
return;
Wallpaper wallpaper = MuzeiHelper.getRandomWallpaper(this);
if (Preferences.get(this).isConnectedAsPreferred()) {
if (wallpaper != null) {
Uri uri = Uri.parse(wallpaper.getURL());
publishArtwork(new Artwork.Builder()
.title(wallpaper.getName())
.byline(wallpaper.getAuthor())
.imageUri(uri)
.build());
scheduleUpdate(System.currentTimeMillis() +
Preferences.get(this).getRotateTime());
}
}
Database.get(this).closeDatabase();
} catch (Exception ignored) {}
}
示例3: onTryUpdate
import com.google.android.apps.muzei.api.Artwork; //導入依賴的package包/類
@Override
protected void onTryUpdate(int reason) throws RetryException {
MuzeiOptionManager manager = MuzeiOptionManager.getInstance(this);
if (manager.isUpdateOnlyInWifi() && !isWifi()) {
return;
}
if (System.currentTimeMillis() - manager.getLastUpdateTime()
< manager.getUpdateInterval() * UNIT_UPDATE_INTERVAL
&& reason != UPDATE_REASON_USER_NEXT) {
return;
}
Artwork art = getCurrentArtwork();
String currentToken = art == null ? null : art.getToken();
update(manager, getRandomCollectionId(manager), currentToken);
}
示例4: exportPhoto
import com.google.android.apps.muzei.api.Artwork; //導入依賴的package包/類
private void exportPhoto(@Nullable Photo photo) {
if (photo != null) {
Intent intent = new Intent(this, PhotoActivity.class);
intent.putExtra(PhotoActivity.KEY_PHOTO_ACTIVITY_ID, photo.id);
publishArtwork(
new Artwork.Builder()
.title(getString(R.string.by) + " " + photo.user.name)
.byline(getString(R.string.on) + " " + photo.created_at.split("T")[0])
.imageUri(Uri.parse(photo.getWallpaperSizeUrl(this)))
.token(photo.id)
.viewIntent(intent)
.build());
List<UserCommand> commands = new ArrayList<>();
commands.add(new UserCommand(BUILTIN_COMMAND_ID_NEXT_ARTWORK));
setUserCommands(commands);
}
}
示例5: fromBundle
import com.google.android.apps.muzei.api.Artwork; //導入依賴的package包/類
public static SourceState fromBundle(Bundle bundle) {
SourceState state = new SourceState();
Bundle artworkBundle = bundle.getBundle("currentArtwork");
if (artworkBundle != null) {
state.mCurrentArtwork = Artwork.fromBundle(artworkBundle);
}
state.mDescription = bundle.getString("description");
state.mWantsNetworkAvailable = bundle.getBoolean("wantsNetworkAvailable");
String[] commandsSerialized = bundle.getStringArray("userCommands");
if (commandsSerialized != null && commandsSerialized.length > 0) {
state.mUserCommands.ensureCapacity(commandsSerialized.length);
for (String s : commandsSerialized) {
state.mUserCommands.add(UserCommand.deserialize(s));
}
}
return state;
}
示例6: shareArtwork
import com.google.android.apps.muzei.api.Artwork; //導入依賴的package包/類
@SuppressWarnings("deprecation")
private void shareArtwork() {
Artwork currentArtwork = getCurrentArtwork();
if (currentArtwork == null) {
displayToastOnMainThread(R.string.error_no_image_to_share);
return;
}
String detailUrl = "https://g.co/ev/" + currentArtwork.getToken();
String title = currentArtwork.getTitle().trim();
String text = getString(R.string.artwork_share_text, title, detailUrl);
Intent shareIntent = new Intent(Intent.ACTION_SEND)
.setType("text/plain")
.putExtra(Intent.EXTRA_TEXT, text)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(Intent.createChooser(shareIntent, getString(R.string.action_share_artwork)));
}
示例7: downloadArtwork
import com.google.android.apps.muzei.api.Artwork; //導入依賴的package包/類
private void downloadArtwork() {
Artwork currentArtwork = getCurrentArtwork();
if (currentArtwork == null) {
displayToastOnMainThread(R.string.error_no_image_to_download);
return;
}
String downloadUrl = earthViewPrefs.get().getDownloadUrl();
if (downloadUrl == null) {
return;
}
String fileName = currentArtwork.getToken() + ".jpg";
Uri downloadUri = Uri.parse(BASE_URL + downloadUrl);
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(downloadUri)
.setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES, fileName)
.setMimeType(MIME_TYPE_IMAGE)
.setVisibleInDownloadsUi(true)
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.allowScanningByMediaScanner();
dm.enqueue(request);
}
示例8: shareArtwork
import com.google.android.apps.muzei.api.Artwork; //導入依賴的package包/類
@Override
public void shareArtwork(Artwork currentArtwork) {
if (currentArtwork == null || currentArtwork.getViewIntent() == null || currentArtwork.getByline() == null) {
Timber.w("No current artwork, can't share.");
displayToast(resources.getString(R.string.error_no_map_to_share));
} else {
analytics.artShared(currentArtwork);
String detailUrl = currentArtwork.getViewIntent().getDataString();
String artist = currentArtwork.getByline().replaceFirst("\\.\\s*($|\\n).*", "").trim();
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, resources.getString(R.string.share_intent_extra_text, currentArtwork.getTitle().trim(), artist, detailUrl));
shareIntent = Intent.createChooser(shareIntent, resources.getString(R.string.share_intent_title));
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(shareIntent);
}
}
示例9: setUp
import com.google.android.apps.muzei.api.Artwork; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
// Uri
PowerMockito.mockStatic(Uri.class);
PowerMockito.when(Uri.class, "parse", anyString()).thenReturn(uri);
when(uri.toString()).thenReturn("imageUri");
// Intent
PowerMockito.whenNew(Intent.class).withArguments(anyString()).thenReturn(intent);
PowerMockito.mockStatic(Intent.class);
PowerMockito.when(Intent.class, "createChooser", eq(intent), anyString()).thenReturn(intent);
when(api.getImages()).thenReturn(retrofitCall);
when(intent.getDataString()).thenReturn("data string");
when(clock.currentTimeMillis()).thenReturn(0L);
artwork = new Artwork.Builder()
.title("title")
.byline("byline")
.imageUri(uri)
.viewIntent(intent)
.build();
sut = new GrandMapsArtSourceService(context, resources, handler, preferences, api, connectivityHelper, clock, analytics);
}
開發者ID:mainthread-technology,項目名稱:grand-maps-for-muzei,代碼行數:25,代碼來源:GrandMapsArtSourceServiceTest.java
示例10: onCustomCommand
import com.google.android.apps.muzei.api.Artwork; //導入依賴的package包/類
@Override
public void onCustomCommand(int id) {
super.onCustomCommand(id);
if (id == COMMAND_ID_SHARE) {
Artwork currentArtwork = getCurrentArtwork();
Intent shareWall = new Intent(Intent.ACTION_SEND);
shareWall.setType("text/plain");
String wallName = currentArtwork.getTitle();
String authorName = currentArtwork.getByline();
String storeUrl = MARKET_URL + getPackageName();
String iconPackName = getString(R.string.app_name);
shareWall.putExtra(Intent.EXTRA_TEXT,
getString(R.string.share_text, wallName, authorName, iconPackName, storeUrl));
shareWall = Intent.createChooser(shareWall, getString(R.string.share_title));
shareWall.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(shareWall);
}
}
示例11: onTryUpdate
import com.google.android.apps.muzei.api.Artwork; //導入依賴的package包/類
@Override
protected void onTryUpdate(int reason) throws RetryException {
Date date = new Date();
DateFormat potdDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
String dateParam = potdDateFormat.format(date);
Photo photo = getPhoto(dateParam);
if (photo == null || photo.uri == null) {
throw new RetryException();
}
Artwork currentArtwork = getCurrentArtwork();
if (currentArtwork == null || !photo.title.equals(currentArtwork.getTitle())) {
publishArtwork(new Artwork.Builder()
.title(photo.title)
.byline(photo.byline)
.imageUri(Uri.parse(photo.uri))
.token(dateParam)
.viewIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(photo.source)))
.build());
}
scheduleUpdate(calculateNextUpdateTime());
}
示例12: onUpdate
import com.google.android.apps.muzei.api.Artwork; //導入依賴的package包/類
@Override
//@DebugLog
protected void onUpdate(int reason) {
try {
ArtInfo info = mMusicService.getCurrentArtInfo().toBlocking().first();
if (info != null) {
final Uri artworUri = ArtworkProvider.createArtworkUri(info.artistName, info.albumName);
String[] meta = Observable.zip(mMusicService.getAlbumName(), mMusicService.getArtistName(),
new Func2<String, String, String[]>() {
@Override
public String[] call(String s, String s2) {
return new String[] {s, s2};
}
}).toBlocking().first();
publishArtwork(new Artwork.Builder()
.imageUri(artworUri)
.title(meta[0])
.byline(meta[1])
.build());
}
} catch (Exception e) {
}
}
示例13: publishAlbum
import com.google.android.apps.muzei.api.Artwork; //導入依賴的package包/類
/**
* Publish the artwork from an Album Cover
*
* @param album
*/
private void publishAlbum(final Album album) {
Artwork.Builder builder = new Artwork.Builder();
builder.title(album.getTitle());
builder.byline(album.getArtist().getName());
builder.imageUri(Uri.parse(album.getCoverUrl() + "?size=" + Constants.COVER_SIZE));
builder.token(Long.toString(album.getId()));
if (album.getLink() != null) {
builder.viewIntent(new Intent(Intent.ACTION_VIEW,
Uri.parse(album.getLink())));
}
// Publish the artwork
publishArtwork(builder.build());
}
示例14: onTryUpdate
import com.google.android.apps.muzei.api.Artwork; //導入依賴的package包/類
@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));
}
}
示例15: onUpdate
import com.google.android.apps.muzei.api.Artwork; //導入依賴的package包/類
protected void onUpdate(int reason) {
if (supplier != null) supplier = (Supplier) getApplicationContext();
if (ContextCompat.checkSelfPermission(this, Manifest.permission.INTERNET) == PackageManager.PERMISSION_GRANTED) {
new Thread() {
@Override
public void run() {
if (!supplier.getNetworkResources()) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(MuzeiArtSource.this, R.string.download_failed, Toast.LENGTH_SHORT).show();
}
});
return;
}
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
for (WallData data : supplier.getWallpapers()) {
for (String url : data.images) {
publishArtwork(new Artwork.Builder()
.imageUri(Uri.parse(url))
.title(data.name)
.byline(data.authorName)
.viewIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(url)))
.build());
}
}
}
});
}
}.start();
}
}