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


Java Achievements类代码示例

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


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

示例1: achievement_unlock_immediate

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
/**
 * Unlock an achievement with a given id immediately
 * with a callback result
 *
 * @param achievement_id achievement id obtained from your Developer Console
 *
 * Usage:
 *      const ST_OK = "STATUS_OK"
 *      var achievement_toasty = "achievemnt123ID"
 *
 *      ...
 *
 *      gpgs.achievement_unlock_immediate(achievement_toasty)
 *
 *
 *      ...
 *
 *      func _on_achievement_unlocked(id, status):
 *          if status == ST_OK:
 *              //succeeded action
 *          else:
 *              //failed action
 */
public void achievement_unlock_immediate(final String achievement_id) {
    logMethod();

    if(!isConnectedLogged()) return;

    achievements.unlockImmediate(
            achievement_id,
            new ResultCallback<Achievements.UpdateAchievementResult>() {
                @Override
                public void onResult(@NonNull Achievements.UpdateAchievementResult updateAchievementResult) {
                    String status = extractStatusNameFromStatus(
                            updateAchievementResult.getStatus().toString());

                    Log.d(TAG, MODULE
                            + ": > tried to unlock achievement " + achievement_id
                            + " with " + status);

                           GodotLib.calldeferred(
                                   instance_id, "_on_achievement_unlocked",
                                   new Object[] { achievement_id, status });

                }
            });
}
 
开发者ID:drtwisted,项目名称:godot-google-play-game-services,代码行数:48,代码来源:GodotPlayGameServices.java

示例2: achievement_reveal_immediate

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
/**
 * Reveal a hidden achievement with a given id immediately
 * with a callback result
 *
 * @param achievement_id achievement id obtained from your Developer Console
 *
 * Usage:
 *      const ST_OK = "STATUS_OK"
 *      var achievement_toasty = "achievemnt123ID"
 *
 *      ...
 *
 *      gpgs.achievement_reveal_immediate(achievement_toasty)
 *
 *      ....
 *
 *      func _on_achievement_revealed(id, status):
 *          if status == ST_OK:
 *              //succeeded action
 *          else:
 *              //failed action
 */
public void achievement_reveal_immediate(final String achievement_id) {
    logMethod();

    if (!isConnectedLogged()) return;

    achievements.revealImmediate(
            achievement_id,
            new ResultCallback<Achievements.UpdateAchievementResult>() {
                @Override
                public void onResult(@NonNull Achievements.UpdateAchievementResult updateAchievementResult) {
                    String status = extractStatusNameFromStatus(
                            updateAchievementResult.getStatus().toString());

                    Log.d(TAG, MODULE
                            + ": > tried to reveal achievement " + achievement_id
                            + " with " + status);

                           GodotLib.calldeferred(
                                   instance_id, "_on_achievement_revealed",
                                   new Object[] { achievement_id, status });
                }
            });
}
 
开发者ID:drtwisted,项目名称:godot-google-play-game-services,代码行数:46,代码来源:GodotPlayGameServices.java

示例3: achievement_increment_immediate

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
/**
 * Increment an achievement with a given id by a given amount of points immediately
 * with a callback result
 *
 * @param achievement_id achievement id obtained from your Developer Console
 * @param increment_amount ammount of points to increment the achievement by
 *
 * Usage:
 *      const ST_OK = "STATUS_OK"
 *      var achievement_toasty = "achievemnt123ID"
 *
 *      ...
 *
 *      gpgs.achievement_reveal_immediate(achievement_toasty)
 *
 *      ....
 *
 *      func _on_achievement_revealed(id, increment_amount, status):
 *          if status == ST_OK:
 *              //succeeded action
 *          else:
 *              //failed action
 */
public void achievement_increment_immediate(final String achievement_id, final int increment_amount) {
    logMethod();

    if(!isConnectedLogged()) return;

    achievements.incrementImmediate(
            achievement_id, increment_amount,
            new ResultCallback<Achievements.UpdateAchievementResult>() {
                @Override
                public void onResult(@NonNull Achievements.UpdateAchievementResult updateAchievementResult) {
                    String status = extractStatusNameFromStatus(
                            updateAchievementResult.getStatus().toString());

                    Log.d(TAG, MODULE
                            + ": > tried to increment achievement " + achievement_id
                            +" by " + String.valueOf(increment_amount)
                            + " with " + status);

                           GodotLib.calldeferred(
                                   instance_id, "_on_achievement_incremented",
                                   new Object[] { achievement_id, increment_amount, status });

                }
            });
}
 
开发者ID:drtwisted,项目名称:godot-google-play-game-services,代码行数:49,代码来源:GodotPlayGameServices.java

示例4: call

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public FREObject call( FREContext context, FREObject[] args ) {
	super.call( context, args );

	AIR.log( "GameServices::unlockAchievement" );
	String achievementId = FREObjectUtils.getString( args[0] );
	boolean immediate = FREObjectUtils.getBoolean( args[1] );

	GameServicesHelper helper = GameServicesHelper.getInstance();
	if( helper.isAuthenticated() ) {
		if( immediate ) {
			PendingResult<Achievements.UpdateAchievementResult> result = Games.Achievements.unlockImmediate( helper.getClient(), achievementId );
			result.setResultCallback( this, 10, TimeUnit.SECONDS );
			return null;
		}

		Games.Achievements.unlock( helper.getClient(), achievementId );
		AIR.log( "Successfully unlocked achievement: " + achievementId );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_UPDATE_SUCCESS );
	} else {
		helper.dispatchAchievementUpdateError();
	}

	return null;
}
 
开发者ID:marpies,项目名称:game-services-ane,代码行数:26,代码来源:UnlockAchievementFunction.java

示例5: call

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public FREObject call( FREContext context, FREObject[] args ) {
	super.call( context, args );

	AIR.log( "GameServices::loadAchievements" );

	if( GameServicesHelper.getInstance().isAuthenticated() ) {
		PendingResult<Achievements.LoadAchievementsResult> result = Games.Achievements.load( GameServicesHelper.getInstance().getClient(), false );
		result.setResultCallback( this, 10, TimeUnit.SECONDS );
	} else {
		AIR.log( "User is not signed in." );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_LOAD_ERROR, "User is not signed in." );
	}

	return null;
}
 
开发者ID:marpies,项目名称:game-services-ane,代码行数:17,代码来源:LoadAchievementsFunction.java

示例6: onResult

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public void onResult( @NonNull Achievements.LoadAchievementsResult result ) {
	com.google.android.gms.common.api.Status status = result.getStatus();

	if( !status.isSuccess() ) {
		result.release();
		AIR.log( "Failed to load achievements: " + status.getStatusMessage() );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_LOAD_ERROR, status.getStatusMessage() );
		return;
	}

	JSONArray achievementsArray = GSAchievementUtils.toJSONArray( result.getAchievements() );
	result.release();
	JSONObject response = new JSONObject();
	try {
		response.put( "achievements", achievementsArray );
		AIR.log( "Successfully loaded achievements" );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_LOAD_SUCCESS, response.toString() );
	} catch( JSONException e ) {
		e.printStackTrace();
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_LOAD_ERROR, e.getMessage() );
	}
}
 
开发者ID:marpies,项目名称:game-services-ane,代码行数:24,代码来源:LoadAchievementsFunction.java

示例7: call

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public FREObject call( FREContext context, FREObject[] args ) {
	super.call( context, args );

	AIR.log( "GameServices::revealAchievement" );
	String achievementId = FREObjectUtils.getString( args[0] );
	boolean immediate = FREObjectUtils.getBoolean( args[1] );

	GameServicesHelper helper = GameServicesHelper.getInstance();
	if( helper.isAuthenticated() ) {
		if( immediate ) {
			PendingResult<Achievements.UpdateAchievementResult> result = Games.Achievements.revealImmediate( helper.getClient(), achievementId );
			result.setResultCallback( this, 10, TimeUnit.SECONDS );
			return null;
		}

		Games.Achievements.reveal( helper.getClient(), achievementId );
		AIR.log( "Successfully revealed achievement: " + achievementId );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_UPDATE_SUCCESS );
	} else {
		helper.dispatchAchievementUpdateError();
	}

	return null;
}
 
开发者ID:marpies,项目名称:game-services-ane,代码行数:26,代码来源:RevealAchievementFunction.java

示例8: call

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public FREObject call( FREContext context, FREObject[] args ) {
	super.call( context, args );

	AIR.log( "GameServices::setAchievementSteps" );
	String achievementId = FREObjectUtils.getString( args[0] );
	int numSteps = FREObjectUtils.getInt( args[1] );
	boolean immediate = FREObjectUtils.getBoolean( args[2] );

	GameServicesHelper helper = GameServicesHelper.getInstance();
	if( helper.isAuthenticated() ) {
		if( immediate ) {
			PendingResult<Achievements.UpdateAchievementResult> result = Games.Achievements.setStepsImmediate( helper.getClient(), achievementId, numSteps );
			result.setResultCallback( this, 10, TimeUnit.SECONDS );
			return null;
		}

		Games.Achievements.setSteps( helper.getClient(), achievementId, numSteps );
		AIR.log( "Successfully set steps for achievement: " + achievementId );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_UPDATE_SUCCESS );
	} else {
		helper.dispatchAchievementUpdateError();
	}

	return null;
}
 
开发者ID:marpies,项目名称:game-services-ane,代码行数:27,代码来源:SetAchievementStepsFunction.java

示例9: call

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public FREObject call( FREContext context, FREObject[] args ) {
	super.call( context, args );

	AIR.log( "GameServices::incrementAchievement" );
	String achievementId = FREObjectUtils.getString( args[0] );
	int numSteps = FREObjectUtils.getInt( args[1] );
	boolean immediate = FREObjectUtils.getBoolean( args[2] );

	GameServicesHelper helper = GameServicesHelper.getInstance();
	if( helper.isAuthenticated() ) {
		if( immediate ) {
			PendingResult<Achievements.UpdateAchievementResult> result = Games.Achievements.incrementImmediate( helper.getClient(), achievementId, numSteps );
			result.setResultCallback( this, 10, TimeUnit.SECONDS );
			return null;
		}

		Games.Achievements.increment( helper.getClient(), achievementId, numSteps );
		AIR.log( "Successfully incremented steps for achievement: " + achievementId );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_UPDATE_SUCCESS );
	} else {
		helper.dispatchAchievementUpdateError();
	}

	return null;
}
 
开发者ID:marpies,项目名称:game-services-ane,代码行数:27,代码来源:IncrementAchievementFunction.java

示例10: t

import com.google.android.gms.games.achievement.Achievements; //导入依赖的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

示例11: setIncrement

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
public void setIncrement(boolean callback, String incrementId, int numSteps) {
	if (!callback) {
		Games.Achievements.increment(mGoogleApiClient, incrementId,
				numSteps);
	} else {
		Games.Achievements.incrementImmediate(mGoogleApiClient,
				incrementId, numSteps).setResultCallback(
				new ResultCallback<Achievements.UpdateAchievementResult>() {
					@Override
					public void onResult(
							Achievements.UpdateAchievementResult updateAchievementResult) {
						if (mCallback != null) {
							mCallback.onActionResult(ActionType.INCREMENT,
									getStatusResult(updateAchievementResult
											.getStatus()));
						}
					}
				});
	}
}
 
开发者ID:sadisasha,项目名称:PlayGames,代码行数:21,代码来源:PlayGamesServices.java

示例12: setReveal

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
public void setReveal(boolean callback, String revealId) {
	if (!callback) {
		Games.Achievements.reveal(mGoogleApiClient, revealId);
	} else {
		Games.Achievements
				.revealImmediate(mGoogleApiClient, revealId)
				.setResultCallback(
						new ResultCallback<Achievements.UpdateAchievementResult>() {
							@Override
							public void onResult(
									Achievements.UpdateAchievementResult updateAchievementResult) {
								if (mCallback != null) {
									mCallback
											.onActionResult(
													ActionType.REVEAL,
													getStatusResult(updateAchievementResult
															.getStatus()));
								}
							}
						});
	}
}
 
开发者ID:sadisasha,项目名称:PlayGames,代码行数:23,代码来源:PlayGamesServices.java

示例13: setSetSteps

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
public void setSetSteps(boolean callback, String stepsId, int numSteps) {
	if (!callback) {
		Games.Achievements.setSteps(mGoogleApiClient, stepsId, numSteps);
	} else {
		Games.Achievements.setStepsImmediate(mGoogleApiClient, stepsId,
				numSteps).setResultCallback(
				new ResultCallback<Achievements.UpdateAchievementResult>() {
					@Override
					public void onResult(
							Achievements.UpdateAchievementResult updateAchievementResult) {
						if (mCallback != null) {
							mCallback.onActionResult(ActionType.SET_STEPS,
									getStatusResult(updateAchievementResult
											.getStatus()));
						}
					}
				});
	}
}
 
开发者ID:sadisasha,项目名称:PlayGames,代码行数:20,代码来源:PlayGamesServices.java

示例14: setUnlockAchievement

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
public void setUnlockAchievement(boolean callback, String achievementId) {
	if (!callback) {
		Games.Achievements.unlock(mGoogleApiClient, achievementId);
	} else {
		Games.Achievements
				.unlockImmediate(mGoogleApiClient, achievementId)
				.setResultCallback(
						new ResultCallback<Achievements.UpdateAchievementResult>() {
							@Override
							public void onResult(
									Achievements.UpdateAchievementResult updateAchievementResult) {
								if (mCallback != null) {
									mCallback
											.onActionResult(
													ActionType.UNLOCK,
													getStatusResult(updateAchievementResult
															.getStatus()));
								}
							}
						});
	}
}
 
开发者ID:sadisasha,项目名称:PlayGames,代码行数:23,代码来源:PlayGamesServices.java

示例15: showAchievements

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public void showAchievements() throws GameServiceException {
    if (isSessionActive())
        myContext.startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient),
                RC_ACHIEVEMENTS);
    else
        throw new GameServiceException.NoSessionException();

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


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