use of com.google.gson.internal.LinkedTreeMap in project instructure-android by instructure.
the class QuizSubmissionQuestionListRecyclerAdapter method addMatchingQuestion.
private void addMatchingQuestion(final QuizSubmissionQuestion baseItem, QuizMatchingViewHolder holder, int position, int courseColor) {
addAnsweredQuestion(baseItem);
QuizMatchingBinder.bind(holder, baseItem, courseColor, position, shouldLetAnswer, getContext(), embeddedWebViewCallback, webViewClientCallback, new QuizPostMatching() {
@Override
public void postMatching(final long questionId, HashMap<Long, Integer> answers) {
QuizManager.postQuizQuestionMatching(quizSubmission, questionId, answers, true, new StatusCallback<QuizSubmissionQuestionResponse>() {
@Override
public void onResponse(@NonNull Response<QuizSubmissionQuestionResponse> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
if (type == ApiType.CACHE)
return;
final QuizSubmissionQuestionResponse quizSubmissionQuestionResponse = response.body();
if (quizSubmissionQuestionResponse.getQuizSubmissionQuestions() != null) {
for (QuizSubmissionQuestion question : quizSubmissionQuestionResponse.getQuizSubmissionQuestions()) {
if (baseItem.getId() == question.getId()) {
baseItem.setAnswer(question.getAnswer());
}
}
// make sure each answer has a match
int numAnswers = 0;
// API returns an ArrayList of LinkedTreeMaps
for (LinkedTreeMap<String, String> map : ((ArrayList<LinkedTreeMap<String, String>>) baseItem.getAnswer())) {
if (map.get(Const.QUIZ_MATCH_ID) != null && !map.get(Const.QUIZ_MATCH_ID).equals("null")) {
numAnswers++;
}
}
if (numAnswers == baseItem.getAnswers().length) {
addAnsweredQuestion(questionId);
} else {
removeAnsweredQuestion(questionId);
}
}
}
});
}
}, flagStateCallback);
}
use of com.google.gson.internal.LinkedTreeMap in project instructure-android by instructure.
the class QuizMatchingBinder method setPreviouslySelectedAnswer.
private static void setPreviouslySelectedAnswer(QuizSubmissionQuestion quizSubmissionQuestion, QuizSubmissionAnswer answer, Spinner spinner, ArrayList<QuizSubmissionMatch> list) {
if (quizSubmissionQuestion.getAnswer() != null) {
// the api returns an ArrayList of LinkedTreeMaps
for (LinkedTreeMap<String, String> map : ((ArrayList<LinkedTreeMap<String, String>>) quizSubmissionQuestion.getAnswer())) {
int answerId = Integer.parseInt(map.get(Const.QUIZ_ANSWER_ID));
if (answerId == answer.getId()) {
if (map.get(Const.QUIZ_MATCH_ID) != null && !map.get(Const.QUIZ_MATCH_ID).equals("null")) {
int matchId = Integer.parseInt(map.get(Const.QUIZ_MATCH_ID));
// now see if we have a match in the list of matches
int listIndex = 0;
for (QuizSubmissionMatch match : list) {
if (match.getMatchId() == matchId) {
spinner.setSelection(listIndex);
break;
}
listIndex++;
}
}
}
}
}
}
use of com.google.gson.internal.LinkedTreeMap in project toolkit by googleapis.
the class DiscoGapicProvider method generate.
public Map<String, Doc> generate(String snippetFileName) {
Map<String, Doc> docs = new LinkedTreeMap<>();
for (DocumentToViewTransformer transformer : transformers) {
List<ViewModel> surfaceDocs = transformer.transform(model, productConfig);
for (ViewModel surfaceDoc : surfaceDocs) {
if (snippetFileName != null && !surfaceDoc.templateFileName().equals(snippetFileName)) {
continue;
}
Doc doc = snippetSetRunner.generate(surfaceDoc);
if (doc == null) {
// generation failed; failures are captured in the model.
continue;
}
docs.put(surfaceDoc.outputPath(), doc);
}
}
return docs;
}
use of com.google.gson.internal.LinkedTreeMap in project OsmAnd-tools by osmandapp.
the class CoinSenderMain method convertPaymentsToMap.
public static Map<String, Double> convertPaymentsToMap(List<LinkedTreeMap> paymentsList, double MIN_PAY) {
Map<String, Double> payments = new LinkedHashMap<>();
for (LinkedTreeMap map : paymentsList) {
Double btc = (Double) map.get("btc");
String address = TransactionAnalyzer.simplifyBTC((String) map.get("btcaddress"));
if (address == null) {
continue;
}
if (payments.containsKey(address)) {
payments.put(address, btc + payments.get(address));
} else {
payments.put(address, btc);
}
}
double skip = 0;
int cnt = 0;
for (String addr : new ArrayList<>(payments.keySet())) {
if (payments.get(addr) < MIN_PAY) {
skip += payments.remove(addr);
cnt++;
}
}
System.out.println("Skipped " + cnt + " payments ( tx < minimal = " + MIN_PAY + ") in total " + skip * 1000 + " mBTC");
return payments;
}
use of com.google.gson.internal.LinkedTreeMap in project webdrivermanager by bonigarcia.
the class WebDriverManager method getDriversFromGitHub.
protected List<URL> getDriversFromGitHub() throws IOException {
List<URL> urls;
URL driverUrl = config().getDriverUrl(driverUrlKey);
String driverNameString = listToString(getDriverName());
log.info("Reading {} to seek {}", driverUrl, driverNameString);
if (isUsingTaobaoMirror()) {
urls = getDriversFromMirror(driverUrl);
} else {
String driverVersion = versionToDownload;
try (BufferedReader reader = new BufferedReader(new InputStreamReader(openGitHubConnection(driverUrl)))) {
GsonBuilder gsonBuilder = new GsonBuilder();
Gson gson = gsonBuilder.create();
GitHubApi[] releaseArray = gson.fromJson(reader, GitHubApi[].class);
if (driverVersion != null) {
releaseArray = new GitHubApi[] { getVersion(releaseArray, driverVersion) };
}
urls = new ArrayList<>();
for (GitHubApi release : releaseArray) {
if (release != null) {
List<LinkedTreeMap<String, Object>> assets = release.getAssets();
for (LinkedTreeMap<String, Object> asset : assets) {
urls.add(new URL(asset.get("browser_download_url").toString()));
}
}
}
}
}
return urls;
}
Aggregations