@Override public void onResume() { super.onResume(); setContentView(R.layout.moreventsbybusiness); vctEmails = new ArrayList<String>(); userActBL = new UserAccountBusinessLayer(); friendBL = new FriendsBusinessLayer(); context = this; objDrawableManager = new DrawableManager(); strBusinessName = getIntent().getExtras().getString(BUSINESSNAME); businessId = getIntent().getExtras().getInt(BUSINESSID); objEventBL = new EventsBusinessLayer(); vctEventDetails = new ArrayList<EventsDetails>(); llMoreEvents = (LinearLayout) findViewById(R.id.llMoreEvents); lvMoreEvents = (ListView) findViewById(R.id.lvMoreEvents); lvMoreEvents.setCacheColorHint(0); lvMoreEvents.setScrollbarFadingEnabled(true); vctEventDetails = objEventBL.getEventsByBusiness(businessId); if (vctEventDetails != null) if (vctEventDetails.size() != 0) lvMoreEvents.setAdapter( objCustomMoreEventsAdapter = new CustomMoreEventsAdapter(vctEventDetails)); if (objCustomMoreEventsAdapter != null) objCustomMoreEventsAdapter.refresh(vctEventDetails); TabsActivity.btnBack.setVisibility(View.VISIBLE); TabsActivity.btnLogout.setVisibility(View.INVISIBLE); TabsActivity.tvTitle.setText(getResources().getString(R.string.events_by) + strBusinessName); TabsActivity.rlCommonTitleBar.setBackgroundResource(R.drawable.top_bar_empty); TabsActivity.btnLogout.setVisibility(View.VISIBLE); TabsActivity.rlCommonTitleBar.invalidate(); TabsActivity.btnBack.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { TabGroupActivity pActivity = (TabGroupActivity) MoreEventsByBusiness.this.getParent(); pActivity.finishFromChild(MoreEventsByBusiness.this); } }); TabsActivity.btnLogout.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MoreEventsByBusiness.this, Login.class); startActivity(intent); TabsActivity.tabActivity.finish(); } }); }
public void showFavouritePopup(final int eventId) { LayoutInflater inflater = getLayoutInflater(); LinearLayout popup = (LinearLayout) inflater.inflate(R.layout.category_popup, null); Button btnCompany = (Button) popup.findViewById(R.id.btnCompany); Button btnEvent = (Button) popup.findViewById(R.id.btnEvent); EventsBusinessLayer ebl = new EventsBusinessLayer(); final UserAccountBusinessLayer uabl = new UserAccountBusinessLayer(); TextView dialogText = (TextView) popup.findViewById(R.id.add_favorite_text); if (ebl.isEventAttendedByUser(eventId, AppConstants.USER_ID) && uabl.isBusinessIsInUserFavorites(businessId, AppConstants.USER_ID)) { dialogText.setText(R.string.all_added_to_favorite); } else { dialogText.setText(R.string.add_to_favorite); } if (ebl.isEventAttendedByUser(eventId, AppConstants.USER_ID)) { btnEvent.setVisibility(View.GONE); } if (uabl.isBusinessIsInUserFavorites(businessId, AppConstants.USER_ID)) { btnCompany.setVisibility(View.GONE); } btnCompany.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { int duration = Toast.LENGTH_SHORT; CharSequence text = ""; int status = Ga2ooJsonParsers.getInstance().addBusinessToUser(AppConstants.USER_ID, businessId); if (status > 0) { text = getResources().getString(R.string.company_added_successfully); Business tmpBusiness = new Business(); tmpBusiness.businessid = businessId; tmpBusiness.businessname = " "; tmpBusiness.useraddedbusinessid = 0; tmpBusiness.date_updated = "0"; uabl.InsertUserBusiness(tmpBusiness); Toast toast = Toast.makeText(context, text, duration); toast.show(); } else if (status == 0) { text = getResources().getString(R.string.compamy_already_in_your_favorite); Toast toast = Toast.makeText(context, text, duration); toast.show(); } else if (status == -1) { DialogUtility.showConnectionErrorDialog(MoreEventsByBusiness.this.getParent()); } customDialog.dismiss(); } }); btnEvent.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { customDialog.dismiss(); int duration = Toast.LENGTH_SHORT; CharSequence text = ""; // Ga2ooParsers objGa2ooParsers=new Ga2ooParsers(); // int status=objGa2ooParsers.addEventToUser(AppConstants.USER_ID,eventId); int status = Ga2ooJsonParsers.getInstance().addEventToUser(AppConstants.USER_ID, eventId); if (status > 0) { text = getResources().getString(R.string.event_successfully_added); eventsBL = new EventsBusinessLayer(); eventsBL.addToAttending(eventId, AppConstants.USER_ID); userActBL.insertUserFavorites(AppConstants.USER_ID, eventId, status); Toast toast = Toast.makeText(context, text, duration); toast.show(); } else if (status == 0) { text = getResources().getString(R.string.event_already_in_palendar); Toast toast = Toast.makeText(context, text, duration); toast.show(); } else if (status == -1) { DialogUtility.showConnectionErrorDialog(MoreEventsByBusiness.this.getParent()); } } }); customDialog = new PopUpDailog(getParent(), popup, 220, LayoutParams.WRAP_CONTENT); customDialog.show(); }