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


Java RemoteMuzeiArtSource.RetryException方法代码示例

本文整理汇总了Java中com.google.android.apps.muzei.api.RemoteMuzeiArtSource.RetryException方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteMuzeiArtSource.RetryException方法的具体用法?Java RemoteMuzeiArtSource.RetryException怎么用?Java RemoteMuzeiArtSource.RetryException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.apps.muzei.api.RemoteMuzeiArtSource的用法示例。


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

示例1: handleError

import com.google.android.apps.muzei.api.RemoteMuzeiArtSource; //导入方法依赖的package包/类
private UpdateArtResponse handleError() throws RemoteMuzeiArtSource.RetryException {
    int retryCount = preferences.getRetryCount();
    if (retryCount < 4) {
        throw new RemoteMuzeiArtSource.RetryException();
    } else {
        int nextRetryFromNow = random.nextInt(FIVE_MINS_IN_MILLI_SECONDS) * 5;
        if (retryCount > 11) {
            nextRetryFromNow = TWELVE_HRS_IN_MILLI_SECONDS * 2; // 24 hours
        } else if (retryCount > 7) {
            nextRetryFromNow = TWELVE_HRS_IN_MILLI_SECONDS;
        }

        return UpdateArtResponse.builder()
                .nextUpdateTime(clock.currentTimeMillis() + nextRetryFromNow)
                .build();
    }
}
 
开发者ID:mainthread-technology,项目名称:grand-maps-for-muzei,代码行数:18,代码来源:GrandMapsArtSourceService.java

示例2: onTryUpdate

import com.google.android.apps.muzei.api.RemoteMuzeiArtSource; //导入方法依赖的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));
    }
}
 
开发者ID:danimahardhika,项目名称:wallpaperboard,代码行数:32,代码来源:WallpaperBoardMuzeiService.java

示例3: updateArtThrowsWhenResponseIsNull

import com.google.android.apps.muzei.api.RemoteMuzeiArtSource; //导入方法依赖的package包/类
@Test(expected = RemoteMuzeiArtSource.RetryException.class)
public void updateArtThrowsWhenResponseIsNull() throws Exception {
    // Given
    when(preferences.getRetryCount()).thenReturn(0);
    when(retrofitCall.execute()).thenReturn(Response.<ImageListResponse>success(null));

    // When
    sut.updateArt(MuzeiArtSource.UPDATE_REASON_OTHER);
}
 
开发者ID:mainthread-technology,项目名称:grand-maps-for-muzei,代码行数:10,代码来源:GrandMapsArtSourceServiceTest.java

示例4: updateArtThrowsWhenImagesNull

import com.google.android.apps.muzei.api.RemoteMuzeiArtSource; //导入方法依赖的package包/类
@Test(expected = RemoteMuzeiArtSource.RetryException.class)
public void updateArtThrowsWhenImagesNull() throws Exception {
    // Given
    when(preferences.getRetryCount()).thenReturn(0);
    when(retrofitCall.execute()).thenReturn(Response.success(ImageListResponse.builder().build()));

    // When
    sut.updateArt(MuzeiArtSource.UPDATE_REASON_OTHER);
}
 
开发者ID:mainthread-technology,项目名称:grand-maps-for-muzei,代码行数:10,代码来源:GrandMapsArtSourceServiceTest.java

示例5: updateArtThrowsWhenImagesEmpty

import com.google.android.apps.muzei.api.RemoteMuzeiArtSource; //导入方法依赖的package包/类
@Test(expected = RemoteMuzeiArtSource.RetryException.class)
public void updateArtThrowsWhenImagesEmpty() throws Exception {
    // Given
    when(preferences.getRetryCount()).thenReturn(0);
    when(retrofitCall.execute()).thenReturn(Response.success(ImageListResponse.builder().images(Collections.<ImageResponse>emptyList()).build()));

    // When
    sut.updateArt(MuzeiArtSource.UPDATE_REASON_OTHER);
}
 
开发者ID:mainthread-technology,项目名称:grand-maps-for-muzei,代码行数:10,代码来源:GrandMapsArtSourceServiceTest.java

示例6: updateArtThrowsWhen0Retries

import com.google.android.apps.muzei.api.RemoteMuzeiArtSource; //导入方法依赖的package包/类
@Test(expected = RemoteMuzeiArtSource.RetryException.class)
public void updateArtThrowsWhen0Retries() throws Exception {
    // Given
    when(preferences.getRetryCount()).thenReturn(0);
    Response<ImageListResponse> error = Response.error(500, ResponseBody.create(MediaType.parse("text/plain"), ""));
    when(retrofitCall.execute()).thenReturn(error);

    // When
    sut.updateArt(MuzeiArtSource.UPDATE_REASON_OTHER);
}
 
开发者ID:mainthread-technology,项目名称:grand-maps-for-muzei,代码行数:11,代码来源:GrandMapsArtSourceServiceTest.java

示例7: updateArtThrowsWhen3Retries

import com.google.android.apps.muzei.api.RemoteMuzeiArtSource; //导入方法依赖的package包/类
@Test(expected = RemoteMuzeiArtSource.RetryException.class)
public void updateArtThrowsWhen3Retries() throws Exception {
    // Given
    when(preferences.getRetryCount()).thenReturn(3);
    Response<ImageListResponse> error = Response.error(400, ResponseBody.create(MediaType.parse("text/plain"), ""));
    when(retrofitCall.execute()).thenReturn(error);

    // When
    sut.updateArt(MuzeiArtSource.UPDATE_REASON_OTHER);
}
 
开发者ID:mainthread-technology,项目名称:grand-maps-for-muzei,代码行数:11,代码来源:GrandMapsArtSourceServiceTest.java

示例8: updateArt

import com.google.android.apps.muzei.api.RemoteMuzeiArtSource; //导入方法依赖的package包/类
/**
 * Updates the next map
 *
 * @param reason         muzei reason for updating
 * @return {@link UpdateArtResponse} - container object
 */
UpdateArtResponse updateArt(int reason) throws RemoteMuzeiArtSource.RetryException;
 
开发者ID:mainthread-technology,项目名称:grand-maps-for-muzei,代码行数:8,代码来源:ArtSourceService.java


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