Skip to content

Commit

Permalink
Access billing service manager directly (fix #687)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniele Ricci <[email protected]>
  • Loading branch information
daniele-athome committed Apr 18, 2016
1 parent edc7a35 commit 1df774d
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions app/src/main/java/org/kontalk/ui/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import android.view.MenuItem;

import org.kontalk.R;
import org.kontalk.billing.BillingServiceManager;
import org.kontalk.billing.IBillingService;


Expand All @@ -50,19 +51,17 @@ public class AboutActivity extends ToolbarActivity {

private static final int NUM_ITEMS = 3;

private AboutPagerAdapter mAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about_screen);

setupToolbar(true);

mAdapter = new AboutPagerAdapter(getSupportFragmentManager());
AboutPagerAdapter adapter = new AboutPagerAdapter(getSupportFragmentManager());

ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(mAdapter);
pager.setAdapter(adapter);

TabLayout tabs = (TabLayout) findViewById(R.id.sliding_tabs);
tabs.setupWithViewPager(pager);
Expand Down Expand Up @@ -94,18 +93,12 @@ public boolean onOptionsItemSelected(MenuItem item) {

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
DonationFragment fragment = mAdapter.getDonationFragment();
IBillingService service = fragment.getBillingService();

IBillingService service = BillingServiceManager.getInstance(this);
if (service == null || !service.handleActivityResult(requestCode, resultCode, data))
super.onActivityResult(requestCode, resultCode, data);
}

private class AboutPagerAdapter extends FragmentPagerAdapter {

// this is for IabHelper
private DonationFragment mDonationFragment;

public AboutPagerAdapter(FragmentManager fm) {
super(fm);
}
Expand All @@ -122,8 +115,7 @@ public Fragment getItem(int position) {
return new AboutFragment();

case ABOUT_DONATION:
mDonationFragment = new DonationFragment();
return mDonationFragment;
return new DonationFragment();

case ABOUT_CREDITS:
return new CreditsFragment();
Expand All @@ -150,10 +142,6 @@ public CharSequence getPageTitle(int position) {
return super.getPageTitle(position);
}

public DonationFragment getDonationFragment() {
return mDonationFragment;
}

}

}

0 comments on commit 1df774d

Please sign in to comment.