package safeluck.drive.evaluation.DB.rtktb; import android.content.Context; import android.util.Log; import androidx.annotation.NonNull; import androidx.work.Worker; import androidx.work.WorkerParameters; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.List; import safeluck.drive.evaluation.Constant; import safeluck.drive.evaluation.DB.Student; import safeluck.drive.evaluation.DB.WorkRoomDataBase; import safeluck.drive.evaluation.util.FileUtil; public class RTKConfigWork extends Worker { private Context context; public RTKConfigWork(@NonNull Context context, @NonNull WorkerParameters workerParams) { super(context, workerParams); this.context = context; } @NonNull @Override public Result doWork() { try { InputStream inputStream = getApplicationContext().getAssets().open(Constant.RTK_CONFIG_JSON); InputStreamReader inputStreamReader = new InputStreamReader(inputStream); JsonReader jsonReader = new JsonReader(inputStreamReader); Gson gson = new Gson(); Type type = new TypeToken(){}.getType(); RTKConfig mstus=gson.fromJson(jsonReader, type); WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getRTKConfigDao().insert(mstus); } catch (IOException e) { e.printStackTrace(); return Result.failure(); } return Result.success(); } }