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 / AndroidManifest
Created December 22, 2015 09:44
Overlay for lock screen
<activity android:name=".MainActivity"
android:showOnLockScreen="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
@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();
}
@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 / App.kt
Created February 5, 2017 10:11
Component Dependency Injection
class App : Application() {
override fun onCreate() {
super.onCreate()
MvpFacade.init()
DI.init(this)
}
}
@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 {