Skip to content

Instantly share code, notes, and snippets.

View jaiselrahman's full-sized avatar

Jaisel Rahman jaiselrahman

View GitHub Profile
@jaiselrahman
jaiselrahman / apps_script.gs
Created September 18, 2021 11:40
Google Sheets Registration
// original from: http://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
// original gist: https://gist.github.com/willpatera/ee41ae374d3c9839c2d6
function doPost(e){
return handleResponse(e);
}
function doGet(e){
return handleResponse(e);
}
def propertiesFile = project.rootProject.file('local.properties')
if (propertiesFile.exists()) {
Properties properties = new Properties()
properties.load(propertiesFile.newDataInputStream())
ext.SECRET_KEY = properties.getProperty('SECRET_KEY') ?: ""
} else {
ext.SECRET_KEY = System.getenv('SECRET_KEY') ?: ""
}
//Saving scroll state
val position = linearLayoutManager.findFirstVisibleItemPosition()
val offset = linearLayoutManager.getChildAt(0).let {
if (it == null) 0 else it.top - linearLayoutManager.paddingTop
}
postFeedViewModel.scrollState = ScrollState.of(position, offset)
//Restoring scroll state
val scrollState = postFeedViewModel.scrollState
linearLayoutManager.scrollToPositionWithOffset(scrollState.position, scrollState.offset)