Skip to content

Instantly share code, notes, and snippets.

View xanderblinov's full-sized avatar

Alexander Blinov xanderblinov

View GitHub Profile
@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 / 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 / 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>
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);