/TaskDevartLab

using MVVM & retrofit & dataBinding &recycler view &card view & hdodenhof lib. &picasso&Coroutines&sneaker&nav graph & google sheet DB & API google script

Primary LanguageKotlin

TaskDevartLab

using MVVM & retrofit & dataBinding &recycler view &card view & hdodenhof lib. &picasso&Coroutines&sneaker&nav graph & google sheet DB & API google script
1-create google sheets like : https://docs.google.com/spreadsheets/d/15H-hd0z2h6OIf_g5e-33fEY6jMxpYJPGs_SYVSoZEa4/edit?usp=sharing
1
2- create google script to create api to google sheets like:https://script.google.com/d/13EGmpLksxWYfErTy6p59LiDJLVP6liJGH1Vk82qIl82vZADGagjEsQN_/edit?usp=sharing
2
Copy this is code to create api at google script πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡:
var id = 'ID_SHEETS'; var name = 'NAME_SHEETS';

function doGet(e) { var url = id; var sheetName = name;

var myData = SpreadsheetApp.openById(id); var sheet = myData.getSheetByName(name);

var json = convertSheet2Json(sheet); return ContentService.createTextOutput(JSON.stringify(json)) .setMimeType(ContentService.MimeType.JSON); } function convertSheet2Json(sheet) { // first line(title) var firstRange = sheet.getRange(1, 1, 1, sheet.getLastColumn()); var firstRowValues = firstRange.getValues(); var titleColumns = firstRowValues[0];

// after the second line(data) var lastRow = sheet.getLastRow(); var rowValues = []; for(var rowIndex=2; rowIndex<=lastRow; rowIndex++) { var colStartIndex = 1; var rowNum = 1; var range = sheet.getRange(rowIndex, colStartIndex, rowNum, sheet.getLastColumn()); var values = range.getValues(); rowValues.push(values[0]); }

// create json var jsonArray = []; for(var i=0; i<rowValues.length; i++) { var line = rowValues[i]; var json = new Object(); for(var j=0; j<titleColumns.length; j++) { json[titleColumns[j]] = line[j]; } jsonArray.push(json); } return jsonArray; }

3-after create google sheets and add code in script change ID_SHEETS to id sheets and NAME_SHEETS to sheet name
4- change base url at ServiceBuilder and change two string user_content_key and lib HomeRepo at code in android studio than run codeπŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰πŸ˜‰