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
import android.content.Context | |
import android.net.ConnectivityManager | |
import java.net.InetAddress | |
import java.net.UnknownHostException | |
class ConnectionService(context: Context) { | |
companion object { | |
private var mInstance: ConnectionService? = null |
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
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 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
import androidx.appcompat.app.AppCompatActivity | |
import androidx.lifecycle.ViewModel | |
import androidx.lifecycle.ViewModelProviders | |
import androidx.lifecycle.ViewModelProvider | |
import android.app.Activity | |
import android.content.Intent | |
inline fun <reified T : Any> Activity.openAndFinish(extras: Intent.() -> Unit = {}) { | |
open<T>(extras) | |
finish() |
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
<?php | |
# START CROPPING -- it just need 4 lines of code to crop an image | |
$img = imagecreatefromjpeg('assets/img/myimage.jpg'); | |
$size = min(imagesx($img), imagesy($img)); | |
$img_squared = imagecrop($img, [ 'x' => 0, 'y' => 0, 'width' => $size, 'height' => $size ]); | |
if ($img_squared !== false) ($img_squared, 'assets/img/myimage-squared.jpg', 80); | |
# END OF CROPPING -- read the explanation below | |
# READ MORE here http://php.net/manual/en/function.imagecrop.php |
NewerOlder