예제 #1
0
  /** This method builds a card with a thumbnail with a resource ID */
  private void init_card_thumb_resourceId() {

    // Create a Card
    Card card = new Card(getActivity());

    // Create a CardHeader
    CardHeader header = new CardHeader(getActivity());

    // Set the header title
    header.setTitle(getString(R.string.demo_header_basetitle));

    // Add header to a card
    card.addCardHeader(header);

    // Create thumbnail
    CardThumbnail thumb = new CardThumbnail(getActivity());

    // Set ID resource
    thumb.setDrawableResource(R.drawable.carddemo_ic_gmaps_large);

    // Add thumbnail to a card
    card.addCardThumbnail(thumb);

    // Set card in the cardView
    CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_thumb_id);
    cardView.setCard(card);
  }
예제 #2
0
  /** This method builds a card with a thumbnail with a resource URL */
  private void init_card_thumb_resourceURL() {

    // Create a Card
    Card card = new Card(getActivity());

    // Create a CardHeader
    CardHeader header = new CardHeader(getActivity());

    // Set the header title
    header.setTitle(getString(R.string.demo_header_basetitle));

    card.addCardHeader(header);

    // Create thumbnail
    CardThumbnail thumb = new CardThumbnail(getActivity());

    // Set URL resource
    thumb.setUrlResource(
        "https://lh5.googleusercontent.com/-N8bz9q4Kz0I/AAAAAAAAAAI/AAAAAAAAAAs/Icl2bQMyK7c/s265-c-k-no/photo.jpg");

    // Error Resource ID
    thumb.setErrorResource(R.drawable.ic_error_loadingorangesmall);

    // Add thumbnail to a card
    card.addCardThumbnail(thumb);

    // Set card in the cardView
    CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_thumb_url);
    cardView.setCard(card);
  }
예제 #3
0
 @Override
 public boolean isEnabled(int position) {
   // Disable card if it is not clickable or longClickable
   Card card = (Card) getItem(position);
   if (card.isClickable() || card.isLongClickable()) return true;
   else return false;
 }
예제 #4
0
 /**
  * Sets up Shadow visibility
  *
  * @return
  */
 protected void setupShadowView() {
   if (mInternalShadowLayout != null) {
     if (mCard != null) {
       if (!mCard.isShadow()) {
         mInternalShadowLayout.setVisibility(GONE);
       } else {
         mInternalShadowLayout.setVisibility(VISIBLE);
       }
     }
   }
 }
예제 #5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);

    int listImages[] =
        new int[] {
          R.drawable.ic_launcher,
          R.drawable.ic_launcher,
          R.drawable.ic_launcher,
          R.drawable.ic_launcher,
          R.drawable.ic_launcher
        };

    ArrayList<Card> cards = new ArrayList<Card>();

    for (int i = 0; i < 5; i++) {
      // Create a Card
      Card card = new Card(this);
      // Create a CardHeader
      CardHeader header = new CardHeader(this);
      // Add Header to card
      header.setTitle("Angry bird: " + i);
      card.setTitle("sample title");
      card.addCardHeader(header);

      CardThumbnail thumb = new CardThumbnail(this);
      thumb.setDrawableResource(listImages[i]);
      card.addCardThumbnail(thumb);

      cards.add(card);
    }

    CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(this, cards);

    CardListView listView = (CardListView) this.findViewById(R.id.myList);
    if (listView != null) {
      listView.setAdapter(mCardArrayAdapter);
    }
  }
예제 #6
0
  /** This method builds a standard header with a custom expand/collpase */
  private Card init_standard_header_with_expandcollapse_button_custom_area(String titleHeader) {

    // Create a Card
    Card card = new Card(getActivity());

    // Create a CardHeader
    CardHeader header = new CardHeader(getActivity());

    // Set the header title
    header.setTitle(titleHeader);

    // Set visible the expand/collapse button
    header.setButtonExpandVisible(true);

    // Add Header to card
    card.addCardHeader(header);

    // This provides a simple (and useless) expand area
    CustomExpandCard expand = new CustomExpandCard(getActivity());
    // Add Expand Area to Card
    card.addCardExpand(expand);

    return card;
  }
 public void setTitle(String title) {
   super.setTitle(title);
   this.mTitle = title;
 }
예제 #8
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Start service to listen for shaking
    startService(new Intent(MainActivity.this, Background_service.class));

    int cnt = getNumDots();
    // cnt = 0;
    if (cnt == 0) {
      try {
        FileOutputStream fos = openFileOutput("Dots.txt", Context.MODE_PRIVATE);
        fos.write((".").getBytes());
        fos.close();
      } catch (Exception e) {
      }
      this.setContentView(R.layout.login);
    } else if (cnt == 1) {
      try {
        FileOutputStream fos = openFileOutput("Dots.txt", Context.MODE_PRIVATE);
        fos.write(("..").getBytes());
        fos.close();
      } catch (Exception e) {
      }

      this.setContentView(R.layout.instructions);
    } else if (cnt == 2) {
      try {
        FileOutputStream fos = openFileOutput("Dots.txt", Context.MODE_PRIVATE);
        fos.write(("...").getBytes());
        fos.close();
      } catch (Exception e) {
      }

      this.setContentView(R.layout.s1);
    } else if (cnt == 3) {
      try {
        FileOutputStream fos = openFileOutput("Dots.txt", Context.MODE_PRIVATE);
        fos.write(("....").getBytes());
        fos.close();
      } catch (Exception e) {
      }
      this.setContentView(R.layout.s2);

    } else if (cnt == 4) {
      try {
        FileOutputStream fos = openFileOutput("Dots.txt", Context.MODE_PRIVATE);
        fos.write((".....").getBytes());
        fos.close();
      } catch (Exception e) {
      }
      this.setContentView(R.layout.s3);
    } else if (cnt == 5) {
      try {
        FileOutputStream fos = openFileOutput("Dots.txt", Context.MODE_PRIVATE);
        fos.write(("......").getBytes());
        fos.close();
      } catch (Exception e) {
      }
      this.setContentView(R.layout.s4);
    } else {
      setContentView(R.layout.activity_main);
      showBalance = (TextView) findViewById(R.id.textView);
      showBalance.setText(dollar("$" + String.valueOf(getTotalTimes() * getAps())));
      startNotification();

      int listImages[] =
          new int[] {
            R.drawable.two, R.drawable.one, R.drawable.three, R.drawable.four, R.drawable.five
          };

      ArrayList<Card> cards = new ArrayList<Card>();

      /* for (int i = 0; i<5; i++) {
          Card card = new Card(this);
          CardHeader header = new CardHeader(this);
          header.setTitle("Angry bird: " + i);
          card.setTitle("sample title");
          card.addCardHeader(header);
          CardThumbnail thumb = new CardThumbnail(this);
          thumb.setDrawableResource(listImages[i]);
          card.addCardThumbnail(thumb);
          cards.add(card);
      }*/

      Card card = new Card(this);
      CardHeader header = new CardHeader(this);
      header.setTitle("Shannon Baker: $15");
      card.setTitle("Perfect Attendance for a week!");
      card.addCardHeader(header);
      CardThumbnail thumb = new CardThumbnail(this);
      thumb.setDrawableResource(listImages[1]);
      card.addCardThumbnail(thumb);
      cards.add(card);

      card = new Card(this);
      header = new CardHeader(this);
      header.setTitle("Russel Heritage: $20");
      card.setTitle("10 Selfies in ten days!");
      card.addCardHeader(header);
      thumb = new CardThumbnail(this);
      thumb.setDrawableResource(listImages[0]);
      card.addCardThumbnail(thumb);
      cards.add(card);

      card = new Card(this);
      header = new CardHeader(this);
      header.setTitle("Melody Li: $5");
      card.setTitle("Discovered every place in her house!");
      card.addCardHeader(header);
      thumb = new CardThumbnail(this);
      thumb.setDrawableResource(listImages[2]);
      card.addCardThumbnail(thumb);
      cards.add(card);

      card = new Card(this);
      header = new CardHeader(this);
      header.setTitle("Bisma Imran: $10");
      card.setTitle("Brought lunch from home all week!");
      card.addCardHeader(header);
      thumb = new CardThumbnail(this);
      thumb.setDrawableResource(listImages[3]);
      card.addCardThumbnail(thumb);
      cards.add(card);

      card = new Card(this);
      header = new CardHeader(this);
      header.setTitle("Adit Patel: $7");
      card.setTitle("Went to practice every day this month!");
      card.addCardHeader(header);
      thumb = new CardThumbnail(this);
      thumb.setDrawableResource(listImages[4]);
      card.addCardThumbnail(thumb);
      cards.add(card);

      CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(this, cards);

      CardListView listView = (CardListView) this.findViewById(R.id.myList);
      if (listView != null) {
        listView.setAdapter(mCardArrayAdapter);
      }
      // showBalance.setText("$124.00");
    }
  }
예제 #9
0
 @Override
 public int getItemViewType(int position) {
   Card card = (Card) getItem(position);
   return card.getType();
 }
예제 #10
0
  // Override and setup custom template
  // Should use ViewHolder pattern for every adapter you build.
  // http://guides.codepath.com/android/Using-an-ArrayAdapter-with-ListView#improving-performance-with-the-viewholder-pattern
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // 1. Get the item from the list
    final DailyMenu option = getItem(position);
    final fragmentNavigationInterface mainParentActivity = this.mainParentActivity;

    // 2. Find or inflate the template
    if (convertView == null) { // need to inflate? Not in recycle views pool
      convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_option, parent, false);
    }
    // 3. Find the subviews (components) from the layout to fill with data in the template
    //    ivFoodImage, tvOptionName, tvDesc, tvPrice
    ImageView ivFoodImage = (ImageView) convertView.findViewById(R.id.ivFoodImage);
    TextView tvOptionName = (TextView) convertView.findViewById(R.id.tvOptionName);
    TextView tvDesc = (TextView) convertView.findViewById(R.id.tvComment);
    TextView tvPrice = (TextView) convertView.findViewById(R.id.tvPrice);
    final TextView tvItems = (TextView) convertView.findViewById(R.id.tvItems);

    tvItems.setText(Integer.toString(option.getQtySelected())); // default value here

    ImageView ibDown = (ImageView) convertView.findViewById(R.id.ibDown);
    ImageView ibUp = (ImageView) convertView.findViewById(R.id.ibUp);

    // on buttons down and up for menu selection
    ibUp.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            tvItems.setText("" + (Integer.parseInt(tvItems.getText().toString()) + 1));
            ShoppingCart.addToShoppingCart(
                option,
                Integer.parseInt(tvItems.getText().toString()),
                v.getContext(),
                mainParentActivity);
          }
        });
    ibDown.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            int newItemQty = Integer.parseInt(tvItems.getText().toString()) - 1;
            if (newItemQty < 0) {
              newItemQty = 0;
            }
            tvItems.setText(Integer.toString(newItemQty)); // default value here
            ShoppingCart.addToShoppingCart(
                option,
                Integer.parseInt(tvItems.getText().toString()),
                v.getContext(),
                mainParentActivity);
          }
        });

    // 4. Populate data into the subviews
    tvOptionName.setText(option.getFoodMenu().getName());
    tvDesc.setText(option.getFoodMenu().getDescription());
    tvPrice.setText("$" + option.getFoodMenu().getPrice());
    ivFoodImage.setImageResource(
        android.R.color.transparent); // clear out the old image for a recycled view
    Picasso.with(getContext()).load(option.getFoodMenu().getImageUrl()).into(ivFoodImage);

    // Create a Card
    Card card = new Card(convertView.getContext());

    // Create a CardHeader
    CustomHeaderInnerCard header = new CustomHeaderInnerCard(convertView.getContext());
    // Create a CardHeader
    // CardHeader header = new CardHeader(convertView.getContext());
    // Set the header title
    // header.setTitle("                More Info...");
    // Set visible the expand/collapse button
    header.setButtonExpandVisible(true);
    // Add Header to card
    card.addCardHeader(header);

    // Card elevation
    //        card.setCardElevation(56.5f);

    // This provides a simple (and useless) expand area
    CardExpand expand = new CardExpand(convertView.getContext());
    // Set inner title in Expand Area
    expand.setTitle("Comes with Drink + Dessert.");
    card.addCardExpand(expand);

    // Set card in the cardView
    CardViewNative cardView = (CardViewNative) convertView.findViewById(R.id.carddemo);
    cardView.setCard(card);

    // 5. Return the view to be inserted into the list
    return convertView; // the final item view
  }