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
| { | |
| "productId": "com.your.product.id", | |
| "type": "subs", | |
| "title": "Subscription title", | |
| "name": "Subscription name", | |
| "description": "Subscription description", | |
| "localizedIn": [ | |
| "en-IN" | |
| ], | |
| "skuDetailsToken": "AE*****83", |
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
| package com.github.example; | |
| import android.content.Context; | |
| import android.graphics.Bitmap; | |
| import android.net.Uri; | |
| import android.text.TextUtils; | |
| import android.util.Log; | |
| import androidx.annotation.Nullable; | |
| import androidx.core.content.FileProvider; |
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.content.Context.CONNECTIVITY_SERVICE | |
| import android.net.ConnectivityManager | |
| import android.net.Network | |
| import android.net.NetworkCapabilities | |
| import android.net.NetworkRequest | |
| import androidx.lifecycle.Lifecycle | |
| import androidx.lifecycle.LifecycleObserver | |
| import androidx.lifecycle.LifecycleOwner | |
| import androidx.lifecycle.OnLifecycleEvent |
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
| package com.kodelabs.boilerplate.domain.executor.impl; | |
| import com.kodelabs.boilerplate.domain.executor.Executor; | |
| import com.kodelabs.boilerplate.domain.interactors.base.AbstractInteractor; | |
| import java.util.concurrent.BlockingQueue; | |
| import java.util.concurrent.LinkedBlockingQueue; | |
| import java.util.concurrent.ThreadPoolExecutor; | |
| import java.util.concurrent.TimeUnit; |
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
| "(?=.*[a-z].*)(.*[A-Z].*)" --- Must contain at least one CAPITAL and one non-capital | |
| ".*\\d.*" --- Must contain digits | |
| ... |
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
| // Spinner. Click->Select->Check | |
| YourObject expectedText = YourObject.PIECE; // for example, if it's ENUM | |
| onData(allOf(is(instanceOf(YourObject.class)), is(expectedText))).perform(click()); | |
| onView(withId(R.id.spinner)).check(matches(withSpinnerText(containsString(expectedText.name())))); | |
| // Spinner. Click on Spinner by id-> then Select exact what you need by specifying expectedText | |
| onView(withId(R.id.spinner)) | |
| .perform(click()); |
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
| // Backgrounds of views | |
| Drawable currentDrawable = textView.getBackground(); | |
| Drawable expectedDrawable = getApplicationContext().getDrawable(R.drawable.background_item_chip_yellow); | |
| assertThat(shadowOf(currentDrawable).getCreatedFromResId()).isEqualTo(shadowOf(expectedDrawable).getCreatedFromResId()); | |
| // Colors of TextView | |
| int expectedColor = ContextCompat.getColor(getApplicationContext(), R.color.text_blue); | |
| assertThat(textView.getCurrentTextColor()).isEqualTo(expectedColor); | |
| // Colors of Drawable backgrounds |
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
| public void checkCalculation() { | |
| Product product = new Product(10, 10); | |
| String totalSum = model.calculateSum(product); | |
| String expected = "100 руб."; // #1 способ | |
| assertThat(totalSum).isEqualTo(expected); // #1 способ | |
| int expectedValue = getString(R.string.total_sum, 100); // #2 способ | |
| assertThat(totalSum).isEqualTo(expectedValue); // #2 способ |
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
| private fun bitmapDescriptorFromVector(vectorResId: Int, context: Context): BitmapDescriptor { | |
| val vectorDrawable = ContextCompat.getDrawable(context, vectorResId) | |
| vectorDrawable!!.setBounds(0, 0, vectorDrawable.intrinsicWidth, vectorDrawable.intrinsicHeight) | |
| val bitmap = Bitmap.createBitmap(vectorDrawable.intrinsicWidth, vectorDrawable.intrinsicHeight, Bitmap.Config.ARGB_8888) | |
| val canvas = Canvas(bitmap) | |
| vectorDrawable.draw(canvas) | |
| return BitmapDescriptorFactory.fromBitmap(bitmap) | |
| } |
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
| const val TIMESTAMP_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" // eg. 2018-04-01T04:20:25.434Z | |
| /** | |
| * Time converting from any timestamp pattern to "5 minutes ago", "1 day ago", etc. | |
| */ | |
| fun convertTime(timestamp: String): String { | |
| val mDataFormat: DateFormat = SimpleDateFormat(TIMESTAMP_PATTERN, Locale.ENGLISH) | |
| return try { | |
| val date = mDataFormat.parse(timestamp) | |
| val relativeDateStr = DateUtils.getRelativeTimeSpanString(date.time, Calendar.getInstance().timeInMillis, DateUtils.MINUTE_IN_MILLIS) |
NewerOlder