Fixed cast exception in adapter factory.

Change-Id: Id21eb128c542ffbb09df1252b3ecd185d91ecf99
Merge "Fixed cast exception in adapter factory."