Coder Social home page Coder Social logo

play-billing-scalable-kotlin's Introduction

Codelab: Scalable Implementation of Play Billing in Kotlin

Sample application sources for Google Play Billing Codelab

Introduction

This sample is provided to demonstrate a scalable way of integrating with Google Play Billing. To read more please open the codelab page.

Support

If you've found an error in this sample, please file an issue: https://github.com/googlecodelabs/play-billing-scalable-kotlin/issues

License

Copyright 2019 Google, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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.

CHANGELOG

play-billing-scalable-kotlin's People

Contributors

isaidamier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

play-billing-scalable-kotlin's Issues

Redundant check for nullability?

Codelab: Scalable Implementation of Google Play Billing in Kotlin
Lesson: 3 - Codelab-00: The Groundwork
Step: Last step - creating LocalBillingDb class

Question:
I am wondering why there is another elvis operator inside the synchronized block. The code inside this block is only getting called if the INSTANCE variable is null because there was already a use of the elvis operator on the line before. Wouldn't it make sense omit the redundant check for nullability? Just have the following code inside the synchronized block:

Room.databaseBuilder(
                   context.applicationContext,
                   LocalBillingDb::class.java,
                   "purchase_db")
                   .fallbackToDestructiveMigration()//remote sources more reliable
                   .build().also { INSTANCE=it }

responseCode: Int is now billingResult: BillingResult?

Before:

override fun onBillingSetupFinished(responseCode: Int) {
   when (responseCode) {
       BillingClient.BillingResponse.OK -> {

After
implementation 'com.android.billingclient:billing:2.0.3'
we override fun like:

  override fun onBillingSetupFinished(billingResult: BillingResult?) {
        when (billingResult?.responseCode) {
            BillingClient.BillingResponseCode.OK -> {

And we can get debug message now from billingResult?.debugMessage for our log tags.

Update Project to Billing 3+

Once it's going to be mandatory this project should be updated to Billing version 3+.
Also if someone want just a simple remove adds in app purchase shouldn't have to implement all this code.
Could please implemente a simple one with just buy the game without cache, localDB or other stuff. Just the basic.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.