0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 20:03:05 +02:00

refactor: convert InMemorySQLiteOpenHelperFactory to Kotlin

com.ichi2.utils.InMemorySQLiteOpenHelperFactory
This commit is contained in:
David Allison 2022-04-20 01:03:25 +01:00 committed by Mike Hardy
parent 7b83ca3f77
commit 8323c5d587
2 changed files with 16 additions and 20 deletions

View File

@ -42,8 +42,8 @@ permission notice:
// Example of class name: "/com/ichi2/anki/UIUtils.kt"
// Ensure that it starts with '/' (slash)
def source = Source.TEST
def className = "/com/ichi2/utils/InMemorySQLiteOpenHelperFactory.kt"
def source = Source.MAIN
def className = ""
enum Source {
MAIN("/src/main/java"),

View File

@ -13,25 +13,21 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ichi2.utils
package com.ichi2.utils;
import androidx.sqlite.db.SupportSQLiteOpenHelper
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
import androidx.annotation.NonNull;
import androidx.sqlite.db.SupportSQLiteOpenHelper;
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory;
public class InMemorySQLiteOpenHelperFactory implements SupportSQLiteOpenHelper.Factory {
@NonNull
@Override
public SupportSQLiteOpenHelper create(
@NonNull SupportSQLiteOpenHelper.Configuration configuration) {
SupportSQLiteOpenHelper.Configuration inMemoryConfig = SupportSQLiteOpenHelper.Configuration
.builder(configuration.context)
.name(null) // in-memory
.callback(configuration.callback)
.noBackupDirectory(configuration.useNoBackupDirectory)
.build();
return new FrameworkSQLiteOpenHelperFactory().create(inMemoryConfig);
class InMemorySQLiteOpenHelperFactory : SupportSQLiteOpenHelper.Factory {
override fun create(
configuration: SupportSQLiteOpenHelper.Configuration
): SupportSQLiteOpenHelper {
val inMemoryConfig = SupportSQLiteOpenHelper.Configuration
.builder(configuration.context)
.name(null) // in-memory
.callback(configuration.callback)
.noBackupDirectory(configuration.useNoBackupDirectory)
.build()
return FrameworkSQLiteOpenHelperFactory().create(inMemoryConfig)
}
}