Example #1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.nfcard);

    final Resources res = getResources();
    this.res = res;

    final View decor = getWindow().getDecorView();
    final TextView board = (TextView) decor.findViewById(R.id.board);
    this.board = board;

    decor.findViewById(R.id.btnCopy).setOnClickListener(this);
    decor.findViewById(R.id.btnNfc).setOnClickListener(this);
    decor.findViewById(R.id.btnExit).setOnClickListener(this);

    board.setMovementMethod(LinkMovementMethod.getInstance());
    board.setFocusable(false);
    board.setClickable(false);
    board.setLongClickable(false);

    nfcAdapter = NfcAdapter.getDefaultAdapter(this);
    pendingIntent =
        PendingIntent.getActivity(
            this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

    onNewIntent(getIntent());
  }
Example #2
0
  public BookView(Context context, AttributeSet attributes) {
    super(context, attributes);

    this.listeners = new HashSet<BookViewListener>();

    this.childView =
        new TextView(context) {

          protected void onSizeChanged(int w, int h, int oldw, int oldh) {
            super.onSizeChanged(w, h, oldw, oldh);
            restorePosition();

            int tableWidth = (int) (this.getWidth() * 0.9);
            tableHandler.setTableWidth(tableWidth);
          }

          public boolean dispatchKeyEvent(KeyEvent event) {
            return BookView.this.dispatchKeyEvent(event);
          }

          @Override
          protected void onSelectionChanged(int selStart, int selEnd) {
            // TODO Auto-generated method stub
            super.onSelectionChanged(selStart, selEnd);

            LOG.debug("Got text selection from " + selStart + " to " + selEnd);
          }
        };

    childView.setCursorVisible(false);
    childView.setLongClickable(true);
    this.setVerticalFadingEdgeEnabled(false);
    childView.setFocusable(true);
    childView.setLinksClickable(true);
    childView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    MovementMethod m = childView.getMovementMethod();
    if ((m == null) || !(m instanceof LinkMovementMethod)) {
      if (childView.getLinksClickable()) {
        childView.setMovementMethod(LinkMovementMethod.getInstance());
      }
    }

    this.setSmoothScrollingEnabled(false);
    this.addView(childView);

    this.anchors = new HashMap<String, Integer>();
    this.tableHandler = new TableHandler();
  }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bug_report_view);
    final String stackTrace = getIntent().getStringExtra(STACKTRACE);
    final TextView reportTextView = (TextView) findViewById(R.id.report_text);
    reportTextView.setMovementMethod(ScrollingMovementMethod.getInstance());
    reportTextView.setClickable(false);
    reportTextView.setLongClickable(false);

    final String versionName = getVersionName();
    reportTextView.append(
        "FBReader "
            + versionName
            + " has been crached, sorry. You can help to fix this bug by sending the report below to FBReader developers. The report will be sent by e-mail. Thank you in advance!\n\n");
    reportTextView.append(stackTrace);

    findViewById(R.id.send_report)
        .setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View view) {
                Intent sendIntent = new Intent(Intent.ACTION_SEND);
                sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"*****@*****.**"});
                sendIntent.putExtra(Intent.EXTRA_TEXT, stackTrace);
                sendIntent.putExtra(
                    Intent.EXTRA_SUBJECT, "FBReader " + versionName + " exception report");
                sendIntent.setType("message/rfc822");
                startActivity(sendIntent);
                finish();
              }
            });

    findViewById(R.id.cancel_report)
        .setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View view) {
                finish();
              }
            });
  }
  private void populateScreen() {
    setContentView(R.layout.salesitemupdate);

    Intent sender = getIntent();
    final int id = sender.getExtras().getInt("id");

    final ArrayList<SalesItemsSold> list = FundraiserCounterActivity.readGsFilex(this);

    if (list == null || id < 0 || id > list.size()) {
      return;
    }

    SalesItemsSold gscs = list.get(id);

    TextView titleView = (TextView) findViewById(R.id.salesitemfortextview);
    String gsName = gscs.getName();
    final String gsNameFinal = gsName;
    titleView.setText("Sales Items for  " + gsName);

    LinearLayout ll = (LinearLayout) findViewById(R.id.mylayoutxxyz);
    if (ll == null) {
      return;
    }

    Button emailButton = (Button) findViewById(R.id.salesitemUpdateEmailButton);
    emailButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            emailIntent.setType("plain/text");

            emailIntent.putExtra(
                android.content.Intent.EXTRA_SUBJECT,
                "Sales List as of " + (new Date()).toString());
            emailIntent.putExtra(
                android.content.Intent.EXTRA_TEXT,
                "List of Items\n" + getSalesItemListEmailString(id));
            startActivity(emailIntent);
          }
        });

    ArrayList<SalesItem> gsList = gscs.getItemsSoldList();
    int i = 0;
    int totalQuantity = 0;
    BigDecimal totalCost = BigDecimal.ZERO;

    for (Iterator<SalesItem> iterator = gsList.iterator(); iterator.hasNext(); ) {
      final SalesItem saleItem = (SalesItem) iterator.next();
      LayoutInflater linflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

      RelativeLayout rl = (RelativeLayout) linflater.inflate(R.layout.salesitemlistupdaterow, null);

      TextView tvDesc = (TextView) rl.findViewById(R.id.salesitemrowdesc);
      tvDesc.setText(saleItem.getName());

      tvDesc.setLongClickable(true);
      tvDesc.setOnLongClickListener(
          new OnLongClickListener() {
            public boolean onLongClick(View v) {
              final View vv = v;

              new AlertDialog.Builder(v.getContext())
                  .setIcon(android.R.drawable.ic_dialog_alert)
                  .setTitle("Delete Item?")
                  .setMessage("Do you want to delete\n\n" + saleItem.getName() + "?")
                  .setPositiveButton(
                      "Delete",
                      new DialogInterface.OnClickListener() {
                        public void onClick(
                            DialogInterface dialog,
                            int which) { // they have clicked on the description so remove this item
                          removeItemFromList(
                              list, gsNameFinal, saleItem.getName(), vv.getContext());
                          populateScreen();
                        }
                      })
                  .setNegativeButton("cancel", null)
                  .show();
              return true;
            }
          });

      TextView tvPrice = (TextView) rl.findViewById(R.id.salesitemrowprice);
      tvPrice.setText("" + saleItem.getCost().setScale(2));

      TextView tvQuantity = (TextView) rl.findViewById(R.id.salesitemrowquantity);
      int quantity = saleItem.getQuantity();
      totalQuantity += quantity;
      totalCost = totalCost.add(saleItem.getTotal());

      tvQuantity.setText("" + quantity);
      UpdateSalesItemLocator ucl = new UpdateSalesItemLocator(id, i, gsList);
      tvQuantity.setTag(ucl);

      TextView tvTotal = (TextView) rl.findViewById(R.id.salesitemrowtotalcost);
      tvTotal.setText(
          saleItem
              .getCost()
              .multiply(new BigDecimal(saleItem.getQuantity()))
              .setScale(2)
              .toString());

      Button plusSign = (Button) rl.findViewById(R.id.salesitemrowplus);
      plusSign.setOnClickListener(
          new View.OnClickListener() {
            public void onClick(View v) {
              (new UpdateSalesItemTotals()).updateRow(v, 1);
            }
          });

      Button plusMinus = (Button) rl.findViewById(R.id.salesitemrowminus);
      plusMinus.setOnClickListener(
          new View.OnClickListener() {
            public void onClick(View v) {
              (new UpdateSalesItemTotals()).updateRow(v, -1);
            }
          });

      ll.addView(rl);

      LayoutInflater x = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      TextView tvLine = (TextView) x.inflate(R.layout.thelineb, null);
      ll.addView(tvLine);
      i += 1;
    }

    writeTotalLine(id, ll, i, totalQuantity, totalCost);
  }