use of android.widget.ViewSwitcher in project materialistic by hidroh.
the class WebFragmentTest method testSearch.
@Test
public void testSearch() {
ShadowLocalBroadcastManager.getInstance(activity).sendBroadcast(new Intent(WebFragment.ACTION_FULLSCREEN).putExtra(WebFragment.EXTRA_FULLSCREEN, true));
activity.findViewById(R.id.button_find).performClick();
ViewSwitcher controlSwitcher = (ViewSwitcher) activity.findViewById(R.id.control_switcher);
assertThat(controlSwitcher.getDisplayedChild()).isEqualTo(1);
ShadowWebView shadowWebView = (ShadowWebView) ShadowExtractor.extract(activity.findViewById(R.id.web_view));
// no query
EditText editText = (EditText) activity.findViewById(R.id.edittext);
shadowOf(editText).getOnEditorActionListener().onEditorAction(null, 0, null);
assertThat(activity.findViewById(R.id.button_next)).isDisabled();
// with results
shadowWebView.setFindCount(1);
editText.setText("abc");
shadowOf(editText).getOnEditorActionListener().onEditorAction(null, 0, null);
assertThat(activity.findViewById(R.id.button_next)).isEnabled();
activity.findViewById(R.id.button_next).performClick();
assertThat(shadowWebView.getFindIndex()).isEqualTo(1);
activity.findViewById(R.id.button_clear).performClick();
assertThat(editText).isEmpty();
assertThat(controlSwitcher.getDisplayedChild()).isEqualTo(0);
// with no results
shadowWebView.setFindCount(0);
editText.setText("abc");
shadowOf(editText).getOnEditorActionListener().onEditorAction(null, 0, null);
assertThat(activity.findViewById(R.id.button_next)).isDisabled();
assertThat(ShadowToast.getTextOfLatestToast()).contains(activity.getString(R.string.no_matches));
}
use of android.widget.ViewSwitcher in project SmartAndroidSource by jaychou2012.
the class AutoLoading method initializeViewContainer.
private void initializeViewContainer() {
setDefaultViews();
mSwitcher = new ViewSwitcher(mContext);
ViewSwitcher.LayoutParams params = new ViewSwitcher.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
mSwitcher.setLayoutParams(params);
ViewGroup group = (ViewGroup) mTargetView.getParent();
int index = 0;
Clonner target = new Clonner(mTargetView);
if (group != null) {
index = group.indexOfChild(mTargetView);
group.removeView(mTargetView);
}
mSwitcher.addView(mContainer, 0);
mSwitcher.addView(target.getmView(), 1);
mSwitcher.setDisplayedChild(1);
if (group != null) {
group.addView(mSwitcher, index);
} else {
((Activity) mContext).setContentView(mSwitcher);
}
}
Aggregations