/[projects]/android/TrainInfo/src/com/example/android/trivialdrivesample/util/IabResult.java
ViewVC logotype

Annotation of /android/TrainInfo/src/com/example/android/trivialdrivesample/util/IabResult.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2123 - (hide annotations) (download)
Wed Mar 5 12:11:16 2014 UTC (10 years, 2 months ago) by torben
File size: 1761 byte(s)
Add billing code
1 torben 2123 /* Copyright (c) 2012 Google Inc.
2     *
3     * Licensed under the Apache License, Version 2.0 (the "License");
4     * you may not use this file except in compliance with the License.
5     * You may obtain a copy of the License at
6     *
7     * http://www.apache.org/licenses/LICENSE-2.0
8     *
9     * Unless required by applicable law or agreed to in writing, software
10     * distributed under the License is distributed on an "AS IS" BASIS,
11     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12     * See the License for the specific language governing permissions and
13     * limitations under the License.
14     */
15    
16     package com.example.android.trivialdrivesample.util;
17    
18     /**
19     * Represents the result of an in-app billing operation.
20     * A result is composed of a response code (an integer) and possibly a
21     * message (String). You can get those by calling
22     * {@link #getResponse} and {@link #getMessage()}, respectively. You
23     * can also inquire whether a result is a success or a failure by
24     * calling {@link #isSuccess()} and {@link #isFailure()}.
25     */
26     public class IabResult {
27     int mResponse;
28     String mMessage;
29    
30     public IabResult(int response, String message) {
31     mResponse = response;
32     if (message == null || message.trim().length() == 0) {
33     mMessage = IabHelper.getResponseDesc(response);
34     }
35     else {
36     mMessage = message + " (response: " + IabHelper.getResponseDesc(response) + ")";
37     }
38     }
39     public int getResponse() { return mResponse; }
40     public String getMessage() { return mMessage; }
41     public boolean isSuccess() { return mResponse == IabHelper.BILLING_RESPONSE_RESULT_OK; }
42     public boolean isFailure() { return !isSuccess(); }
43     public String toString() { return "IabResult: " + getMessage(); }
44     }

  ViewVC Help
Powered by ViewVC 1.1.20