Skip to content

Instantly share code, notes, and snippets.

View xanderblinov's full-sized avatar

Alexander Blinov xanderblinov

View GitHub Profile
private static PendingIntent getAlarmIntent(Context context)
{
return PendingIntent.getService(context, 0, new AlarmIntent(context, GeoLocationService.class).putExtra(KEY_INTENT_FLAG, VALUE_START), PendingIntent.FLAG_UPDATE_CURRENT);
}
private static void cancelAlarm(Context context)
{
PendingIntent pendingIntent = getAlarmIntent(context);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarmManager.cancel(pendingIntent);
@xanderblinov
xanderblinov / LockScreenService
Created December 22, 2015 09:46
Home Screen overlay
package com.arellomobile.wagamamamvp;
import android.app.Service;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.Handler;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
@xanderblinov
xanderblinov / MvpFragment
Created November 26, 2016 10:15
How to prevent Moxy's delegate onDestroy call of fragment in backstack while configuration changing.
public void onDestroy() {
super.onDestroy();
boolean anyParentIsRemoving = false;
for (Fragment parent = this.getParentFragment(); !anyParentIsRemoving && parent != null;
parent = parent.getParentFragment()) {
anyParentIsRemoving = parent.isRemoving();
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_address_search_manual)
val address = intent.getSerializableExtra(KEY_BUNDLE_ADDRESS) as Address?
getPresenter().init(address, intent.getBooleanExtra(KEY_BUNDLE_WAITING_FOR_RESULT, false))
initViews()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_address_search_manual)
val address = intent.getSerializableExtra(KEY_BUNDLE_ADDRESS) as Address?
getPresenter().init(address, intent.getBooleanExtra(KEY_BUNDLE_WAITING_FOR_RESULT, false))
initViews()
}
@xanderblinov
xanderblinov / HashSetUnitTest.kt
Last active February 10, 2018 11:04
HashSet and modifiable objects example
package com.test.hashset
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class HashSetUnitTest {
class Some(var a: Int, var b: Int) {
override fun equals(other: Any?): Boolean {
{
    "items": [
        {
            "experiment_name": "short_builder_in_app",
            "user_is_affected": true,
            "paramteter" : 
            {
              "backurl": "/vacancies",
 "source" : 17
@xanderblinov
xanderblinov / MvpFragment
Created November 26, 2016 10:15
How to prevent Moxy's delegate onDestroy call of fragment in backstack while configuration changing.
public void onDestroy() {
super.onDestroy();
boolean anyParentIsRemoving = false;
for (Fragment parent = this.getParentFragment(); !anyParentIsRemoving && parent != null;
parent = parent.getParentFragment()) {
anyParentIsRemoving = parent.isRemoving();
}
@xanderblinov
xanderblinov / RecyclerExtentions.kt
Created May 8, 2019 13:25
Pagination extantion for Kakao test
fun RecyclerActions.scrollToEndWithPagination() {
scrollToEnd()
view.perform(ViewActions.swipeUp())
}
fun <T : KRecyclerItem<T>> KRecyclerView.paginateUntilChildMatching(
childMatcher: ViewBuilder.() -> Unit,
timeoutS: Long = WAITER_TIMEOUT_S) {
while (true) {