/** Called when button is clicked. */
  public void onClick(View v) {
    // Get input from user
    long n = Long.parseLong(in.getText().toString());

    Log.d(TAG, "onClicked with n=" + n);

    try {
      // Java Recursive
      long start = System.currentTimeMillis();
      long fibJR = service.fibJR(n);
      long timeJR = System.currentTimeMillis() - start;
      out.append(String.format("\nfibJR(%d)=%d (%d ms)", n, fibJR, timeJR));

      // Native Recursive
      start = System.currentTimeMillis();
      long fibNR = service.fibNR(n);
      long timeNR = System.currentTimeMillis() - start;
      out.append(String.format("\nfibNR(%d)=%d (%d ms)", n, fibNR, timeNR));

      // Java Iterative
      start = System.nanoTime();
      long fibJI = service.fibJI(n);
      long timeJI = System.nanoTime() - start;
      out.append(String.format("\nfibJI(%d)=%d (%d ns)", n, fibJI, timeJI));

      // Native Iterative
      start = System.nanoTime();
      long fibNI = service.fibNI(n);
      long timeNI = System.nanoTime() - start;
      out.append(String.format("\nfibNI(%d)=%d (%d ns)", n, fibNI, timeNI));
    } catch (RemoteException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Example #2
0
  @Override
  protected void onNewIntent(Intent intent) {
    toast("INTENT");
    // NDEF Exchange
    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
      // vibrate(500); //Vibrate for half a secondb.
      receiveTab.append("\nWe Discovered an NDEsF tag");
      NdefMessage[] msgs = getNdefData(intent);
      if (msgs == null) {
        receiveTab.append("\nThere are NO messages");
        return;
      } else {
        receiveTab.append("\nThere ARE MESSAGES");
        Toast.makeText(this, "There are messages", Toast.LENGTH_LONG).show();
      }
    } else if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) {
      receiveTab.append("\nNew  Card found");
      resolveIntent(intent); // From example on mifareclassic..blogspot
    } else if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
      receiveTab.append("\nTag found from card");
      resolveIntent(intent);
    }

    // Mifare Classic Mode
    /*
    if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction()))
    {
    	vibrate(1000); //Vibrate for a second
    	Toast.makeText(this, "Mifare Type received",
    			Toast.LENGTH_LONG).show();
    }
    */
  }
Example #3
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show);
    SharedPreferences mySharedPreference =
        getSharedPreferences("filesMTime", Activity.MODE_PRIVATE);
    SharedPreferences mySharedPreference2 =
        getSharedPreferences("filesATime", Activity.MODE_PRIVATE);
    setTitle("Notepad");
    String title = this.getIntent().getStringExtra("Name");

    showpanel = (TextView) findViewById(R.id.textView);
    showpanel.setTextSize(5.0f);
    showpanel.setTextColor(Color.BLUE);
    showpanel.append("创建时间:" + mySharedPreference2.getString(title, "") + "\n");
    showpanel.append("最后修改时间:" + mySharedPreference.getString(title, "") + "\n\n");
    showpanel.setTextSize(20.0f);
    showpanel.setTextColor(Color.BLACK);
    showpanel.append(title + ":\n");
    try {
      FileInputStream ins = openFileInput(title);
      byte[] buffer = new byte[ins.available()];
      ins.read(buffer);
      showpanel.append(new String(buffer));
      ins.close();
    } catch (Exception e) {
      // TODO 自动生成的 catch 块
      e.printStackTrace();
    }
  }
Example #4
0
  private void populateItem() {

    for (int i = 0; i < mRecipientList.size(); i++) {

      HashMap<String, String> item = (HashMap<String, String>) mRecipientList.get(i);
      String name = item.get("name");
      String status = item.get("status");
      String deviceToken = item.get("deviceToken");

      if (Boolean.parseBoolean(status) && deviceToken != null) {

        if (deviceToken.equals("Email")) {
          if (txvEmail == null) {
            txvEmail = (TextView) findViewById(R.id.txvEmail);
            txvEmail.setText(name);
          } else {
            txvEmail.append(", " + name);
          }
        } else if (deviceToken.equals("Push")) {
          if (txvDevice == null) {
            txvDevice = (TextView) findViewById(R.id.txvDevice);
            txvDevice.setText(name);
          } else {
            txvDevice.append(", " + name);
          }
        }
      }
    }
  }
        @Override
        public void onReceive(Context context, Intent intent) {
          final String action = intent.getAction();

          Log.d(TAG, "receive BLE Action :" + action);
          if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
            // 发现蓝牙服务,这时可以发送数据
            //	tv_log.append("发现蓝牙服务完成,发送同步时间命令\n");
            //	mBluetoothLeService.setSynTime();

            tv_log.append("发现蓝牙服务完成,发送获取设备WatchID命令\n");
            mBluetoothLeService.getWatchId();

          } else if (BluetoothLeService.ACTION_GATT_SERVICES_TIMEOUT.equals(action)) {
            // 蓝牙通讯超时,这里可以重发未响应的命令
            tv_log.append("蓝牙命令超时.......\n");

          } else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) {
            // 蓝牙断开
            tv_log.append("蓝牙连接断开.......\n");

          } else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
            // 接收到蓝牙数据

            byte[] bytes = intent.getByteArrayExtra(BluetoothLeService.EXTRA_DATA);
            tv_log.append("接收到数据:" + ProtocolParser.bytes2HexString(bytes) + "\n");

            pasrseData(bytes);
          }
        }
Example #6
0
  private void updateLog(String iData) {
    if (_service != null) {
      List<String> aTempOut = _service.popOutput();
      if (aTempOut != null) {
        Log.d(Tools.TAG, "Popping temporary logs (" + aTempOut.size() + " lines)");
        _logTextView.append(Tools.ToString(aTempOut));
      }
    }
    if (iData != null) _logTextView.append(iData + "\n");

    // Limit log size (allow 10% to avoid doing it on each iteration)
    if (_service != null && _logTextView.getLineCount() > 1.1 * _service._maxLogSize) {
      int excessLineNumber = _logTextView.getLineCount() - _service._maxLogSize;
      Log.d(Tools.TAG, "Truncating logs (deleting " + excessLineNumber + " lines)");
      int eolIndex = -1;
      CharSequence charSequence = _logTextView.getText();
      for (int i = 0; i < excessLineNumber; i++) {
        do {
          eolIndex++;
        } while (eolIndex < charSequence.length() && charSequence.charAt(eolIndex) != '\n');
      }
      if (eolIndex < charSequence.length()) {
        _logTextView.getEditableText().delete(0, eolIndex + 1);
      } else {
        _logTextView.setText("");
      }
    }
  }
Example #7
0
  @Click(R.id.get_purchases_button)
  public void getPurchases(View v) {
    try {
      Bundle ownedItems;
      ownedItems = billingService.getPurchases(apiLevel, getPackageName(), "inapp", null);

      if (ownedItems.getInt("RESPONSE_CODE") != 0) {
        logView.append("getPurchases Fail\n");
        return;
      }

      ArrayList<String> purchaseDataList =
          ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
      if (purchaseDataList.size() == 0) {
        logView.append("getPurchases empty\n");
      }

      for (String purchaseData : purchaseDataList) {
        logView.append("getPurchases: " + purchaseData + "\n");
      }
    } catch (RemoteException e) {
      String msg = "getPurchases: " + e.getMessage() + "\n";
      logView.append(msg);

      Log.e(TAG, msg);
      e.printStackTrace();
    }
  }
Example #8
0
 private void showSalaries() {
   tvSalaries.setText("");
   tvSalaries.append("Total Salary\tMonth\n");
   for (Salary s : salaries) {
     tvSalaries.append("" + s.getTotalSalary() + "\t\t" + s.getMonth() + "\n");
   }
 }
Example #9
0
 public void setDataFromPhone(File myFile) {
   try {
     FileReader fileReader = new FileReader(myFile);
     BufferedReader bufferedReader = new BufferedReader(fileReader);
     stopText = (TextView) findViewById(R.id.show_title);
     stopText.setText(bufferedReader.readLine().substring(0, 4));
     inboundText = (TextView) findViewById(R.id.inbound);
     inboundText.setText(bufferedReader.readLine());
     outboundText = (TextView) findViewById(R.id.outbound);
     outboundText.setText(bufferedReader.readLine());
     test = (TextView) findViewById(R.id.page_source);
     MobileDevice myDevice = new MobileDevice();
     test.setText(myDevice.getWeekday() + " " + deviceMinutes);
     test.append("\n" + bufferedReader.readLine());
     String outBoundLine = bufferedReader.readLine();
     test.append("\n" + outBoundLine);
     test.append("\nRead from phone.");
     test.append("\nNextTime: " + minutesToTime(nextTime(stringLineToArray(outBoundLine))));
     test.append("\n752 = " + minutesToTime(752));
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.eventstatus);

    try {
      getDataFromIntent();

      TextView t = (TextView) findViewById(R.id.eventStatusNameTextView);
      t.append(" " + name);
      t = (TextView) findViewById(R.id.eventStatusStartDateTextView);
      t.append(" " + startdate);
      t = (TextView) findViewById(R.id.eventStatusEndDateTextView);
      t.append(" " + enddate);

      mRoundsButton = (Button) findViewById(R.id.eventStatusRoundsButton);
      mRoundsButton.setOnClickListener(
          new View.OnClickListener() {
            public void onClick(View v) {
              Log.d(TAG, "Rounds Button Clicked.");
              LaunchRounds();
            }
          });

    } catch (JSONException e) {
      Log.e(TAG, "Exception thrown while retrieving JSON event information: " + e.toString());
    }
  }
 private void addSymbol(String upCase, String lowCase) {
   if (mSelectedMode == LAST_NAME_SELECTED) {
     if (tvLastName.length() > 0) tvLastName.append(lowCase);
     else tvLastName.append(upCase);
   } else {
     if (tvName.length() > 0) tvName.append(lowCase);
     else tvName.append(upCase);
   }
 }
Example #12
0
 /* Execute the script and switch to IRB tab*/
 private void executeScript(String name) {
   try {
     irbOutput.append("[Running " + name + "]\n");
     irbOutput.append("=> " + (new Script(name).execute()) + "\n>> ");
     tabs.setCurrentTab(IRB_TAB);
   } catch (IOException e) {
     Toast.makeText(this, "Could not open " + name, Toast.LENGTH_SHORT).show();
   }
 }
Example #13
0
 private void parseMifareTag(Tag tag) {
   MifareClassic mfc = MifareClassic.get(tag);
   try {
     mfc.connect();
     receiveTab.append("\nThis worked for Mifare");
   } catch (IOException ex) {
     receiveTab.append("\nMifare read attempt threw an error");
   }
 }
 public void onClick(View v) {
   Intent intent;
   switch (v.getId()) {
     case R.id.btnRequest:
       Log.i(TAG, "---------Step1: Get requestToken--------");
       try {
         // 向腾讯微博开放平台请求获得未授权的Request_Token
         oAuth = OAuthV1Client.requestToken(oAuth);
       } catch (Exception e) {
         e.printStackTrace();
       }
       textRequest.append(
           "\nrequest_token:\n"
               + oAuth.getOauthToken()
               + "\nrequest_token_secret:\n"
               + oAuth.getOauthTokenSecret());
       break;
     case R.id.btnAuthorize:
       Log.i(TAG, "---------Step2: authorization--------");
       Log.i(TAG, "start WebView intent");
       intent =
           new Intent(
               OAuthV1Activity.this,
               OAuthV1AuthorizeWebView.class); // 创建Intent,使用WebView让用户授权
       intent.putExtra("oauth", oAuth);
       startActivityForResult(intent, 1);
       break;
     case R.id.btnAccess:
       Log.i(TAG, "---------Step3: getAccessToken--------");
       try {
         oAuth = OAuthV1Client.accessToken(oAuth);
         /*
          * 注意:此时oauth中的Oauth_token和Oauth_token_secret将发生变化,用新获取到的
          * 已授权的access_token和access_token_secret替换之前存储的未授权的request_token
          * 和request_token_secret.
          */
       } catch (Exception e) {
         e.printStackTrace();
       }
       textAccess.append(
           "\naccess_token:\n"
               + oAuth.getOauthToken()
               + "\naccess_token_secret:\n"
               + oAuth.getOauthTokenSecret());
       break;
     case R.id.btnAPItest:
       Log.i(TAG, "---------Step4: Test API V1--------");
       intent =
           new Intent(
               OAuthV1Activity.this,
               WeiBoAPIV1Activity.class); // 创建Intent,转到调用Qweibo API的Activity
       intent.putExtra("oauth", oAuth);
       startActivity(intent);
       break;
   }
 }
Example #15
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (requestCode == this.requestCode) {
     if (resultCode == RESULT_OK) {
       logView.append("アイテムを購入\n");
     } else {
       logView.append("アイテムの購入に失敗: " + resultCode + "\n");
     }
   }
 }
Example #16
0
 /* Run the script currently in the editor */
 private void runEditorScript() {
   try {
     irbOutput.append("[Running editor script (" + currentScript.getName() + ")]\n");
     String inspected = currentScript.setContents(sourceEditor.getText().toString()).execute();
     irbOutput.append("=> " + inspected + "\n>> ");
     tabs.setCurrentTab(IRB_TAB);
   } catch (IOException e) {
     Toast.makeText(this, "Could not execute script", Toast.LENGTH_SHORT).show();
   }
 }
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    /*Set the layout to that defined in the XML file*/
    setContentView(R.layout.renderscriptprototypetwo);

    /*Bind the text view to the one found in the XML file*/
    notifyUser = (TextView) findViewById(R.id.notifyUser);

    /*Create a new RenderScript and a new object from the generated class*/
    RenderScript mRs = RenderScript.create(this);
    ScriptC_rsprototypetwo mScript =
        new ScriptC_rsprototypetwo(mRs, getResources(), R.raw.rsprototypetwo);

    /*Initialise this variable which will serve as a count for how
     * successfully data has returned from the RenderScript layer*/
    int successes = 0;

    /*Define three integer arrays*/
    int[] A = new int[1000];
    int[] B = new int[1000];
    int[] C = new int[1000];

    /*Create a new random object*/
    Random rand = new Random();

    /*Fill the two input arrays with random numbers between 1 and 10*/
    for (int i = 0; i < A.length; i++) {
      A[i] = (int) (int) Math.round(rand.nextInt(10));
      B[i] = (int) (int) Math.round(rand.nextInt(10));
    }

    /*Create a new object from the intOperationsRS class*/
    intOperationsRS intOp = new intOperationsRS();

    /*Call the integer addition function*/
    C = intOp.intAdd(A, B, mRs, mScript);

    /*Notify the user that the test is complete, and display the
     * result for the success rate. */
    notifyUser.append("\n Integer Additon Test Complete!");
    calculateSuccessRate(successes, C);

    /*Provide the user with some feedback about this prototype*/
    notifyUser.append("\n The disadvantages of this program are:");
    notifyUser.append(
        "\n 1. The data takes a long time to return from RenderScript,"
            + "so a significant delay has been added which slows down the running a lot.");
    notifyUser.append(
        "\n 2. Because of this delay, that determines the rate at which this "
            + "program runs, it is the rate determining step if you will. Need to find a way of "
            + "benchmarking the processing of array elements.");
  }
Example #18
0
  /**
   * Fills the text views in the current view with all of messages to send array and messages to
   * receive array
   */
  private void updateTextViews() {
    messagesToSend.setText("Messages to send: \n");
    for (int counter = 0; counter < messagesToSendQueue.size(); counter++) {
      messagesToSend.append(messagesToSendQueue.get(counter) + "\n");
    }

    receivedMessageOutput.setText("Messages to receive: \n");
    for (int counter = 0; counter < messagesToReceiveQueue.size(); counter++) {
      receivedMessageOutput.append(messagesToReceiveQueue.get(counter) + "\n");
    }
  }
  private void setDeliveryData() {
    TextView head = (TextView) findViewById(R.id.header);
    TextView tv = (TextView) findViewById(R.id.delivery);

    head.append(application.current_delivery.id.toString());

    tv.setText(
        "Number of packages: " + application.current_delivery.packages.size() + "\nLocations:\n");
    for (Location l : application.current_delivery.locations.values())
      tv.append("\t\t" + l.name + " - " + l.deadline + "\n");
    tv.append("Route Length: " + application.current_delivery.route.length);
  }
Example #20
0
 private void displayCurrentInfoFromReading(BgReading lastBgReading, boolean predictive) {
   double estimate = 0;
   if ((new Date().getTime()) - (60000 * 11) - lastBgReading.timestamp > 0) {
     notificationText.setText("Signal Missed");
     if (!predictive) {
       estimate = lastBgReading.calculated_value;
     } else {
       estimate = BgReading.estimated_bg(lastBgReading.timestamp + (6000 * 7));
     }
     currentBgValueText.setText(bgGraphBuilder.unitized_string(estimate));
     currentBgValueText.setPaintFlags(
         currentBgValueText.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
     dexbridgeBattery.setPaintFlags(
         dexbridgeBattery.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
   } else {
     if (notificationText.getText().length() == 0) {
       notificationText.setTextColor(Color.WHITE);
     }
     if (!predictive) {
       estimate = lastBgReading.calculated_value;
       String stringEstimate = bgGraphBuilder.unitized_string(estimate);
       String slope_arrow = lastBgReading.slopeArrow();
       if (lastBgReading.hide_slope) {
         slope_arrow = "";
       }
       currentBgValueText.setText(stringEstimate + " " + slope_arrow);
     } else {
       estimate = BgReading.activePrediction();
       String stringEstimate = bgGraphBuilder.unitized_string(estimate);
       currentBgValueText.setText(stringEstimate + " " + BgReading.activeSlopeArrow());
     }
   }
   int minutes = (int) (System.currentTimeMillis() - lastBgReading.timestamp) / (60 * 1000);
   notificationText.append("\n" + minutes + ((minutes == 1) ? " Minute ago" : " Minutes ago"));
   List<BgReading> bgReadingList = BgReading.latest(2);
   if (bgReadingList != null && bgReadingList.size() == 2) {
     // same logic as in xDripWidget (refactor that to BGReadings to avoid redundancy / later
     // inconsistencies)?
     if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
       notificationText.append("  ");
     } else {
       notificationText.append("\n");
     }
     notificationText.append(bgGraphBuilder.unitizedDeltaString(true, true));
   }
   if (bgGraphBuilder.unitized(estimate) <= bgGraphBuilder.lowMark) {
     currentBgValueText.setTextColor(Color.parseColor("#C30909"));
   } else if (bgGraphBuilder.unitized(estimate) >= bgGraphBuilder.highMark) {
     currentBgValueText.setTextColor(Color.parseColor("#FFBB33"));
   } else {
     currentBgValueText.setTextColor(Color.WHITE);
   }
 }
 public void run() {
   // TODO Auto-generated method stub
   try {
     // statusmsg.append(sequence_number);
     statusmsg.append(sequence);
     statusmsg.append(",");
     statusmsg.append(teststr);
     statusmsg.append("\n");
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Example #22
0
 private void manageIntent(Intent intent) {
   try {
     Tag tag = intent.getExtras().getParcelable(NfcAdapter.EXTRA_TAG);
     if (tag != null) {
       String msg = TULReader.readStrings(tag)[0];
       txt.append(msg);
       txt.append("\n");
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
        @Override
        public void onReceive(Context context, Intent intent) {

          Bundle extras = intent.getExtras();
          if (extras != null) {

            String action = intent.getAction();

            if (action.equals("UPLOAD_METADATA")) {

              ProgressBar pbar = (ProgressBar) findViewById(R.id.progressBar1);
              pbar.setVisibility(View.GONE);

              TextView txt = (TextView) findViewById(R.id.metadataSaved);

              Button btnClose = (Button) findViewById(R.id.btnClose);
              btnClose.setOnClickListener(
                  new View.OnClickListener() {
                    public void onClick(View v) {
                      finish();
                    }
                  });
              btnClose.setVisibility(View.VISIBLE);
              findViewById(R.id.progressBar1).setVisibility(View.GONE);

              Boolean success = extras.getBoolean("UPLOAD_METADATA");
              if (success == true) {
                Toast.makeText(getBaseContext(), "Metadata uploaded!", Toast.LENGTH_SHORT).show();

                txt.append("Uploaded succesfully");

              } else if (success == false) {
                Toast.makeText(
                        getBaseContext(),
                        "Error uploading, problem with authentication?",
                        Toast.LENGTH_LONG)
                    .show();

                txt.append("Error in uploading. Check username and password");

                Button btnVrest = (Button) findViewById(R.id.btnVrestSettings);
                btnVrest.setOnClickListener(
                    new View.OnClickListener() {
                      public void onClick(View v) {
                        startActivity(new Intent("tut.heikki.accountsettings"));
                      }
                    });
                btnVrest.setVisibility(View.VISIBLE);
              }
            }
          }
        }
Example #24
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_c);
    openActivityBButton = (Button) findViewById(R.id.button);
    openActivityCButton = (Button) findViewById(R.id.button2);
    messageTextView = (TextView) findViewById(R.id.messageTextView);
    Intent receivedIntent = getIntent();
    final ArrayList<String> list = receivedIntent.getStringArrayListExtra(KeyHelper.DATA);

    if (list != null) {
      TextView myText = new TextView(this);
      for (int i = 0; i < list.size(); i++) {
        myText.append(list.get(i));
        myText.append("\n");
      }
      messageTextView.setText(myText.getText());
    }
    View.OnClickListener ocl =
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            Intent launchActivityIntent = new Intent(ActivityC.this, ActivityB.class);

            String dataString = "then was opened by Activity C";

            list.add(dataString);
            launchActivityIntent.putStringArrayListExtra(KeyHelper.DATA, list);

            startActivity(launchActivityIntent);
          }
        };
    openActivityBButton.setOnClickListener(ocl);

    View.OnClickListener ocl2 =
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            Intent launchActivityIntent = new Intent(ActivityC.this, ActivityB.class);

            String dataString = "then was opened by Activity C";

            list.add(dataString);
            launchActivityIntent.putStringArrayListExtra(KeyHelper.DATA, list);

            startActivity(launchActivityIntent);
          }
        };
    openActivityCButton.setOnClickListener(ocl2);
  }
  private void printTreeNodeInfo(ArrayList<TreeNodeObject> treeList) {

    for (TreeNodeObject mChildNode : treeList) {
      mText.append("obj.getScene_img_id() : " + mChildNode.getScene_img_id() + "\n");
      mText.append("obj.isRoot() : " + mChildNode.isRoot() + "\n");

      for (ChildCoordObject child_coord : mChildNode.getChildren_coord()) {
        mText.append("child_coord.getX():" + child_coord.getX() + "\n");
        mText.append("child_coord.getY():" + child_coord.getY() + "\n");
        mText.append("child_coord.getZ():" + child_coord.getZ() + "\n");
      }
    }
  }
Example #26
0
  public void addChatMessage(Spannable text) {
    chatText.append(text);
    chatText.append(Html.fromHtml("<br>"));

    chatScroll.post(
        new Runnable() {

          @Override
          public void run() {
            chatScroll.smoothScrollTo(0, chatText.getHeight());
          }
        });
  }
 public AlertDialog lookDetailDialog(final WinPrizeQueryInfo info) {
   LayoutInflater factory = LayoutInflater.from(this);
   /* 中奖查询的查看详情使用余额查询的布局 */
   View view = factory.inflate(R.layout.win_detail, null);
   final AlertDialog dialog = new AlertDialog.Builder(this).create();
   TextView lotkind = (TextView) view.findViewById(R.id.gift_detail_text_lotno);
   TextView batchcode = (TextView) view.findViewById(R.id.gift_detail_text_batchcode);
   TextView dingdanno = (TextView) view.findViewById(R.id.gift_detail_text_dingdan);
   TextView beishu = (TextView) view.findViewById(R.id.gift_detail_text_beishu);
   TextView zhushu = (TextView) view.findViewById(R.id.gift_detail_text_zhushu);
   TextView atm = (TextView) view.findViewById(R.id.gift_detail_text_atm);
   TextView statetext = (TextView) view.findViewById(R.id.gift_detail_text_state);
   TextView bettime = (TextView) view.findViewById(R.id.gift_detail_tex_gifttime);
   TextView content = (TextView) view.findViewById(R.id.gift_detail_text_content);
   TextView person = (TextView) view.findViewById(R.id.gift_detail_text_person);
   TextView kaijianghao = (TextView) view.findViewById(R.id.gift_detail_text_kaijianghao);
   TextView atmz = (TextView) view.findViewById(R.id.gift_detail_text_atmzhong);
   TextView cashtime = (TextView) view.findViewById(R.id.gift_detail_tex_time);
   final String lotno = info.getLotNo();
   lotkind.append(info.getLotName());
   if (lotno.equals("J00001")
       || lotno.equals("J00002")
       || lotno.equals("J00003")
       || lotno.equals("J00004")
       || lotno.equals(Constants.LOTNO_JCLQ)
       || lotno.equals(Constants.LOTNO_JCLQ_DXF)
       || lotno.equals(Constants.LOTNO_JCLQ_RF)
       || lotno.equals(Constants.LOTNO_JCLQ_SFC)) {
     batchcode.setVisibility(View.GONE);
   } else {
     batchcode.setVisibility(TextView.VISIBLE);
     batchcode.append(info.getBatchCode());
   }
   dingdanno.append(info.getOrderId());
   beishu.append(info.getLotMulti());
   zhushu.append(info.getBetNum());
   final String FormatAmount = PublicMethod.toYuan(info.getAmount());
   atm.append(FormatAmount + "元");
   atmz.append(PublicMethod.toYuan(info.getWinAmount()) + "元");
   cashtime.append(info.getCashTime());
   person.setVisibility(View.GONE);
   statetext.setVisibility(View.GONE);
   kaijianghao.setVisibility(View.GONE);
   bettime.append(info.getSellTime());
   content.setText(Html.fromHtml("方案内容:<br>" + info.getBetCodeHtml()));
   Button cancleLook = (Button) view.findViewById(R.id.gift_detail_img_cannle);
   cancleLook.setOnClickListener(
       new OnClickListener() {
         public void onClick(View v) {
           dialog.cancel();
         }
       });
   dialog.show();
   dialog.getWindow().setContentView(view);
   return dialog;
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_home, container, false);

    try {
      /*
      Replace the string in the apiMethod with the API you want to access. You can use system/get_token/, user/auth, etc
       */
      String apiMethod = "system/get_token";
      JSONObject tokenObj =
          new APIRequest().execute("http://www.buyctgrown.com/api/" + apiMethod).get();
      tokenstr = tokenObj.getString("token").toString();

      String apiMethod1 = "ct/stats";
      JSONObject tokenObj1 =
          new APIRequest1().execute("http://www.buyctgrown.com/api/" + apiMethod1).get();

      TextView textView = (TextView) view.findViewById(R.id.textView);

      JSONObject index = (JSONObject) tokenObj1.getJSONObject("raw_data");
      String people = index.getString("people").toString();
      String businesses = index.getString("businesses").toString();
      String locally = index.getString("locally").toString();

      double peoplePD = Double.parseDouble(people);
      DecimalFormat peopleformatter = new DecimalFormat("#,###");
      String peopleF = peopleformatter.format(peoplePD);

      double locallyPD = Double.parseDouble(locally);
      DecimalFormat locallyformatter = new DecimalFormat("#,###,###");
      String locallyF = locallyformatter.format(locallyPD);

      textView.setText(Html.fromHtml("<font color='#e64a19'>" + peopleF + "</font>"));
      textView.append(" PEOPLE and ");
      textView.append(Html.fromHtml("<font color='#e64a19'>" + businesses + "</font>"));
      textView.append(" BUSINESSES SPENT ");
      textView.append(Html.fromHtml("<font color='#e64a19'>" + "$" + locallyF + "</font>"));
      textView.append(" LOCALLY since August 2013");

    } catch (ExecutionException e1) {
      System.out.println("ExecutionException");
    } catch (InterruptedException e2) {
      System.out.println("InterruptedException");
    } catch (JSONException e3) {
      System.out.println("JSONException");
    }
    return view;
  }
Example #29
0
 private void printMessage(NdefRecord record) {
   byte[] id; // Id of the record
   short tnf; // TNF: See android.nfc.NdefRecord
   byte[] payload; // Payload of the record (the actual message)
   String finalMessage, id_string;
   id = record.getId();
   tnf = record.getTnf();
   payload = record.getPayload();
   id_string = DataConversion.bytesToASCIIString(id);
   receiveTab.append("\nID is " + id_string);
   receiveTab.append("\nTNF is " + tnf);
   finalMessage = DataConversion.bytesToASCIIString(payload);
   receiveTab.append("\n" + finalMessage + "\n");
 }
Example #30
0
 /**
  * Print a status message from a callback (or some other place) to the TextView in this activity
  *
  * @param status Status message
  */
 private void logStatus(String status) {
   Log.i("SpotifySdkDemo", status);
   if (!TextUtils.isEmpty(mStatusText.getText())) {
     mStatusText.append("\n");
   }
   mStatusText.append(status);
   mStatusTextScrollView.post(
       new Runnable() {
         @Override
         public void run() {
           // Scroll to the bottom
           mStatusTextScrollView.fullScroll(View.FOCUS_DOWN);
         }
       });
 }