List of usage examples for java.lang NullPointerException printStackTrace
public void printStackTrace()
From source file:com.alibaba.akita.widget.TitlePageIndicator.java
public boolean onTouchEvent(android.view.MotionEvent ev) { if (super.onTouchEvent(ev)) { return true; }//w w w .ja va2s.c om if ((mViewPager == null) || (mViewPager.getAdapter().getCount() == 0)) { return false; } final int action = ev.getAction(); switch (action & MotionEventCompat.ACTION_MASK) { case MotionEvent.ACTION_DOWN: mActivePointerId = MotionEventCompat.getPointerId(ev, 0); mLastMotionX = ev.getX(); break; case MotionEvent.ACTION_MOVE: { final int activePointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId); final float x = MotionEventCompat.getX(ev, activePointerIndex); final float deltaX = x - mLastMotionX; if (!mIsDragging) { if (Math.abs(deltaX) > mTouchSlop) { mIsDragging = true; } } if (mIsDragging) { if (!mViewPager.isFakeDragging()) { mViewPager.beginFakeDrag(); } mLastMotionX = x; try { mViewPager.fakeDragBy(deltaX); } catch (Exception e) { e.printStackTrace(); } } break; } case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: if (!mIsDragging) { final int count = mViewPager.getAdapter().getCount(); final int width = getWidth(); final float halfWidth = width / 2f; final float sixthWidth = width / 6f; final float leftThird = halfWidth - sixthWidth; final float rightThird = halfWidth + sixthWidth; final float eventX = ev.getX(); if (eventX < leftThird) { if (mCurrentPage > 0) { mViewPager.setCurrentItem(mCurrentPage - 1); return true; } } else if (eventX > rightThird) { if (mCurrentPage < count - 1) { mViewPager.setCurrentItem(mCurrentPage + 1); return true; } } else { //Middle third if (mCenterItemClickListener != null) { mCenterItemClickListener.onCenterItemClick(mCurrentPage); } } } mIsDragging = false; mActivePointerId = INVALID_POINTER; if (mViewPager.isFakeDragging()) { try { mViewPager.endFakeDrag(); } catch (NullPointerException npe) { npe.printStackTrace(); // fix a crash report. } } break; case MotionEventCompat.ACTION_POINTER_DOWN: { final int index = MotionEventCompat.getActionIndex(ev); final float x = MotionEventCompat.getX(ev, index); mLastMotionX = x; mActivePointerId = MotionEventCompat.getPointerId(ev, index); break; } case MotionEventCompat.ACTION_POINTER_UP: final int pointerIndex = MotionEventCompat.getActionIndex(ev); final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex); if (pointerId == mActivePointerId) { final int newPointerIndex = pointerIndex == 0 ? 1 : 0; mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex); } mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, mActivePointerId)); break; } return true; }
From source file:fm.krui.kruifm.StreamActivity.java
private void addTrackToFavorites() { String trackName = ""; String artistAlbumName = ""; TextView trackNameTextView = (TextView) this.findViewById(R.id.song_name_textview); TextView artistAlbumNameTextView = (TextView) this.findViewById(R.id.artist_album_name_textview); // Extract text from their views try {//ww w. j a v a 2 s. c o m trackName = trackNameTextView.getText().toString(); artistAlbumName = artistAlbumNameTextView.getText().toString(); } catch (NullPointerException e) { Log.e(TAG, "Caught NullPointerException when extracting values from StreamFragment textviews!"); e.printStackTrace(); } // Build a Track from currently playing track. Track track = new Track(); track.setTitle(trackName); // Separate Artist/Album Name String[] arr = artistAlbumName.split("-"); track.setAlbum(arr[1]); track.setArtist(arr[0]); // Add this track to favorites favTrackManager.addTrackToFavorites(track); String message = getString(R.string.add_favorite); showStreamStatusBar(message, false); FavoriteTrackManager.setFavoriteFlag(this, true); }
From source file:com.sldeditor.test.unit.tool.vector.VectorToolTest.java
@Test public void testVectorToolDBDataSource() { TestMissingSLDAttributes testAttribute = new TestMissingSLDAttributes(); List<CheckAttributeInterface> checkList = new ArrayList<CheckAttributeInterface>(); checkList.add(testAttribute);//from w w w . j a va 2s. c o m CheckAttributeFactory.setOverideCheckList(checkList); String testsldfile = "/polygon/sld/polygon_polygonwithdefaultlabel.sld"; TestSLDEditor testSLDEditor = null; try { testSLDEditor = TestSLDEditor.createAndShowGUI2(null, null, true, null); } catch (Exception e) { e.printStackTrace(); } RenderPanelImpl.setUnderTest(true); InputStream inputStream = VectorToolTest.class.getResourceAsStream(testsldfile); if (inputStream == null) { Assert.assertNotNull("Failed to find sld test file : " + testsldfile, inputStream); } else { File f = null; try { f = stream2file(inputStream); try { testSLDEditor.openFile(f.toURI().toURL()); } catch (NullPointerException nullException) { nullException.printStackTrace(); StackTraceElement[] stackTraceElements = nullException.getStackTrace(); System.out.println(stackTraceElements[0].getMethodName()); } f.delete(); } catch (IOException e1) { e1.printStackTrace(); } } // Fields extracted from the SLD file DataSourceInterface dataSource = DataSourceFactory.createDataSource(null); Collection<PropertyDescriptor> propertyList = dataSource.getPropertyDescriptorList(); assertEquals(2, propertyList.size()); Map<String, PropertyDescriptor> map = new HashMap<String, PropertyDescriptor>(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } AttributeDescriptor name = (AttributeDescriptor) map.get("name"); assertNotNull(name); GeometryDescriptor geometry = (GeometryDescriptor) map.get("geom"); assertNotNull(geometry); File tempFolder = Files.createTempDir(); TestVectorTool vectorTool = new TestVectorTool(testSLDEditor); try { InputStream gpkgInputStream = VectorToolTest.class .getResourceAsStream("/test/sld_cookbook_polygon.gpkg"); final File gpkgFile = new File(tempFolder, "sld_cookbook_polygon.gpkg"); try (FileOutputStream out = new FileOutputStream(gpkgFile)) { IOUtils.copy(gpkgInputStream, out); } DatabaseConnection databaseConnection = DatabaseConnectionFactory .getConnection(gpkgFile.getAbsolutePath()); DatabaseFeatureClassNode dbFCTreeNode = new DatabaseFeatureClassNode(null, databaseConnection, "sld_cookbook_polygon"); DatabaseConnectionManager.getInstance().addNewConnection(null, databaseConnection); vectorTool.testSetDataSource(dbFCTreeNode); dataSource = DataSourceFactory.createDataSource(null); propertyList = dataSource.getPropertyDescriptorList(); assertEquals(3, propertyList.size()); map.clear(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } name = (AttributeDescriptor) map.get("name"); assertNotNull(name); geometry = (GeometryDescriptor) map.get("geometry"); assertNotNull(geometry); AttributeDescriptor pop = (AttributeDescriptor) map.get("pop"); assertNotNull(pop); // Create SLD from geopackage layer vectorTool.testImportFeatureClass(dbFCTreeNode); dataSource = DataSourceFactory.createDataSource(null); propertyList = dataSource.getPropertyDescriptorList(); assertEquals(3, propertyList.size()); map.clear(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } name = (AttributeDescriptor) map.get("name"); assertNotNull(name); geometry = (GeometryDescriptor) map.get("geometry"); assertNotNull(geometry); pop = (AttributeDescriptor) map.get("pop"); assertNotNull(pop); // Release locks dataSource.reset(); } catch (IOException e) { e.printStackTrace(); fail(); } // Tidy up so the remaining unit tests are ok JFrame frame = testSLDEditor.getApplicationFrame(); frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING)); testSLDEditor = null; clearDown(); // Delete the shape files we extracted purgeDirectory(tempFolder); }
From source file:com.sldeditor.test.unit.tool.vector.VectorToolTest.java
/** * Test method for {@link com.sldeditor.tool.vector.VectorTool#VectorTool(com.sldeditor.common.SLDEditorInterface)}. *///from w ww.ja va 2 s . com @Test public void testVectorToolFileDataSource() { TestMissingSLDAttributes testAttribute = new TestMissingSLDAttributes(); List<CheckAttributeInterface> checkList = new ArrayList<CheckAttributeInterface>(); checkList.add(testAttribute); CheckAttributeFactory.setOverideCheckList(checkList); String testsldfile = "/polygon/sld/polygon_polygonwithdefaultlabel.sld"; TestSLDEditor testSLDEditor = null; try { testSLDEditor = TestSLDEditor.createAndShowGUI2(null, null, true, null); } catch (Exception e) { e.printStackTrace(); } InputStream inputStream = VectorToolTest.class.getResourceAsStream(testsldfile); if (inputStream == null) { Assert.assertNotNull("Failed to find sld test file : " + testsldfile, inputStream); } else { File f = null; try { f = stream2file(inputStream); try { testSLDEditor.openFile(f.toURI().toURL()); } catch (NullPointerException nullException) { nullException.printStackTrace(); StackTraceElement[] stackTraceElements = nullException.getStackTrace(); System.out.println(stackTraceElements[0].getMethodName()); } f.delete(); } catch (IOException e1) { e1.printStackTrace(); } } // Fields extracted from the SLD file DataSourceInterface dataSource = DataSourceFactory.createDataSource(null); Collection<PropertyDescriptor> propertyList = dataSource.getPropertyDescriptorList(); assertEquals(2, propertyList.size()); Map<String, PropertyDescriptor> map = new HashMap<String, PropertyDescriptor>(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } AttributeDescriptor name = (AttributeDescriptor) map.get("name"); assertNotNull(name); GeometryDescriptor geometry = (GeometryDescriptor) map.get("geom"); assertNotNull(geometry); File tempFolder = Files.createTempDir(); TestVectorTool vectorTool = new TestVectorTool(testSLDEditor); try { // Set a shape file as a data source - that matches the SLD File matchingShpFile = extractShapeFile(tempFolder, "/test/sld_cookbook_polygon.zip"); FileTreeNode fileTreeNode = new FileTreeNode(matchingShpFile.getParentFile(), matchingShpFile.getName()); vectorTool.testSetDataSource(fileTreeNode); dataSource = DataSourceFactory.createDataSource(null); propertyList = dataSource.getPropertyDescriptorList(); assertEquals(3, propertyList.size()); map.clear(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } name = (AttributeDescriptor) map.get("name"); assertNotNull(name); geometry = (GeometryDescriptor) map.get("the_geom"); assertNotNull(geometry); AttributeDescriptor pop = (AttributeDescriptor) map.get("pop"); assertNotNull(pop); // Set a shape file as a data source - that does not match the SLD File nonMatchingShpFile = extractShapeFile(tempFolder, "/test/states.zip"); FileTreeNode fileTreeNode2 = new FileTreeNode(nonMatchingShpFile.getParentFile(), nonMatchingShpFile.getName()); vectorTool.testSetDataSource(fileTreeNode2); dataSource = DataSourceFactory.createDataSource(null); propertyList = dataSource.getPropertyDescriptorList(); assertEquals(23, propertyList.size()); map.clear(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } name = (AttributeDescriptor) map.get("name"); assertNull(name); geometry = (GeometryDescriptor) map.get("the_geom"); assertNotNull(geometry); pop = (AttributeDescriptor) map.get("pop"); assertNull(pop); assertEquals(1, testAttribute.getMissingFieldList().size()); assertEquals("name", testAttribute.getMissingFieldList().get(0)); // Create SLD from shape file vectorTool.testImportFile(fileTreeNode); dataSource = DataSourceFactory.createDataSource(null); propertyList = dataSource.getPropertyDescriptorList(); assertEquals(3, propertyList.size()); map.clear(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } name = (AttributeDescriptor) map.get("name"); assertNotNull(name); geometry = (GeometryDescriptor) map.get("the_geom"); assertNotNull(geometry); pop = (AttributeDescriptor) map.get("pop"); assertNotNull(pop); // Release locks dataSource.reset(); } catch (IOException e) { e.printStackTrace(); fail(); } // Tidy up so the remaining unit tests are ok JFrame frame = testSLDEditor.getApplicationFrame(); frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING)); testSLDEditor = null; clearDown(); // Delete the shape files we extracted purgeDirectory(tempFolder); }
From source file:com.nutsuser.ridersdomain.activities.LiveforDream.java
private File savebitmap(Bitmap filename) { File imageF = null;/*from w ww.ja va 2 s. com*/ try { if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { File storageDir = new File(ApplicationGlobal.LOCAL_STORAGE_BASE_PATH_FOR_POSTED_PHOTOS) .getParentFile(); if (storageDir != null) { if (!storageDir.mkdirs()) { if (!storageDir.exists()) { Log.d("CameraSample", "failed to create directory"); return null; } } } imageF = File.createTempFile(ApplicationGlobal.JPEG_FILE_PREFIX + System.currentTimeMillis() + "_", ApplicationGlobal.JPEG_FILE_SUFFIX, storageDir); } else { Log.v("image loading status", "External storage is not mounted READ/WRITE."); } } catch (NullPointerException e) { e.printStackTrace(); Rollbar.reportException(e, "minor", "LiveforDream savebitmap"); } catch (Exception e) { e.printStackTrace(); Rollbar.reportException(e, "minor", "LiveforDream savebitmap"); } OutputStream outStream = null; try { // make a new bitmap from your file Bitmap bitmap = filename; outStream = new FileOutputStream(imageF); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream); outStream.flush(); outStream.close(); } catch (Exception e) { e.printStackTrace(); Rollbar.reportException(e, "minor", "LiveforDream savebitmap"); } Log.e("file", "" + imageF); return imageF; }
From source file:com.symbian.driver.core.environment.TDConfigTest.java
public void testClearConfig() { try {//from w ww. ja va 2 s .co m CONFIG.clearConfig(); String lBuildNumber = CONFIG.getPreference(TDConfig.BUILD_NUMBER); if (lBuildNumber != null) { fail(); } } catch (NullPointerException e) { // Correct behaviour } catch (IOException e) { e.printStackTrace(); fail(); } catch (ParseException e) { e.printStackTrace(); fail(); } }
From source file:de.chdev.artools.loga.controller.FltrController.java
private boolean checkOperationDeferred(String textWoPrefix, int lineNumber) { Matcher m = patternOperationDeferred.matcher(textWoPrefix.trim()); boolean valid = m.matches(); if (valid) {//from www . j av a 2 s .co m // Extract Filter information String temp = textWoPrefix; String threadId = temp.substring(0, temp.indexOf(">") + 1); temp = temp.substring(threadId.length()); String rpcId = temp.substring(0, temp.indexOf(">") + 1); temp = temp.substring(rpcId.length()); String queue = temp.substring(0, temp.indexOf(">") + 1); temp = temp.substring(queue.length()); String clientRpc = temp.substring(0, temp.indexOf(">") + 1); temp = temp.substring(clientRpc.length()); String user = temp.substring(0, temp.indexOf(">") + 1); temp = temp.substring(user.length()); String overlay = temp.substring(0, temp.indexOf(">") + 1); temp = temp.substring(overlay.length()); String fltrText = temp.trim(); String phaseString = fltrText.substring(fltrText.length() - 2, fltrText.length() - 1); // LogElement parent = // MainController.getInstance().getLastOpenLogElement(); ControlLogElement parent = eventCache.peek(); try { if (phaseString.equalsIgnoreCase("2")) { parent.setPhase2Available(true); } else if (phaseString.equals("3")) { parent.setPhase3Available(true); } } catch (NullPointerException npe) { System.out.println("Parent event not available"); npe.printStackTrace(); } return true; } else { return false; } }
From source file:com.nearnotes.NoteEdit.java
/** * Populates the checkboxes on the side by analyzing the current text from * the body of the note./*from www . j a va 2s . c om*/ * * @param currentString * the current body of the note. * */ public ArrayList<NoteRow> populateBoxes(String currentString) { // Load ArrayList<String> mLines with the current bodytext seperated into seperate lines. mLines = Arrays.asList(currentString.split(System.getProperty("line.separator"))); // row counter to determine what the current line number is for the for loop int row = 0; // realRow counter to determine what line of text in the actual display we are on // used to get the number of characters on each line int realRow = 0; int activeRow = 0; int finishedCount = 0; ArrayList<NoteRow> tempRealRow = new ArrayList<NoteRow>(); for (String line : mLines) { NoteRow temp = new NoteRow(0, 1, row); // Create a note row object with rowType of 0 (invisible), lineSize of 1 and the current row number if (!line.isEmpty()) { activeRow++; temp.setType(1); // Set the NoteRow object to 1 (visible) // Determine how many lines the note takes up int internalCounter = 0; try { float lineLength = (float) line.length(); for (int k = 0; (lineLength / (getFloatLineEnd(realRow + k) - getFloatLineEnd(realRow - 1))) > 1; k++) { internalCounter++; } } catch (NullPointerException e) { e.printStackTrace(); } // Detemine if the note is supposed to be checked and set the NoteRow object to 2 (Checked) if (line.startsWith("[X]")) { finishedCount++; int spanstart = 0; StrikethroughSpan STRIKE_THROUGH_SPAN = new StrikethroughSpan(); Spannable spannable = (Spannable) mBodyText.getText(); // TableRow checkRow1 = (TableRow) View.inflate(getActivity(), R.layout.table_row, null); for (int j = 0; j < row; j++) { spanstart += mLines.get(j).length() + 1; } Object spansToRemove[] = spannable.getSpans(spanstart, spanstart + mLines.get(row).length(), Object.class); for (Object span : spansToRemove) { if (span instanceof CharacterStyle) spannable.removeSpan(span); } spannable.setSpan(STRIKE_THROUGH_SPAN, spanstart, spanstart + mLines.get(row).length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); temp.setType(2); } temp.setSize(1 + internalCounter); // Set the amount of rows the note takes up realRow = realRow + internalCounter; // Determine the real line on the display text we are on } tempRealRow.add(temp); // NoteRow object has been finalized - add to the ListArray<NoteRow> realRow++; // Increase the noteRow and the displayRow for the next line row++; } if (finishedCount == activeRow && finishedCount != 0) { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity()); boolean useListPref = sharedPref.getBoolean("pref_key_use_checklist_default", false); String stringlistPref = sharedPref.getString("pref_key_checklist_listPref", "2"); int listPref = Integer.parseInt(stringlistPref); ChecklistDialog newFragment = new ChecklistDialog(); if (mRowId == null) { saveState(); } Bundle args = new Bundle(); args.putLong("_id", mRowId); args.putBoolean("useDefault", useListPref); args.putInt("listPref", listPref); newFragment.setArguments(args); if (listPref == 2 && useListPref) { return tempRealRow; } if (getFragmentManager().findFragmentByTag("MyDialog") == null) { newFragment.show(getFragmentManager(), "MyDialog"); } } return tempRealRow; }
From source file:freed.cam.apis.camera2.modules.PictureModuleApi2.java
protected void finishCapture(Builder captureBuilder) { try {/* ww w .j a v a 2s .co m*/ Log.d(TAG, "CaptureDone"); cameraHolder.CaptureSessionH.StartRepeatingCaptureSession(); if (cameraHolder .get(CaptureRequest.CONTROL_AF_MODE) == CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE || cameraHolder.get( CaptureRequest.CONTROL_AF_MODE) == CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_VIDEO) { cameraHolder.SetParameterRepeating(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_CANCEL); cameraHolder.SetParameterRepeating(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_IDLE); } } catch (NullPointerException ex) { ex.printStackTrace(); ; } isWorking = false; }
From source file:com.slim.turboeditor.activity.MainActivity.java
@Override public void onDestroy() { try {//from w ww. ja v a 2 s .co m closeKeyBoard(); } catch (NullPointerException e) { e.printStackTrace(); } SettingsProvider.get(this).unregisterOnSharedPreferenceChangeListener(mPreferenceListener); super.onDestroy(); }