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


Java Wallpaper类代码示例

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


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

示例1: post

import com.ivkos.wallhaven4j.models.wallpaper.Wallpaper; //导入依赖的package包/类
public static void post() throws IOException {
	Config.LOGGER.info("Connection to WallHaven, getting random wallpaper... ");

	Wallpaper wallpaper;
	do {
		SearchQuery query = new SearchQueryBuilder()
				.sorting(Sorting.RANDOM)
				.purity(Purity.SFW)
				.pages(1)
				.build();

		List<Wallpaper> wallpapers = WALLHAVEN.search(query);
		wallpaper = wallpapers.get(RAND.nextInt(wallpapers.size()));
	} while(!WallpaperManager.isValid(wallpaper));

	Utils.downloadAndSaveImage(wallpaper.getImageUrl(), Storage.IMAGE_FILE);
	Storage.addToHistory(wallpaper.getId());

	StatusUpdate status = new StatusUpdate(wallpaper.getShortLink() + "\nResolution : " + wallpaper.getResolution().toString());
	status.setMedia(Storage.IMAGE_FILE);

	Config.LOGGER.info("Posting tweet...");
	TwitterUtils.tweet(status);
	Config.LOGGER.info("Tweet posted.");
}
 
开发者ID:Shadorc,项目名称:1Day1Wallpaper,代码行数:26,代码来源:WallpaperManager.java

示例2: getPage

import com.ivkos.wallhaven4j.models.wallpaper.Wallpaper; //导入依赖的package包/类
@Override
public List<Wallpaper> getPage(long pageNumber, Map<String, String> queryParams)
{
   checkArgument(pageNumber > 0, "page number must be greater than zero");

   ImmutableMap<String, String> params = ImmutableMap.<String, String>builder()
         .put("page", Long.toString(pageNumber))
         .putAll(queryParams)
         .build();

   HttpResponse response = httpClient.get(getUrl(), ImmutableMap.of(
         X_REQUESTED_WITH, "XMLHttpRequest",
         CONTENT_TYPE, JSON_UTF_8.toString()
   ), params);

   HtmlElement dom = htmlParser.parse(response.getBody());

   List<HtmlElement> figureElements = dom.find("li > figure");

   return unmodifiableList(transform(figureElements, thumbnailTransformer::transform));
}
 
开发者ID:ivkos,项目名称:wallhaven4j,代码行数:22,代码来源:ThumbnailPageCrawler.java

示例3: searchWithQuery

import com.ivkos.wallhaven4j.models.wallpaper.Wallpaper; //导入依赖的package包/类
@Test
public void searchWithQuery() throws Exception
{
   List<Wallpaper> result1 = getWallhaven().search(new SearchQueryBuilder()
         .keywords("cars")
         .resolutions(new Resolution(1920, 1080))
         .sorting(Sorting.VIEWS)
         .order(Order.DESC)
         .build()
   );
   assertFalse(result1.isEmpty());

   List<Wallpaper> result2 = getWallhaven(true).search(new SearchQueryBuilder()
         .sorting(Sorting.FAVORITES)
         .order(Order.DESC)
         .build()
   );
   assertFalse(result2.isEmpty());
}
 
开发者ID:ivkos,项目名称:wallhaven4j,代码行数:20,代码来源:WallhavenTest.java

示例4: isValid

import com.ivkos.wallhaven4j.models.wallpaper.Wallpaper; //导入依赖的package包/类
public static boolean isValid(Wallpaper wallpaper) {
	if(Utils.toList(Storage.getHistory()).contains(wallpaper.getId())) {
		Config.LOGGER.info("Retrying... [Wallpaper already posted]");
		return false;
	}

	if(!WallpaperManager.isAppropriateSize(wallpaper)) {
		Config.LOGGER.info("Retrying... [Resolution : " + wallpaper.getResolution() + "]");
		return false;
	}

	if(wallpaper.getViewsCount() < Config.MIN_VIEWS) {
		Config.LOGGER.info("Retrying... [Views : " + wallpaper.getViewsCount() + "/" + Config.MIN_VIEWS + "]");
		return false;
	}

	if(WallpaperManager.containsTag(wallpaper, "women") && wallpaper.getCategory().equals(Category.PEOPLE)) {
		Config.LOGGER.info("Retrying... [Category : 'People', containing #women]");
		return false;
	}

	if(WallpaperManager.containsTag(wallpaper, "car") && wallpaper.getCategory().equals(Category.GENERAL)) {
		Config.LOGGER.info("Retrying... [Category : 'General', containing #car]");
		return false;
	}

	return true;
}
 
开发者ID:Shadorc,项目名称:1Day1Wallpaper,代码行数:29,代码来源:WallpaperManager.java

示例5: isAppropriateSize

import com.ivkos.wallhaven4j.models.wallpaper.Wallpaper; //导入依赖的package包/类
public static boolean isAppropriateSize(Wallpaper wallpaper) {
	float width = wallpaper.getResolution().getWidth();
	float height = wallpaper.getResolution().getHeight();
	float ratio = width / height;

	return width >= 1920 && height >= 1080 && ratio >= 1.6 && ratio <= 1.8;
}
 
开发者ID:Shadorc,项目名称:1Day1Wallpaper,代码行数:8,代码来源:WallpaperManager.java

示例6: search

import com.ivkos.wallhaven4j.models.wallpaper.Wallpaper; //导入依赖的package包/类
/**
 * Executes the search query and returns a list of wallpapers matching the query
 *
 * @param searchQuery the search query
 * @return a list of wallpapers matching the query
 * @throws NullPointerException if searchQuery is null
 */
public List<Wallpaper> search(SearchQuery searchQuery)
{
   checkNotNull(searchQuery, "searchQuery must not be null");

   return thumbnailPageCrawlerFactory
         .create(UrlPrefixes.URL_SEARCH)
         .getPageSequence(
               searchQuery.getPages(),
               searchQuery.getQueryParamsMap()
         );
}
 
开发者ID:ivkos,项目名称:wallhaven4j,代码行数:19,代码来源:Wallhaven.java

示例7: getFactoryFor

import com.ivkos.wallhaven4j.models.wallpaper.Wallpaper; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <I, F extends ResourceFactory<R, I>, R extends AbstractResource<I>> F getFactoryFor(Class<R> resourceClass)
{
   if (resourceClass == Tag.class) return (F) tagFactory;
   if (resourceClass == TagCategory.class) return (F) tagCategoryFactory;
   if (resourceClass == User.class) return (F) userFactory;
   if (resourceClass == Wallpaper.class) return (F) wallpaperFactory;
   if (resourceClass == WallpaperCollection.class) return (F) wallpaperCollectionFactory;

   throw new IllegalArgumentException("There is no factory for the resource type " +
         resourceClass.getSimpleName());
}
 
开发者ID:ivkos,项目名称:wallhaven4j,代码行数:13,代码来源:ResourceFactoryFactory.java

示例8: searchLatest

import com.ivkos.wallhaven4j.models.wallpaper.Wallpaper; //导入依赖的package包/类
@Test
public void searchLatest() throws Exception
{
   List<Wallpaper> result = getWallhaven().search(new SearchQueryBuilder()
         .sorting(Sorting.DATE_ADDED)
         .order(Order.DESC)
         .build());

   assertFalse(result.isEmpty());
}
 
开发者ID:ivkos,项目名称:wallhaven4j,代码行数:11,代码来源:WallhavenTest.java

示例9: searchPageWithQuery

import com.ivkos.wallhaven4j.models.wallpaper.Wallpaper; //导入依赖的package包/类
@Test
public void searchPageWithQuery() throws Exception
{
   SearchQuery query = new SearchQueryBuilder()
         .keywords("minimal")
         .categories(Category.GENERAL)
         .ratios(new Ratio(9, 16))
         .build();

   List<Wallpaper> page2 = getWallhaven().search(query, 2);

   assertFalse(page2.isEmpty());
}
 
开发者ID:ivkos,项目名称:wallhaven4j,代码行数:14,代码来源:WallhavenTest.java

示例10: inequalObjectsAreInequal

import com.ivkos.wallhaven4j.models.wallpaper.Wallpaper; //导入依赖的package包/类
@Test
public void inequalObjectsAreInequal()
{
   Tag tag1 = tagFactory.create(false, 1L, "somename", Purity.SFW);
   Wallpaper wallpaper = wallpaperFactory.create(false, 1L);

   assertFalse(tag1.equals(wallpaper));
   assertFalse(tag1.hashCode() == wallpaper.hashCode());
}
 
开发者ID:ivkos,项目名称:wallhaven4j,代码行数:10,代码来源:AbstractResourceTest.java

示例11: toStringDefault

import com.ivkos.wallhaven4j.models.wallpaper.Wallpaper; //导入依赖的package包/类
@Test
public void toStringDefault() throws Exception
{
   Wallpaper wallpaper = wallpaperFactory.create(false, 42L);

   assertEquals("42", wallpaper.toString());
}
 
开发者ID:ivkos,项目名称:wallhaven4j,代码行数:8,代码来源:AbstractResourceTest.java

示例12: toStringWithoutResourceType

import com.ivkos.wallhaven4j.models.wallpaper.Wallpaper; //导入依赖的package包/类
@Test
public void toStringWithoutResourceType() throws Exception
{
   Wallpaper wallpaper = wallpaperFactory.create(false, 42L);

   assertEquals("42", wallpaper.toString(false));
}
 
开发者ID:ivkos,项目名称:wallhaven4j,代码行数:8,代码来源:AbstractResourceTest.java

示例13: toStringWithResourceType

import com.ivkos.wallhaven4j.models.wallpaper.Wallpaper; //导入依赖的package包/类
@Test
public void toStringWithResourceType() throws Exception
{
   Wallpaper wallpaper = wallpaperFactory.create(false, 42L);

   assertEquals("Wallpaper 42", wallpaper.toString(true));
}
 
开发者ID:ivkos,项目名称:wallhaven4j,代码行数:8,代码来源:AbstractResourceTest.java

示例14: getWallpapers

import com.ivkos.wallhaven4j.models.wallpaper.Wallpaper; //导入依赖的package包/类
@Test
public void getWallpapers() throws Exception
{
   List<Wallpaper> wallpapers = wc.getWallpapers(3, Purity.SFW, Purity.SKETCHY, Purity.NSFW);

   assertEquals(3 * 24, wallpapers.size());
}
 
开发者ID:ivkos,项目名称:wallhaven4j,代码行数:8,代码来源:WallpaperCollectionTest.java

示例15: supplyForClass

import com.ivkos.wallhaven4j.models.wallpaper.Wallpaper; //导入依赖的package包/类
@Test
public void supplyForClass() throws Exception
{
   DescriptiveParseExceptionSupplier supplier = forResource(Wallpaper.class, "name");

   assertEquals(ParseException.class, supplier.get().getClass());
   assertEquals("Could not parse name of Wallpaper", supplier.get().getMessage());
}
 
开发者ID:ivkos,项目名称:wallhaven4j,代码行数:9,代码来源:DescriptiveParseExceptionSupplierTest.java


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