@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int type = getItemViewType(position); if (type == INSTANT_ANSWER) { Deflection.trackDeflection("show", deflectingType, (BaseModel) getItem(position)); Utils.showModel(context, (BaseModel) getItem(position), deflectingType); } }
protected void onButtonTapped() { if (state == State.INIT) { String query = textField.getText().toString().trim(); if (query.length() == 0) return; state = State.INIT_LOADING; notifyDataSetChanged(); Deflection.setSearchText(query); Article.loadInstantAnswers( query, new DefaultCallback<List<BaseModel>>(context) { @Override public void onModel(List<BaseModel> model) { List<BaseModel> results = model.subList(0, Math.min(model.size(), 3)); Deflection.trackSearchDeflection(results, deflectingType); instantAnswers = model; if (instantAnswers.isEmpty()) state = State.DETAILS; else state = State.INSTANT_ANSWERS; notifyDataSetChanged(); } }); } else if (state == State.INSTANT_ANSWERS) { state = State.DETAILS; notifyDataSetChanged(); } else if (state == State.DETAILS) { String name = nameField.getText().toString(); String email = emailField.getText().toString(); if (email.length() == 0) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.uv_error); builder.setMessage(R.string.uv_msg_user_identity_validation); builder.create().show(); } else { Session.getInstance().persistIdentity(name, email); doSubmit(); } } }