Skip to content

Instantly share code, notes, and snippets.

View vicky7230's full-sized avatar
🎯
Focusing

Vipin Kumar vicky7230

🎯
Focusing
View GitHub Profile

JaCoCo Code Coverage Report for Multi-Module Android Project

This guide explains how to set up and generate a complete code coverage report for a multi-module Android project using JaCoCo. It includes both unit and instrumented tests.

Steps to Implement JaCoCo in Your Project

1. Apply JaCoCo Plugin in All Modules

To begin, apply the JaCoCo plugin in all modules of your project (including the root module)

@vicky7230
vicky7230 / BatteryOptimizationUtil.java
Created July 15, 2020 04:10 — forked from moopat/BatteryOptimizationUtil.java
Many Android manufacturers cause trouble by implementing battery optimizations that cause apps to behave unexpectedly at runtime. This util class allows you to show a dialog to users having such phones and sends them to the settings screen where they can turn of battery optimizations for your app.
/*
* MIT License
*
* Copyright (c) 2018 Markus Deutsch
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
//In local.properties
tmdb_api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxx"
//In build.gradle (Module: app)
buildTypes.each {
Properties properties = new Properties()
properties.load(project.rootProject.file("local.properties").newDataInputStream())
def tmdbApiKey = properties.getProperty("tmdb_api_key", "")
it.buildConfigField 'String', "TMDB_API_KEY", tmdbApiKey
@vicky7230
vicky7230 / README.md
Created September 25, 2019 07:37 — forked from cr7pt0gr4ph7/README.md
Gradle Dependency Resolution

Gradle Dependency Resolution

Normal Gradle behavior

The default behavior of Gradle to pick the newest version also applies if a lower version has been declared locally, but another dependency transitively pulls in a newer version. This is in contrast with Maven, where a locally declared version will always win.

For example, if your build.gradle specifies the dependency org.springframework:spring-tx:3.2.3.RELEASE, and another dependency declares 4.0.5.RELEASE as a transitive dependency, then 4.0.5.RELEASE will take precedence:

dependencies {
    compile("org.springframework.data:spring-data-hadoop:2.0.0.RELEASE")
    compile("org.springframework:spring-tx:3.2.3.RELEASE")

// will select org.springframework:spring-tx:4.0.5.RELEASE

@vicky7230
vicky7230 / Get Path from Uri
Last active August 20, 2018 06:27 — forked from WrathChaos/android-real-path-uri.md
Android: How to get Real Path from Uri?
private String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = { MediaStore.Images.Media.DATA };
cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} catch (Exception e) {
Log.e(TAG, "getRealPathFromURI Exception : " + e.toString());
commonApiService.sendOtp(phone)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(login -> {
if (!isViewAttached()) {
return;
}
getMvpView().hideLoading();
if (login != null && login.getSuccess() != null) {
if (login.getSuccess()) {
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
if (BuildConfig.DEBUG) {
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
} else {
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.NONE);
}
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(1000, TimeUnit.SECONDS)
.addInterceptor(httpLoggingInterceptor)
class TvAdapter(private val resultList: MutableList<Result>?) :
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private val TYPE_LOADING = -1
private val TYPE_TV = 1
interface Callback {
fun onTvShowClick(id: Int)
}
class TvFragment : BaseFragment(), TvMvpView, TvAdapter.Callback {
@Inject
lateinit var presenter: TvMvpPresenter<TvMvpView>
@Inject
lateinit var gridLayoutManager: GridLayoutManager
@Inject
lateinit var itemOffsetDecoration: ItemOffsetDecoration
@Inject
lateinit var tvAdapter: TvAdapter
data class Result(
var type: String = "TV",
@SerializedName("original_name")
@Expose
var originalName: String? = null,
@SerializedName("genre_ids")
@Expose
var genreIds: List<Int>? = null,