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 static String codeHere(String inputData) { | |
// Use this function to write your solution; | |
String[] arrayInfo = inputData.split("\n"); | |
int size = Integer.parseInt(arrayInfo[0]); | |
int[] lenghsArray = new int[size]; | |
String[] stringArray = arrayInfo[1].split(" "); | |
List<Integer> subArray = new ArrayList<>(); | |
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 static double EARTH_RADIUS = 6378137.0; | |
public static LatLng to4326(Wgs84 wgs84) { | |
double lat = Math.toDegrees(Math.atan(Math.exp(wgs84.getY() / EARTH_RADIUS)) * 2 - Math.PI/2); | |
double lng = Math.toDegrees(wgs84.getX() / EARTH_RADIUS); | |
return new LatLng(lat, lng); | |
} | |
public static Wgs84 toWgs84(LatLng latLng) { | |
double x = Math.toRadians(latLng.longitude) * EARTH_RADIUS; |
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 BObserver<T> extends DisposableObserver<T> { | |
private StateLiveData<T> liveData; | |
public BObserver(StateLiveData<T> liveData) { | |
this.liveData = liveData; | |
} | |
@Override |
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.MotionEvent; | |
import android.view.View; | |
/** | |
* @author ali ([email protected]) | |
* @since 6/11/19 12:24 PM. | |
*/ | |
public class OnTouchListener implements View.OnTouchListener { |
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.annotation.SuppressLint | |
import android.view.MotionEvent | |
import android.view.View | |
import android.view.View.OnTouchListener | |
import java.util.* | |
/** | |
* Detects left and right swipes across a view. | |
*/ |
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
//Reference// | |
//https://github.com/orhanobut/logger | |
//https://github.com/JakeWharton/timber | |
// 1- Add this initializations to the oncreate method of Application class | |
Logger.addLogAdapter(AndroidLogAdapter()) | |
Timber.plant(Timber.DebugTree()) | |
// 2- Create a snippet to detect log is a json format (I used a string extention function) | |
fun String.isJson(): Boolean { |
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
/* packagingOptions { | |
exclude 'META-INF/androidx.localbroadcastmanager_localbroadcastmanager.version' | |
exclude 'META-INF/androidx.appcompat_appcompat.version' | |
exclude 'META-INF/androidx.customview_customview.version' | |
exclude 'META-INF/androidx.legacy_legacy-support-core-ui.version' | |
exclude 'META-INF/androidx.drawerlayout_drawerlayout.version' | |
exclude 'META-INF/androidx.interpolator_interpolator.version' | |
exclude 'META-INF/androidx.legacy_legacy-support-core-utils.version' | |
exclude 'META-INF/androidx.slidingpanelayout_slidingpanelayout.version' | |
exclude 'META-INF/androidx.swiperefreshlayout_swiperefreshlayout.version' |
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 Drawable.toBitmap(): Bitmap { | |
val bitmap = if (this.intrinsicWidth <= 0 || this.intrinsicHeight <= 0) { | |
Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888) // Single color bitmap will be created of 1x1 pixel | |
} else { | |
Bitmap.createBitmap(this.intrinsicWidth, this.intrinsicHeight, Bitmap.Config.ARGB_8888) | |
} | |
if (this is BitmapDrawable) { | |
if (this.bitmap != null) { | |
return this.bitmap |
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
/* | |
Given a collection of intervals, merge all overlapping intervals. | |
Example 1: | |
Input: [[1,3],[2,6],[8,10],[15,18]] | |
Output: [[1,6],[8,10],[15,18]] | |
Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6]. | |
Example 2: |