List of usage examples for java.lang NullPointerException printStackTrace
public void printStackTrace()
From source file:info.guardianproject.pixelknot.PixelKnotActivity.java
@Override public void onEmbedded(final File out_file) { h.post(new Runnable() { @Override// w w w. j a v a2 s .c o m public void run() { hasSuccessfullyEmbed = true; pixel_knot.setOutFile(out_file); ((ImageButton) options_holder.getChildAt(0)).setEnabled(true); try { progress_dialog.dismiss(); } catch (NullPointerException e) { Log.e(Logger.UI, e.toString()); e.printStackTrace(); } ((ActivityListener) pk_pager.getItem(view_pager.getCurrentItem())).updateUi(); } }); }
From source file:ilearn.orb.controller.AnnotationController.java
@RequestMapping(value = "/annotation") public ModelAndView textAnnotation(Locale locale, ModelMap modelMap, HttpServletRequest request, HttpSession session) {//w ww. j a v a 2 s .c o m try { request.setCharacterEncoding("UTF-8"); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } // System.err.println(request.getRemoteAddr()); // System.err.println(request.getRemoteHost()); // System.err.println(request.getRemotePort()); txModule = new TextAnnotationModule(); ModelAndView model = new ModelAndView(); model.setViewName("annotation"); try { Gson gson = new GsonBuilder().registerTypeAdapter(java.util.Date.class, new UtilDateDeserializer()) .setDateFormat(DateFormat.LONG).create(); User[] students = null; try { String json = UserServices.getProfiles(Integer.parseInt(session.getAttribute("id").toString()), session.getAttribute("auth").toString()); students = gson.fromJson(json, User[].class); } catch (NullPointerException e) { } if (students == null || students.length == 0) { students = HardcodedUsers.defaultStudents(); } modelMap.put("students", students); String text = request.getParameter("inputText"); String profileId = request.getParameter("selectedId"); if (text != null) { text = new String(text.getBytes("8859_1"), "UTF-8"); } else text = ""; modelMap.put("profileId", profileId); modelMap.put("text", text); // UserProfile pr = retrieveProfile(session, // Integer.parseInt(profileId)); } catch (NumberFormatException e) { //e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return model; }
From source file:AppSpringLayout.java
protected ImageIcon scaleBufferedImageWithoutLabel(BufferedImage img) { ImageIcon icon = null;//from w w w . j a va2 s. com try { icon = new ImageIcon(img); double width = icon.getIconWidth(); double height = icon.getIconHeight(); double labelWidth = 300; double labelHight = 300; double scaleWidth = width / labelWidth; double scaleHeight = height / labelHight; if (width >= height) { // horizontal image double newWidth = width / scaleWidth; icon = new ImageIcon(icon.getImage().getScaledInstance((int) newWidth, -1, Image.SCALE_SMOOTH)); } else { // vertical image double newHeight = height / scaleHeight; icon = new ImageIcon(icon.getImage().getScaledInstance(-1, (int) newHeight, Image.SCALE_SMOOTH)); } } catch (NullPointerException e) { try { originalImage = (BufferedImage) ImageIO.read(new File("img/error.png")); } catch (IOException e2) { e2.printStackTrace(); } e.printStackTrace(); } return icon; }
From source file:AppSpringLayout.java
protected ImageIcon scaleBufferedImage(BufferedImage img, JLabel label) { ImageIcon icon = null;//from w ww. j a va2 s . c o m try { icon = new ImageIcon(img); double width = icon.getIconWidth(); double height = icon.getIconHeight(); double labelWidth = label.getWidth(); double labelHight = label.getHeight(); double scaleWidth = width / labelWidth; double scaleHeight = height / labelHight; if (width >= height) { // horizontal image double newWidth = width / scaleWidth; icon = new ImageIcon(icon.getImage().getScaledInstance((int) newWidth, -1, Image.SCALE_SMOOTH)); } else { // vertical image double newHeight = height / scaleHeight; icon = new ImageIcon(icon.getImage().getScaledInstance(-1, (int) newHeight, Image.SCALE_SMOOTH)); } } catch (NullPointerException e) { try { originalImage = (BufferedImage) ImageIO.read(new File("img/error.png")); } catch (IOException e2) { e2.printStackTrace(); } e.printStackTrace(); } return icon; }
From source file:freed.cam.apis.camera2.modules.PictureModuleApi2.java
/** * Capture a still picture. This method should be called when we get a response in * *//*w ww . java 2 s .c om*/ protected void captureStillPicture() { Log.d(TAG, "StartStillCapture"); // Use the same AE and AF modes as the preview. try { captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, cameraHolder.get(CaptureRequest.CONTROL_AF_MODE)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, cameraHolder.get(CaptureRequest.CONTROL_AE_MODE)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.FLASH_MODE, cameraHolder.get(CaptureRequest.FLASH_MODE)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.COLOR_CORRECTION_MODE, cameraHolder.get(CaptureRequest.COLOR_CORRECTION_MODE)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.COLOR_CORRECTION_TRANSFORM, cameraHolder.get(CaptureRequest.COLOR_CORRECTION_TRANSFORM)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.COLOR_CORRECTION_GAINS, cameraHolder.get(CaptureRequest.COLOR_CORRECTION_GAINS)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.TONEMAP_CURVE, cameraHolder.get(CaptureRequest.TONEMAP_CURVE)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { if (Build.VERSION.SDK_INT >= VERSION_CODES.M) captureBuilder.set(CaptureRequest.TONEMAP_GAMMA, cameraHolder.get(CaptureRequest.TONEMAP_GAMMA)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { int awb = cameraHolder.get(CaptureRequest.CONTROL_AWB_MODE); captureBuilder.set(CaptureRequest.CONTROL_AWB_MODE, awb); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.EDGE_MODE, cameraHolder.get(CaptureRequest.EDGE_MODE)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.HOT_PIXEL_MODE, cameraHolder.get(CaptureRequest.HOT_PIXEL_MODE)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.NOISE_REDUCTION_MODE, cameraHolder.get(CaptureRequest.NOISE_REDUCTION_MODE)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, cameraHolder.get(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { long val = 0; if (!parameterHandler.ManualIso.GetStringValue().equals(KEYS.AUTO)) val = (long) (AbstractManualShutter.getMilliSecondStringFromShutterString( parameterHandler.ManualShutter.getStringValues()[parameterHandler.ManualShutter.GetValue()]) * 1000f); else val = cameraHolder.get(CaptureRequest.SENSOR_EXPOSURE_TIME); Log.d(TAG, "Set ExposureTime for Capture to:" + val); captureBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, val); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, cameraHolder.get(CaptureRequest.SENSOR_SENSITIVITY)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, cameraHolder.get(CaptureRequest.CONTROL_EFFECT_MODE)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, cameraHolder.get(CaptureRequest.CONTROL_SCENE_MODE)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, cameraHolder.get(CaptureRequest.LENS_FOCUS_DISTANCE)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, cameraUiWrapper.getActivityInterface().getOrientation()); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE, cameraHolder.get(CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { captureBuilder.set(CaptureRequest.SCALER_CROP_REGION, cameraHolder.get(CaptureRequest.SCALER_CROP_REGION)); } catch (NullPointerException ex) { ex.printStackTrace(); } try { if (appSettingsManager.getApiString(AppSettingsManager.SETTING_LOCATION).equals(KEYS.ON)) captureBuilder.set(CaptureRequest.JPEG_GPS_LOCATION, cameraUiWrapper.getActivityInterface().getLocationHandler().getCurrentLocation()); } catch (NullPointerException ex) { ex.printStackTrace(); } prepareCaptureBuilder(captureBuilder); imagecount = 0; //mDngResult = null; if (parameterHandler.Burst != null && parameterHandler.Burst.GetValue() > 0) { initBurstCapture(captureBuilder, CaptureCallback); } else { //cameraHolder.CaptureSessionH.StopRepeatingCaptureSession(); captureBuilder.setTag(mRequestCounter.getAndIncrement()); captureBuilder.addTarget(mImageReader.getSurface()); if (cameraHolder.get(CaptureRequest.SENSOR_EXPOSURE_TIME) != null && cameraHolder.get(CaptureRequest.SENSOR_EXPOSURE_TIME) > 500000 * 1000) cameraHolder.CaptureSessionH.StopRepeatingCaptureSession(); ImageHolder imageHolder = new ImageHolder(); resultQueue.put((int) captureBuilder.build().getTag(), imageHolder); changeCaptureState(CaptureStates.image_capture_start); cameraHolder.CaptureSessionH.StartImageCapture(captureBuilder, CaptureCallback, mBackgroundHandler); } }
From source file:io.github.sislivros.persistencia.UsuarioBdDao.java
@Override public boolean alterar(Usuario usuario) { try {/*w ww. j a v a2 s .co m*/ if (getConnection() == null || getConnection().isClosed()) { conectar(); } String sql = "UPDATE usuario SET email = ?, apelido = ?, data_nascimento = ?, cidade = ?" + ", estado = ?, nome = ?, foto_perfil = ?, foto_capa = ?, tipo = ? WHERE id = ?"; PreparedStatement ps = getConnection().prepareStatement(sql); Date dataNascimento = null; try { dataNascimento = new Date(usuario.getDataNascimento().getTime()); } catch (NullPointerException ex) { } ps.setString(1, usuario.getEmail()); ps.setString(2, usuario.getApelido()); ps.setDate(3, dataNascimento); ps.setString(4, usuario.getCidade()); ps.setString(5, usuario.getEstado()); ps.setString(6, usuario.getNome()); ps.setString(7, usuario.getFotoPerfil()); ps.setString(8, usuario.getFotoCapa()); ps.setInt(9, usuario.getTipo().id); ps.setInt(10, usuario.getId()); ps.executeUpdate(); return true; } catch (SQLException | URISyntaxException | IOException | ClassNotFoundException ex) { ex.printStackTrace(); return false; } finally { desconectar(); } }
From source file:leoisasmendi.android.com.suricatepodcast.services.MediaPlayerService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { try {/* www .j a va 2 s .c o m*/ //Load data from SharedPreferences StorageUtil storage = new StorageUtil(getApplicationContext()); audioIndex = storage.loadAudioIndex(); Log.d(TAG, "onStartCommand: " + R.string.media_player_connecting); loadActiveAudio(); } catch (NullPointerException e) { Log.d(TAG, "onStartCommand: " + R.string.media_player_error_1); stopSelf(); } //Request audio focus if (!requestAudioFocus()) { //Could not gain focus stopSelf(); } if (mediaSessionManager == null) { try { initMediaSession(); initMediaPlayer(); } catch (RemoteException e) { e.printStackTrace(); stopSelf(); } buildNotification(PlaybackStatus.PLAYING); } //Handle Intent action from MediaSession.TransportControls handleIncomingActions(intent); return super.onStartCommand(intent, flags, startId); }
From source file:de.codesourcery.jasm16.utils.ASTInspector.java
private ITextRegion getVisibleTextRegion() { final Point startPoint = editorScrollPane.getViewport().getViewPosition(); final Dimension size = editorScrollPane.getViewport().getExtentSize(); final Point endPoint = new Point(startPoint.x + size.width, startPoint.y + size.height); try {//from w ww .jav a 2 s .co m final int start = editorPane.viewToModel(startPoint); final int end = editorPane.viewToModel(endPoint); return new TextRegion(start, end - start); } catch (NullPointerException e) { System.out.println("startPoint: " + startPoint + " / size: " + size); e.printStackTrace(); return null; } }
From source file:org.schabi.newpipe.VideoItemDetailFragment.java
private void updateInfo(final StreamInfo info) { try {//from w w w . ja v a 2 s . c om Context c = getContext(); VideoInfoItemViewCreator videoItemViewCreator = new VideoInfoItemViewCreator( LayoutInflater.from(getActivity())); RelativeLayout textContentLayout = (RelativeLayout) activity.findViewById(R.id.detailTextContentLayout); final TextView videoTitleView = (TextView) activity.findViewById(R.id.detailVideoTitleView); TextView uploaderView = (TextView) activity.findViewById(R.id.detailUploaderView); TextView viewCountView = (TextView) activity.findViewById(R.id.detailViewCountView); TextView thumbsUpView = (TextView) activity.findViewById(R.id.detailThumbsUpCountView); TextView thumbsDownView = (TextView) activity.findViewById(R.id.detailThumbsDownCountView); TextView uploadDateView = (TextView) activity.findViewById(R.id.detailUploadDateView); TextView descriptionView = (TextView) activity.findViewById(R.id.detailDescriptionView); FrameLayout nextVideoFrame = (FrameLayout) activity.findViewById(R.id.detailNextVideoFrame); RelativeLayout nextVideoRootFrame = (RelativeLayout) activity .findViewById(R.id.detailNextVideoRootLayout); Button nextVideoButton = (Button) activity.findViewById(R.id.detailNextVideoButton); TextView similarTitle = (TextView) activity.findViewById(R.id.detailSimilarTitle); Button backgroundButton = (Button) activity .findViewById(R.id.detailVideoThumbnailWindowBackgroundButton); View topView = activity.findViewById(R.id.detailTopView); View nextVideoView = null; if (info.next_video != null) { nextVideoView = videoItemViewCreator.getViewFromVideoInfoItem(null, nextVideoFrame, info.next_video); } else { activity.findViewById(R.id.detailNextVidButtonAndContentLayout).setVisibility(View.GONE); activity.findViewById(R.id.detailNextVideoTitle).setVisibility(View.GONE); activity.findViewById(R.id.detailNextVideoButton).setVisibility(View.GONE); } progressBar.setVisibility(View.GONE); if (nextVideoView != null) { nextVideoFrame.addView(nextVideoView); } initThumbnailViews(info, nextVideoFrame); textContentLayout.setVisibility(View.VISIBLE); if (android.os.Build.VERSION.SDK_INT < 18) { playVideoButton.setVisibility(View.VISIBLE); } else { ImageView playArrowView = (ImageView) activity.findViewById(R.id.playArrowView); playArrowView.setVisibility(View.VISIBLE); } if (!showNextVideoItem) { nextVideoRootFrame.setVisibility(View.GONE); similarTitle.setVisibility(View.GONE); } videoTitleView.setText(info.title); topView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == android.view.MotionEvent.ACTION_UP) { ImageView arrow = (ImageView) activity.findViewById(R.id.toggleDescriptionView); View extra = activity.findViewById(R.id.detailExtraView); if (extra.getVisibility() == View.VISIBLE) { extra.setVisibility(View.GONE); arrow.setImageResource(R.drawable.arrow_down); } else { extra.setVisibility(View.VISIBLE); arrow.setImageResource(R.drawable.arrow_up); } } return true; } }); // Since newpipe is designed to work even if certain information is not available, // the UI has to react on missing information. videoTitleView.setText(info.title); if (!info.uploader.isEmpty()) { uploaderView.setText(info.uploader); } else { activity.findViewById(R.id.detailUploaderWrapView).setVisibility(View.GONE); } if (info.view_count >= 0) { viewCountView.setText(Localization.localizeViewCount(info.view_count, c)); } else { viewCountView.setVisibility(View.GONE); } if (info.dislike_count >= 0) { thumbsDownView.setText(Localization.localizeNumber(info.dislike_count, c)); } else { thumbsDownView.setVisibility(View.INVISIBLE); activity.findViewById(R.id.detailThumbsDownImgView).setVisibility(View.GONE); } if (info.like_count >= 0) { thumbsUpView.setText(Localization.localizeNumber(info.like_count, c)); } else { thumbsUpView.setVisibility(View.GONE); activity.findViewById(R.id.detailThumbsUpImgView).setVisibility(View.GONE); thumbsDownView.setVisibility(View.GONE); activity.findViewById(R.id.detailThumbsDownImgView).setVisibility(View.GONE); } if (!info.upload_date.isEmpty()) { uploadDateView.setText(Localization.localizeDate(info.upload_date, c)); } else { uploadDateView.setVisibility(View.GONE); } if (!info.description.isEmpty()) { descriptionView.setText(Html.fromHtml(info.description)); } else { descriptionView.setVisibility(View.GONE); } descriptionView.setMovementMethod(LinkMovementMethod.getInstance()); // parse streams Vector<VideoStream> streamsToUse = new Vector<>(); for (VideoStream i : info.video_streams) { if (useStream(i, streamsToUse)) { streamsToUse.add(i); } } nextVideoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent detailIntent = new Intent(getActivity(), VideoItemDetailActivity.class); /*detailIntent.putExtra( VideoItemDetailFragment.ARG_ITEM_ID, currentVideoInfo.nextVideo.id); */ detailIntent.putExtra(VideoItemDetailFragment.VIDEO_URL, info.next_video.webpage_url); detailIntent.putExtra(VideoItemDetailFragment.STREAMING_SERVICE, streamingServiceId); startActivity(detailIntent); } }); textContentLayout.setVisibility(View.VISIBLE); if (info.related_videos != null && !info.related_videos.isEmpty()) { initSimilarVideos(info, videoItemViewCreator); } else { activity.findViewById(R.id.detailSimilarTitle).setVisibility(View.GONE); activity.findViewById(R.id.similarVideosView).setVisibility(View.GONE); } setupActionBarHandler(info); if (autoPlayEnabled) { playVideo(info); } if (android.os.Build.VERSION.SDK_INT < 18) { playVideoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { playVideo(info); } }); } backgroundButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { playVideo(info); } }); } catch (java.lang.NullPointerException e) { Log.w(TAG, "updateInfo(): Fragment closed before thread ended work... or else"); e.printStackTrace(); } }
From source file:fr.dyade.aaa.util.MySqlDBRepository.java
/** * Save the corresponding bytes array./*from w ww . ja va 2 s .c om*/ */ public void save(String dirName, String name, byte[] content) throws IOException { String fname = null; if (dirName == null) { fname = name; } else { fname = new StringBuffer(dirName).append('/').append(name).toString(); } boolean requireReconnect = false; try { insertStmt.setString(1, fname); insertStmt.setBytes(2, content); insertStmt.executeUpdate(); } catch (SQLException e) { // e.printStackTrace(); try { updateStmt.setBytes(1, content); updateStmt.setString(2, fname); updateStmt.executeUpdate(); } catch (com.mysql.jdbc.PacketTooBigException ptbe) { System.err.println( "MySqlDBRepository.save - was trying to save\ndirName: " + dirName + "\nname: " + name); ptbe.printStackTrace(); } catch (SQLException sqle) { if (sqle instanceof com.mysql.jdbc.CommunicationsException && !reconnectLoop) { logger.log(BasicLevel.WARN, "Database CommunicationsException problem at save, requires Reconnection"); requireReconnect = true; } else { if (reconnectLoop) logger.log(BasicLevel.WARN, "Database reconnection problem at save. Still have CommunicationsException"); logger.log(BasicLevel.WARN, "save, CommunicationsException problem saving " + name); sqle.printStackTrace(); // throw new IOException(sqle.getMessage()); } } catch (NullPointerException ne) { if (!reconnectLoop) { logger.log(BasicLevel.WARN, "Database NullPointerException problem at save, requires Reconnection"); requireReconnect = true; } else { if (reconnectLoop) logger.log(BasicLevel.WARN, "Database reconnection problem at save. Still have NullPointerException"); logger.log(BasicLevel.WARN, "save, NullPointerException problem saving " + name); ne.printStackTrace(); // throw new IOException(sqle.getMessage()); } } catch (Exception e2) { logger.log(BasicLevel.WARN, "save, problem saving " + name + " in e2 with " + e2.getMessage()); e2.printStackTrace(); // throw e2; } } if (requireReconnect) { logger.log(BasicLevel.WARN, "Database problem at save, Reconnecting"); reconnection(); reconnectLoop = true; save(dirName, name, content); reconnectLoop = false; } nbsaved += 1; }