private void initializeWidgets(View view) { imgViewCircle = (RoundedImageView) view.findViewById(R.id.simulation_fragment_image_view_circle); imgViewsArray[0] = (RoundedImageView) view.findViewById(R.id.simulation_fragment_image_view_option1_rounded); imgViewsArray[1] = (RoundedImageView) view.findViewById(R.id.simulation_fragment_image_view_option2_rounded); imgViewsArray[2] = (RoundedImageView) view.findViewById(R.id.simulation_fragment_image_view_option3_rounded); imgViewsArray[3] = (RoundedImageView) view.findViewById(R.id.simulation_fragment_image_view_option4_rounded); for (RoundedImageView roundedImageView : imgViewsArray) { roundedImageView.setCornerRadius((float) 20); } txtViewsArray[0] = (TextView) view.findViewById(R.id.simulation_fragment_text_view_option1); txtViewsArray[1] = (TextView) view.findViewById(R.id.simulation_fragment_text_view_option2); txtViewsArray[2] = (TextView) view.findViewById(R.id.simulation_fragment_text_view_option3); txtViewsArray[3] = (TextView) view.findViewById(R.id.simulation_fragment_text_view_option4); View toastView = getActivity().getLayoutInflater().inflate(R.layout.toast_error, null); errorToast = new Toast(getActivity().getApplicationContext()); errorToast.setGravity(Gravity.BOTTOM, 0, 0); errorToast.setView(toastView); }
private void setWidgetsIncongruent( int[] otherColorIds, int correctImageViewIndex, int correctColorId) { imgViewCircle.setImageDrawable(getResources().getDrawable(COLOR_BACKGROUNDS[correctColorId])); int imgViewIndexForCorrectColor = random.nextInt(imgViewsArray.length); while (imgViewIndexForCorrectColor == correctImageViewIndex) { imgViewIndexForCorrectColor = random.nextInt(imgViewsArray.length); } int[] txtIds = randomizeValues(otherColorIds); for (int i = 0, txtIndex = 0, imageIndex = 0; i < imgViewsArray.length; ++i) { if (i == correctImageViewIndex) { imgViewsArray[i].setImageDrawable( getResources().getDrawable(COLOR_BACKGROUNDS[otherColorIds[imageIndex++]])); txtViewsArray[i].setText(COLOR_NAMES[correctColorId]); } else { if (i == imgViewIndexForCorrectColor) { imgViewsArray[i].setImageDrawable( getResources().getDrawable(COLOR_BACKGROUNDS[correctColorId])); } else { imgViewsArray[i].setImageDrawable( getResources().getDrawable(COLOR_BACKGROUNDS[otherColorIds[imageIndex++]])); } txtViewsArray[i].setText(COLOR_NAMES[txtIds[txtIndex++]]); } } }
private void setWidgetsCongruent( int[] otherColorsIds, int correctAnswerIndex, int correctColorId) { imgViewCircle.setImageDrawable(getResources().getDrawable(COLOR_BACKGROUNDS[correctColorId])); for (int i = 0, j = 0; i < imgViewsArray.length; ++i) { if (i == correctAnswerIndex) { imgViewsArray[i].setImageDrawable( getResources().getDrawable(COLOR_BACKGROUNDS[correctColorId])); txtViewsArray[i].setText(COLOR_NAMES[correctColorId]); } else { imgViewsArray[i].setImageDrawable( getResources().getDrawable(COLOR_BACKGROUNDS[otherColorsIds[j]])); txtViewsArray[i].setText(COLOR_NAMES[otherColorsIds[j++]]); } } }
public RegisterDialog(Context context) { super(context); View rootView = LayoutInflater.from(context).inflate(R.layout.dialog_register, null); setContentView(rootView); ButterKnife.bind(this); mCodeImage.setScaleType(ImageView.ScaleType.FIT_CENTER); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; getWindow().setAttributes(lp); presenter = new LoginPresenter(); mInputName.addTextChangedListener(new InputTextWatcher(mInputName)); mInputPwd.addTextChangedListener(new InputTextWatcher(mInputPwd)); mInputEmail.addTextChangedListener(new InputTextWatcher(mInputEmail)); mInputCode.addTextChangedListener(new InputTextWatcher(mInputCode)); mRegisterBtn.setOnClickListener(this); }