本文整理汇总了Java中com.soomla.SoomlaUtils类的典型用法代码示例。如果您正苦于以下问题:Java SoomlaUtils类的具体用法?Java SoomlaUtils怎么用?Java SoomlaUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SoomlaUtils类属于com.soomla包,在下文中一共展示了SoomlaUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startIabHelper
import com.soomla.SoomlaUtils; //导入依赖的package包/类
/**
* Create a new IAB helper and set it up.
*
* @param onIabSetupFinishedListener is a callback that lets users to add their own implementation for when the Iab is started
*/
private synchronized void startIabHelper(OnIabSetupFinishedListener onIabSetupFinishedListener) {
if (isIabServiceInitialized())
{
SoomlaUtils.LogDebug(TAG, "The helper is started. Just running the post start function.");
if (onIabSetupFinishedListener != null && onIabSetupFinishedListener.getIabInitListener() != null) {
onIabSetupFinishedListener.getIabInitListener().success(true);
}
return;
}
SoomlaUtils.LogDebug(TAG, "Creating IAB helper.");
mHelper = new TapClashIabHelper();
SoomlaUtils.LogDebug(TAG, "IAB helper Starting setup.");
mHelper.startSetup(onIabSetupFinishedListener);
}
示例2: onRestorePurchasessFinished
import com.soomla.SoomlaUtils; //导入依赖的package包/类
@Override
public void onRestorePurchasessFinished(IabResult result, IabInventory inventory) {
SoomlaUtils.LogDebug(TAG, "Restore Purchases succeeded");
if (result.getResponse() == IabResult.BILLING_RESPONSE_RESULT_OK && mRestorePurchasesListener != null) {
// fetching owned items
List<String> itemSkus = inventory.getAllOwnedSkus(IabHelper.ITEM_TYPE_INAPP);
List<IabPurchase> purchases = new ArrayList<IabPurchase>();
for (String sku : itemSkus) {
IabPurchase purchase = inventory.getPurchase(sku);
purchases.add(purchase);
}
this.mRestorePurchasesListener.success(purchases);
} else {
SoomlaUtils.LogError(TAG, "Wither mRestorePurchasesListener==null OR Restore purchases error: " + result.getMessage());
if (this.mRestorePurchasesListener != null) this.mRestorePurchasesListener.fail(result.getMessage());
}
stopIabHelper(null);
}
示例3: onFetchSkusDetailsFinished
import com.soomla.SoomlaUtils; //导入依赖的package包/类
@Override
public void onFetchSkusDetailsFinished(IabResult result, IabInventory inventory) {
SoomlaUtils.LogDebug(TAG, "Restore Purchases succeeded");
if (result.getResponse() == IabResult.BILLING_RESPONSE_RESULT_OK && mFetchSkusDetailsListener != null) {
// @lassic (May 1st): actually, here (query finished) it only makes sense to get the details
// of the SKUs we already queried for
List<String> skuList = inventory.getAllQueriedSkus(false);
List<IabSkuDetails> skuDetails = new ArrayList<IabSkuDetails>();
for (String sku : skuList) {
IabSkuDetails skuDetail = inventory.getSkuDetails(sku);
if (skuDetail != null) {
skuDetails.add(skuDetail);
}
}
this.mFetchSkusDetailsListener.success(skuDetails);
} else {
SoomlaUtils.LogError(TAG, "Wither mFetchSkusDetailsListener==null OR Fetching details error: " + result.getMessage());
if (this.mFetchSkusDetailsListener != null) this.mFetchSkusDetailsListener.fail(result.getMessage());
}
stopIabHelper(null);
}
示例4: onIabPurchaseFinished
import com.soomla.SoomlaUtils; //导入依赖的package包/类
@Override
public void onIabPurchaseFinished(IabResult result, IabPurchase purchase) {
/**
* Wait to see if the purchase succeeded, then start the consumption process.
*/
SoomlaUtils.LogDebug(TAG, "IabPurchase finished: " + result + ", purchase: " + purchase);
TapClashIabService.getInstance().mWaitingServiceResponse = false;
if (result.getResponse() == IabResult.BILLING_RESPONSE_RESULT_OK) {
TapClashIabService.getInstance().mSavedOnPurchaseListener.success(purchase);
} else if (result.getResponse() == IabResult.BILLING_RESPONSE_RESULT_USER_CANCELED) {
TapClashIabService.getInstance().mSavedOnPurchaseListener.cancelled(purchase);
} else if (result.getResponse() == IabResult.BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED) {
TapClashIabService.getInstance().mSavedOnPurchaseListener.alreadyOwned(purchase);
} else {
TapClashIabService.getInstance().mSavedOnPurchaseListener.fail(result.getMessage());
}
TapClashIabService.getInstance().mSavedOnPurchaseListener = null;
TapClashIabService.getInstance().stopIabHelper(null);
}
示例5: onStart
import com.soomla.SoomlaUtils; //导入依赖的package包/类
@Override
protected void onStart() {
SoomlaUtils.LogDebug(TAG, "onStart 1");
super.onStart();
if (!firstTime && SoomlaApp.getAppContext() instanceof Activity) {
SoomlaUtils.LogDebug(TAG, "onStart 2");
onActivityResult(10001, Activity.RESULT_CANCELED, null);
Intent tabIntent = new Intent(this, ((Activity) SoomlaApp.getAppContext()).getClass());
tabIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
SoomlaUtils.LogDebug(TAG, "onStart 3");
startActivity(tabIntent);
}
SoomlaUtils.LogDebug(TAG, "onStart 4");
}
示例6: onDestroy
import com.soomla.SoomlaUtils; //导入依赖的package包/类
@Override
protected void onDestroy() {
SoomlaUtils.LogDebug(TAG, "onDestroy 1");
if (!mInProgressDestroy && TapClashIabService.getInstance().mWaitingServiceResponse)
{
SoomlaUtils.LogDebug(TAG, "onDestroy 2");
TapClashIabService.getInstance().mWaitingServiceResponse = false;
String err = "IabActivity is destroyed during purchase.";
SoomlaUtils.LogError(TAG, err);
// we're letting the helper take care of closing so there won't be any async process stuck in it.
onActivityResult(10001, Activity.RESULT_CANCELED, null);
// if (TapClashIabService.getInstance().mSavedOnPurchaseListener != null) {
// SoomlaUtils.LogDebug(TAG, "onDestroy 3");
// TapClashIabService.getInstance().mSavedOnPurchaseListener.fail(err);
// TapClashIabService.getInstance().mSavedOnPurchaseListener = null;
// }
}
SoomlaUtils.LogDebug(TAG, "onDestroy 4");
super.onDestroy();
}
示例7: getRewardsState
import com.soomla.SoomlaUtils; //导入依赖的package包/类
public static JSONObject getRewardsState() {
List<String> rewardIds = getRewardIds();
JSONObject rewardsStateJSON = new JSONObject();
for (String rewardId : rewardIds) {
JSONObject rewardValuesJSON = new JSONObject();
try {
int timesGiven = RewardStorage.getTimesGiven(rewardId);
rewardValuesJSON.put("timesGiven", timesGiven);
long lastGiven = RewardStorage.getLastGivenTimeMillis(rewardId);
rewardValuesJSON.put("lastGiven", lastGiven);
//TODO: add LastSeqIdxGiven when sequence reward is fixed
rewardsStateJSON.put(rewardId, rewardValuesJSON);
}
catch (JSONException e) {
SoomlaUtils.LogDebug(TAG, "Unable to set reward " + rewardId + " state. error: " + e.getLocalizedMessage());
}
}
return rewardsStateJSON;
}
示例8: SequenceReward
import com.soomla.SoomlaUtils; //导入依赖的package包/类
/**
* Constructor.
* Generates an instance of <code>SequenceReward</code> from the given <code>JSONObject</code>.
*
* @param jsonObject A JSONObject representation of the wanted <code>SequenceReward</code>.
* @throws JSONException
*/
public SequenceReward(JSONObject jsonObject) throws JSONException {
super(jsonObject);
mRewards = new ArrayList<Reward>();
JSONArray rewardsArr = jsonObject.optJSONArray(com.soomla.data.JSONConsts.SOOM_REWARDS);
if (rewardsArr == null) {
SoomlaUtils.LogWarning(TAG, "reward has no meaning without children");
rewardsArr = new JSONArray();
}
for(int i=0; i<rewardsArr.length(); i++) {
JSONObject rewardJSON = rewardsArr.getJSONObject(i);
Reward reward = fromJSONObject(rewardJSON);
if (reward != null) {
mRewards.add(reward);
}
}
}
示例9: RandomReward
import com.soomla.SoomlaUtils; //导入依赖的package包/类
/**
* Constructor.
* Generates an instance of <code>RandomReward</code> from the given <code>JSONObject</code>.
*
* @param jsonObject A JSONObject representation of the wanted <code>RandomReward</code>.
* @throws JSONException
*/
public RandomReward(JSONObject jsonObject) throws JSONException {
super(jsonObject);
mRewards = new ArrayList<Reward>();
JSONArray rewardsArr = jsonObject.optJSONArray(com.soomla.data.JSONConsts.SOOM_REWARDS);
if (rewardsArr == null) {
SoomlaUtils.LogWarning(TAG, "reward has no meaning without children");
rewardsArr = new JSONArray();
}
// Iterate over all rewards in the JSON array and for each one create
// an instance according to the reward type
for (int i = 0; i < rewardsArr.length(); i++) {
JSONObject rewardJSON = rewardsArr.getJSONObject(i);
Reward reward = Reward.fromJSONObject(rewardJSON);
if (reward != null) {
mRewards.add(reward);
}
}
}
示例10: toJSONObject
import com.soomla.SoomlaUtils; //导入依赖的package包/类
/**
* Converts the current <code>RandomReward</code> to a JSONObject.
*
* @return A <code>JSONObject</code> representation of the current <code>RandomReward</code>.
*/
@Override
public JSONObject toJSONObject(){
JSONObject jsonObject = super.toJSONObject();
try {
JSONArray rewardsArr = new JSONArray();
for (Reward reward : mRewards) {
rewardsArr.put(reward.toJSONObject());
}
jsonObject.put(com.soomla.data.JSONConsts.SOOM_REWARDS, rewardsArr);
} catch (JSONException e) {
SoomlaUtils.LogError(TAG, "An error occurred while generating JSON object.");
}
return jsonObject;
}
示例11: giveInner
import com.soomla.SoomlaUtils; //导入依赖的package包/类
/**
* Gives a random reward from the list of rewards.
*
* @return <code>true</code>
*/
@Override
protected boolean giveInner() {
List<Reward> canBeGivenRewards = new ArrayList<Reward>();
for (Reward reward : this.mRewards) {
if (reward.canGive()) {
canBeGivenRewards.add(reward);
}
}
if (canBeGivenRewards.isEmpty()) {
SoomlaUtils.LogDebug(TAG, "No more rewards to give in this Random Reward: " + this.mID);
return false;
}
Random rand = new Random();
int n = rand.nextInt(canBeGivenRewards.size());
final Reward randomReward = canBeGivenRewards.get(n);
randomReward.give();
mLastGivenReward = randomReward;
return true;
}
示例12: resetStateFromJSON
import com.soomla.SoomlaUtils; //导入依赖的package包/类
private static boolean resetStateFromJSON(JSONObject state, String targetListName, IItemStateApplier stateApplier) {
if (!state.has(targetListName)) {
return true;
}
SoomlaUtils.LogDebug(TAG, "Resetting state for " + targetListName);
try {
JSONObject itemsJSON = state.getJSONObject(targetListName);
Iterator keysIter = itemsJSON.keys();
while (keysIter.hasNext()) {
String itemId = (String) keysIter.next();
JSONObject itemValuesJSON = itemsJSON.getJSONObject(itemId);
if (!stateApplier.applyState(itemId, itemValuesJSON)) {
return false;
}
}
}
catch (JSONException e) {
SoomlaUtils.LogError(TAG, "Unable to set state for " + targetListName + ". error: " + e.getLocalizedMessage());
return false;
}
return true;
}
示例13: onGoodBalanceChanged
import com.soomla.SoomlaUtils; //导入依赖的package包/类
/**
* Receives the given <code>goodBalanceChangedEvent</code>. Upon notification, fetches the
* good associated with the given <code>goodBalanceChangedEvent</code> and displays its price
* and the balance.
*
* @param goodBalanceChangedEvent the event received
*/
@Subscribe
public void onGoodBalanceChanged(GoodBalanceChangedEvent goodBalanceChangedEvent) {
VirtualGood good = null;
try {
good = (VirtualGood) StoreInfo.getVirtualItem(goodBalanceChangedEvent.getGoodItemId());
int id = 0;
for(int i=0; i<StoreInfo.getGoods().size(); i++) {
if (StoreInfo.getGoods().get(i).getItemId().equals(good.getItemId())) {
id = i;
break;
}
}
ListView list = (ListView) findViewById(R.id.list);
TextView info = (TextView)list.getChildAt(id).findViewById(R.id.item_info);
PurchaseWithVirtualItem pwvi = (PurchaseWithVirtualItem) good.getPurchaseType();
info.setText("price: " + pwvi.getAmount() +
" balance: " + goodBalanceChangedEvent.getBalance());
} catch (VirtualItemNotFoundException e) {
SoomlaUtils.LogDebug("StoreGoodsActivity", e.getMessage());
}
}
示例14: onDestroy
import com.soomla.SoomlaUtils; //导入依赖的package包/类
@Override
protected void onDestroy() {
if (NokiaStoreIabService.getInstance().mWaitingServiceResponse)
{
NokiaStoreIabService.getInstance().mWaitingServiceResponse = false;
String err = "IabActivity is destroyed during purchase.";
SoomlaUtils.LogError(TAG, err);
if (NokiaStoreIabService.getInstance().mSavedOnPurchaseListener != null) {
NokiaStoreIabService.getInstance().mSavedOnPurchaseListener.fail(err);
NokiaStoreIabService.getInstance().mSavedOnPurchaseListener = null;
}
}
super.onDestroy();
}
示例15: getUserProfile
import com.soomla.SoomlaUtils; //导入依赖的package包/类
/**
* Fetches the user profile stored for the given provider
*
* @param provider the provider which will be used to fetch the user profile
* @return a user profile
*/
public static UserProfile getUserProfile(IProvider.Provider provider) {
String userProfileJSON = KeyValueStorage.getValue(keyUserProfile(provider));
if (TextUtils.isEmpty(userProfileJSON)) {
return null;
}
try {
JSONObject upJSON = new JSONObject(userProfileJSON);
return new UserProfile(upJSON);
} catch (JSONException e) {
SoomlaUtils.LogError(TAG, "Couldn't create UserProfile from json: " + userProfileJSON);
}
return null;
}