Skip to content

Instantly share code, notes, and snippets.

View budioktaviyan's full-sized avatar
🇸🇬

Budi Oktaviyan budioktaviyan

🇸🇬
View GitHub Profile
@budioktaviyan
budioktaviyan / Version.kt
Created June 20, 2021 04:36
Check application version for Android
object version {
val String.isStable: Boolean
get() = !this.isNotStable
val String.isNotStable: Boolean
get() = listOf("alpha", "beta", "cr", "m", "preview", "b", "ea")
.map { label -> Regex("(?i).*[.-]$label[.\\d-+]*") }
.any { regex -> regex.matches(this) }
}
@budioktaviyan
budioktaviyan / coverage.gradle.kts
Created June 20, 2021 04:35
Generate Coverage Reports (Jacoco) Tasks
//
// Generate Coverage Reports (Jacoco) Tasks
//
project.afterEvaluate {
/* ktlint-disable max-line-length */
//
// Check if project contain Android Application plugin
//
project.plugins.firstOrNull { plugin -> plugin is AppPlugin } ?: return@afterEvaluate
@budioktaviyan
budioktaviyan / version.gradle.kts
Last active June 20, 2021 04:34
Gradle Versions Plugin
//
// Gradle Versions Plugin
//
apply(plugin = dep.plugin.versions)
tasks.withType<DependencyUpdatesTask>().configureEach {
rejectVersionIf {
currentVersion.isStable && candidate.version.isNotStable
}
gradleReleaseChannel = "current"
package id.kotlin.situng
import org.apache.commons.io.FileUtils
import org.openqa.selenium.OutputType
import org.openqa.selenium.TakesScreenshot
import org.openqa.selenium.chrome.ChromeDriver
import java.io.File
import java.text.SimpleDateFormat
import java.util.Date
@budioktaviyan
budioktaviyan / item_home.xml
Created December 27, 2016 17:27
Item Home (Cont'd)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:padding="8dp">
<ImageView
android:id="@+id/iv_home"
@budioktaviyan
budioktaviyan / HomeFragment.java
Created December 27, 2016 17:23
Home Fragment Class (Cont'd)
public class HomeFragment extends Fragment {
@Override
public void onActivityCreated(@Nullable final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// Prepare mock object into list of items
final List<String> items = new ArrayList<>();
items.add("Opsi Satu");
items.add("Opsi Dua");
@budioktaviyan
budioktaviyan / HomeFragment.java
Created December 27, 2016 17:19
Home Fragment Class (Cont'd)
public class HomeFragment extends Fragment {
@Override
public void onActivityCreated(@Nullable final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final RecyclerView recyclerView = (RecyclerView) getActivity().findViewById(R.id.rv_home);
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
final HomeAdapter homeAdapter = new HomeAdapter(items);
recyclerView.setLayoutManager(linearLayoutManager);
@budioktaviyan
budioktaviyan / HomeAdapter.java
Last active December 27, 2016 17:17
Home Adapter Class
public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.HomeHolder> {
private final List<String> mItems;
public HomeAdapter(final List<String> items) {
mItems = items;
}
@Override
public HomeHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
final View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home, parent, false);
@budioktaviyan
budioktaviyan / fragment_home.xml
Created December 27, 2016 17:10
Home Fragment (Cont'd)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
@budioktaviyan
budioktaviyan / item_home.xml
Created December 26, 2016 10:49
Item Home
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
<ImageView
android:id="@+id/iv_home"
android:layout_width="48dp"
android:layout_height="48dp"