Skip to content

Instantly share code, notes, and snippets.

View thsaravana's full-sized avatar
🐢
Just being lazy and crazy

Saravana thsaravana

🐢
Just being lazy and crazy
View GitHub Profile
@thsaravana
thsaravana / google_sheets_translation_script.js
Created August 23, 2021 11:38
Simple Google Apps script to generate Android strings.xml files from Google Sheets
// Add menu
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('Android')
.addItem('Export', 'exportTranslations')
.addToUi();
}
function exportTranslations() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
@thsaravana
thsaravana / MyApplication.java
Created March 2, 2020 04:23
To know if App has gone to background or is in foreground
public class MyApplication implements LifecycleObserver {
@Override
public void onCreate() {
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onStart() {
Log.d("App in foreground");
@thsaravana
thsaravana / AppTransitionStatus.java
Last active March 2, 2020 04:24
Used to identify when the app goes to foreground or background
public final class AppTransitionStatus implements Application.ActivityLifecycleCallbacks {
private static final long MAX_BACKGROUND_TIME = 2000;
private Timer timer;
private TimerTask task;
private boolean isBackground = true;
private final Transition transition;
public AppTransitionStatus(@NonNull Transition transition) {