Skip to content

Instantly share code, notes, and snippets.

View luciofm's full-sized avatar

Lucio Maciel luciofm

View GitHub Profile
/**
* Copyright 2013 Bo Wang
*
* 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
private class MyHttpClient extends UrlConnectionClient {
SSLContext sslContext = null;
SSLSocketFactory sslSocketFactory = null;
private final OkHttpClient client;
static final int CONNECT_TIMEOUT_MILLIS = 15 * 1000; // 15s
static final int READ_TIMEOUT_MILLIS = 20 * 1000; // 20s
public MyHttpClient(Context context) {
client = generateDefaultOkHttp();
diff --git a/library/src/main/java/org/lucasr/twowayview/TWSpannableGridLayoutManager.java b/library/src/main/java/org/lucasr/twowayview/TWSpannableGridLayoutManager.java
index e631060..d6956ff 100644
--- a/library/src/main/java/org/lucasr/twowayview/TWSpannableGridLayoutManager.java
+++ b/library/src/main/java/org/lucasr/twowayview/TWSpannableGridLayoutManager.java
@@ -218,6 +218,8 @@ public class TWSpannableGridLayoutManager extends TWGridLayoutManager {
int childCount = 0, i = 0;
while (i < itemCount && i < laneCount) {
SpannableItemEntry entry = (SpannableItemEntry) getItemEntryForPosition(i);
+ if (entry == null)
+ break;
E Process: org.lucasr.twowayview.sample, PID: 7606
E java.lang.NullPointerException: Attempt to read from field 'int org.lucasr.twowayview.widget.TWSpannableGridLayoutManager$SpannableItemEntry.rowSpan' on a
null object reference
E at org.lucasr.twowayview.widget.TWSpannableGridLayoutManager$SpannableItemEntry.access$100(TWSpannableGridLayoutManager.java:40)
E at org.lucasr.twowayview.widget.TWSpannableGridLayoutManager.getFirstChildCountInLanes(TWSpannableGridLayoutManager.java:223)
E at org.lucasr.twowayview.widget.TWSpannableGridLayoutManager.moveLayoutToPosition(TWSpannableGridLayoutManager.java:262)
E at org.lucasr.twowayview.widget.TWLanedLayoutManager.onLayoutChildren(TWLanedLayoutManager.java:236)
E at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:1461)
E at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:1600)
E at android.view.View.layout(View.java:15273)
@luciofm
luciofm / Pager.java
Created November 4, 2015 16:22 — forked from mttkay/Pager.java
A simple Rx based pager
public class Pager<I, O> {
private static final Observable FINISH_SEQUENCE = Observable.never();
private PublishSubject<Observable<I>> pages;
private Observable<I> nextPage = finish();
private Subscription subscription = Subscriptions.empty();
private final PagingFunction<I> pagingFunction;
private final Func1<I, O> pageTransformer;
@luciofm
luciofm / build.gradle
Created December 2, 2015 14:59
Auto increment version number on release builds... You can change the build type on versionCode.gradle, you also will need to commit and push gradle.properties on your CI
apply from: 'versionCode.gradle'
android {
defaultConfig {
versionName VERSION_NAME
versionCode Integer.parseInt(VERSION_CODE)
}
}
@luciofm
luciofm / AmazonS3RequestFactory.java
Created July 10, 2017 22:26 — forked from NightlyNexus/AmazonS3RequestFactory.java
Creates okhttp3.Requests for uploading files to an Amazon S3 storage bucket. Implements https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-authentication-HTTPPOST.html
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import okio.BufferedSource;
import okio.ByteString;
/*
* Copyright 2018 Lucio Maciel, Rocket.Chat
* Copyright 2016 Serj Lotutovici
*
* 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
*
@luciofm
luciofm / AlphaSpan.kt
Created April 26, 2018 18:12
Animate alhpa of each character separately
package com.luciofm.playground
import android.text.TextPaint
import android.text.style.CharacterStyle
import android.text.style.UpdateAppearance
class AlphaSpan(var alpha: Int) : CharacterStyle(), UpdateAppearance {
override fun updateDrawState(ds: TextPaint) {
ds.alpha = alpha