This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void prepareNetwork() { | |
File httpCacheDirectory = new File(getCacheDir(), "responses"); | |
int cacheSize = 10 * 1024 * 1024; // 10 MiB | |
Cache cache = new Cache(httpCacheDirectory, cacheSize); | |
OkHttpClient client = new OkHttpClient.Builder() | |
.cache(cache) | |
.addNetworkInterceptor(REWRITE_CACHE_CONTROL_INTERCEPTOR) | |
.build(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ConsumeResponseListener listener = new ConsumeResponseListener() { | |
@Override | |
public void onConsumeResponse(@BillingResponse int responseCode, String outToken) { | |
if (responseCode == BillingResponse.OK) { | |
// Handle the success of the consume operation. | |
// For example, increase the number of coins inside the user's basket. | |
} | |
}; | |
mBillingClient.consumeAsync(purchaseToken, listener); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mBillingClient.queryPurchaseHistoryAsync(SkuType.INAPP, | |
new PurchaseHistoryResponseListener() { | |
@Override | |
public void onPurchaseHistoryResponse(@BillingResponse int responseCode, | |
List<Purchase> purchasesList) { | |
if (responseCode == BillingResponse.OK | |
&& purchasesList != null) { | |
for (Purchase purchase : purchasesList) { | |
// Process the result. | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<String> skuList = new ArrayList<>(); | |
skuList.add("product_1"); | |
skuList.add("product_2"); | |
SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder(); | |
params.setSkusList(skuList).setType(BillingClient.SkuType.INAPP); | |
mBillingClient.querySkuDetailsAsync(params.build(), | |
new SkuDetailsResponseListener() { | |
@Override | |
public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) { | |
if (responseCode == BillingClient.BillingResponse.OK |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* To purchase an Product | |
*/ | |
final List<String> skuList = new ArrayList<>(); | |
skuList.add("product_1"); // SKU Id | |
SkuDetailsParams params = SkuDetailsParams.newBuilder() | |
.setSkusList(skuList) | |
.setType(BillingClient.SkuType.INAPP) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BillingClient mBillingClient; | |
mBillingClient = BillingClient.newBuilder(this).setListener(new PurchasesUpdatedListener() { | |
@Override | |
public void onPurchasesUpdated(int responseCode, @Nullable List<Purchase> purchases) { | |
for(Purchase purchase: purchases) { | |
//When every a new purchase is made | |
} | |
} | |
}).build(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To enable ProGuard in your project, edit project.properties | |
# to define the proguard.config property as described in that file. | |
# | |
# Add project specific ProGuard rules here. | |
# By default, the flags in this file are appended to flags specified | |
# in ${sdk.dir}/tools/proguard/proguard-android.txt | |
# You can edit the include path and order by changing the ProGuard | |
# include property in project.properties. | |
# | |
# For more details, see |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ghm.rtoexam.utils; | |
/** | |
* Created by ponna on 16-08-2017. | |
*/ | |
import android.content.Context; | |
import android.graphics.Canvas; | |
import android.support.v7.widget.AppCompatTextView; | |
import android.text.Layout; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String toTitleCase(String str) | |
{ | |
String[] words = str.trim().split(" "); | |
StringBuilder ret = new StringBuilder(); | |
for(int i = 0; i < words.length; i++) | |
{ | |
if(words[i].trim().length() > 0) | |
{ | |
Log.e("words[i].trim",""+words[i].trim().charAt(0)); | |
ret.append(Character.toUpperCase(words[i].trim().charAt(0))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<!-- | |
Copyright 2017 Google 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 |