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); } }
@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; }
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; }