Exemplo n.º 1
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splitbill);

    TippyTipperApplication appState = ((TippyTipperApplication) this.getApplication());

    splitBill(appState.service.getNumberOfPeople());

    View btn_add_person = findViewById(R.id.btn_add_person);
    btn_add_person.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            addPerson();
            FlurryAgent.onEvent("Add Person Button");
          }
        });

    View btn_remove_person = findViewById(R.id.btn_remove_person);
    btn_remove_person.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            removePerson();
            FlurryAgent.onEvent("Remove Person Button");
          }
        });
  }
Exemplo n.º 2
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder;
      if (convertView == null) {
        holder = new ViewHolder();
        convertView = LayoutInflater.from(getActivity()).inflate(R.layout.item_song, null);
        holder.mTvName = (TextView) convertView.findViewById(R.id.tv_name);
        holder.mTvArtist = (TextView) convertView.findViewById(R.id.tv_artist);
        holder.mTvDuration = (TextView) convertView.findViewById(R.id.tv_duration);
        holder.aboveView = convertView.findViewById(R.id.item_root);
        holder.behindView = convertView.findViewById(R.id.behind);
        convertView.setTag(holder);
        convertViewList.add((PullRightLayout) convertView);
      } else {
        holder = (ViewHolder) convertView.getTag();
      }
      if (HideApplication.showListAnim) {
        startAnim(convertView);
      }

      SongInfo info = SongManager.with(getActivity()).getSongByIndex(position);
      holder.mTvName.setText(info.getTitle());
      holder.mTvArtist.setText(info.getArtist() + " - " + info.getAlbum());
      holder.mTvDuration.setText(
          CommonUtils.durationToString(info.getDuration())
              + " - "
              + CommonUtils.getFileSize(info.getPath()));

      setItemSelected(holder, info.getId() == playingId);

      convertView.setOnClickListener(new OnItemClick(position));
      holder.behindView.setOnClickListener(new OnBehindClick(position));

      return convertView;
    }
Exemplo n.º 3
0
 public ViewHolder(View itemView) {
   super(itemView);
   cv = (CardView) itemView.findViewById(R.id.card_view);
   tittle = (TextView) itemView.findViewById(R.id.titletxt);
   description = (TextView) itemView.findViewById(R.id.descriptiontext);
   background = (RelativeLayout) itemView.findViewById(R.id.relativelayouthome);
   itemView.setOnClickListener(this);
 }
Exemplo n.º 4
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    if (weChatUtils.getIWXAPI().isWXAppInstalled()) {
      inflater.inflate(R.menu.main_wechat, menu);
    } else {
      inflater.inflate(R.menu.main, menu);
    }

    MenuItem shareItem = menu.findItem(R.id.action_share);
    android.support.v4.view.ActionProvider actionProvider =
        MenuItemCompat.getActionProvider(shareItem);
    if (null != actionProvider && actionProvider instanceof ShareActionProvider) {
      mShareActionProvider.setShareHistoryFileName(
          ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
      // mShareActionProvider.setShareIntent(Utils.getShareRawIntent(this));

      mShareActionProvider.setOnShareTargetSelectedListener(
          new ShareActionProvider.OnShareTargetSelectedListener() {
            @Override
            public boolean onShareTargetSelected(
                ShareActionProvider shareActionProvider, Intent intent) {
              updateShareIntent();
              return false;
            }
          });
      updateShareIntent();

      for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        if (item.getItemId() == R.id.action_share) {
          View itemChooser = MenuItemCompat.getActionView(item);
          if (itemChooser != null) {
            itemChooser.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                    EFLogger.i(TAG, "onClick");
                    ScreenshotUtils.shotBitmap(MainActivity.this, shareFileName);
                  }
                });
          }
        }
      }
    }

    return super.onCreateOptionsMenu(menu);
  }
Exemplo n.º 5
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   ViewHodler holder = null;
   if (null == convertView) {
     convertView = View.inflate(context, R.layout.li_child_click_item, null);
     holder = new ViewHodler();
     holder.mCountry = (Button) convertView.findViewById(R.id.licc_btn_country);
     holder.mName = (TextView) convertView.findViewById(R.id.licc_tv_name);
     convertView.setTag(holder);
   } else {
     holder = (ViewHodler) convertView.getTag();
   }
   LiData data = list.get(position);
   holder.mCountry.setText(data.country);
   holder.mCountry.setOnClickListener(new OnItemChildClickListener(CLICK_INDEX_COUNTRY, position));
   holder.mName.setText(data.name);
   holder.mName.setOnClickListener(new OnItemChildClickListener(CLICK_INDEX_NAME, position));
   convertView.setOnClickListener(new OnItemChildClickListener(CLICK_INDEX_ITEM, position));
   return convertView;
 }
Exemplo n.º 6
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // open up the DbAdaptor
    db.open();

    // gives us more screen space
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // need to do this because the camera doesn't do portrait mode
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    // initialize all our views.
    LayoutInflater inflater = getLayoutInflater();
    viewCaptureNote = inflater.inflate(R.layout.view_capture_note, null);
    viewNote = inflater.inflate(R.layout.view_note, null);
    viewTagList = inflater.inflate(R.layout.view_tag_list, null);
    viewNoteGallery = inflater.inflate(R.layout.view_note_gallery, null);

    // set the content view initially to save notes
    setContentView(viewCaptureNote);

    // set up the click listeners for the camera preview screen
    CameraPreview cameraPreview = (CameraPreview) findViewById(R.id.surface);
    findViewById(R.id.discard).setOnClickListener(cameraPreview);
    findViewById(R.id.take).setOnClickListener(cameraPreview);
    findViewById(R.id.save_untagged).setOnClickListener(cameraPreview);
    findViewById(R.id.save_and_tag).setOnClickListener(cameraPreview);

    // set up the 'view untagged' option in the list menu
    View someView = viewTagList.findViewById(R.id.tag_list_untagged);
    someView.findViewById(R.id.tag_subtags).setVisibility(View.GONE);
    ((TextView) someView.findViewById(R.id.tag_name)).setText("Click to view untagged notes");
    someView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Gallery g = (Gallery) viewNoteGallery.findViewById(R.id.note_gallery);
            g.setAdapter(new NoteGalleryImageAdaptor(SBActivity.this, db.getUntaggedNotes()));
            setContentView(viewNoteGallery);
          }
        });

    // set the list adaptor for our tag list
    final ListView lv = (ListView) viewTagList.findViewById(R.id.item_list);
    lv.setAdapter(new TagViewListAdaptor(this, db.getTagList()));
    registerForContextMenu(lv);
    lv.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            TextView v = (TextView) view.findViewById(R.id.tag_subtags);
            v.setVisibility(v.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
            long tagId = (Long) view.findViewById(R.id.tag_name).getTag();
            if (v.getVisibility() == View.VISIBLE) {
              int subtagCount = 0;
              StringBuilder subTags = new StringBuilder("Sub-tags: ");
              Cursor c = db.getSubTags(tagId);
              while (c.moveToNext()) {
                subTags.append(c.getString(1) + " ");
                subtagCount++;
              }
              if (subtagCount > 0) v.setText(subTags);
              else v.setText("No sub-tags.");
            }
          }
        });
    lv.setOnCreateContextMenuListener(
        new View.OnCreateContextMenuListener() {
          public void onCreateContextMenu(
              ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
            menu.setHeaderIcon(android.R.drawable.ic_menu_info_details);
            ListView lv = (ListView) viewTagList.findViewById(R.id.item_list);
            Cursor listItem =
                (Cursor)
                    lv.getItemAtPosition(((AdapterView.AdapterContextMenuInfo) menuInfo).position);
            String tagName = listItem.getString(1);
            menu.setHeaderTitle("Tag '" + tagName + "'");
            menu.add(0, CONTEXT_VIEW_NOTES, 0, "View notes tagged with '" + tagName + "'");
            menu.add(0, CONTEXT_DELETE_TAG, 0, "Delete tag");
          }
        });

    // set up click listeners for add tag
    viewTagList
        .findViewById(R.id.save_tag)
        .setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View view) {
                EditText editText = (EditText) viewTagList.findViewById(R.id.tag_id);
                if (editText.getText().length() == 0) return;
                db.addNewTag(editText.getText());
                ((TagViewListAdaptor) lv.getAdapter()).refreshData();
                Toast.makeText(
                        SBActivity.this,
                        "Tag '" + editText.getText() + "' added.",
                        Toast.LENGTH_SHORT)
                    .show();
                editText.setText("");
              }
            });
    viewTagList.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View view, boolean b) {
            Log.i(TAG, "Focus changed innit: " + b);
            if (b) ((TagViewListAdaptor) lv.getAdapter()).refreshData();
          }
        });

    // set up our note viewing gallery
    final Gallery g = (Gallery) viewNoteGallery.findViewById(R.id.note_gallery);
    g.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            // set the note number i.e. 1/3
            ((TextView) viewNoteGallery.findViewById(R.id.gallery_note_number))
                .setText((i + 1) + " / " + g.getCount());

            // set the date field
            Date d = new Date(((Note) view.getTag()).getSaveTime());
            ((TextView) viewNoteGallery.findViewById(R.id.gallery_note_date))
                .setText(DateFormat.getDateTimeInstance().format(d));

            // set the tag field
            Cursor c = db.getTagListForImg(l);
            StringBuilder sb = new StringBuilder();
            while (c.moveToNext()) {
              if (c.getInt(2) == 0) continue;
              sb.append(c.getString(1));
              sb.append(", ");
            }
            // delete the last 2 chars: ", "
            if (sb.length() > 0) sb.delete(sb.length() - 2, sb.length());
            else sb.append("none");
            ((TextView) viewNoteGallery.findViewById(R.id.gallery_note_tags))
                .setText(sb.toString());
          }

          @Override
          public void onNothingSelected(AdapterView<?> adapterView) {}
        });
    g.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {

            return true;
          }
        });
    viewNoteGallery
        .findViewById(R.id.note_gallery_examine)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                Note n = (Note) ((View) g.getSelectedView()).getTag();
                setViewSingleNote(n.getFileName());
              }
            });

    Handler btProgressHandler =
        new Handler() {
          public void handleMessage(Message msg) {
            if (btProgressDialog == null) return;
            switch (msg.what) {
              case BluetoothService.MSG_CONNECTED:
                btProgressDialog.setMessage("Bluetooth connected! Sending updates...");
                break;
              case BluetoothService.MSG_RECEIVING:
                btProgressDialog.setMessage("Receiving updates from computer..");
                break;
              case BluetoothService.MSG_PROGRESS:
                int cur = msg.arg1;
                int max = msg.arg2;
                btProgressDialog.setProgress(cur);
                btProgressDialog.setMax(max);
                break;
              case BluetoothService.MSG_DONE:
                btProgressDialog.dismiss();
                break;
            }
          }
        };
    bService.setProgressHandler(btProgressHandler);
  }
Exemplo n.º 7
0
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      if (convertView == null) {
        convertView = inflater.inflate(R.layout.ext_cashila_pending_row, null);
      }

      final BillPay billPay = getItem(position);

      TextView tvName = ButterKnife.findById(convertView, R.id.tvName);
      TextView tvAmount = ButterKnife.findById(convertView, R.id.tvAmount);
      TextView tvOutstandingAmount = ButterKnife.findById(convertView, R.id.tvOutstandingAmount);
      TextView tvStatus = ButterKnife.findById(convertView, R.id.tvStatus);
      TextView tvFee = ButterKnife.findById(convertView, R.id.tvFee);
      TextView tvSectionHeader = ButterKnife.findById(convertView, R.id.tvSectionHeader);
      TextView tvReference = ButterKnife.findById(convertView, R.id.tvReference);
      TextView tvDate = ButterKnife.findById(convertView, R.id.tvDate);

      if (billPay.recipient != null) {
        tvName.setText(billPay.recipient.name);
      } else {
        tvName.setText("");
      }

      if (billPay.payment != null) {
        tvAmount.setText(
            Utils.formatFiatValueAsString(billPay.payment.amount) + " " + billPay.payment.currency);
        tvReference.setText(billPay.payment.reference);
      }

      tvStatus.setText(billPay.status.getLocalizedString(getActivity()));

      if (billPay.details != null) {
        String fee;
        if (billPay.details.fee != null) {
          fee = Utils.formatFiatValueAsString(billPay.details.fee) + " " + billPay.payment.currency;
        } else {
          fee = "???";
        }
        tvFee.setText(getResources().getString(R.string.cashila_fee, fee));

        // if there is already an amount deposited but still outstanding we have underpaid (maybe
        // because of some latency of
        // the bitcoin network and/or changes in exchange rate)

        BigDecimal amountDeposited =
            billPay.details.amountDeposited == null
                ? BigDecimal.ZERO
                : billPay.details.amountDeposited;
        BigDecimal amountToDeposit =
            billPay.details.amountToDeposit == null
                ? BigDecimal.ZERO
                : billPay.details.amountToDeposit;
        if (BigDecimal.ZERO.compareTo(amountDeposited) < 0
            && BigDecimal.ZERO.compareTo(amountToDeposit) < 0) {
          tvOutstandingAmount.setVisibility(View.VISIBLE);
          long satoshisOutstanding = Bitcoins.nearestValue(amountToDeposit).getLongValue();
          tvOutstandingAmount.setText(
              String.format(
                  getResources().getString(R.string.cashila_amount_outstanding),
                  mbw.getBtcValueString(satoshisOutstanding)));
        } else {
          tvOutstandingAmount.setVisibility(View.GONE);
        }
        tvDate.setText(Utils.getFormattedDate(getContext(), billPay.details.createdAt));
      }

      if (position == 0) {
        tvSectionHeader.setVisibility(View.VISIBLE);
      } else if (getItem(position - 1).getSortOrder() != billPay.getSortOrder()) {
        tvSectionHeader.setVisibility(View.VISIBLE);
      } else {
        tvSectionHeader.setVisibility(View.GONE);
      }
      if (billPay.isPayable()) {
        tvSectionHeader.setText(getResources().getString(R.string.cashila_pending));
      } else if (billPay.status.equals(BillPayStatus.uploaded)) {
        tvSectionHeader.setText(getResources().getString(R.string.cashila_uploaded_title));
      } else {
        tvSectionHeader.setText(getResources().getString(R.string.cashila_done));
      }

      final ActionBarActivity actionBarActivity = (ActionBarActivity) getActivity();

      final RelativeLayout rlReference = ButterKnife.findById(convertView, R.id.rlReference);
      convertView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              currentActionMode =
                  actionBarActivity.startSupportActionMode(
                      new ActionMode.Callback() {
                        @Override
                        public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
                          if (billPay.isPayable()) {
                            actionMode
                                .getMenuInflater()
                                .inflate(R.menu.ext_cashila_pending_payments_menu, menu);
                            currentActionMode = actionMode;
                          }
                          rlReference.setVisibility(View.VISIBLE);
                          lvPending.setItemChecked(position, true);
                          return true;
                        }

                        @Override
                        public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
                          rlReference.setVisibility(View.VISIBLE);
                          return billPay.isPayable();
                        }

                        @Override
                        public boolean onActionItemClicked(
                            ActionMode actionMode, MenuItem menuItem) {
                          final int itemId = menuItem.getItemId();
                          if (itemId == R.id.miDeletePayment) {
                            deletePayment(billPay);
                            return true;
                          } else if (itemId == R.id.miPayNow) {
                            payNow(billPay);
                            return true;
                          }

                          return false;
                        }

                        @Override
                        public void onDestroyActionMode(ActionMode actionMode) {
                          lvPending.setItemChecked(position, false);
                          rlReference.setVisibility(View.GONE);
                          currentActionMode = null;
                        }
                      });
            }
          });

      return convertView;
    }