Working on setting a song on repeat
This commit is contained in:
@@ -22,6 +22,8 @@ set (SOURCES
|
|||||||
APIRepository.cpp
|
APIRepository.cpp
|
||||||
BaseRepository.cpp
|
BaseRepository.cpp
|
||||||
Demo.cpp
|
Demo.cpp
|
||||||
|
RepeatRepository.cpp
|
||||||
|
ShuffleRepository.cpp
|
||||||
SongRepository.cpp
|
SongRepository.cpp
|
||||||
Tok.cpp
|
Tok.cpp
|
||||||
TokenRepository.cpp
|
TokenRepository.cpp
|
||||||
@@ -36,6 +38,10 @@ set (HEADERS
|
|||||||
model/Song.h
|
model/Song.h
|
||||||
model/Token.h
|
model/Token.h
|
||||||
model/User.h
|
model/User.h
|
||||||
|
RepeatRepository.h
|
||||||
|
RepeatTypes.h
|
||||||
|
ShuffleRepository.h
|
||||||
|
ShuffleTypes.h
|
||||||
SongRepository.h
|
SongRepository.h
|
||||||
Tok.h
|
Tok.h
|
||||||
TokenRepository.h
|
TokenRepository.h
|
||||||
@@ -50,16 +56,12 @@ add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/3rdparty/SQLiteCpp)
|
|||||||
|
|
||||||
|
|
||||||
add_library(native-lib SHARED
|
add_library(native-lib SHARED
|
||||||
|
|
||||||
# Provides a relative path to your source file(s).
|
|
||||||
${SOURCES}
|
${SOURCES}
|
||||||
${HEADERS}
|
${HEADERS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
find_library(log-lib
|
find_library(log-lib
|
||||||
# Specifies the name of the NDK library that
|
|
||||||
# you want CMake to locate.
|
|
||||||
log
|
log
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -84,16 +86,13 @@ set_target_properties(boo PROPERTIES IMPORTED_LOCATION
|
|||||||
"${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/android/${ANDROID_ABI}/libcurl.a"
|
"${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/android/${ANDROID_ABI}/libcurl.a"
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(${CURL_INCLUDE_DIR} ${SQLITECPP_INCLUDE}) #${BASS_INCLUDE_DIR})
|
include_directories(${CURL_INCLUDE_DIR} ${SQLITECPP_INCLUDE})
|
||||||
|
|
||||||
target_link_libraries(native-lib PRIVATE
|
target_link_libraries(native-lib PRIVATE
|
||||||
|
|
||||||
nlohmann_json::nlohmann_json
|
nlohmann_json::nlohmann_json
|
||||||
boo
|
boo
|
||||||
#bass
|
|
||||||
SQLiteCpp
|
SQLiteCpp
|
||||||
sqlite3
|
sqlite3
|
||||||
#pthread
|
|
||||||
dl
|
dl
|
||||||
${log-lib}
|
${log-lib}
|
||||||
z
|
z
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
//
|
||||||
|
// Created by brahmix on 10/21/19.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "RepeatRepository.h"
|
||||||
|
|
||||||
|
namespace repository { namespace local {
|
||||||
|
RepeatRepository::RepeatRepository() {
|
||||||
|
m_tableName = repeatTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RepeatTypes RepeatRepository::retrieveRepeatMode(const std::string& path) {
|
||||||
|
try {
|
||||||
|
auto db = getDbConn(path, ConnType::ReadOnly);
|
||||||
|
std::string queryString("SELECT * FROM ");
|
||||||
|
queryString.append(m_tableName);
|
||||||
|
queryString.append(" LIMIT 1");
|
||||||
|
|
||||||
|
SQLite::Statement query(db, queryString);
|
||||||
|
|
||||||
|
const auto result = query.executeStep();
|
||||||
|
|
||||||
|
return static_cast<RepeatTypes>(query.getColumn(1).getInt());
|
||||||
|
} catch (std::exception& ex) {
|
||||||
|
auto msg = ex.what();
|
||||||
|
}
|
||||||
|
|
||||||
|
return RepeatTypes::RepeatOff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RepeatRepository::createRepeatTable(const std::string& path) {
|
||||||
|
try {
|
||||||
|
auto db = getDbConn(path, ConnType::ReadWrite);
|
||||||
|
std::string queryString("CREATE TABLE ");
|
||||||
|
queryString.append(m_tableName);
|
||||||
|
queryString.append(" (Id INTEGER PRIMARY KEY, RepeatMode INT)");
|
||||||
|
|
||||||
|
db.exec(queryString);
|
||||||
|
} catch (std::exception& ex) {
|
||||||
|
auto msg = ex.what();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RepeatRepository::updateRepeat(const std::string& path) {
|
||||||
|
try {
|
||||||
|
auto db = getDbConn(path, ConnType::ReadWrite);
|
||||||
|
|
||||||
|
if (isTableEmpty(path)) {
|
||||||
|
std::string queryString("INSERT INTO ");
|
||||||
|
queryString.append(m_tableName);
|
||||||
|
queryString.append(" (RepeatMode) VALUES (?)");
|
||||||
|
|
||||||
|
SQLite::Statement query(db, queryString);
|
||||||
|
query.bind(1, static_cast<int>(RepeatTypes::RepeatOff));
|
||||||
|
query.exec();
|
||||||
|
} else {
|
||||||
|
std::string queryString("UPDATE ");
|
||||||
|
queryString.append(m_tableName);
|
||||||
|
queryString.append(" SET RepeatMode = ?");
|
||||||
|
|
||||||
|
auto repeatMode = retrieveRepeatMode(path);
|
||||||
|
SQLite::Statement query(db, queryString);
|
||||||
|
|
||||||
|
switch (repeatMode) {
|
||||||
|
case RepeatTypes::RepeatOff:
|
||||||
|
query.bind(1, static_cast<int>(RepeatTypes::RepeatSong));
|
||||||
|
break;
|
||||||
|
case RepeatTypes::RepeatSong:
|
||||||
|
query.bind(1, static_cast<int>(RepeatTypes::RepeatOff));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
query.exec();
|
||||||
|
}
|
||||||
|
} catch (std::exception& ex) {
|
||||||
|
auto msg = ex.what();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string RepeatRepository::repeatTable() { return "Repeat"; }
|
||||||
|
}}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
//
|
||||||
|
// Created by brahmix on 10/21/19.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef MEAR_REPEATREPOSITORY_H
|
||||||
|
#define MEAR_REPEATREPOSITORY_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "BaseRepository.h"
|
||||||
|
#include "RepeatTypes.h"
|
||||||
|
|
||||||
|
namespace repository { namespace local {
|
||||||
|
class RepeatRepository : public BaseRepository {
|
||||||
|
public:
|
||||||
|
RepeatRepository();
|
||||||
|
|
||||||
|
RepeatTypes retrieveRepeatMode(const std::string&);
|
||||||
|
|
||||||
|
void createRepeatTable(const std::string&);
|
||||||
|
void updateRepeat(const std::string&);
|
||||||
|
private:
|
||||||
|
constexpr std::string repeatTable() noexcept;
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
#endif //MEAR_REPEATREPOSITORY_H
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
//
|
||||||
|
// Created by brahmix on 10/21/19.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef MEAR_REPEATTYPES_H
|
||||||
|
#define MEAR_REPEATTYPES_H
|
||||||
|
|
||||||
|
|
||||||
|
enum class RepeatTypes {
|
||||||
|
RepeatSong = 0,
|
||||||
|
RepeatOff
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //MEAR_REPEATTYPES_H
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
//
|
||||||
|
// Created by brahmix on 10/21/19.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "ShuffleRepository.h"
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
//
|
||||||
|
// Created by brahmix on 10/21/19.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef MEAR_SHUFFLEREPOSITORY_H
|
||||||
|
#define MEAR_SHUFFLEREPOSITORY_H
|
||||||
|
|
||||||
|
|
||||||
|
class ShuffleRepository {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //MEAR_SHUFFLEREPOSITORY_H
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
//
|
||||||
|
// Created by brahmix on 10/21/19.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef MEAR_SHUFFLETYPES_H
|
||||||
|
#define MEAR_SHUFFLETYPES_H
|
||||||
|
|
||||||
|
enum class ShuffleTypes {
|
||||||
|
ShuffleQueue = 0,
|
||||||
|
ShuffleOff
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //MEAR_SHUFFLETYPES_H
|
||||||
@@ -88,10 +88,6 @@ open class BaseServiceActivity: AppCompatActivity() {
|
|||||||
startService(intent)
|
startService(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = bindService(intent, mConnection, Context.BIND_AUTO_CREATE)
|
val result = bindService(intent, mConnection, Context.BIND_AUTO_CREATE)
|
||||||
if (result) {
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,6 @@ package com.example.mear.activities
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Environment
|
|
||||||
import android.support.design.widget.Snackbar
|
import android.support.design.widget.Snackbar
|
||||||
import com.example.mear.R
|
import com.example.mear.R
|
||||||
import com.example.mear.models.*
|
import com.example.mear.models.*
|
||||||
@@ -58,7 +57,6 @@ class LoginActivity : BaseServiceActivity() {
|
|||||||
usrRepo.saveCredentials(usr, pa)
|
usrRepo.saveCredentials(usr, pa)
|
||||||
}
|
}
|
||||||
tokenRepo.saveToken(myToken, pa)
|
tokenRepo.saveToken(myToken, pa)
|
||||||
//startActivity(Intent(this, IcarusSongActivity::class.java))
|
|
||||||
startActivity(Intent(this, MainActivity::class.java))
|
startActivity(Intent(this, MainActivity::class.java))
|
||||||
}
|
}
|
||||||
catch (ex: Exception) {
|
catch (ex: Exception) {
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
package com.example.mear.playback
|
|
||||||
|
|
||||||
class PlayMusic {
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user