예제 #1
0
  public void refreshViews() {
    layout.removeAllViews();
    views = new ArrayList<View>();
    cardViews = new ArrayList<CardUI>();
    profilePictures = new ArrayList<MLRoundedImageView>();

    users = ItemsData.retrieveUserIdsCurrentlyRenting(getActivity());
    bitmaps = new ArrayList<Bitmap>();
    if (users.size() == 0) {
      CardUI cards = new CardUI(getActivity());
      cards.setPadding(0, 20, 0, 20);
      cards.addCard(new EmptyRentalListCard(getActivity()));
      cards.refresh();
      views.add(cards);
    } else {
      for (User u : users) {
        views.add(createProfile(u));
        views.add(
            createUserRentals(
                ItemsData.retrieveItemsLentByUserId(u.getFacebookId(), getActivity())));
      }
    }

    for (int i = 0; i < views.size(); i++) {
      View v = views.get(i);
      v.setVisibility(LinearLayout.VISIBLE);
      Animation animation = AnimationUtils.loadAnimation(getActivity(), R.animator.fade_in);
      animation.setDuration(300);
      animation.setStartOffset(i * 100);
      v.setAnimation(animation);
      layout.addView(v);
    }
  }
예제 #2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    profilePictures = new ArrayList<MLRoundedImageView>();
    views = new ArrayList<View>();
    cardViews = new ArrayList<CardUI>();
    myInflater = inflater;
    scroller = new ScrollView(getActivity().getApplicationContext());
    layout = new LinearLayout(getActivity().getApplicationContext());
    layout.setPadding(0, 5, 0, 5);
    layout.setOrientation(LinearLayout.VERTICAL);

    scroller.addView(layout);
    scroller.setBackgroundColor(Color.parseColor(Utils.BACKGROUND_COLOR));

    users = ItemsData.retrieveUserIdsCurrentlyRenting(getActivity());
    bitmaps = new ArrayList<Bitmap>();
    if (users.size() == 0) {
      CardUI cards = new CardUI(getActivity());
      cards.setPadding(0, 20, 0, 20);
      cards.addCard(new EmptyRentalListCard(getActivity()));
      cards.refresh();
      views.add(cards);
    } else {
      for (User u : users) {
        views.add(createProfile(u));
        views.add(
            createUserRentals(
                ItemsData.retrieveItemsLentByUserId(u.getFacebookId(), getActivity())));
      }
    }
    for (int i = 0; i < views.size(); i++) {
      View v = views.get(i);
      v.setVisibility(LinearLayout.VISIBLE);
      Animation animation = AnimationUtils.loadAnimation(getActivity(), R.animator.fade_in);
      animation.setDuration(300);
      animation.setStartOffset(i * 100);
      v.setAnimation(animation);
      layout.addView(v);
    }

    return scroller;
  }
예제 #3
0
    protected Void doInBackground(Void... voids) {

      users = ItemsData.retrieveUserIdsCurrentlyRenting(getActivity());
      bitmaps = new ArrayList<Bitmap>();
      if (users.size() == 0) {
        CardUI cards = new CardUI(getActivity());
        cards.setPadding(0, 20, 0, 20);
        cards.addCard(new EmptyRentalListCard(getActivity()));
        cards.refresh();
        views.add(cards);
      } else {
        for (User u : users) {
          views.add(createProfile(u));
          views.add(
              createUserRentals(
                  ItemsData.retrieveItemsLentByUserId(u.getFacebookId(), getActivity())));
        }
      }

      return null;
    }
예제 #4
0
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    System.out.println("VENMO DONE!");
    switch (requestCode) {
      case 1:
        { // 1 is the requestCode we picked for Venmo earlier when we called startActivityForResult
          if (resultCode == getActivity().RESULT_OK) {
            String signedrequest = data.getStringExtra("signedrequest");
            if (signedrequest != null) {
              VenmoResponse response =
                  (new VenmoLibrary())
                      .validateVenmoPaymentResponse(signedrequest, VenmoLibrary.SECRET);
              if (response.getSuccess().equals("1")) {
                // Payment successful.  Use data from response object to display a success message
                String note = response.getNote();
                String amount = response.getAmount();

                // need to notify the server that the payment is successful.

                // change the rentals database from pending to complete.
                ItemsData.venmoChargeComplete(venmo_item_id, getActivity());
                // refreshViews();
              }
            } else {
              String error_message = data.getStringExtra("error_message");
              // An error ocurred.  Make sure to display the error_message to the user
            }
          } else if (resultCode == getActivity().RESULT_CANCELED) {
            // The user cancelled the payment
          }
          break;
        }
    }
  }