Skip to content

Instantly share code, notes, and snippets.

Gerard Coll webserveis

Block or report user

Report or block webserveis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@webserveis
webserveis / MainActivity.kt
Last active Sep 3, 2019
Resource Design Pattern
View MainActivity.kt
class MainActivity : AppCompatActivity() {
companion object {
val TAG: String = MainActivity::class.java.simpleName
}
private val mViewModel: IpInfoViewModel by lazy {
ViewModelProviders.of(this).get(IpInfoViewModel::class.java)
}
@webserveis
webserveis / BatteryInfo.kt
Last active May 29, 2019
Ejemplo de cómo usar la batería en Android con Kotlin
View BatteryInfo.kt
package com.webserveis.batterycheck
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.BatteryManager
import android.os.Build
import android.os.Bundle
import android.util.Log
@webserveis
webserveis / MainActivity.java
Last active Apr 30, 2019
RecyclerView onClick
View MainActivity.java
package com.example.testlist;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
View Breaklines_java.md

DOS/Windows:\r\n Unix: "\n" MacOS: "\r"

Separar el texto por lineas

Independientemente del caracters o conjunto de caracteres pra definier un salto de linea.

  String[] lines = str.split("\r\n|\r|\n");
View jsoup_readme.md

JSOUP PARSERS

CODIFICACIÓN DE CARACTERES

Detección de charset**

Dependencia implementation 'com.ibm.icu:icu4j-charset:63.1'

@webserveis
webserveis / MediatorLivedata.java
Last active Mar 5, 2019
Combine MediatorLiveData
View MediatorLivedata.java
/*
https://stackoverflow.com/questions/49493772/mediatorlivedata-or-switchmap-transformation-with-multiple-parameters
https://medium.com/@BladeCoder/to-implement-a-manual-refresh-without-modifying-your-existing-livedata-logic-i-suggest-that-your-7db1b8414c0e
https://coredump.uno/questions/48769812/best-practice-runtime-filters-with-room-and-livedata
https://www.e-learn.cn/content/wangluowenzhang/1592769
https://coredump.uno/questions/49493772/mediatorlivedata-or-switchmap-transformation-with-multiple-parameters
*/
public class LiveDataUtil2<A, B, C, Y> {
public interface Thunk2<A, B, C, Y> {
@webserveis
webserveis / ClipboardUtils.java
Created Feb 27, 2019
Clipboard Utils for Java Android
View ClipboardUtils.java
package com.webserveis.basewebtool.utils;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.widget.Toast;
import com.webserveis.basewebtool.R;
import androidx.annotation.Nullable;
@webserveis
webserveis / PreferenceActivityCompat.md
Created Feb 27, 2019
Ventana de preferencia smartphone y tableta
View PreferenceActivityCompat.md

Crear ventana de configuración con soporte a tabletas y sus secciones

@webserveis
webserveis / HTTPUtils2.java
Last active Mar 12, 2019 — forked from liangzai-cool/HttpUtils.java
convert relative url to absolute url and beautify the result in java.
View HTTPUtils2.java
package com.webserveis.httpredirectiontrace.utils;
import android.net.Uri;
import android.util.Log;
import android.util.Patterns;
import android.webkit.URLUtil;
import java.io.UnsupportedEncodingException;
import java.net.IDN;
import java.net.MalformedURLException;
@webserveis
webserveis / KeyValueAdapter.java
Created Feb 19, 2019
Drag and Swipe recyclerview
View KeyValueAdapter.java
package com.example.webserveis.testkeyvalue;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.Collections;
import java.util.List;
You can’t perform that action at this time.