Skip to content

Commit

Permalink
Preserve API compatibility for Database.DatabaseDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
jasta committed Mar 11, 2017
1 parent 1506dd2 commit e94789e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
3 changes: 1 addition & 2 deletions stetho/src/main/java/com/facebook/stetho/Stetho.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import com.facebook.stetho.inspector.protocol.module.DOMStorage;
import com.facebook.stetho.inspector.protocol.module.Database;
import com.facebook.stetho.inspector.protocol.module.DatabaseConstants;
import com.facebook.stetho.inspector.protocol.module.DatabaseDriver;
import com.facebook.stetho.inspector.protocol.module.DatabaseDriver2;
import com.facebook.stetho.inspector.protocol.module.Debugger;
import com.facebook.stetho.inspector.protocol.module.HeapProfiler;
Expand Down Expand Up @@ -301,7 +300,7 @@ public DefaultInspectorModulesBuilder databaseFiles(DatabaseFilesProvider provid
* @deprecated Convert your custom database driver to {@link DatabaseDriver2}.
*/
@Deprecated
public DefaultInspectorModulesBuilder provideDatabaseDriver(DatabaseDriver databaseDriver) {
public DefaultInspectorModulesBuilder provideDatabaseDriver(Database.DatabaseDriver databaseDriver) {
provideDatabaseDriver(new DatabaseDriver2Adapter(databaseDriver));
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import com.facebook.stetho.inspector.protocol.module.Database;
import com.facebook.stetho.inspector.protocol.module.DatabaseDescriptor;
import com.facebook.stetho.inspector.protocol.module.DatabaseDriver;
import com.facebook.stetho.inspector.protocol.module.DatabaseDriver2;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import com.facebook.stetho.inspector.protocol.module.Database;
import com.facebook.stetho.inspector.protocol.module.DatabaseDescriptor;
import com.facebook.stetho.inspector.protocol.module.DatabaseDriver;
import com.facebook.stetho.inspector.protocol.module.DatabaseDriver2;

import java.util.ArrayList;
Expand All @@ -17,9 +16,9 @@
@Deprecated
public class DatabaseDriver2Adapter
extends DatabaseDriver2<DatabaseDriver2Adapter.StringDatabaseDescriptor> {
private final DatabaseDriver mLegacy;
private final Database.DatabaseDriver mLegacy;

public DatabaseDriver2Adapter(DatabaseDriver legacy) {
public DatabaseDriver2Adapter(Database.DatabaseDriver legacy) {
super(legacy.getContext());
mLegacy = legacy;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
import java.util.List;

/**
* @deprecated Use {@link DatabaseDriver2} instead which enforces generics of
* {@link DatabaseDescriptor}.
* Extend {@link DatabaseDriver2} directly. This class is provided only as a common API compatible
* base layer for the legacy {@link Database.DatabaseDriver}.
*/
@Deprecated
public abstract class DatabaseDriver<DESC> {
public abstract class BaseDatabaseDriver<DESC> {

protected Context mContext;

public DatabaseDriver(Context context) {
public BaseDatabaseDriver(Context context) {
mContext = context;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.List;

import android.annotation.TargetApi;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteException;
import android.os.Build;
Expand Down Expand Up @@ -365,4 +366,15 @@ public static class Error {
public int code;
}

/**
* @deprecated Use {@link DatabaseDriver2} which allows for structured identifiers of database
* objects (such as a file path instead of just a string name) which also serves as a
* namespacing separation of multiple drivers.
*/
@Deprecated
public static abstract class DatabaseDriver extends BaseDatabaseDriver<String> {
public DatabaseDriver(Context context) {
super(context);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import android.content.Context;

/**
* Replaces {@link DatabaseDriver} to enforce that the generic type must
* Replaces {@link Database.DatabaseDriver} to enforce that the generic type must
* extend {@link DatabaseDescriptor}.
*/
public abstract class DatabaseDriver2<DESC extends DatabaseDescriptor>
extends DatabaseDriver<DESC> {
extends BaseDatabaseDriver<DESC> {
public DatabaseDriver2(Context context) {
super(context);
}
Expand Down

0 comments on commit e94789e

Please sign in to comment.