using namespace std;
const string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz @#$%^&*()"; //a 62 character string
string input, output;
const int shift = 3;
getline(cin, input);
for (string::size_type index = 0; index < input.length(); ++index) {
string::size_type found_index = alphabet.find(input[index]);
if (found_index != string::npos) {
output += alphabet[(found_index + shift) % alphabet.size()];
}
}
/*
Or, using C++11 or later:
for (char c : input) {
auto found_index = alphabet.find(c);
... (same as above) ...
}
*/
因此逻辑是,从本地数据库的stock_id获取列表,然后使用API检查服务器,如果为true,则服务器上已经存在stock_id,如果为false,则stock_id数据尚不存在。并且响应的结果需要使用is_sync = true / false
列更新回本地数据库调试时,指针不会进入onResponse,而是进入下一个循环
我想问一个问题,并且需要有关如何立即从服务器获取响应的建议(使用sqlite数据库),这有解决方案吗?
更新,重构代码后的“我的解决方案”:
?
我不知道这是否是最好的方法,但是它解决了我的问题。
答案 0 :(得分:0)
定义初始光标后,在onClick上调用此方法。抱歉,我没有IDE。
public void callMethod(Cursor cursor){
if (cursor.moveToNext()) {
//Retrofit
onResponse: () -> {
callMethod(cursor);
}
}else {
cursor.close();
}
}