Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.swarmerapp.swarmer.PeopleAttendingEventTable.ui;
- import android.app.Activity;
- import android.app.FragmentManager;
- import android.content.ComponentName;
- import android.content.Intent;
- import android.content.pm.LabeledIntent;
- import android.content.pm.PackageManager;
- import android.content.pm.ResolveInfo;
- import android.graphics.Paint;
- import android.net.Uri;
- import android.os.Bundle;
- import android.support.v4.app.ShareCompat;
- import android.support.v4.content.ContextCompat;
- import android.support.v4.view.ViewPager;
- import android.support.v4.widget.NestedScrollView;
- import android.support.v4.widget.SwipeRefreshLayout;
- import android.support.v7.app.AppCompatActivity;
- import android.text.Html;
- import android.view.View;
- import android.view.animation.AnimationUtils;
- import android.webkit.WebView;
- import android.widget.Button;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.RelativeLayout;
- import android.widget.TableLayout;
- import android.widget.TableRow;
- import android.widget.TextView;
- import android.widget.Toast;
- import com.google.android.gms.maps.GoogleMap;
- import com.google.android.gms.maps.OnMapReadyCallback;
- import com.google.android.gms.maps.SupportMapFragment;
- import com.google.android.gms.maps.model.LatLng;
- import com.google.gson.Gson;
- import com.squareup.picasso.Picasso;
- import com.swarmerapp.swarmer.App;
- import com.swarmerapp.swarmer.BookTableActivity;
- import com.swarmerapp.swarmer.BookedEventDetailsActivity;
- import com.swarmerapp.swarmer.BookingConfirmationActivity;
- import com.swarmerapp.swarmer.ImagesPreviewPagerActivity;
- import com.swarmerapp.swarmer.LocationDisplayActivity;
- import com.swarmerapp.swarmer.PeopleAttendingEventTable.PeopleAttendingEventTableContract;
- import com.swarmerapp.swarmer.PeopleAttendingEventTable.PeopleAttendingEventTablePresenter;
- import com.swarmerapp.swarmer.VideoActivity;
- import com.swarmerapp.swarmer.R;
- import com.swarmerapp.swarmer.activityFeed.presenter.StickyResponseOnRequest;
- import com.swarmerapp.swarmer.createTable.ListOfPeopleAttending;
- import com.swarmerapp.swarmer.createTable.VenueInfo;
- import java.io.Serializable;
- import java.lang.ref.WeakReference;
- import java.text.DecimalFormat;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Calendar;
- import java.util.Collections;
- import java.util.Date;
- import java.util.HashSet;
- import java.util.List;
- import java.util.Objects;
- import java.util.Set;
- import java.util.TimeZone;
- import adapters.RequestsRecyclerViewAdapter;
- import adapters.UserGalleryAdapter;
- import butterknife.BindView;
- import butterknife.ButterKnife;
- import butterknife.OnClick;
- import customViews.AcceptDenyBottomView;
- import customViews.MultiSwipeRefreshLayout;
- import customViews.PeopleTableSeatView;
- import de.greenrobot.event.EventBus;
- import io.reactivex.SingleObserver;
- import io.reactivex.android.schedulers.AndroidSchedulers;
- import io.reactivex.disposables.Disposable;
- import io.reactivex.schedulers.Schedulers;
- import com.swarmerapp.swarmer.login.ui.LoginDialog;
- import com.trekeye.swarmer_sdk_library.modules.AppUser;
- import models.Booking;
- import models.BookingInnerItem;
- import com.trekeye.swarmer_sdk_library.modules.Event;
- import models.Receipt;
- import models.Recipient;
- import com.trekeye.swarmer_sdk_library.modules.Table;
- import com.trekeye.swarmer_sdk_library.modules.TableSeat;
- import models.busEvents.connectionEvents.Errors.ErrorServerResponse;
- import models.busEvents.connectionEvents.Errors.ErrorWatchTable;
- import models.busEvents.connectionEvents.RequestBookedTable;
- import models.busEvents.connectionEvents.RequestCheckTableWatched;
- import models.busEvents.connectionEvents.RequestInviteOnTableResponse;
- import models.busEvents.connectionEvents.RequestResponseOnTableInvitation;
- import models.busEvents.connectionEvents.RequestSocialiteTableBooking;
- import models.busEvents.connectionEvents.RequestSocialiteTableRequestConfirmation;
- import models.busEvents.connectionEvents.RequestUnwatchTable;
- import models.busEvents.connectionEvents.RequestWatchTable;
- import models.busEvents.connectionEvents.connectionResponse.ResponseCheckWatched;
- import models.busEvents.connectionEvents.connectionResponse.ResponseInviteOnTableConfirmation;
- import models.busEvents.connectionEvents.connectionResponse.ResponseOnSocialiteTableRequest;
- import models.busEvents.connectionEvents.connectionResponse.ResponseWatchTable;
- import services.RxMessagingService;
- import services.RxNetworkLayer;
- import com.trekeye.swarmer_sdk_library.utils.AppConstants;
- import com.trekeye.swarmer_sdk_library.utils.BaseUtils;
- import utils.Common;
- import utils.GeoUtils;
- import utils.GsonFactory;
- import utils.PageIndicator;
- import utils.SwipeRefreshLayoutOptions;
- import utils.Utils;
- import utils.bus_events.TableInvitationTempHolder;
- import utils.bus_events.TableRequestsWrapper;
- /**
- * Created by Blagoj Bojcevski on 8/15/2017.
- */
- public class PeopleAttendingActivity extends AppCompatActivity implements PeopleAttendingEventTableContract.PeopleAttendingEventTableView, SwipeRefreshLayout.OnRefreshListener,Serializable, OnMapReadyCallback , PeopleTableSeatView.PeopleTableSeatActionListener{
- private String eventId;
- private String tableId = null;
- private Table table;
- private String userType;
- private GoogleMap googleMap;
- private PeopleAttendingEventTablePresenter presenter;
- private UserGalleryAdapter eventPhotosAdapter;
- private ViewPager imagesPager;
- private ImageView venuePhoto;
- private static final int REQ_CODE_BOOK = 1;
- private static final int CONFIRM_BOOKING = 1153;
- private static final int BOOKED_EVENT_DETAILS = 1154;
- private final RxNetworkLayer rxNetwork = Common.getInstance().getRxNetworkLayer();
- @BindView(R.id.swipeRefresh)
- MultiSwipeRefreshLayout mSwipeRefreshLayout;
- @BindView(R.id.noContent)
- View noContent;
- @BindView(R.id.scrlMainContainer)
- NestedScrollView scrlMainContainer;
- @BindView(R.id.join_table_name)
- TextView tvTableName;
- @BindView(R.id.people_attending_info_dress_code_label)
- View txtDressCode;
- @BindView(R.id.people_attending_bottle_allocation)
- TextView txtBottleAllocation;
- @BindView(R.id.people_attending_need_to_know)
- TextView txtNeedToKnow;
- @BindView(R.id.people_attending_bottle_allocation_label)
- View txtBottleAllocationLabel;
- @BindView(R.id.join_table_event_name)
- TextView txtEventName;
- @BindView(R.id.join_table_event_date)
- TextView txtEventDate;
- @BindView(R.id.join_table_details_table_type)
- TextView txtEventTableType;
- @BindView(R.id.people_attending_details_price)
- TextView txtEventSeatPrice;
- @BindView(R.id.joint_table_details_rseats)
- TextView txtEventRemainigSeats;
- @BindView(R.id.join_table_info_event_name)
- TextView tvInfoEventName;
- @BindView(R.id.join_table_info_venue_name)
- TextView tvInfoVenueName;
- @BindView(R.id.join_table_info_street)
- TextView tvInfoStreet;
- @BindView(R.id.join_table_info_city_state)
- TextView tvInfoStateZip;
- @BindView(R.id.people_attending_info_dress_code)
- TextView tvInfoDressCode;
- @BindView(R.id.people_attending_need_to_know_label)
- TextView tvNeedToKnow;
- @BindView(R.id.event_time)
- TextView eventTime;
- @BindView(R.id.join_table_info_event_description_label)
- View txtEventDescriptionLabel;
- @BindView(R.id.join_table_info_event_description)
- TextView txtEventDescription;
- @BindView(R.id.join_table_info_important_info)
- TextView txtImportantInfo;
- @BindView(R.id.join_table_important_info)
- TextView txtImportantEventInfo;
- @BindView(R.id.event_pictures_page_indicator)
- PageIndicator eventsPicturesPageIndicator;
- @BindView(R.id.accept_deny_view)
- AcceptDenyBottomView acceptDenyView;
- @BindView(R.id.tblFemaleGuests)
- TableLayout tblFemaleGuests;
- @BindView(R.id.imageBottleAllocation)
- ImageView imageBottleAllocation;
- @BindView(R.id.imageWhatToWear)
- ImageView imageWhatToWear;
- @BindView(R.id.imageImpInfo)
- ImageView imageImpInfo;
- @BindView(R.id.imageEventDesciption)
- ImageView imageEventDesciption;
- @BindView(R.id.imageneed_to_know)
- ImageView imageneedToKnow;
- @BindView(R.id.watch_table_btn)
- ImageView btnWatchTable;
- @BindView(R.id.joint_table_join_btn)
- Button btnJoinNow;
- @BindView(R.id.join_table_num_of_socialites)
- TextView txtNumOfSocialites;
- @BindView(R.id.not_seats_left)
- TextView notSeatsLeftTv;
- @BindView(R.id.descriton_table)
- LinearLayout descritonTable;
- @BindView(R.id.showMore)
- TextView showmore;
- @BindView(R.id.ll_transparent1)
- View line1;
- @BindView(R.id.ll_transparent2)
- View line2;
- private Event event;
- private List<TableSeat> getSeats;
- private TableRequestsWrapper tempWrapper;
- private String eventOrTableType;
- private boolean socialitesJoined = false;
- private Gson gson;
- private final static int NUMBER_OF_ICONS_IN_ROW = 4;
- private int numSwarmerSeatsTaken, numSocialiteSeatsTaken;
- private boolean isWatched = false;
- private ImageView videoView;
- private ImageView playButton;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.people_attending);
- ButterKnife.bind(this);
- uiRef();
- eventId = getIntent().getStringExtra("eventId");
- Intent intent = getIntent();
- String action = intent.getAction();
- Uri data = intent.getData();
- if(data!=null){
- String link = data.toString();
- String [] parsed = link.split("/");
- eventId = parsed[4];
- tableId = parsed[6];
- }
- userType = Common.getInstance().getPref().getUserType();
- presenter = new PeopleAttendingEventTablePresenter(this, this);
- presenter.getEvent(eventId);
- venuePhoto = findViewById(R.id.join_table_venue_info_image);
- tempWrapper = GsonFactory.getInstance().fromJson(getIntent().getExtras().getString("wrapper"), TableRequestsWrapper.class);
- userType = Common.getInstance().getPref().getUserType();
- gson = new Gson();
- if (userType != null) {
- if (userType.equals(getResources().getString(R.string.u_type_socialite))) {
- socialitesJoined = true;
- }
- }
- }
- private void uiRef(){
- mSwipeRefreshLayout.setSwipeableChildren(R.id.join_table_photos);
- imagesPager = findViewById(R.id.join_table_photos);
- videoView = findViewById(R.id.join_table_video);
- playButton = findViewById(R.id.play_button);
- mSwipeRefreshLayout.setOnRefreshListener(this);
- SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.join_table_map_view);
- mapFragment.getMapAsync(this);
- }
- private void showContent() {
- hideNoContent();
- btnJoinNow.setVisibility(View.VISIBLE);
- scrlMainContainer.setVisibility(View.VISIBLE);
- }
- @Override
- public void onItemClick(int pos, String uri) {
- Intent i = new Intent(PeopleAttendingActivity.this, ImagesPreviewPagerActivity.class);
- i.putExtra("images", getImagesFromEvent(event));
- i.putExtra("position", pos);
- startActivity(i);
- }
- private void fillSeats() {
- tblFemaleGuests.removeAllViews();
- final List<String> socialiteSeats = new ArrayList<>();
- final List<String> swarmerSeats = new ArrayList<>();
- for (TableSeat ts : table.getSeats()) {
- if(ts.getUserType().equals(getResources().getString(R.string.u_type_swarmer)))
- swarmerSeats.add(ts.getFacebookId());
- else
- socialiteSeats.add(ts.getFacebookId());
- }
- final Set<TableSeat> tempSocialiteSeats = new HashSet<>();
- final Set<TableSeat> tempswarmerSeats = new HashSet<>();
- for (TableSeat ts : table.getSeats()) {
- ts.setSwarmerSeats(numSwarmerSeatsTaken);
- ts.setSocialiteSeats(numSocialiteSeatsTaken);
- ts.setPeopleSeats(table.getPeopleSeats());
- ts.setSwarmerSeats(table.getSwarmerSeats());
- ts.setSocialiteSeats(table.getSocialiteSeats());
- int occurrences = 0;
- if(ts.getUserType().equals(getResources().getString(R.string.u_type_swarmer))) {
- occurrences = Collections.frequency(swarmerSeats, ts.getFacebookId());
- ts.setNumberOfReservedSeats(occurrences);
- tempswarmerSeats.add(ts);
- }else {
- occurrences = Collections.frequency(socialiteSeats, ts.getFacebookId());
- ts.setNumberOfReservedSeats(occurrences);
- tempSocialiteSeats.add(ts);
- }
- }
- getSeats = new ArrayList<>(tempSocialiteSeats);
- getSeats.addAll(tempswarmerSeats);
- int chunkEnd = NUMBER_OF_ICONS_IN_ROW;
- TableRow row = new TableRow(this);
- for (int j = 0; j < chunkEnd; j++) {
- PeopleTableSeatView seatView = new PeopleTableSeatView(getApplicationContext());
- seatView.setActionListener(this);
- if (j > getSeats.size() - 1) {
- break;
- }else {
- final TableSeat seat = getSeats.get(j);
- seatView.setModel(seat);
- row.addView(seatView);
- }
- }
- int num = chunkEnd-getSeats.size();
- if (getSeats.size() < 4) {
- for (int c = 0; c < num; c++) {
- PeopleTableSeatView t2 = new PeopleTableSeatView(getApplicationContext());
- t2.setEmptySeat();
- row.addView(t2);
- }
- }
- tblFemaleGuests.addView(row);
- }
- private void hideNoContent() {
- noContent.setVisibility(View.GONE);
- }
- /**
- * Function that returns the desired suffix for a given day of month
- *
- * @param day
- * @return the correct suffix
- */
- private String getSuffixForDay(int day) {
- if (day >= 1 && day <= 31) {
- if (day >= 11 && day <= 13) {
- return "th";
- }
- switch (day % 10) {
- case 1:
- return "st";
- case 2:
- return "nd";
- case 3:
- return "rd";
- default:
- return "th";
- }
- } else {
- return "";
- }
- }
- private void initMap(GoogleMap googleMap) {
- boolean mapSuccess = GeoUtils.displayVenueLocationOnMap(event, googleMap, new OnMapClickListener(this));
- }
- @Override
- public void onMapReady(GoogleMap googleMap) {
- this.googleMap = googleMap;
- }
- @Override
- public void displayError(String err) {
- Toast.makeText(this, err, Toast.LENGTH_SHORT).show();
- }
- @OnClick(R.id.showMore)
- public void setShowmore() {
- RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
- params.setMargins(0, 10, 0, 0);
- descritonTable.setLayoutParams(params);
- line1.setVisibility(View.GONE);
- line2.setVisibility(View.GONE);
- showmore.setVisibility(View.GONE);
- }
- @OnClick(R.id.see_all_people_btn)
- public void submit() {
- if (!Common.getInstance().getPref().getToken().equals(""))
- {
- if(table != null){
- Intent intent = new Intent(PeopleAttendingActivity.this, ListOfPeopleAttending.class);
- intent.putExtra("list", (Serializable) getSeats);
- if(table.isGenderNeutral()){
- intent.putExtra("genderNeutral", table.isGenderNeutral());
- intent.putExtra("peopleSeats", table.getPeopleSeats());
- startActivity(intent);
- }else {
- intent.putExtra("genderNeutral", table.isGenderNeutral());
- intent.putExtra("peopleSeats", table.getSwarmerSeats());
- intent.putExtra("numberOfSocialiteSeatsLeft", table.getSocialiteSeats());
- startActivity(intent);
- }
- }
- }else
- {
- FragmentManager fm = getFragmentManager();
- LoginDialog dialog = new LoginDialog();
- dialog.setRetainInstance(true);
- dialog.show(fm, "loginDialog");
- }
- }
- @OnClick(R.id.join_table_info_venue_name)
- public void info() {
- Intent i = new Intent(PeopleAttendingActivity.this, VenueInfo.class);
- i.putExtra("venueId", event.getVenueId());
- startActivity(i);
- }
- @OnClick(R.id.backBtn)
- public void onBackClick(){
- finish();
- }
- @OnClick(R.id.share_btn)
- public void onShareClick(){
- openEmailApp();
- }
- @OnClick(R.id.joint_table_join_btn)
- public void joinBt(){
- if (!Common.getInstance().getPref().getToken().equals(""))
- {
- joinTable();
- }else
- {
- android.app.FragmentManager fm = getFragmentManager();
- LoginDialog dialog = new LoginDialog();
- dialog.setRetainInstance(true);
- dialog.show(fm, "loginDialog");
- }
- }
- @Override
- public void openTableDetails(Event res) {
- mSwipeRefreshLayout.post(new SwipeRefreshLayoutOptions(new WeakReference<SwipeRefreshLayout>(mSwipeRefreshLayout), false));
- showContent();
- if(tableId==null){
- tableId = getIntent().getStringExtra("tableId");
- }
- event = res;
- if (event != null) {
- for (Table t : event.getTables()) {
- if (t.getId().equals(tableId)) {
- table = t;
- }
- }
- if (table != null) {
- if(table.getType() != null && table.getType().length() > 0){
- eventOrTableType = table.getType();
- }else{
- eventOrTableType = event.getType();
- }
- DecimalFormat decimalFormatter = new DecimalFormat("0.#");
- if (userType.equals(getResources().getString(R.string.u_type_swarmer))) {
- txtEventSeatPrice.setText("$" + decimalFormatter.format(table.getSwarmerSeatPrice()));
- } else {
- txtEventSeatPrice.setText("$" + decimalFormatter.format(table.getSocialiteSeatPrice()));
- }
- if (event.getDescription() != null && !"".equals(event.getDescription())) {
- String [] parsedDescription = event.getDescription().split("\\r?\\n");
- String bulletDescription = "";
- String circle = "\u25CF";
- for (int i = 0; i < parsedDescription.length; i++) {
- bulletDescription = circle + " " + parsedDescription[i] + "\n";
- }
- txtEventDescription.setText(bulletDescription);
- } else {
- txtEventDescription.setVisibility(View.GONE);
- txtEventDescriptionLabel.setVisibility(View.GONE);
- imageEventDesciption.setVisibility(View.GONE);
- }
- if (event.getImportantInfo() != null && !"".equals(event.getImportantInfo())) {
- txtImportantInfo.setText(event.getImportantInfo());
- } else {
- txtImportantInfo.setVisibility(View.GONE);
- txtImportantEventInfo.setVisibility(View.GONE);
- imageImpInfo.setVisibility(View.GONE);
- }
- if (table.getLocation() != null) {
- tvTableName.setText(table.getLocation());
- txtEventTableType.setText(table.getLocation());
- }
- if (userType.equals(getResources().getString(R.string.u_type_socialite))) {
- txtEventRemainigSeats.setText(String.format("%d seats remaning", (table.getSocialiteSeatsLeft())));
- } else {
- txtEventRemainigSeats.setText(String.format("%d seats remaning", (table.getSwarmerSeatsLeft())));
- }
- txtEventName.setText(event.getName());
- tblFemaleGuests = findViewById(R.id.tblFemaleGuests);
- tvInfoVenueName.setPaintFlags(tvInfoVenueName.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEEE, MMMM d");
- simpleDateFormat.setTimeZone(TimeZone.getTimeZone(event.getVenueTimezone()));
- Date tmp = null;
- try {
- tmp = BaseUtils.getDateWithSpecificTimeZone(event.getOpen(), event.getVenueTimezone());
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- Calendar c = Calendar.getInstance();
- c.setTime(tmp);
- String formattedDate = simpleDateFormat.format(tmp);
- formattedDate += getSuffixForDay(c.get(Calendar.DAY_OF_MONTH));
- txtEventDate.setText(formattedDate);
- if (event.getVenueArea() != null) {
- tvInfoEventName.setText(event.getVenueArea().toUpperCase());
- }
- if (event.getVenueName() != null) {
- tvInfoVenueName.setText(event.getVenueName().toUpperCase());
- }
- if (event.getVenueLine1() != null) {
- tvInfoStreet.setText(event.getVenueLine1());
- }
- if (event.getOpen() != null) {
- //Date d = BaseUtils.getDateWithSpecificTimeZone(event.getOpen(), event.getVenueTimezone());
- eventTime.setText("Event Start Time : " + Utils.formatEventTime(event.getOpen(), event.getVenueTimezone()));
- }
- if (event.getVenueState() != null && event.getVenueCity() != null && event.getVenueZip() != null) {
- String s = event.getVenueLine1() + ", " + event.getVenueCity() + ", " + event.getVenueState() + ", " + event.getVenueZip();
- tvInfoStateZip.setText(s);
- }
- if (event.getDressCode() != null && !"".equals(event.getDressCode())) {
- tvInfoDressCode.setText(event.getDressCode());
- } else {
- txtDressCode.setVisibility(View.GONE);
- tvInfoDressCode.setVisibility(View.GONE);
- imageWhatToWear.setVisibility(View.GONE);
- }
- if (event.getVenueNeedToKnow() != null && !"".equals(event.getVenueNeedToKnow())) {
- txtNeedToKnow.setText(event.getVenueNeedToKnow());
- } else {
- txtNeedToKnow.setVisibility(View.GONE);
- tvNeedToKnow.setVisibility(View.GONE);
- imageneedToKnow.setVisibility(View.GONE);
- }
- if (table != null && table.getRefundPolicy() != null && !"".equals(table.getRefundPolicy())) {
- txtBottleAllocation.setText(table.getRefundPolicy());
- } else {
- txtBottleAllocation.setVisibility(View.GONE);
- txtBottleAllocationLabel.setVisibility(View.GONE);
- imageBottleAllocation.setVisibility(View.GONE);
- }
- numSwarmerSeatsTaken = table.getSwarmerSeats() - table.getSwarmerSeatsLeft();
- numSocialiteSeatsTaken = table.getSocialiteSeats() - table.getSocialiteSeatsLeft();
- int numGenderNeutralSeatsTaken = table.getPeopleSeats() - table.getPeopleSeatsLeft();
- if(table.isGenderNeutral()){
- txtNumOfSocialites.setText(String.format("%d/%d", numGenderNeutralSeatsTaken, table.getPeopleSeats()));
- if(numGenderNeutralSeatsTaken ==table.getPeopleSeats()){
- notSeatsLeftTv.setVisibility(View.VISIBLE);
- notSeatsLeftTv.setText(getResources().getString(R.string.no_more_seats_left).toUpperCase());
- }
- }else {
- int numOfAllPeopleSeats = numSwarmerSeatsTaken + numSocialiteSeatsTaken;
- txtNumOfSocialites.setText(String.format("%d/%d", numOfAllPeopleSeats, table.getSocialiteSeats()+table.getSwarmerSeats()));
- if(userType.equals(getResources().getString(R.string.u_type_swarmer)) && table.getSwarmerSeatsLeft() == 0){
- notSeatsLeftTv.setVisibility(View.VISIBLE);
- notSeatsLeftTv.setText(getResources().getString(R.string.table_closed_for_gentlemens).toUpperCase());
- } else if(userType.equals(getResources().getString(R.string.u_type_socialite)) && table.getSocialiteSeatsLeft() == 0){
- notSeatsLeftTv.setVisibility(View.VISIBLE);
- notSeatsLeftTv.setText(getResources().getString(R.string.table_closed_for_ladies).toUpperCase());
- }
- }
- if (event.getPhotos() != null || event.getVideos() != null) {
- eventPhotosAdapter = new UserGalleryAdapter(this, getImagesFromEvent(event), (pos, uri) -> {
- Intent i = new Intent(PeopleAttendingActivity.this, ImagesPreviewPagerActivity.class);
- i.putExtra("images", getImagesFromEvent(event));
- i.putExtra("position", pos);
- startActivity(i);
- });
- imagesPager.setAdapter(eventPhotosAdapter);
- if(event.getPhotos().size() > 1){
- eventsPicturesPageIndicator.setViewPager(imagesPager);
- }
- }
- imagesPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- if(position >= event.getVideos().size()){
- videoView.setVisibility(View.INVISIBLE);
- playButton.setVisibility(View.INVISIBLE);
- }else {
- playButton.setVisibility(View.VISIBLE);
- playButton.setBackground(null);
- videoView.setVisibility(View.VISIBLE);
- if(!Objects.equals(event.getVideos().get(position).getThumbnailUrl(), ""))
- Picasso.with(getApplicationContext()).load(event.getVideos().get(position).getThumbnailUrl()).fit().centerCrop().into(videoView);
- }
- playButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent i = new Intent(PeopleAttendingActivity.this, VideoActivity.class);
- i.putExtra("video", event.getVideos().get(position).getUrl());
- startActivity(i);
- }
- });
- }
- @Override
- public void onPageSelected(int position) {
- }
- @Override
- public void onPageScrollStateChanged(int state) {
- }
- });
- if (tempWrapper != null) {
- btnJoinNow.setVisibility(View.GONE);
- acceptDenyView.setVisibility(View.VISIBLE);
- acceptDenyView.setOnActionListener(new PeopleAttendingActivity.AcceptDenyTableInvitationListener(this));
- if(AcceptDenyBottomView.ACCEPTDENYSCREEN.equals("GONE")){
- checkAcceptDenyScreen();
- }
- }else{
- acceptDenyView.setVisibility(View.GONE);
- btnJoinNow.setVisibility(View.VISIBLE);
- }
- if (event.getVenuePhotoUrl() != null) {
- Picasso.with(this).load(event.getVenuePhotoUrl()).fit().centerCrop().into(venuePhoto);
- }
- fillSeats();
- updateJoinTableButton();
- EventBus.getDefault().post(new RequestCheckTableWatched(table.getEventId(), table.getId()));
- initMap(googleMap);
- if(txtImportantInfo.getVisibility()==View.GONE && txtEventDescription.getVisibility()==View.GONE && txtDressCode.getVisibility()==View.GONE && txtBottleAllocationLabel.getVisibility()==View.GONE){
- showmore.setVisibility(View.GONE);
- descritonTable.setVisibility(View.GONE);
- }
- }
- }
- }
- @OnClick(R.id.watch_table_btn)
- public void setBtnWatchTable() {
- if (isWatched) {
- EventBus.getDefault().post(new RequestUnwatchTable(table.getId()));
- btnWatchTable.setSelected(false);
- isWatched=false;
- } else {
- EventBus.getDefault().post(new RequestWatchTable(table.getEventId(), table.getId()));
- btnWatchTable.setSelected(true);
- isWatched=true;
- }
- }
- public void onEventMainThread(ResponseCheckWatched res) {
- isWatched = res.isWatched();
- btnWatchTable.setSelected(isWatched);
- btnWatchTable.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
- }
- public void onEventMainThread(ResponseWatchTable res) {
- Toast.makeText(this, isWatched ? "Event added to Favourites" : "Event removed from Favourites", Toast.LENGTH_SHORT).show();
- isWatched = res.isWatched();
- btnWatchTable.setSelected(isWatched);
- btnWatchTable.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
- }
- public void onEventMainThread(ErrorWatchTable error) {
- Toast.makeText(this, "Error happened, Try again", Toast.LENGTH_SHORT).show();
- btnWatchTable.setSelected(isWatched);
- btnWatchTable.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
- }
- private void checkAcceptDenyScreen(){
- acceptDenyView.setVisibility(View.GONE);
- btnJoinNow.setVisibility(View.VISIBLE);
- }
- private String[] getImagesFromEvent(Event event) {
- final String[] imgVideoUris = new String[event.getPhotos().size()+event.getVideos().size()];
- int index = event.getVideos().size();
- for (int i = 0; i < event.getVideos().size(); i++) {
- if(!event.getVideos().get(i).getUrl().equals(AppConstants.EMPTY_VIDEO)){
- imgVideoUris[i] = event.getVideos().get(i).getUrl();
- }
- }
- for (int i = 0; i < event.getPhotos().size(); i++) {
- if(!event.getPhotos().get(i).getUrl().equals(AppConstants.EMPTY_IMAGE)){
- imgVideoUris[i+index] = event.getPhotos().get(i).getUrl();
- }
- }
- return imgVideoUris;
- }
- @Override
- public void onPeopleTableEmptySeatClick() {
- }
- @Override
- public void onSeatClick(TableSeat seat) {
- if (Common.getInstance().getPref().getToken().equals(""))
- {
- android.app.FragmentManager fm = getFragmentManager();
- LoginDialog dialog = new LoginDialog();
- dialog.setRetainInstance(true);
- dialog.show(fm, "loginDialog");
- }else{
- Intent intent = new Intent(this, com.swarmerapp.swarmer.userProfile.ui.UserProfileActivity.class);
- intent.putExtra("facebookId", seat.getFacebookId());
- startActivity(intent);
- }
- }
- private void updateJoinTableButton(/*Event event, Table table*/) {
- if (event == null || table == null) {
- return;
- }
- btnJoinNow.setEnabled(true);
- String closed = "";
- if (table.getLabelType() != null) {
- switch (table.getLabelType()) {
- case Table.LABEL_TYPE_TABLE:
- closed = getResources().getString(R.string.table_closed_t).toLowerCase();
- break;
- case Table.LABEL_TYPE_STANDARD:
- closed = getResources().getString(R.string.sold_out).toLowerCase();
- break;
- case Table.LABEL_TYPE_PACKAGE:
- closed = getResources().getString(R.string.sold_out).toLowerCase();
- break;
- }
- }else{
- closed = getResources().getString(R.string.table_closed_t);
- }
- int sNumOfSeats = 0;
- int numOfGenderNeutralSeats = table.getPeopleSeatsLeft();
- boolean isEventPassed = Utils.checkIfEventIsPassed(event.getClose());
- if (table.isGenderNeutral()){
- sNumOfSeats = numOfGenderNeutralSeats;
- } else {
- if (Common.getInstance().getPref().getUserType().equals(getResources().getString(R.string.u_type_swarmer))) {
- sNumOfSeats = table.getSwarmerSeatsLeft();
- } else {
- sNumOfSeats = table.getSocialiteSeatsLeft();
- }
- }
- if (sNumOfSeats != 0 && !isEventPassed ) {
- if(userType.equals(getResources().getString(R.string.u_type_socialite))){
- if(isUserAlreadyOnTable(table)){
- if(table.getSocialiteSeatPrice() > 0){
- if (eventOrTableType.equals(Event.EVENT_TYPE_OPEN)){
- btnJoinNow.setText( getString(R.string.purchase_additional_seats));
- btnJoinNow.setBackgroundColor(ContextCompat.getColor(this, R.color.light_green_pressed));
- }
- } else {
- btnJoinNow.setText(getResources().getString(R.string.invite_friends).toUpperCase());
- }
- }else{
- if(eventOrTableType.equals(Event.EVENT_TYPE_INVITE)){
- btnJoinNow.setText(getResources().getString(R.string.request_to_join).toUpperCase());
- } else if (eventOrTableType.equals(Event.EVENT_TYPE_OPEN)){
- String txt = "";
- if(table.getSocialiteSeatPrice() > 0){
- txt = getResources().getString(R.string.join_event).toUpperCase() + " | " + String.valueOf(Utils.formatAmountWithComma(table.getSocialiteSeatPrice()));
- }else{
- txt = getResources().getString(R.string.join_event).toUpperCase();
- }
- if(table.getLabelType().equals(Table.LABEL_TYPE_PACKAGE)){
- txt = getResources().getString(R.string.purchase);
- } else if(table.getLabelType().equals(Table.LABEL_TYPE_TABLE)){
- txt = getResources().getString(R.string.join_table_btn).toUpperCase() + " | " + String.valueOf(Utils.formatAmountWithComma(table.getSocialiteSeatPrice()));
- txt = table.getSocialiteSeatPrice()==0 ? getString(R.string.join_table_btn).toUpperCase() : txt;
- }
- btnJoinNow.setText(txt);
- }
- }
- }else{
- String txt;
- switch (table.getLabelType()) {
- case Table.LABEL_TYPE_PACKAGE:
- txt = getResources().getString(R.string.purchase);
- btnJoinNow.setText(isUserAlreadyOnTable(table) ? getString(R.string.invite_friends) : txt);
- break;
- case Table.LABEL_TYPE_TABLE:
- txt = getResources().getString(R.string.join_table_btn).toUpperCase() + " | " + String.valueOf(Utils.formatAmountWithComma(table.getSwarmerSeatPrice()));
- // btnJoinNow.setText(isUserAlreadyOnTable(table) ? getString(R.string.purchase_additional_seats) : table.getSwarmerSeatPrice()==0 ? getString(R.string.join_table_btn).toUpperCase() : txt);
- if (isUserAlreadyOnTable(table)) {
- isFreeTable();
- } else {
- if (table.getSwarmerSeatPrice() == 0) {
- btnJoinNow.setText(getString(R.string.join_table_btn).toUpperCase());
- } else {
- btnJoinNow.setText(txt);
- }
- }
- break;
- default:
- txt = getResources().getString(R.string.join_event).toUpperCase() + " | " + String.valueOf(Utils.formatAmountWithComma(table.getSwarmerSeatPrice()));
- if (isUserAlreadyOnTable(table)) {
- isFreeTable();
- } else {
- btnJoinNow.setText(txt);
- }
- break;
- }
- btnJoinNow.setBackgroundColor(ContextCompat.getColor(this, R.color.light_green_pressed));
- }
- } else {
- if(isEventPassed){
- btnJoinNow.setText(getResources().getString(R.string.event_expired));
- }else {
- btnJoinNow.setText(closed);
- }
- btnJoinNow.setBackgroundColor(getResources().getColor(R.color.material_red));
- btnJoinNow.setEnabled(false);
- }
- }
- private void isFreeTable(){
- if(isUserAlreadyOnTable(table) && table.getSwarmerSeatPrice()==0){
- btnJoinNow.setText(getString(R.string.invite_friends));
- }else {
- btnJoinNow.setText(getString(R.string.purchase_additional_seats));
- if(table.getLabelType().equals(Table.LABEL_TYPE_STANDARD)){
- btnJoinNow.setText(getString(R.string.purchase_additional_tickets));
- }
- }
- }
- private boolean isUserAlreadyOnTable(Table t) {
- for (TableSeat seat : t.getSeats()) {
- if (seat.getFacebookId().equals(Common.getInstance().getPref().getSocialId())) {
- return true;
- }
- }
- return false;
- }
- private static class OnMapClickListener implements GoogleMap.OnMapClickListener {
- final WeakReference<PeopleAttendingActivity> peopleAttendingActivityWeakReference;
- OnMapClickListener(PeopleAttendingActivity activity) {
- peopleAttendingActivityWeakReference = new WeakReference<>(activity);
- }
- @Override
- public void onMapClick(LatLng latLng) {
- PeopleAttendingActivity activity = peopleAttendingActivityWeakReference.get();
- if (activity != null) {
- final double lat = activity.event.getVenueGeoLocation().getCoordinates()[1];
- final double lon = activity.event.getVenueGeoLocation().getCoordinates()[0];
- Intent i = new Intent(activity, LocationDisplayActivity.class);
- i.putExtra("lon", lon);
- i.putExtra("lat", lat);
- i.putExtra("venueName", activity.event.getVenueName());
- activity.startActivity(i);
- }
- }
- }
- private void joinTable(){
- Intent intent = new Intent(this, BookTableActivity.class);
- String txt = (String) btnJoinNow.getText();
- int price = (int) table.getSocialiteSeatPrice();
- if (socialitesJoined && !table.isGenderNeutral()) {
- if (table.getSocialiteSeatsLeft() > 0) {
- if ((eventOrTableType.equals(Event.EVENT_TYPE_OPEN) && price > 0 ) && txt.equals(R.string.join_table_btn)) {
- Bundle b = new Bundle();
- b.putString("table", gson.toJson(table));
- b.putString("Event", gson.toJson(event));
- b.putInt(BookTableActivity.INTENT_SEATS_LEFT, table.getSocialiteSeatsLeft());
- intent.putExtras(b);
- startActivityForResult(intent, REQ_CODE_BOOK);
- } else {
- if (isUserAlreadyOnTable(table)|| txt.equals(R.string.invite_friends)) {
- if (table.getSeats().size() > 0) {
- openEmailApp();
- } else {
- Toast.makeText(this, "There is no swarmers present on this table to approve your request!", Toast.LENGTH_SHORT).show();
- }
- } else {
- if (table.getSeats().size() > 0 ) {
- if (table.getSocialiteSeatsLeft() > 0 && price == 0) {
- navigateToBookingConfirmation();
- } else {
- onRequestToJoin(event.getId(), table.getId());
- }
- } else {
- Toast.makeText(this, "There is no swarmers present on this table to approve your request!", Toast.LENGTH_SHORT).show();
- }
- }
- }
- }else{
- Toast.makeText(PeopleAttendingActivity.this, "There are no seats left to join.", Toast.LENGTH_SHORT).show();
- }
- } else if (table.isGenderNeutral()){
- if (table.getPeopleSeatsLeft() > 0 && table.getSwarmerSeatPrice() != 0 && table.getSocialiteSeatPrice() != 0) {
- Bundle b = new Bundle();
- b.putString("table", gson.toJson(table));
- b.putString("Event", gson.toJson(event));
- b.putInt(BookTableActivity.INTENT_SEATS_LEFT, table.getPeopleSeatsLeft());
- intent.putExtras(b);
- startActivityForResult(intent, REQ_CODE_BOOK);
- } else if (table.getPeopleSeatsLeft() > 0 && table.getSwarmerSeatPrice() == 0 && table.getSocialiteSeatPrice() == 0) {
- navigateToBookingConfirmation();
- } else {
- Toast.makeText(PeopleAttendingActivity.this, "There are no seats left to join.", Toast.LENGTH_SHORT).show();
- }
- } else {
- if (table.getSwarmerSeatsLeft() > 0 && table.getSwarmerSeatPrice() != 0) {
- Bundle b = new Bundle();
- b.putString("table", gson.toJson(table));
- b.putString("Event", gson.toJson(event));
- b.putInt(BookTableActivity.INTENT_SEATS_LEFT, table.getSwarmerSeatsLeft());
- intent.putExtras(b);
- startActivityForResult(intent, REQ_CODE_BOOK);
- } else if (table.getSwarmerSeatsLeft() > 0 && table.getSwarmerSeatPrice() == 0 && !btnJoinNow.getText().equals(txt)) {
- navigateToBookingConfirmation();
- } else {
- if (isUserAlreadyOnTable(table) || btnJoinNow.getText().equals(txt)) {
- if (table.getSeats().size() > 0) {
- openEmailApp();
- } else {
- Toast.makeText(PeopleAttendingActivity.this, "There are no seats left to join.", Toast.LENGTH_SHORT).show();
- }
- }
- }
- }
- }
- private void navigateToBookingConfirmation() {
- Intent i1 = new Intent(PeopleAttendingActivity.this, BookingConfirmationActivity.class);
- i1.putExtra("event", gson.toJson(event));
- i1.putExtra("table", gson.toJson(table));
- i1.putExtra("price", String.valueOf(0));
- startActivityForResult(i1, CONFIRM_BOOKING);
- }
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (resultCode == Activity.RESULT_OK) {
- switch (requestCode) {
- case CONFIRM_BOOKING:
- startPayment();
- break;
- }
- } else {
- if (requestCode == BOOKED_EVENT_DETAILS) {
- finishPayment();
- }
- }
- }
- private void startPayment() {
- List<BookingInnerItem> items = new ArrayList<>();
- BookingInnerItem item = new BookingInnerItem();
- item.setType("TableSeat");
- item.setPrice(0);
- item.setQty(1);
- item.setItemName(table.getLocation());
- item.setItemId(table.getId());
- items.add(item);
- String promoCode = "";
- EventBus.getDefault().post(new RequestBookedTable(event.getId(), promoCode, "Free Of Charge", items));
- }
- private void finishPayment() {
- if (event != null) {
- List<Table> tmpTables = event.getTables();
- Table toReturn = null;
- for (Table t : tmpTables) {
- if (t.getId().equals(table.getId())) {
- toReturn = t;
- }
- }
- Intent backToJoin = new Intent();
- Bundle b = new Bundle();
- b.putString("table", gson.toJson(toReturn));
- b.putString("Event", gson.toJson(event));
- backToJoin.putExtras(b);
- setResult(RESULT_OK, backToJoin);
- finish();
- }
- }
- public void onEventMainThread(Booking res) {
- rxNetwork.getEventById(res.getEventId())
- .subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread())
- .subscribeWith(new OnGetEventByIdObserver(this));
- TableInvitationTempHolder invitation = EventBus.getDefault().getStickyEvent(TableInvitationTempHolder.class);
- if (invitation != null) {
- EventBus.getDefault().post(new RequestResponseOnTableInvitation(invitation.getFacebookId(), invitation.getInviteId(), invitation.isAccept()));
- EventBus.getDefault().removeStickyEvent(invitation);
- }
- Toast.makeText(this, "Table successfully booked", Toast.LENGTH_SHORT).show();
- }
- public void onEventMainThread(ErrorServerResponse error) {
- Toast.makeText(this, error.getMessage(), Toast.LENGTH_SHORT).show();
- }
- private Receipt createReceipt() {
- Receipt receipt = new Receipt();
- receipt.setPromoCode("");
- receipt.setFee(0);
- receipt.setGratuity(0);
- receipt.setTax(0);
- receipt.setSubtotal(0);
- receipt.setDiscount(0);
- receipt.setTotal(0);
- receipt.setSeatSinglePrice(0);
- return receipt;
- }
- private void openEmailApp() {
- String text = "Hey, I'm going to "+ event.getName() + " @ " + event.getVenueName().toUpperCase() + ". Wanna join? ";
- String link = AppConstants.DEVELOPMENT_BASE_URL + "events/" + event.getId() + "/tables/" +
- table.getId() + "/share";
- PackageManager pm = getPackageManager();
- Intent basicIntent = new Intent();
- basicIntent.setAction(Intent.ACTION_SEND);
- basicIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- basicIntent.putExtra(Intent.EXTRA_TEXT, link);
- basicIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, text);
- basicIntent.setType("text/plain");
- List<ResolveInfo> resInfo = pm.queryIntentActivities(basicIntent, 0);
- startActivity(Intent.createChooser(basicIntent, "Share"));
- }
- @Override
- protected void onResume() {
- super.onResume();
- if(!EventBus.getDefault().isRegistered(this)){
- EventBus.getDefault().register(this);
- }
- getData();
- }
- private void getData() {
- presenter.getEvent(eventId);
- }
- @Override
- public void onRefresh() {
- getData();
- }
- @Override
- protected void onPause() {
- super.onPause();
- EventBus.getDefault().unregister(this);
- }
- @Override
- protected void onDestroy() {
- super.onDestroy();
- if (eventPhotosAdapter != null) {
- eventPhotosAdapter.setOnItemClickListener(null);
- }
- if (btnJoinNow != null) {
- btnJoinNow.setOnClickListener(null);
- }
- if (mSwipeRefreshLayout != null) {
- mSwipeRefreshLayout.setOnRefreshListener(null);
- }
- acceptDenyView.unbindViews();
- App.watchReference(this);
- }
- private void onRequestToJoin(String eventId, String tableId){
- Recipient u = new Recipient();
- AppUser user = Common.getInstance().getPref().getUser();
- List<Recipient> from = new ArrayList<>();
- u.setFirstName(user.getFirstName());
- u.setLastName(user.getLastName());
- u.setProfilePhotoUrl(user.getProfilePhotoUrl());
- u.setFacebookId(user.getFacebookId());
- u.setUserType(user.getUserType());
- from.add(u);
- EventBus.getDefault().post(new RequestSocialiteTableBooking(eventId, tableId, from));
- }
- public void onEventMainThread(ResponseOnSocialiteTableRequest res){
- if(res.isSuccess()){
- Toast.makeText(PeopleAttendingActivity.this, "Request to join the table has been sent", Toast.LENGTH_SHORT).show();
- }else{
- if(res.getError() != null){
- Toast.makeText(PeopleAttendingActivity.this, res.getError(), Toast.LENGTH_SHORT).show();
- }else{
- Toast.makeText(PeopleAttendingActivity.this, "Error sending request", Toast.LENGTH_SHORT).show();
- }
- }
- }
- public void onEventMainThread(ResponseInviteOnTableConfirmation res){
- if (res.isSuccess()) {
- tempWrapper = null;
- EventBus.getDefault().postSticky(new StickyResponseOnRequest(res.getInviteId()));
- getData();
- }else{
- Toast.makeText(this, "Something went wrong!", Toast.LENGTH_SHORT).show();
- }
- }
- private static class AcceptDenyTableInvitationListener implements AcceptDenyBottomView.OnActionListener{
- private final WeakReference<PeopleAttendingActivity> weakAct;
- AcceptDenyTableInvitationListener(PeopleAttendingActivity act) {
- weakAct = new WeakReference<PeopleAttendingActivity>(act);
- }
- @Override
- public void onResponse(boolean accepted) {
- PeopleAttendingActivity act = weakAct.get();
- if (act != null) {
- Table table = act.table;
- TableRequestsWrapper wrapper = act.tempWrapper;
- if (wrapper != null) {
- if(wrapper.getType() == RequestsRecyclerViewAdapter.SOCIALITE_REQUEST_TYPE){
- EventBus.getDefault().post(new RequestSocialiteTableRequestConfirmation(accepted, wrapper.getRequest().get_id()));
- AcceptDenyBottomView.ACCEPTDENYSCREEN="GONE";
- act.checkAcceptDenyScreen();
- }
- else if(wrapper.getType() == RequestsRecyclerViewAdapter.INVITE_TABLE_TYPE){
- if (accepted) {
- if (table.getType().equals(Event.EVENT_TYPE_INVITE) && act.userType.equals(act.getResources().getString(R.string.u_type_socialite))) {
- EventBus.getDefault().post(new RequestInviteOnTableResponse(wrapper.getInvitation().getInvitedByFacebookId(), wrapper.getInvitation().get_id(), accepted));
- } else {
- TableInvitationTempHolder invitation = new TableInvitationTempHolder(wrapper.getInvitation().getInvitedByFacebookId(), wrapper.getInvitation().get_id(), accepted);
- EventBus.getDefault().post(new RequestInviteOnTableResponse(wrapper.getInvitation().getInvitedByFacebookId(), wrapper.getInvitation().get_id(), accepted));
- //Utils.removeCachedInvitation(invitation.getInviteId(), table.getId());
- // EventBus.getDefault().postSticky(new RequestResponseOnTableInvitation(wrapper.getInvitation().getInvitedByFacebookId(), wrapper.getInvitation().get_id(), accepted));
- act.joinTable();
- }
- AcceptDenyBottomView.ACCEPTDENYSCREEN="GONE";
- act.checkAcceptDenyScreen();
- act.onRefresh();
- } else {
- AcceptDenyBottomView.ACCEPTDENYSCREEN="GONE";
- act.checkAcceptDenyScreen();
- EventBus.getDefault().post(new RequestInviteOnTableResponse(wrapper.getInvitation().getInvitedByFacebookId(), wrapper.getInvitation().get_id(), accepted));
- }
- }
- }
- }
- }
- }
- private static class OnGetEventByIdObserver implements SingleObserver<Event> {
- private final WeakReference<PeopleAttendingActivity> weakAct;
- private Disposable d;
- OnGetEventByIdObserver(PeopleAttendingActivity act) {
- weakAct = new WeakReference<PeopleAttendingActivity>(act);
- }
- @Override
- public void onSubscribe(Disposable d) {
- this.d = d;
- }
- @Override
- public void onSuccess(Event e) {
- PeopleAttendingActivity act = weakAct.get();
- if (act != null) {
- act.event = e;
- RxMessagingService.startService(act);
- Intent i = new Intent(act, BookedEventDetailsActivity.class);
- String event = GsonFactory.getInstance().toJson(act.event);
- i.putExtra("event", event);
- i.putExtra("receipt", act.createReceipt());
- i.putExtra("tableId", act.table.getId());
- act.startActivityForResult(i, BOOKED_EVENT_DETAILS);
- }
- if (d != null && d.isDisposed()) {
- d.dispose();
- }
- }
- @Override
- public void onError(Throwable e) {
- if (d != null && d.isDisposed()) {
- d.dispose();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement