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:
parent
7b83ca3f77
commit
8323c5d587
@ -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"),
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user