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
def getVersionName = { getVersionProps()['appVersionName'] } | |
def getVersionProps() { | |
def versionPropsFile = file('gradle.properties') | |
if (!versionPropsFile.exists()) { | |
versionPropsFile.createNewFile() | |
} | |
def versionProps = new Properties() | |
versionProps.load(new FileInputStream(versionPropsFile)) | |
return versionProps |
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
name: Android Build | |
on: pull_request | |
jobs: | |
build: | |
runs-on: ubuntu-latest |
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.Intent | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import kotlinx.coroutines.* | |
class CoroutinesSplashActivity : AppCompatActivity() { | |
val activityScope = CoroutineScope(Dispatchers.Main) | |
override fun onCreate(savedInstanceState: Bundle?) { |
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
class Laptop(builder: Builder) { | |
private val processor: String = builder.processor | |
private val ram: String = builder.ram | |
private val battery: String = builder.battery | |
private val screenSize: String = builder.screenSize | |
// Builder class | |
class Builder(processor: String) { | |
var processor: String = processor // this is necessary |
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
public class Circle implements Shape { | |
@Override | |
public void draw() { | |
System.out.println("Circle::draw()"); | |
} | |
} |
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
// Java code to demonstrate Builder Pattern | |
// Server Side Code | |
final class Student { | |
// final instance fields | |
private final int id; | |
private final String name; | |
private final String address; |
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
$ ls -dl ~/files | |
drwx------ 9 root root 4096 2009-04-06 15:56 files | |
$ sudo chown grunt547:grunt547 ~/files | |
[sudo] password for grunt547: | |
$ chmod 755 ~/files | |
$ ls -dl ~/files | |
drwxr-xr-x 9 grunt547 grunt547 4096 2009-04-06 15:56 files |
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
fun Long.getFriendlyTime(): String { | |
val dateTime = Date(this * 1000) | |
val sb = StringBuffer() | |
val current = Calendar.getInstance().time | |
var diffInSeconds = ((current.time - dateTime.time) / 1000).toInt() | |
val sec = if (diffInSeconds >= 60) (diffInSeconds % 60) else diffInSeconds | |
diffInSeconds /= 60 | |
val min = if (diffInSeconds >= 60) (diffInSeconds % 60) else diffInSeconds | |
diffInSeconds /= 60 |
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.Context; | |
import android.net.ConnectivityManager; | |
import android.net.NetworkInfo; | |
public class NetworkHelper { | |
public static final boolean hasNetworkAccess(Context context){ | |
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | |
try { | |
NetworkInfo networkInfo = cm.getActiveNetworkInfo(); | |
return networkInfo != null && networkInfo.isConnectedOrConnecting(); |
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
E.g. for 50% white you'd use #80FFFFFF | |
100% — FF | |
95% — F2 | |
90% — E6 | |
85% — D9 | |
80% — CC | |
75% — BF | |
70% — B3 | |
65% — A6 |
NewerOlder