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

Java AchievementBuffer类代码示例

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

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



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

示例1: t

import com.google.android.gms.games.achievement.AchievementBuffer; //导入依赖的package包/类
public Achievements.LoadAchievementsResult t(final Status paramStatus)
{
  return new Achievements.LoadAchievementsResult()
  {
    public AchievementBuffer getAchievements()
    {
      return new AchievementBuffer(DataHolder.empty(14));
    }

    public Status getStatus()
    {
      return paramStatus;
    }

    public void release()
    {
    }
  };
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:20,代码来源:fs.java


示例2: onAchievementsLoaded

import com.google.android.gms.games.achievement.AchievementBuffer; //导入依赖的package包/类
@Override
public void onAchievementsLoaded(int statusCode, AchievementBuffer achBuffer) {
	if (statusCode == GamesClient.STATUS_OK) {
		Iterator<Achievement> iterator = achBuffer.iterator();
		while(iterator.hasNext()){
			Achievement achievement = iterator.next();
			if(achievement.getType() == Achievement.TYPE_INCREMENTAL && achievement.getAchievementId().equals(achievementId))
			{
			    this.incrementAchievementWhenDataIsLoaded(achievement);
			}
		}
		
	}
	else{
		//Achievements loading has failed
	}
	achBuffer.close();
}
 
开发者ID:freshplanet,项目名称:ANE-Google-Play-Game-Services,代码行数:19,代码来源:AchievementsLoadListener.java


示例3: fetchAchievementsSync

import com.google.android.gms.games.achievement.AchievementBuffer; //导入依赖的package包/类
public boolean fetchAchievementsSync(IFetchAchievementsResponseListener callback) {
    if (!isSessionActive())
        return false;

    Achievements.LoadAchievementsResult achievementsResult = Games.Achievements.load(
            mGoogleApiClient, forceRefresh).await();

    if (!achievementsResult.getStatus().isSuccess()) {
        Gdx.app.log(GAMESERVICE_ID, "Failed to fetch achievements:" +
                achievementsResult.getStatus().getStatusMessage());
        callback.onFetchAchievementsResponse(null);
        return false;
    }

    AchievementBuffer achievements = achievementsResult.getAchievements();

    Array<IAchievement> gpgsAchs = new Array<IAchievement>(achievements.getCount());

    for (Achievement ach : achievements) {
        GpgsAchievement gpgsAchievement = new GpgsAchievement();

        gpgsAchievement.achievementId = ach.getAchievementId();
        gpgsAchievement.achievementMapper = gpgsAchievementIdMapper;
        gpgsAchievement.description = ach.getDescription();
        gpgsAchievement.title = ach.getName();

        if (ach.getState() == Achievement.STATE_UNLOCKED)
            gpgsAchievement.percCompl = 1f;
        else if (ach.getType() == Achievement.TYPE_INCREMENTAL)
            gpgsAchievement.percCompl = (float) ach.getCurrentSteps() / ach.getTotalSteps();

        gpgsAchs.add(gpgsAchievement);
    }

    achievements.release();

    callback.onFetchAchievementsResponse(gpgsAchs);

    return true;
}
 
开发者ID:MrStahlfelge,项目名称:gdx-gamesvcs,代码行数:41,代码来源:GpgsClient.java


示例4: toJSONArray

import com.google.android.gms.games.achievement.AchievementBuffer; //导入依赖的package包/类
public static JSONArray toJSONArray( AchievementBuffer buffer ) {
	JSONArray result = new JSONArray();
	int bufSize = buffer.getCount();
	for( int i = 0; i < bufSize; i++ ) {
		Achievement achievement = buffer.get( i );
		JSONObject json = new JSONObject();
		try {
			json.put( "id", achievement.getAchievementId() );
			float progress = 0.0f;
			/* Is unlocked */
			if( achievement.getState() == Achievement.STATE_UNLOCKED ) {
				progress = 100.0f;
			}
			/* Is incremental */
			if( achievement.getType() == Achievement.TYPE_INCREMENTAL ) {
				int steps = achievement.getCurrentSteps();
				int totalSteps = achievement.getTotalSteps();
				json.put( "steps", steps );
				json.put( "totalSteps", totalSteps );
				if( progress < 0.001 ) {
					/* Calc progress from the steps */
					progress = ((float) steps / (float) totalSteps) * 100.0f;
				}
			}
			json.put( "progress", progress );
			result.put( json.toString() );
		} catch( JSONException e ) {
			e.printStackTrace();
		}
	}
	buffer.release();
	return result;
}
 
开发者ID:marpies,项目名称:game-services-ane,代码行数:34,代码来源:GSAchievementUtils.java


示例5: loadAchievements

import com.google.android.gms.games.achievement.AchievementBuffer; //导入依赖的package包/类
public void loadAchievements(boolean forceReload) {
	Games.Achievements
			.load(mGoogleApiClient, forceReload)
			.setResultCallback(
					new ResultCallback<Achievements.LoadAchievementsResult>() {
						@Override
						public void onResult(
								Achievements.LoadAchievementsResult loadAchievementsResult) {
							AchievementBuffer buffer = loadAchievementsResult
									.getAchievements();
							String jsonString = "{";
							for (int i = 0; i < buffer.getCount(); i++) {
								jsonString += "\""
										+ buffer.get(i).getAchievementId()
										+ "\":\"" + buffer.get(i).getName();
								if (i < buffer.getCount() - 1) {
									jsonString += "\",";
								} else {
									jsonString += "\"}";
								}
							}
							JSONObject json = null;
							try {
								json = new JSONObject(jsonString);
							} catch (JSONException e) {
								e.printStackTrace();
								Log.e(TAG, e.getLocalizedMessage());
							}
							if (mCallback != null) {
								mCallback.onLoadAchievements(
										ActionType.LOAD, json);
							}
						}
					});
}
 
开发者ID:sadisasha,项目名称:PlayGames,代码行数:36,代码来源:PlayGamesServices.java


示例6: onAchievementsLoaded

import com.google.android.gms.games.achievement.AchievementBuffer; //导入依赖的package包/类
public void onAchievementsLoaded(int statusCode, AchievementBuffer buffer)
{
  Log.i("trace", what + ": GooglePlayCallback.onAchievementsLoaded: " + statusCode);
  for(Achievement a : buffer)
  {
    String id = a.getAchievementId();
    int state = a.getState();
    int type = a.getType();

    GooglePlay.connectionCallback.call("addAchievement",
        new Object[] {id, state, type});
  }

  GooglePlay.connectionCallback.call("onAchievementsLoaded", new Object[]{});
}
 
开发者ID:sergey-miryanov,项目名称:ExtensionsPack,代码行数:16,代码来源:GooglePlay.java


示例7: g

import com.google.android.gms.games.achievement.AchievementBuffer; //导入依赖的package包/类
g(DataHolder arg2)
{
  super(localc, localDataHolder);
  this.ub = new AchievementBuffer(localDataHolder);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:6,代码来源:fl.java


示例8: getAchievements

import com.google.android.gms.games.achievement.AchievementBuffer; //导入依赖的package包/类
public final AchievementBuffer getAchievements()
{
  return this.ub;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:5,代码来源:fl.java


示例9: onAchievementsLoaded

import com.google.android.gms.games.achievement.AchievementBuffer; //导入依赖的package包/类
@Override
public void onAchievementsLoaded(int statusCode, AchievementBuffer buffer){
    JSONObject json = new JSONObject();
    try{
        json.put("type", GAME_ACHIEVEMENT_LOADED);
        json.put("statusCode", statusCode);
        switch (statusCode) {
            case GamesClient.STATUS_OK:
                // if data was successfully loaded and is up-to-date
                JSONArray achievements = new JSONArray();
                JSONObject achievement;
                Achievement a;
                for(int i=0,l=buffer.getCount(); i<l; i++){
                    a = buffer.get(i);
                    achievement = new JSONObject();
                    achievement.put("achievementId", a.getAchievementId());
                    achievement.put("description", a.getDescription());
                    achievement.put("lastUpdatedTimestamp", a.getLastUpdatedTimestamp());
                    achievement.put("name", a.getName());
                    achievement.put("achievementId", a.getPlayer().getPlayerId());
                    achievement.put("state", a.getState());
                    achievement.put("type", a.getType());
                    if (Achievement. TYPE_INCREMENTAL == a.getType()){
                        achievement.put("currentSteps", a.getCurrentSteps());
                        achievement.put("totalSteps", a.getTotalSteps());
                        achievement.put("formattedCurrentSteps", a.getFormattedCurrentSteps());
                        achievement.put("formattedTotalSteps", a.getFormattedTotalSteps());
                    }
                    Uri uri = a.getRevealedImageUri();
                    if (null != uri)
                        achievement.put("revealedImageUri", uri.getScheme()+':'+uri.getSchemeSpecificPart());
                    uri = a.getUnlockedImageUri();
                    if (null != uri)
                        achievement.put("unlockedImageUri", uri.getScheme()+':'+uri.getSchemeSpecificPart());
                    achievements.put(achievement);
                }
                json.put("list", achievements);
                break;        
            case GamesClient.STATUS_NETWORK_ERROR_NO_DATA:
                // A network error occurred while attempting to retrieve fresh data, and no data was available locally.
                break;
            case GamesClient.STATUS_INTERNAL_ERROR:
                // if an unexpected error occurred in the service 
                break;
            case GamesClient.STATUS_NETWORK_ERROR_STALE_DATA:
                // if the device was unable to communicate with the network. In this case, the operation is not retried automatically.
                break;
            case GamesClient.STATUS_CLIENT_RECONNECT_REQUIRED:
                // need to reconnect GamesClient
                mHelper.reconnectClients(clientTypes);
                break;
            case GamesClient.STATUS_LICENSE_CHECK_FAILED:
                // The game is not licensed to the user. Further calls will return the same code.
                break;
            default:
                // error
                break;
        }
    }catch(JSONException ex){
        Log.e(TAG, "GAME_ACHIEVEMENT_LOADED ["+statusCode+"] exception: "+ex.getMessage());
        return;
    }

    buffer.close();
    PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, json);
    pluginResult.setKeepCallback(true);
    connectionCB.sendPluginResult(pluginResult);
}
 
开发者ID:ldarren,项目名称:pico-phonegap-base,代码行数:69,代码来源:PlayServices.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java EditorComboBoxRenderer类代码示例发布时间:2022-05-22
下一篇:
Java SimpleFeatureImpl类代码示例发布时间: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