Skip to content

Instantly share code, notes, and snippets.

View srmdev29's full-sized avatar

Sree srmdev29

  • Dallas
View GitHub Profile
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.Canvas;
@srmdev29
srmdev29 / IInAppBillingService.txt
Last active February 25, 2016 12:03
IInAppBillingService - In app subscription service helper class.
final InAppSub mInAppSub = new InAppSub(this);
mInAppSub.bindServiceConn();
Bundle ownedItems = mInAppSub.getPurchaseIntent();
if (ownedItems != null) {
int response = ownedItems.getInt("RESPONSE_CODE");
if (response != 0) {
@srmdev29
srmdev29 / FlipAnimation-MainActivity
Last active February 26, 2016 11:14
FlipAnimation-Android
public class MainActivity extends AppCompatActivity {
private AnimatorSet mSetRightOut;
private AnimatorSet mSetLeftIn;
private boolean mIsBackVisible = false;
private View mCardFrontLayout;
private View mCardBackLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
@srmdev29
srmdev29 / build.gradle
Created February 26, 2016 11:31 — forked from danielgomezrico/build.gradle
Android / add app version and build number to assembled apk.
def appVersionName = "1.0.0"
def appVersionCode = 12
android {
//...
defaultConfig {
//..
// Add version and build number to apk name
setProperty("archivesBaseName", "app-${appVersionName}-${appVersionCode}")
}
@srmdev29
srmdev29 / UploadService.kt
Created February 26, 2016 11:31 — forked from danielgomezrico/UploadService.kt
Android / Retrofit - how to upload a file without multipart (as binary) for Kotlin
interface UploadService {
@Headers("Content-Type: image/jpeg")
@POST("/files")
fun uploadFile(@Body file: TypedFile): Observable<UploadedFile>
}
@srmdev29
srmdev29 / Android useful articles .txt
Last active March 2, 2016 18:30
Android Useful Articles.
1 .Recyclerview Item Decoration.
https://www.bignerdranch.com/blog/a-view-divided-adding-dividers-to-your-recyclerview-with-itemdecoration/
2. android-data-sync- sync Adapter
http://chariotsolutions.com/blog/post/android-data-sync/
https://software.intel.com/en-us/android/articles/handling-offline-capability-and-data-sync-in-an-android-app-part-2
http://blog.udinic.com/2013/07/24/write-your-own-android-sync-adapter
<resources>
<style name="AppTheme" parent="AppBaseTheme">
<!-- Extends the base theme below -->
</style>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>
@srmdev29
srmdev29 / 1_drawable_ic_hash_io16.xml
Created March 21, 2016 13:53 — forked from nickbutcher/1_drawable_ic_hash_io16.xml
Animated Stroke. The google I/O website this year (https://google.com/io) has some funky animated lettering. I especially liked the animated stroke around the letters and wondered how you might implement that on Android. Turns out that AnimatedVectorDrawable makes this very easy! Here's how it looks: https://twitter.com/crafty/status/71077957997…
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016 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
@srmdev29
srmdev29 / CustomRecyclerViewAdapter.java
Last active May 4, 2016 18:58 — forked from frapontillo/CustomRecyclerViewAdapter.java
How to use SwitchCompat inside a RecyclerView item
// omissis
@Override
public void onBindViewHolder(final CustomViewHolder holder, final int position) {
holder.mSwitch.setOnCheckedChangeListener(
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, final boolean isChecked) {
// TODO: handle your switch toggling logic here
}
@srmdev29
srmdev29 / gradle_task_grant_permission
Created June 11, 2016 18:39 — forked from fangzhzh/gradle_task_grant_permission
gradle task to grant permission to device
android.applicationVariants.all { variant ->
def applicationId = variant.applicationId
def adb = androidadbExe. as String
def variantName = variant.name.capitalize()
def grantPermissionTask = task.create("create${variantName}Permissions") << {
"${adb} devices".execute().text.eachLine {
if(it.endsWith("device")){
def device = it.split()[0]
println "Granting permissions on devices ${device}"
"${adb} -s ${devices} shell pm grant ${applicationId} android.permission.ACCESS_FINE_LOCATION".execute()