@Override
 public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
   if (parent == mSpinnerGeology) {
     geologyIndex = position;
     new PreferencesUtil(getContext()).save("geologyIndex", geologyIndex);
     initConditions(getActivity());
     initConditions(getActivity());
     initConditiontValue(getActivity());
     changeAllGeology();
   }
   if (parent == mSpinnerCondition) {
     conditionIndex = position;
     initConditions(getActivity());
     initConditiontValue(getActivity());
   }
   if (parent == mSpinnerConditionValue) {
     conditionValueIndex = position;
   }
   String selectItem = null;
   try {
     selectItem = mSpinnerConditionValue.getSelectedItem().toString();
   } catch (Exception e) {
     e.printStackTrace();
   }
   slog.p(TAG, "selectItem " + selectItem);
   if (mETValue1 != null && mETValue2 != null) {
     if (selectItem != null && selectItem.equals("自定义")) {
       mETValue1.setVisibility(View.VISIBLE);
       mETValue2.setVisibility(View.VISIBLE);
     } else {
       mETValue1.setVisibility(View.GONE);
       mETValue2.setVisibility(View.GONE);
     }
   }
 }
    @Override
    protected String[] doInBackground(String... params) {
      // bankNumber:银行卡号 accountNumber:证件号 mobile:手机号码 accountname:用户姓名

      FastpayBean fastpayBean = new FastpayBean();
      fastpayBean.setService("query_timestamp");
      fastpayBean.setPartner(Url.Partner);
      fastpayBean.setSign_type("MD5");
      fastpayBean.setInput_charset("UTF-8");

      String urlPath = "https://www.ebatong.com/gateway.htm";
      urlPath += "?service=query_timestamp";
      urlPath =
          urlPath
              + "&partner="
              + Url.Partner
              + "&input_charset=UTF-8&sign_type=MD5&sign="
              + fastpayBean.getNeedSignCode();

      Log.i("lyjtest", "urlPath:" + urlPath);

      String[] result = new String[2];
      InputStream is = null;
      try {
        is = NetTool.sendGetData(urlPath);
        result = NetTool.readXML(is);
      } catch (Exception e) {
        e.printStackTrace();
      }

      return result;
    }
    @Override
    protected String doInBackground(String... params) {
      // bankNumber:银行卡号 accountNumber:证件号 mobile:手机号码 accountname:用户姓名

      FastpayBean fastpayBean = new FastpayBean();
      fastpayBean.setService("ebatong_mp_unbind");
      fastpayBean.setPartner(Url.Partner);
      fastpayBean.setSign_type("MD5");
      fastpayBean.setInput_charset("UTF-8");
      fastpayBean.setBank_card_no(getIntent().getStringExtra("bankNumber"));
      fastpayBean.setOut_trade_no(billno);
      fastpayBean.setPhone(getIntent().getStringExtra("phone"));
      fastpayBean.setNotify_url("www.hao123.com");
      fastpayBean.setCustomerId(PreferenceUtils.getUserId() + "");
      fastpayBean.setSubject("描述");

      String urlPath = "https://www.ebatong.com/mobileFast/unbind.htm";
      String postJson = fastpayBean.getPostJson();
      Log.i("lyjtest", "getPostJson:" + postJson);
      byte[] data = postJson.getBytes();
      InputStream is = null;
      try {
        is = NetTool.sendXMLData(urlPath, data, "UTF-8");
        data = NetTool.readStream(is);
        Log.i("lyjtest", new String(data));
      } catch (Exception e) {
        e.printStackTrace();
      }

      return new String(data);
    }
Example #4
0
  protected void onListItemClick(ListView l, View v, int position, long id) {
    ProfilerAudioAdapter profileAudioAdapter = (ProfilerAudioAdapter) getListAdapter();
    String selectedValue = profileAudioAdapter.getItem(position);
    Toast.makeText(this, selectedValue, Toast.LENGTH_SHORT).show();

    GetFile task = new GetFile();
    String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
    File folder = new File(extStorageDirectory, "Audio");
    folder.mkdir();
    ArrayList<String> params = new ArrayList<String>();
    params.add(fileLocation[position]);
    params.add(fileName[position]);
    params.add(String.valueOf(folder));
    task.execute(new ArrayList[] {params});

    try {
      Intent intent = new Intent();
      intent.setAction(Intent.ACTION_VIEW);
      File fileToRead = new File(folder + "/" + fileName[position]);
      Uri uri = Uri.fromFile(fileToRead.getAbsoluteFile());
      intent.setDataAndType(uri, "audio/mp3");
      startActivity(intent);
    } catch (ActivityNotFoundException activityNotFoundException) {
      activityNotFoundException.printStackTrace();
      Toast.makeText(this, "There doesn't seem to be an Audio player installed.", Toast.LENGTH_LONG)
          .show();
    } catch (Exception ex) {
      ex.printStackTrace();
      Toast.makeText(this, "Cannot open the selected file.", Toast.LENGTH_LONG).show();
    }
  }
 /**
  * 获取所有会话
  *
  * @return +
  */
 private List<EMConversation> loadConversationsWithRecentChat() {
   // 获取所有会话,包括陌生人
   Hashtable<String, EMConversation> conversations =
       EMChatManager.getInstance().getAllConversations();
   // 过滤掉messages size为0的conversation
   /**
    * 如果在排序过程中有新消息收到,lastMsgTime会发生变化 影响排序过程,Collection.sort会产生异常 保证Conversation在Sort过程中最后一条消息的时间不变
    * 避免并发问题
    */
   List<Pair<Long, EMConversation>> sortList = new ArrayList<Pair<Long, EMConversation>>();
   synchronized (conversations) {
     for (EMConversation conversation : conversations.values()) {
       if (conversation.getAllMessages().size() != 0) {
         // if(conversation.getType() != EMConversationType.ChatRoom){
         sortList.add(
             new Pair<Long, EMConversation>(
                 conversation.getLastMessage().getMsgTime(), conversation));
         // }
       }
     }
   }
   try {
     // Internal is TimSort algorithm, has bug
     sortConversationByLastChatTime(sortList);
   } catch (Exception e) {
     e.printStackTrace();
   }
   List<EMConversation> list = new ArrayList<EMConversation>();
   for (Pair<Long, EMConversation> sortItem : sortList) {
     list.add(sortItem.second);
   }
   return list;
 }
Example #6
0
  public List parsePage(String pageCode) {
    List sections = new ArrayList();
    List folders = new ArrayList();
    List files = new ArrayList();
    int start = pageCode.indexOf("<div id=\"list-view\" class=\"view\"");
    int end = pageCode.indexOf("<div id=\"gallery-view\" class=\"view\"");
    String usefulSection = "";
    if (start != -1 && end != -1) {
      usefulSection = pageCode.substring(start, end);
    } else {
      debug("Could not parse page");
    }
    try {
      DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      InputSource is = new InputSource();
      is.setCharacterStream(new StringReader(usefulSection));
      Document doc = db.parse(is);

      NodeList divs = doc.getElementsByTagName("div");
      for (int i = 0; i < divs.getLength(); i++) {
        Element div = (Element) divs.item(i);
        boolean isFolder = false;
        if (div.getAttribute("class").equals("filename")) {
          NodeList imgs = div.getElementsByTagName("img");
          for (int j = 0; j < imgs.getLength(); j++) {
            Element img = (Element) imgs.item(j);
            if (img.getAttribute("class").indexOf("folder") > 0) {
              isFolder = true;
            } else {
              isFolder = false; // it's a file
            }
          }

          NodeList anchors = div.getElementsByTagName("a");
          Element anchor = (Element) anchors.item(0);
          String attr = anchor.getAttribute("href");
          String fileName = anchor.getAttribute("title");
          String fileURL;
          if (isFolder && !attr.equals("#")) {
            folders.add(attr);
            folders.add(fileName);
          } else if (!isFolder && !attr.equals("#")) {
            // Dropbox uses ajax to get the file for download, so the url isn't enough. We must be
            // sneaky here.
            fileURL = "https://dl.dropbox.com" + attr.substring(23) + "?dl=1";
            files.add(fileURL);
            files.add(fileName);
          }
        }
      }
    } catch (Exception e) {
      debug(e.toString());
    }

    sections.add(files);
    sections.add(folders);

    return sections;
  }
 /**
  * This method takes a string as an argument; Decrypts it and return it as a string. Or it returns
  * null
  *
  * @param text of type string
  * @return a string
  */
 public static final String decrypt(String data) {
   try {
     return new String(decrypt(hex2byte(data.getBytes())));
   } catch (Exception e5) {
     e5.printStackTrace();
   }
   return null;
 }
 /**
  * This method takes a string as an argument; Encrypts it and return it as a string. Or it returns
  * null
  *
  * @param text of type string
  * @return a string
  */
 public static final String encrypt(String text) {
   try {
     return byte2hex(encrypt(text, pubKey));
   } catch (Exception e4) {
     e4.printStackTrace();
   }
   return null;
 }
 @Override
 public void onClick(View view) {
   switch (view.getId()) {
     case R.id.back:
       finish();
       break;
     case R.id.button_djs:
       // 点击获得验证码
       try {
         isMobileNet = HttpUtils.isMobileDataEnable(getApplicationContext());
         isWifiNet = HttpUtils.isWifiDataEnable(getApplicationContext());
         if (!isMobileNet && !isWifiNet) {
           Toast.makeText(this, R.string.network_error, Toast.LENGTH_SHORT).show();
           return;
         }
       } catch (Exception e) {
         e.printStackTrace();
       }
       mobile_str = mobile.getText().toString();
       if (StringUtil.isNullOrEmpty(mobile_str)) {
         Toast.makeText(this, R.string.reg_error_one, Toast.LENGTH_SHORT).show();
         return;
       }
       button_djs.setClickable(false); // 不可点击
       MyTimer myTimer = new MyTimer(60000, 1000);
       myTimer.start();
       getCard();
       break;
     case R.id.next:
       // 下一步
       try {
         isMobileNet = HttpUtils.isMobileDataEnable(getApplicationContext());
         isWifiNet = HttpUtils.isWifiDataEnable(getApplicationContext());
         if (!isMobileNet && !isWifiNet) {
           Toast.makeText(this, R.string.network_error, Toast.LENGTH_SHORT).show();
           return;
         }
       } catch (Exception e) {
         e.printStackTrace();
       }
       mobile_str = mobile.getText().toString();
       card_str = card.getText().toString();
       if (StringUtil.isNullOrEmpty(mobile_str)) {
         Toast.makeText(this, R.string.reg_error_one, Toast.LENGTH_SHORT).show();
         return;
       }
       if (StringUtil.isNullOrEmpty(card_str)) {
         Toast.makeText(this, R.string.reg_error_five, Toast.LENGTH_SHORT).show();
         return;
       }
       getReg();
       break;
     case R.id.quest:
       // 问题
       break;
   }
 }
  public void mediaControls(View view) {
    switch (view.getId()) {
      case R.id.recordbutton:
        // TODO Auto-generated method stub
        if (recording) {
          mediaRecorder.stop();
          releaseMediaRecorder();
          camerabtn.setBackgroundDrawable(
              getResources().getDrawable(R.drawable.button_notrecording));

          SavePreferences("customVideoPath", customVideoPath.toString());
          SavePreferences("MEDIA_TYPE", "5");
          Intent intent = new Intent(media_Video.this, categories_Writemessage.class);
          startActivity(intent);
          finish();

        } else {
          releaseCamera();
          if (!prepareMediaRecorder()) {
            finish();
          }
          try {
            mediaRecorder.start();
            doInBackground();
            gotimer();
          } catch (Exception e) {
            e.printStackTrace();
          }
          camerabtn.setBackgroundDrawable(
              getResources().getDrawable(R.drawable.button_isrecording));
          recording = true;
        }
        break;

      case R.id.flashbutton:
        if (!flashLight) {
          flashLight = true;
          flashbtn.setBackgroundDrawable(getResources().getDrawable(R.drawable.camera_flash));
        } else {
          flashLight = false;
          flashbtn.setBackgroundDrawable(getResources().getDrawable(R.drawable.camera_flashoff));
        }
        break;

      case R.id.switchbtn:
        switchCameras();
        break;

      case R.id.backbtn:
        finish();
        if (isPLaying == true) {
          player.stop();
          isPLaying = false;
        }
        break;
    }
  }
  public void onSensorChanged(String sensorStr) {
    Log.v(TAG, "onSensorChanged : " + sensorStr);

    String[] fs = sensorStr.split(",");
    if (fs.length == 4) {
      acceValusW = Float.parseFloat(fs[0]) * (BASE - 10);
      // 获得x轴的值
      acceValusX = Float.parseFloat(fs[1]) * (BASE - 10);
      // 获得y轴的值
      acceValusY = Float.parseFloat(fs[2]) * (BASE - 10);
      // 获得z轴的值
      acceValusZ = Float.parseFloat(fs[3]) * (BASE - 10);
      // 锁定整个SurfaceView
      Canvas mCanvas = mSurfaceHolder.lockCanvas();
      try {
        if (mCanvas != null) {
          // 画笔的颜色(红)
          mPaint.setColor(Color.RED);
          // 画X轴的点
          mCanvas.drawPoint(x, (int) (BASE + acceValusX), mPaint);
          // 画笔的颜色(绿)
          mPaint.setColor(Color.GREEN);
          // 画Y轴的点
          mCanvas.drawPoint(x, (int) (BASE * 2 + acceValusY), mPaint);
          // 画笔的颜色(蓝)
          mPaint.setColor(Color.CYAN);
          // 画Z轴的点
          mCanvas.drawPoint(x, (int) (BASE * 3 + acceValusZ), mPaint);
          // 画笔的颜色(huang)
          mPaint.setColor(Color.WHITE);
          // 画W轴的点
          mCanvas.drawPoint(x, (int) (BASE * 4 + acceValusW), mPaint);
          // 横坐标+1

          x++;
          // 如果已经画到了屏幕的最右边
          // if (x > getWindowManager().getDefaultDisplay().getWidth()) {
          if (x > mCanvas.getWidth()) {
            x = 0;
            // 清屏
            mCanvas.drawColor(Color.BLACK);
          }
          // 绘制完成,提交修改
          mSurfaceHolder.unlockCanvasAndPost(mCanvas);
        }
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        if (mCanvas != null) {
          // 重新锁一次
          mSurfaceHolder.lockCanvas(new Rect(0, 0, 0, 0));
          mSurfaceHolder.unlockCanvasAndPost(mCanvas);
        }
      }
    }
  }
 private Camera getCameraInstance(int x) {
   // TODO Auto-generated method stub
   Camera c = null;
   try {
     c = Camera.open(x); // attempt to get a Camera instance
   } catch (Exception e) {
     e.printStackTrace();
   }
   return c; // returns null if camera is unavailable
 }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == Activity.RESULT_OK) {
      String sdStatus = Environment.getExternalStorageState();
      if (!sdStatus.equals(Environment.MEDIA_MOUNTED)) { // 检测sd是否可用
        Log.i("TestFile", "SD card is not avaiable/writeable right now.");
        return;
      }
      String name =
          new DateFormat().format("yyyyMMdd_hhmmss", Calendar.getInstance(Locale.CHINA)) + ".jpg";
      Toast.makeText(this, name, Toast.LENGTH_LONG).show();
      Bundle bundle = data.getExtras();
      Bitmap bitmap = (Bitmap) bundle.get("data"); // 获取相机返回的数据,并转换为Bitmap图片格式

      FileOutputStream b = null;
      File file = new File("/sdcard/myImage/");
      if (!file.exists()) file.mkdirs(); // 创建文件夹

      String fileName = "/sdcard/myImage/" + name;
      File photofile = new File(fileName);
      if (!photofile.exists()) {
        try {
          photofile.createNewFile();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      try {
        b = new FileOutputStream(photofile);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, b); // 把数据写入文件
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        try {
          b.flush();
          b.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      // 动态的改变gridview中的一个Item的内容
      bitmapList.set(currentIndex, bitmap);
      myGalleryAdapter.notifyDataSetChanged();
      updatePhoto(
          Long.valueOf(phoneNumberToId.get(phoneNumber.get(currentIndex))), bitmapToBytes(bitmap));
      //            ((ImageView) findViewById(R.id.imageView)).setImageBitmap(bitmap);//
      // 将图片显示在ImageView里
      Intent intent = new Intent(ContactActivity.this, ContactActivity.class);
      this.startActivity(intent);
      this.finish();
    }
  }
Example #14
0
  private Bitmap getVideoDrawable(String path) throws OutOfMemoryError {

    try {
      Bitmap thumb =
          ThumbnailUtils.createVideoThumbnail(path, MediaStore.Images.Thumbnails.MINI_KIND);
      return thumb;
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
Example #15
0
 public String getData(String url) {
   HttpClient client = new DefaultHttpClient();
   HttpGet get = new HttpGet(url);
   String response = "";
   try {
     ResponseHandler<String> responseHandler = new BasicResponseHandler();
     response = client.execute(get, responseHandler);
   } catch (Exception e) {
     debug(e.toString());
   }
   return response;
 }
 private double getEditValue(EditText etvalue) {
   try {
     if (etvalue.getVisibility() == View.VISIBLE) {
       double value = Double.parseDouble(etvalue.getText().toString());
       return value;
     }
   } catch (Exception e) {
     slog.e(TAG, "getMaxValue error mETValue1.getText() " + etvalue.getText());
     e.printStackTrace();
   }
   return -1;
 }
    @Override
    protected String doInBackground(String... params) {
      // bankNumber:银行卡号 accountNumber:证件号 mobile:手机号码 accountname:用户姓名

      FastpayBean fastpayBean = new FastpayBean();
      fastpayBean.setService("create_direct_pay_by_mp");
      fastpayBean.setPartner(Url.Partner);
      fastpayBean.setSign_type("MD5");
      fastpayBean.setInput_charset("UTF-8");
      fastpayBean.setBank_card_no(bankid);

      fastpayBean.setCardHolderName(name);

      fastpayBean.setIdType("01");
      fastpayBean.setCardHolderId(idcard);

      fastpayBean.setPhone(phone);
      fastpayBean.setOut_trade_no(params[0]);
      fastpayBean.setTotal_fee(params[3]); // (8,2) 位数至少2位
      fastpayBean.setSign_type("MD5");
      fastpayBean.setNotify_url("www.hao123.com");
      fastpayBean.setToken(params[1]);
      fastpayBean.setValidCode(params[2]);
      fastpayBean.setCustomerId(PreferenceUtils.getUserId() + "");
      fastpayBean.setDefault_bank(bank_code);

      fastpayBean.setExter_invoke_ip("11.11.11.11");
      fastpayBean.setAnti_phishing_key(params[4]);

      fastpayBean.setSubject("txwl");
      fastpayBean.setBody("spms");
      fastpayBean.setShow_url("spzs");
      fastpayBean.setExtend_param("ggcs");
      fastpayBean.setExtra_common_param("hccs");
      fastpayBean.setPay_method("");
      //            fastpayBean.setBankId("CCB");

      String urlPath = "https://www.ebatong.com/mobileFast/pay.htm";
      String postJson = fastpayBean.getPostJson();
      Log.i("lyjtest", "getPostJson:" + postJson);
      byte[] data = postJson.getBytes();
      InputStream is = null;
      try {
        is = NetTool.sendXMLData(urlPath, data, "UTF-8");
        data = NetTool.readStream(is);
        Log.i("lyjtest", new String(data));
      } catch (Exception e) {
        e.printStackTrace();
      }

      return new String(data);
    }
Example #18
0
 @Override
 protected Void doInBackground(Integer... params) {
   try {
     Log.v("drive", "2exit");
     if (driver.drive2Exit() == false) {
       Toast.makeText(StatePlay.this, "Fuel Empty", Toast.LENGTH_SHORT).show();
       Intent i = new Intent(StatePlay.this, AMazeActivity.class);
       startActivity(i);
     }
   } catch (Exception e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return (null);
 }
Example #19
0
 public String getClasses() {
   String name = "";
   try {
     URL site = new URL("http://www.marksonvisuals.com/sitapp/cc.php");
     URLConnection yc = site.openConnection();
     BufferedReader out = new BufferedReader(new InputStreamReader(yc.getInputStream()));
     String inputLine;
     while ((inputLine = out.readLine()) != null) {
       name += inputLine + "\n";
     }
     out.close();
   } catch (Exception e) {
     e.printStackTrace();
   }
   return name.trim();
 }
 private void sendExceptionMsg(int what, Exception e) {
   e.printStackTrace();
   Message msg = Message.obtain();
   msg.obj = e;
   msg.what = what;
   queryHandler.sendMessage(msg);
 }
Example #21
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   try {
     if (resultCode == TickerMonitorEditActivity.APPLY_RESULT) {
       Monitor.Data monitorData =
           data.getExtras().getParcelable(TickerMonitorEditActivity.MONITOR_DATA);
       long id = data.getLongExtra(TickerMonitorEditActivity.MONITOR_ID, -1);
       if (monitorData != null
           && id != -1) { // we might get null if something went wrong in the edit activity
         monitoringService.applyMonitorChange(id, monitorData);
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  private void failure(Exception use) {
    Log.e(VisualVoicemail.LOG_TAG, "Failure", use);
    String toastText = getString(R.string.account_setup_bad_uri, use.getMessage());

    Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_LONG);
    toast.show();
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.receiver);

    final Button cancelbtn = (Button) findViewById(R.id.ButtonCancel);
    // cancelbtn.setEnabled(false);
    cancelbtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // streamtask.cancel(true);
            finish();
          }
        });

    try {
      Intent intent = getIntent();
      String action = intent.getAction();
      String type = intent.getType();

      if ((!(Intent.ACTION_SEND.equals(action))) || (type == null)) {
        throw new RuntimeException("Unknown intent action or type");
      }

      if (!("text/plain".equals(type))) {
        throw new RuntimeException("Type is not text/plain");
      }

      String extra = intent.getStringExtra(Intent.EXTRA_TEXT);
      if (extra == null) {
        throw new RuntimeException("Cannot get shared text");
      }

      final DownloadStreamTask streamtask = new DownloadStreamTask(this);

      //	Once created, a task is executed very simply:
      streamtask.execute(extra);

    } catch (Exception e) {
      Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
    }
  }
Example #24
0
 public void mOnClick(View v) {
   switch (v.getId()) {
     case R.id.test:
       String rootdir = Environment.getRootDirectory().getAbsolutePath();
       String datadir = Environment.getDataDirectory().getAbsolutePath();
       String cachedir = Environment.getDownloadCacheDirectory().getAbsolutePath();
       mEdit.setText(
           String.format(
               "ext = %s\nroot=%s\ndata=%s\ncache=%s", mSdPath, rootdir, datadir, cachedir));
       break;
     case R.id.save:
       File dir = new File(mSdPath + "/dir");
       dir.mkdir();
       File file = new File(mSdPath + "/dir/file.txt");
       try {
         FileOutputStream fos = new FileOutputStream(file);
         String str = "This file exists in SDcard";
         fos.write(str.getBytes());
         fos.close();
         mEdit.setText("write success");
       } catch (FileNotFoundException e) {
         mEdit.setText("File Not Found." + e.getMessage());
       } catch (SecurityException e) {
         mEdit.setText("Security Exception");
       } catch (Exception e) {
         mEdit.setText(e.getMessage());
       }
       break;
     case R.id.load:
       try {
         FileInputStream fis = new FileInputStream(mSdPath + "/dir/file.txt");
         byte[] data = new byte[fis.available()];
         while (fis.read(data) != -1) {;
         }
         fis.close();
         mEdit.setText(new String(data));
       } catch (FileNotFoundException e) {
         mEdit.setText("File Not Found");
       } catch (Exception e) {;
       }
       break;
   }
 }
  public void startTranscode() {

    try {
      transcode();

    } catch (Exception e) {

      buttonStart.setEnabled(false);

      String message = (e.getMessage() != null) ? e.getMessage() : e.toString();

      showMessageBox(
          message,
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {}
          });
    }
  }
Example #26
0
  public void downloadFile(String url, String savePath, String fileName) {

    try {
      URL theURL = new URL(url);
      InputStream input = theURL.openStream();
      OutputStream output = new FileOutputStream(new File(savePath, fileName));
      try {
        byte[] buffer = new byte[1024];
        int bytesRead = 0;
        while ((bytesRead = input.read(buffer, 0, buffer.length)) >= 0) {
          output.write(buffer, 0, bytesRead);
        }
      } catch (Exception e) {
        debug(e.toString());
      } finally {
        output.close();
      }
    } catch (Exception e) {
      debug(e.toString());
    }
  }
  protected void getFileInfo() {
    try {
      mediaFileInfo = new MediaFileInfo(new AndroidMediaObjectFactory(getApplicationContext()));
      mediaFileInfo.setUri(mediaUri1);

      duration = mediaFileInfo.getDurationInMicroSec();

      audioFormat = (AudioFormat) mediaFileInfo.getAudioFormat();
      if (audioFormat == null) {
        showMessageBox(
            "Audio format info unavailable",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {}
            });
      }

      videoFormat = (VideoFormat) mediaFileInfo.getVideoFormat();
      if (videoFormat == null) {
        showMessageBox(
            "Video format info unavailable",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {}
            });
      } else {
        videoWidthIn = videoFormat.getVideoFrameSize().width();
        videoHeightIn = videoFormat.getVideoFrameSize().height();
      }
    } catch (Exception e) {
      String message = (e.getMessage() != null) ? e.getMessage() : e.toString();

      showMessageBox(
          message,
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {}
          });
    }
  }
  protected void displayVideoFrame(SurfaceHolder holder) {

    if (videoFormat != null) {
      try {
        ISurfaceWrapper surface = AndroidMediaObjectFactory.Converter.convert(holder.getSurface());
        mediaFileInfo.setOutputSurface(surface);

        ByteBuffer buffer = ByteBuffer.allocate(1);
        mediaFileInfo.getFrameAtPosition(100, buffer);

      } catch (Exception e) {
        String message = (e.getMessage() != null) ? e.getMessage() : e.toString();

        showMessageBox(
            message,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {}
            });
      }
    }
  }
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
   try {
     generateKey();
   } catch (Exception e1) {
     // TODO Auto-generated catch block
     e1.printStackTrace();
   }
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   final Button encryptButton = (Button) findViewById(R.id.encryptbutton);
   final Button decryptButton = (Button) findViewById(R.id.decryptbutton);
   final EditText input = (EditText) findViewById(R.id.secretMessage);
   final EditText CodedMessage = (EditText) findViewById(R.id.encryptedCode);
   final EditText output = (EditText) findViewById(R.id.originalMessage);
   encryptButton.setOnClickListener(
       new OnClickListener() {
         public void onClick(View v) {
           try {
             CodedMessage.setText(encrypt(input.getText().toString()));
           } catch (Exception e2) {
             // TODO Auto-generated catch block
             e2.printStackTrace();
           }
         };
       });
   decryptButton.setOnClickListener(
       new OnClickListener() {
         public void onClick(View v) {
           try {
             output.setText(String.valueOf(decrypt(CodedMessage.getText().toString())));
           } catch (Exception e3) {
             // TODO Auto-generated catch block
             e3.printStackTrace();
           }
         }
       });
 }
Example #30
0
 public String getFolderName(String pageCode) {
   String usefulSection =
       pageCode.substring(
           pageCode.indexOf("<h3 id=\"breadcrumb\">"),
           pageCode.indexOf("<div id=\"list-view\" class=\"view\""));
   String folderName;
   try {
     DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
     InputSource is = new InputSource();
     is.setCharacterStream(new StringReader(usefulSection));
     Document doc = db.parse(is);
     NodeList divs = doc.getElementsByTagName("h3");
     for (int i = 0; i < divs.getLength(); i++) {
       Element div = (Element) divs.item(i);
       String a = div.getTextContent();
       folderName = a.substring(a.indexOf("/>") + 2).trim();
       return folderName;
     }
   } catch (Exception e) {
     debug(e.toString());
   }
   return "Error!";
 }