@Override protected void onPreExecute() { if (!restaurant.isCompleteDataLoaded()) { progressDialog = ProgressDialog.show(activity, restaurant.getRetaurantName(), "Recuperando informaciĆ³n"); progressDialog.setInverseBackgroundForced(true); } }
private RelativeLayout createAndFillDataMovementLayout(RestaurantDao restaurant, int position) { RelativeLayout relativeMovementLayout = (RelativeLayout) inflater.inflate(R.layout.restaurant_data, null, false); RelativeLayout relativeMovementInfoLayout = (RelativeLayout) relativeMovementLayout.findViewById(R.id.restaurant_data_info_layout); ((TextView) relativeMovementInfoLayout.findViewById(R.id.restaurant_data_name)) .setText(restaurant.getRetaurantName()); ((TextView) relativeMovementInfoLayout.findViewById(R.id.restaurant_data_direction)) .setText(restaurant.getRestaurantDisplayDirection()); String foodType = getFoodType(restaurant); ((TextView) relativeMovementInfoLayout.findViewById(R.id.restaurant_data_type)) .setText(foodType); ((TextView) relativeMovementInfoLayout.findViewById(R.id.restaurant_data_phone)) .setText(restaurant.getPhoneNumber()); LinearLayout buttonsLayout = (LinearLayout) relativeMovementLayout.findViewById(R.id.restaurant_data_apps_layout); buttonsLayout.setId(position); if (wazeInstalled) { ImageButton wazeButton = (ImageButton) buttonsLayout.findViewById(R.id.restaurant_data_waze_image); wazeButton.setVisibility(View.VISIBLE); wazeButton.setOnTouchListener(new TouchElementsListener<ImageButton>()); wazeButton.setOnClickListener(new WazeClickListener(restaurant)); } if (gNavigationInstalled) { ImageButton gNavigationButton = (ImageButton) buttonsLayout.findViewById(R.id.restaurant_data_nav_image); gNavigationButton.setVisibility(View.VISIBLE); gNavigationButton.setOnTouchListener(new TouchElementsListener<ImageButton>()); gNavigationButton.setOnClickListener(new GNavClickListener(restaurant)); } TextView restaurantDataClose = (TextView) relativeMovementInfoLayout.findViewById(R.id.restaurant_data_close); restaurantDataClose.setOnClickListener( new OnClickListener() { public void onClick(View v) { dialog.hide(); dialog.cancel(); } }); ImageButton iButtonMaps = (ImageButton) buttonsLayout.findViewById(R.id.restaurant_data_maps); iButtonMaps.setOnTouchListener(new TouchElementsListener<ImageButton>()); iButtonMaps.setOnClickListener(new GMapsClickListener(restaurant)); return relativeMovementLayout; }
private String getFoodType(RestaurantDao restaurant) { String foodTypeTitle = activity.getResources().getText(R.string.restaurant_data_text_type).toString(); String foodType = restaurant.getFoodType(); if (foodTypeWithoutTitleWithValue(foodTypeTitle, foodType)) { foodType = foodTypeTitle + " " + foodType; } return foodType; }
@Override protected Void doInBackground(Void... params) { TRCardManagerHttpAction httpAction = new TRCardManagerHttpAction(); try { if (!restaurant.isCompleteDataLoaded()) { httpAction.completeResaturantInfo(restaurant); } } catch (IOException e) { error = Boolean.TRUE; Log.e(TAG, "Error loading restaurant info", e); } return null; }
@Override protected void onPostExecute(Void result) { if (progressDialog != null) { progressDialog.cancel(); } if (!error) { restaurant.setCompleteDataLoaded(Boolean.TRUE); } dialog = new AlertDialog.Builder(activity).create(); dialog.setInverseBackgroundForced(true); View view = createAndFillDataMovementLayout(restaurant, position); dialog.setView(view); dialog.show(); dialog.setOnDismissListener( new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { dialog.cancel(); } }); }