This file contains 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 String getHotspotIpAddress() { | |
String ip = ""; | |
try { | |
Enumeration<NetworkInterface> enumNetworkInterfaces = NetworkInterface | |
.getNetworkInterfaces(); | |
while (enumNetworkInterfaces.hasMoreElements()) { | |
NetworkInterface networkInterface = enumNetworkInterfaces | |
.nextElement(); | |
Enumeration<InetAddress> enumInetAddress = networkInterface | |
.getInetAddresses(); |
This file contains 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
import java.io.InputStream | |
import java.io.OutputStream | |
fun InputStream.copyTo(out: OutputStream, onCopy: (totalBytesCopied: Long, bytesJustCopied: Int) -> Any): Long { | |
var bytesCopied: Long = 0 | |
val buffer = ByteArray(DEFAULT_BUFFER_SIZE) | |
var bytes = read(buffer) | |
while (bytes >= 0) { | |
out.write(buffer, 0, bytes) | |
bytesCopied += bytes |
This file contains 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
/* | |
* Copyright (C) 2018 Square, 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 |
This file contains 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
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import androidx.recyclerview.widget.RecyclerView | |
abstract class AnyAdapter<T>(val items: MutableList<T>) : RecyclerView.Adapter<AnyViewHolder<T>>() { | |
abstract fun getLayoutId(): Int | |
abstract fun onCreateViewHolder(view: View): AnyViewHolder<T> |
This file contains 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
import android.content.ContentUris | |
import android.content.Context | |
import android.database.Cursor | |
import android.net.Uri | |
import android.os.Build | |
import android.os.Environment | |
import android.provider.DocumentsContract | |
import android.provider.MediaStore | |
import android.support.v4.content.CursorLoader | |
import android.text.TextUtils |
This file contains 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
ANDROID | |
THIS IS THE ACTIVITY CLASS | |
============================================================================================================================= | |
public class AyudaEntelDialog extends android.support.v4.app.DialogFragment{ | |
private ImageView ivExit; | |
private VideoView vvTutorial; | |
private View rootView; |
This file contains 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
import com.sun.jersey.core.util.Base64; | |
import java.io.UnsupportedEncodingException; | |
import java.security.InvalidAlgorithmParameterException; | |
import java.security.InvalidKeyException; | |
import java.security.MessageDigest; | |
import java.security.NoSuchAlgorithmException; | |
import java.security.SecureRandom; | |
import java.util.Arrays; | |
import java.util.Random; | |
import javax.crypto.BadPaddingException; |
This file contains 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
// This is a super simplified example of how to use the new dagger.android framework | |
// introduced in Dagger 2.10. For a more complete, in-depth guide to dagger.android | |
// read https://proandroiddev.com/how-to-android-dagger-2-10-2-11-butterknife-mvp-part-1-eb0f6b970fd | |
// For a complete codebase using dagger.android 2.11-2.17, butterknife 8.7-8.8, and MVP, | |
// see https://github.com/vestrel00/android-dagger-butterknife-mvp | |
// This example works with Dagger 2.11-2.17. Starting with Dagger 2.11, | |
// @ContributesAndroidInjector was introduced removing the need to define @Subcomponent classes. |
This file contains 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
@Database(entities = arrayOf(Note::class, User::class), version = 1) | |
@TypeConverters(Converters::class) | |
abstract class AppDatabse : RoomDatabase() { | |
abstract fun userDAO(): UserDAO | |
abstract fun noteDAO(): NoteDAO | |
} |
This file contains 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
import java.math.BigInteger | |
import java.security.MessageDigest | |
fun String.md5(): String { | |
val md = MessageDigest.getInstance("MD5") | |
return BigInteger(1, md.digest(toByteArray())).toString(16).padStart(32, '0') | |
} |
NewerOlder