Working on implementing the Toggle controls like Repeat and Shuffle. Having a little issues with Repeat, haven't started with Shuffle
This commit is contained in:
@@ -18,13 +18,13 @@
|
||||
#include <android/asset_manager_jni.h>
|
||||
#include <android/log.h>
|
||||
#include <android/sharedmem.h>
|
||||
#include <curl/curl.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <sqlite3.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <curl/curl.h>
|
||||
#include <sqlite3.h>
|
||||
|
||||
#include "APIRepository.h"
|
||||
#include "RepeatRepository.h"
|
||||
#include "SongRepository.h"
|
||||
#include "Tok.h"
|
||||
#include "TokenRepository.h"
|
||||
@@ -75,6 +75,12 @@ jobject songToObj(JNIEnv *env, const model::Song& song)
|
||||
}
|
||||
|
||||
|
||||
std::string jstringToString(JNIEnv *env, jstring& val)
|
||||
{
|
||||
return env->GetStringUTFChars(val, nullptr);
|
||||
}
|
||||
|
||||
|
||||
model::APIInfo retrieveAPIInfo(const std::string& path)
|
||||
{
|
||||
repository::local::APIRepository apiRepo;
|
||||
@@ -127,6 +133,19 @@ model::User retrieveCredentials(const std::string& dataPath)
|
||||
}
|
||||
|
||||
|
||||
int retrieveRepeatMode(const std::string& path)
|
||||
{
|
||||
repository::local::RepeatRepository repeatRepo;
|
||||
if (!repeatRepo.doesTableExist(path)) {
|
||||
repeatRepo.createRepeatTable(path);
|
||||
}
|
||||
|
||||
auto repeatMode = repeatRepo.retrieveRepeatMode(path);
|
||||
|
||||
return static_cast<int>(repeatMode);
|
||||
}
|
||||
|
||||
|
||||
bool doesDatabaseExist(const std::string& dataPath)
|
||||
{
|
||||
repository::local::UserRepository userRepo;
|
||||
@@ -207,6 +226,12 @@ void saveToken(const model::Token& token, const std::string& path)
|
||||
tokenRepo.saveToken(token, path);
|
||||
}
|
||||
|
||||
void updateRepeatMode(const std::string& path)
|
||||
{
|
||||
repository::local::RepeatRepository repeatRepo;
|
||||
repeatRepo.updateRepeat(path);
|
||||
}
|
||||
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jobjectArray
|
||||
@@ -380,6 +405,21 @@ Java_com_example_mear_repositories_UserRepository_logUser(
|
||||
}
|
||||
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jint
|
||||
JNICALL
|
||||
Java_com_example_mear_repositories_RepeatRepository_retrieveRepeatMode(
|
||||
JNIEnv *env,
|
||||
jobject thisObj,
|
||||
jstring pathStr
|
||||
) {
|
||||
const auto dataPath = jstringToString(env, pathStr);
|
||||
auto repeatMode = retrieveRepeatMode(dataPath);
|
||||
|
||||
return repeatMode;
|
||||
}
|
||||
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jboolean
|
||||
JNICALL
|
||||
@@ -501,3 +541,15 @@ Java_com_example_mear_repositories_TokenRepository_saveTokenRecord(
|
||||
|
||||
saveToken(token, path);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void
|
||||
JNICALL
|
||||
Java_com_example_mear_repositories_RepeatRepository_updateRepeatMode(
|
||||
JNIEnv *env,
|
||||
jobject thisObj,
|
||||
jstring pathStr
|
||||
) {
|
||||
const auto dataPath = jstringToString(env, pathStr);
|
||||
updateRepeatMode(dataPath);
|
||||
}
|
||||
Reference in New Issue
Block a user