use of com.soomla.store.IStoreAssets in project android-store by soomla.
the class StoreExampleActivity method onCreate.
/**
* Called when the activity starts.
* Displays the main UI screen of the game.
*
* @param savedInstanceState if the activity should be re-initialized after previously being
* shut down then this <code>Bundle</code> will contain the most
* recent data, otherwise it will be null.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// PurchasingManager.registerObserver(new PurchasingObserver(this));
mRobotView = (ImageView) findViewById(R.id.drag_img);
mRobotView.setOnTouchListener(new MyTouchListener());
findViewById(R.id.rightbox).setOnDragListener(new MyDragListener());
Typeface font = Typeface.createFromAsset(getAssets(), "GoodDog.otf");
((TextView) findViewById(R.id.title_text)).setTypeface(font);
((TextView) findViewById(R.id.main_text)).setTypeface(font);
/*
Initialize SoomlaStore and EventHandler before the store is opened.
Compute your public key (that you got from the Android Market publisher site).
Instead of just storing the entire literal string here embedded in the program,
construct the key at runtime from pieces or use bit manipulation (for example,
XOR with some other string) to hide the actual key. The key itself is not secret
information, but we don't want to make it easy for an adversary to replace the
public key with one of their own and then fake messages from the server.
Generally, encryption keys/passwords should only be kept in memory
long enough to perform the operation they need to perform.
*/
IStoreAssets storeAssets = new MuffinRushAssets();
mEventHandler = new ExampleEventHandler(mHandler, this);
Soomla.initialize("[CUSTOM SECRET HERE]");
SoomlaConfig.logDebug = true;
SoomlaStore.getInstance().initialize(storeAssets);
GooglePlayIabService.AllowAndroidTestPurchases = true;
GooglePlayIabService iabService = GooglePlayIabService.getInstance();
iabService.setPublicKey("xxx");
iabService.configVerifyPurchases(new HashMap<String, Object>() {
{
put("clientId", "xxx.apps.googleusercontent.com");
put("clientSecret", "xxx");
put("refreshToken", "1/xxx");
}
});
// FOR TESTING PURPOSES ONLY: Check if it's a first run, if so add 10000 currencies.
SharedPreferences prefs = SoomlaApp.getAppContext().getSharedPreferences(SoomlaConfig.PREFS_NAME, Context.MODE_PRIVATE);
boolean initialized = prefs.getBoolean(FIRST_RUN, false);
if (!initialized) {
try {
for (VirtualCurrency currency : storeAssets.getCurrencies()) {
StoreInventory.giveVirtualItem(currency.getItemId(), 10000);
}
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean(FIRST_RUN, true);
edit.commit();
} catch (VirtualItemNotFoundException e) {
SoomlaUtils.LogError("Example Activity", "Couldn't add first 10000 currencies.");
}
}
}
Aggregations