* @param init The view initializer employed only when the view is not present
* in the view cache
*/
@SuppressWarnings("unchecked")
void setCurrentView(IViewInitializer init) {
final ViewKey key = init.getViewKey();
Log.debug("Setting current view: '" + key + "' ..");
CView e;
final ViewOptions options = init.getViewKey().getViewClass().getViewOptions();
final int cacheIndex = cache.searchQueue(key);
final boolean showPopped = ((cacheIndex == -1) && options.isInitiallyPopped());
if(cacheIndex != -1) {
// existing cached view
e = cache.removeAt(cacheIndex);
assert e != null;
setCurrentView(e, showPopped);
}
else {
Log.debug("Creating and initializing view: " + key + " ..");
// non-cached view
final IView<IViewInitializer> view = (IView<IViewInitializer>) key.getViewClass().newView();
// initialize the view
view.initialize(init);
e = new CView(new ViewContainer(view, options, key), init);