• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Result类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: updateNowPlaying

import de.umass.lastfm.Result; //导入依赖的package包/类
public void updateNowPlaying(Track track) {
  if (!client.isAuthenticated()) {
    Log.d(TAG, "Skipping now playing update, not logged in.");
    return;
  }

  NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
  boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();

  if (!isConnected) {
    return;
  }
  client.updateNowPlaying(
      track,
      message -> {
        LastfmClient.Result result = (LastfmClient.Result) message.obj;
        int errorCode = result.errorCode();
        if (LastfmClient.isAuthenticationError(errorCode)) {
          notificationManager.notifyAuthError();
          ScroballApplication.getEventBus().post(AuthErrorEvent.create(errorCode));
        }
        return true;
      });
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:25,代码来源:Scrobbler.java


示例2: createResultFromInputStream

import de.umass.lastfm.Result; //导入依赖的package包/类
/**
     * Builds LastFM result
     * @param inputStream
     * @return
     * @throws SAXException
     * @throws IOException
     */
    private Result createResultFromInputStream(InputStream inputStream) throws SAXException, IOException {
        Document document = newDocumentBuilder().parse(new InputSource(new InputStreamReader(inputStream, "UTF-8")));
        Element root = document.getDocumentElement(); // lfm element
        String statusString = root.getAttribute("status");
        Result.Status status = "ok".equals(statusString) ? Result.Status.OK : Result.Status.FAILED;
        if (status == Result.Status.FAILED) {
            throw new IOException("Status=FAILED");
//            Element errorElement = (Element) root.getElementsByTagName("error").item(0);
//            int errorCode = Integer.parseInt(errorElement.getAttribute("code"));
//            String message = errorElement.getTextContent();
//            return Result.createRestErrorResult(errorCode, message);
        } else {
            return Result.createOkResult(document);
        }
    }
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:23,代码来源:MusicEntryRequest.java


示例3: ScrobbleResult

import de.umass.lastfm.Result; //导入依赖的package包/类
public ScrobbleResult(Result result) {
	super(result.getResultDocument());
	super.status = result.getStatus();
	super.errorMessage = result.getErrorMessage();
	super.errorCode = result.getErrorCode();
	super.httpErrorCode = result.getHttpErrorCode();
}
 
开发者ID:kawaiiDango,项目名称:pScrobbler,代码行数:8,代码来源:ScrobbleResult.java


示例4: addToPlaylist

import de.umass.lastfm.Result; //导入依赖的package包/类
public void addToPlaylist(String playlistId, String artist, String track, Context c) throws ServiceCommException{
	if(session == null)
		throw new ServiceCommException(ServiceID.LASTFM, ServiceErr.NOT_AUTH);
	
	Result res = null;
	try{
		res = Playlist.addTrack(Integer.parseInt(playlistId), artist, track, session);
	}catch(RuntimeException e){
		throw new ServiceCommException(ServiceID.LASTFM, ServiceErr.IO);			
	}			

	if(!res.isSuccessful()){
		switch (res.getErrorCode()) {
		case 4:
		case 9:
		case 14:
			cleanAuth(c);
			throw new ServiceCommException(ServiceID.LASTFM, ServiceErr.NOT_AUTH);
		case 6:
			Log.w(Util.APP, "Song ["+track+" - "+artist+"] not found on Last.fm!");
			return;
		case 8:
		case 16:
		case 29:
			throw new ServiceCommException(ServiceID.LASTFM, ServiceErr.TRY_LATER);

		default:
			Log.w(Util.APP,"Unknown error on Last.fm Playlist.getTrack()! Err=[("+res.getErrorCode()+") - "+res.getErrorMessage() +"]");
			throw new ServiceCommException(ServiceID.LASTFM, ServiceErr.UNKNOWN);
		}
	}
}
 
开发者ID:helderm,项目名称:songseeker,代码行数:33,代码来源:LastfmComm.java


示例5: ScrobbleResult

import de.umass.lastfm.Result; //导入依赖的package包/类
public ScrobbleResult(Result result) {
    super(result.getResultDocument());
    super.status = result.getStatus();
    super.errorMessage = result.getErrorMessage();
    super.errorCode = result.getErrorCode();
    super.httpErrorCode = result.getHttpErrorCode();
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:8,代码来源:ScrobbleResult.java


示例6: criarMensagem

import de.umass.lastfm.Result; //导入依赖的package包/类
private static String criarMensagem(Result result) {
	if (result.isSuccessful()) {
		throw new IllegalArgumentException("Não é um resultado de erro: " + result);
	}

	StringBuilder messageBuilder = new StringBuilder();
	messageBuilder.append("código HTTP: ").append(result.getHttpErrorCode()).append(MESSAGE_SEPARATOR)
			.append("código LastFM: ").append(result.getErrorCode()).append(MESSAGE_SEPARATOR).append("mensagem: ")
			.append(result.getErrorMessage());
	return messageBuilder.toString();
}
 
开发者ID:Ryudo302,项目名称:mychart,代码行数:12,代码来源:LastFmException.java


示例7: fetchTrackDurationAndSubmit

import de.umass.lastfm.Result; //导入依赖的package包/类
public void fetchTrackDurationAndSubmit(final PlaybackItem playbackItem) {
  NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
  boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();

  if (!isConnected || !client.isAuthenticated()) {
    Log.d(TAG, "Offline or unauthenticated, can't fetch track duration. Saving for later.");
    queuePendingPlaybackItem(playbackItem);
    return;
  }

  Track track = playbackItem.getTrack();
  client.getTrackInfo(
      track,
      message -> {
        if (message.obj == null) {
          Result result = Caller.getInstance().getLastResult();
          int errorCode = 1;

          if (result != null) {
            errorCode = result.getErrorCode();
          }
          if (errorCode == 6) {
            Log.d(TAG, "Track not found, cannot scrobble.");
            // TODO prompt user to scrobble anyway
          } else {
            if (LastfmClient.isTransientError(errorCode)) {
              Log.d(TAG, "Failed to fetch track duration, saving for later.");
              queuePendingPlaybackItem(playbackItem);
            }
            if (LastfmClient.isAuthenticationError(errorCode)) {
              notificationManager.notifyAuthError();
              ScroballApplication.getEventBus().post(AuthErrorEvent.create(errorCode));
            }
          }
          return true;
        }

        Track updatedTrack = (Track) message.obj;
        playbackItem.updateTrack(updatedTrack);
        Log.d(TAG, String.format("Track info updated: %s", playbackItem));

        submit(playbackItem);
        return true;
      });
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:46,代码来源:Scrobbler.java


示例8: scrobblePending

import de.umass.lastfm.Result; //导入依赖的package包/类
public void scrobblePending() {
  NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
  boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();
  boolean tracksPending = !(pending.isEmpty() && pendingPlaybackItems.isEmpty());
  boolean backoff = lastScrobbleTime + nextScrobbleDelay > System.currentTimeMillis();

  if (isScrobbling || !tracksPending || !isConnected || !client.isAuthenticated() || backoff) {
    return;
  }

  List<PlaybackItem> playbackItems = new ArrayList<>(pendingPlaybackItems);
  pendingPlaybackItems.clear();
  scroballDB.clearPendingPlaybackItems();

  if (!playbackItems.isEmpty()) {
    Log.d(TAG, "Re-processing queued items with missing durations.");
  }

  for (PlaybackItem playbackItem : playbackItems) {
    fetchTrackDurationAndSubmit(playbackItem);
  }

  if (pending.isEmpty()) {
    return;
  }

  isScrobbling = true;
  final List<Scrobble> tracksToScrobble = new ArrayList<>(pending);

  while (tracksToScrobble.size() > MAX_SCROBBLES) {
    tracksToScrobble.remove(tracksToScrobble.size() - 1);
  }

  client.scrobbleTracks(
      tracksToScrobble,
      message -> {
        List<LastfmClient.Result> results = (List<LastfmClient.Result>) message.obj;
        boolean shouldBackoff = false;

        for (int i = 0; i < results.size(); i++) {
          LastfmClient.Result result = results.get(i);
          Scrobble scrobble = tracksToScrobble.get(i);

          if (result.isSuccessful()) {
            scrobble.status().setScrobbled(true);
            scroballDB.writeScrobble(scrobble);
            pending.remove(scrobble);
          } else {
            int errorCode = result.errorCode();
            if (!LastfmClient.isTransientError(errorCode)) {
              pending.remove(scrobble);
              shouldBackoff = true;
            }
            if (LastfmClient.isAuthenticationError(errorCode)) {
              notificationManager.notifyAuthError();
              ScroballApplication.getEventBus().post(AuthErrorEvent.create(errorCode));
            }
            scrobble.status().setErrorCode(errorCode);
            scroballDB.writeScrobble(scrobble);
          }
        }

        isScrobbling = false;
        lastScrobbleTime = System.currentTimeMillis();

        if (shouldBackoff) {
          // Back off starting at 1 second, up to an hour max.
          if (nextScrobbleDelay == 0) {
            nextScrobbleDelay = 1000;
          } else if (nextScrobbleDelay < 60 * 60 * 1000) {
            nextScrobbleDelay *= 4;
          }
        } else {
          nextScrobbleDelay = 0;

          // There may be more tracks waiting to scrobble. Keep going.
          scrobblePending();
        }
        return false;
      });
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:82,代码来源:Scrobbler.java


示例9: buildEntry

import de.umass.lastfm.Result; //导入依赖的package包/类
@Override
protected Album buildEntry(Result result) {
    return ResponseBuilder.buildItem(result, Album.class);
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:5,代码来源:AlbumRequest.java


示例10: buildEntry

import de.umass.lastfm.Result; //导入依赖的package包/类
@Override
protected Artist buildEntry(Result result) {
    return ResponseBuilder.buildItem(result, Artist.class);
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:5,代码来源:ArtistRequest.java


示例11: buildEntry

import de.umass.lastfm.Result; //导入依赖的package包/类
/**
 * Creates object T from Result
 */
protected abstract T buildEntry(Result result);
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:5,代码来源:MusicEntryRequest.java


示例12: LastFmException

import de.umass.lastfm.Result; //导入依赖的package包/类
/**
 * Cria uma nova exceção a partir das informações contidas em um {@link Result}.
 * 
 * @param result
 *            o resultado de uma chamada a um WebService da LastFM
 * @throws IllegalArgumentException
 *             caso o resultado informado não seja de erro
 */
public LastFmException(Result result) {
	super(criarMensagem(result));
}
 
开发者ID:Ryudo302,项目名称:mychart,代码行数:12,代码来源:LastFmException.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UtilityException类代码示例发布时间:2022-05-22
下一篇:
Java Facets类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap