Skip to content

Commit

Permalink
A new method for event handling using Square's 'otto'
Browse files Browse the repository at this point in the history
  • Loading branch information
refaelos committed Jan 7, 2013
1 parent b37a6be commit ac8e901
Show file tree
Hide file tree
Showing 17 changed files with 426 additions and 0 deletions.
Binary file added SoomlaAndroidExample/libs/square-otto-1.3.2.jar
Binary file not shown.
Binary file added SoomlaAndroidStore/libs/square-otto-1.3.2.jar
Binary file not shown.
35 changes: 35 additions & 0 deletions SoomlaAndroidStore/src/com/soomla/store/BusProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.soomla.store;

/*
* Copyright (C) 2012 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import com.squareup.otto.Bus;

/**
* Maintains a singleton instance for obtaining the bus. Ideally this would be replaced with a more efficient means
* such as through injection directly into interested classes.
*/
public final class BusProvider {
private static final Bus BUS = new Bus();

public static Bus getInstance() {
return BUS;
}

private BusProvider() {
// No instances.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2012 Soomla Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.soomla.store.events;


public class BillingNotSupportedEvent {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2012 Soomla Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.soomla.store.events;


public class BillingSupportedEvent {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2012 Soomla Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.soomla.store.events;


public class ClosingStoreEvent {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2012 Soomla Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.soomla.store.events;

import com.soomla.store.domain.data.VirtualCurrency;

public class CurrencyBalanceChangedEvent {

private VirtualCurrency mCurrency;
private int mBalance;

public CurrencyBalanceChangedEvent(VirtualCurrency currency, int balance) {
mCurrency = currency;
mBalance = balance;
}

public VirtualCurrency getCurrency() {
return mCurrency;
}

public int getBalance() {
return mBalance;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2012 Soomla Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.soomla.store.events;

import com.soomla.store.domain.data.VirtualGood;

public class GoodBalanceChangedEvent {

private VirtualGood mGood;
private int mBalance;

public GoodBalanceChangedEvent(VirtualGood good, int balance) {
mGood = good;
mBalance = balance;
}

public VirtualGood getGood() {
return mGood;
}

public int getBalance() {
return mBalance;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C) 2012 Soomla Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.soomla.store.events;

import com.soomla.store.domain.data.VirtualGood;

public class GoodPurchaseStartedEvent {

private VirtualGood mGood;

public GoodPurchaseStartedEvent(VirtualGood good) {
mGood = good;
}

public VirtualGood getGood() {
return mGood;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C) 2012 Soomla Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.soomla.store.events;

import com.soomla.store.domain.data.VirtualGood;

public class GoodPurchasedEvent {

private VirtualGood mGood;

public GoodPurchasedEvent(VirtualGood good) {
mGood = good;
}

public VirtualGood getGood() {
return mGood;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C) 2012 Soomla Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.soomla.store.events;

import com.soomla.store.domain.data.GoogleMarketItem;

public class MarketPurchaseEvent {

private GoogleMarketItem mGoogleMarketItem;

public MarketPurchaseEvent(GoogleMarketItem googleMarketItem) {
mGoogleMarketItem = googleMarketItem;
}

public GoogleMarketItem getGoogleMarketItem() {
return mGoogleMarketItem;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C) 2012 Soomla Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.soomla.store.events;

import com.soomla.store.domain.data.GoogleMarketItem;

public class MarketPurchaseStartedEvent {

private GoogleMarketItem mGoogleMarketItem;

public MarketPurchaseStartedEvent(GoogleMarketItem googleMarketItem) {
mGoogleMarketItem = googleMarketItem;
}

public GoogleMarketItem getGoogleMarketItem() {
return mGoogleMarketItem;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C) 2012 Soomla Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.soomla.store.events;

import com.soomla.store.domain.data.GoogleMarketItem;

public class MarketRefundEvent {

private GoogleMarketItem mGoogleMarketItem;

public MarketRefundEvent(GoogleMarketItem googleMarketItem) {
mGoogleMarketItem = googleMarketItem;
}

public GoogleMarketItem getGoogleMarketItem() {
return mGoogleMarketItem;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2012 Soomla Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.soomla.store.events;


public class OpeningStoreEvent {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2012 Soomla Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.soomla.store.events;


public class UnexpectedStoreErrorEvent {
}
Loading

0 comments on commit ac8e901

Please sign in to comment.