List of usage examples for java.lang NullPointerException printStackTrace
public void printStackTrace()
From source file:at.tomtasche.reader.ui.activity.DocumentActivity.java
private void dismissProgress() { // dirty hack because committing isn't allowed right after // onLoadFinished: // "java.lang.IllegalStateException: Can not perform this action inside of onLoadFinished" if (progressDialog == null) progressDialog = (ProgressDialogFragment) getSupportFragmentManager() .findFragmentByTag(ProgressDialogFragment.FRAGMENT_TAG); if (progressDialog != null && progressDialog.getShowsDialog() && progressDialog.isNotNull()) { try {//from ww w . j a va 2s . c o m progressDialog.dismissAllowingStateLoss(); } catch (NullPointerException e) { e.printStackTrace(); } progressDialog = null; } }
From source file:org.parosproxy.paros.extension.spider.ExtensionSpider.java
private void startSpider(SiteNode startNode) { if (spider == null) { try {/* w ww .ja va 2 s . co m*/ getModel().getDb().getTableHistory().deleteHistoryType(getModel().getSession().getSessionId(), HistoryReference.TYPE_SPIDER_SEED); getModel().getDb().getTableHistory().deleteHistoryType(getModel().getSession().getSessionId(), HistoryReference.TYPE_SPIDER_VISITED); } catch (SQLException e) { e.printStackTrace(); } spider = new Spider(getSpiderParam(), getModel().getOptionsParam().getConnectionParam(), getModel()); spider.addSpiderListener(this); inOrderSeed(spider, startNode); } getSpiderPanel().setTabFocus(); try { spider.start(); } catch (NullPointerException e1) { e1.printStackTrace(); } }
From source file:org.fracturedatlas.athena.apa.indexing.IndexingApaAdapter.java
public void deleteFromIndex(Object oid) { if (oid == null || indexingDisabled) { return;//w ww. ja v a 2 s . c o m } String id = IdAdapter.toString(oid); IndexWriter indexWriter = null; try { indexWriter = getWriter(); indexWriter.deleteDocuments(new Term("_id", id)); indexWriter.optimize(); } catch (NullPointerException npe) { logger.error("Null pointer exception coming. Did you call initializeIndex() ?"); npe.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:br.com.totvs.java3C.fluig.util.FluigAPI.java
public FluigAPI(ItensAmbienteFluig itensAmbienteFluig, String tipo) { if (itensAmbienteFluig.getModalidade().equals("C")) { // Se o Fluig for "Compartilhado" HttpClient httpClient = new DefaultHttpClient(); try {// w ww. j a v a 2 s . co m String urlMonit = "http://" + itensAmbienteFluig.getIp() + ":" + itensAmbienteFluig.getPortaWeb() + "/monitor/report/" + tipo; HttpGet httpGet = new HttpGet(urlMonit); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody; responseBody = httpClient.execute(httpGet, responseHandler); try { jsonObject = new JSONObject(responseBody); result = (String) jsonObject.getString(tipo).trim(); } catch (NullPointerException e) { System.out.println("Nao foi possivel obter resposta JSON a partir do Fluig (null)."); System.exit(3); } catch (JSONException j) { System.out.println("JSON invalido: " + responseBody); System.exit(3); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { httpClient.getConnectionManager().shutdown(); } } }
From source file:com.xorcode.andtweet.net.ConnectionOAuth.java
/** * Universal method for several Timelines... * /*from w w w . j a va 2s. com*/ * @param url URL predefined for this timeline * @param sinceId * @param maxId * @param limit * @param page * @return * @throws ConnectionException */ private JSONArray getTimeline(String url, long sinceId, long maxId, int limit, int page) throws ConnectionException { setSinceId(sinceId); setLimit(limit); boolean ok = false; JSONArray jArr = null; try { Uri sUri = Uri.parse(url); Uri.Builder builder = sUri.buildUpon(); if (getSinceId() != 0) { builder.appendQueryParameter("since_id", String.valueOf(getSinceId())); } else if (maxId != 0) { // these are mutually exclusive builder.appendQueryParameter("max_id", String.valueOf(maxId)); } if (getLimit() != 0) { builder.appendQueryParameter("count", String.valueOf(getLimit())); } if (page != 0) { builder.appendQueryParameter("page", String.valueOf(page)); } HttpGet get = new HttpGet(builder.build().toString()); mConsumer.sign(get); String response = mClient.execute(get, new BasicResponseHandler()); jArr = new JSONArray(response); ok = (jArr != null); } catch (NullPointerException e) { // It looks like a bug in the library, but we have to catch it Log.e(TAG, "NullPointerException was caught, URL='" + url + "'"); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); throw new ConnectionException(e.getLocalizedMessage()); } if (MyLog.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "getTimeline '" + url + "' " + (ok ? "OK, " + jArr.length() + " statuses" : "FAILED")); } return jArr; }
From source file:com.streaming.sweetplayer.PlayerActivity.java
private void getSongDetail() { JSONParser jsonParser = new JSONParser(); JSONArray jsonArray;/*from w ww. j av a2 s . c o m*/ try { JSONObject json = jsonParser.getJSONFromUrl(sSongDetailUrl); if (json != null) { jsonArray = json.getJSONArray(Config.SONGS_ITEM); int items_length = jsonArray.length(); for (int i = 0; i < items_length; i++) { HashMap<String, String> map = new HashMap<String, String>(); JSONObject jsonObject = jsonArray.getJSONObject(i); map.put(Config.LYRICS, jsonObject.getString(Config.LYRICS)); try { mSongDetailList.add(map); } catch (NullPointerException e) { e.printStackTrace(); } } } } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.nqsky.nest.home.activity.RecyclerGridFragment.java
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final RecyclerListAdapter adapter = new RecyclerListAdapter(getActivity(), this) { View view;/*from www.j ava 2s . c o m*/ @Override public ItemViewHolder onCreatViewFristVHoleder(ViewGroup parent, int viewType) { view = new WebView(getActivity()); view.setId(R.id.webview); GridLayoutManager.LayoutParams params = new GridLayoutManager.LayoutParams( GridLayoutManager.LayoutParams.MATCH_PARENT, 800); view.setLayoutParams(params); return new AppItemViewHolder(view, viewType); } @Override public ItemViewHolder onCreatViewItemVHoleder(ViewGroup parent, int viewType) { view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main, null, false); return new AppItemViewHolder(view, viewType); } @Override public ItemViewHolder onCreatViewHeaderVHoleder(ViewGroup parent, int viewType) { view = LayoutInflater.from(parent.getContext()).inflate(R.layout.header, parent, false); return new AppItemViewHolder(view, viewType); } @Override public void onBindViewFristHolder(ItemViewHolder holder, int position) { if (holder instanceof AppItemViewHolder) { ((AppItemViewHolder) holder).webview.loadUrl("http://www.qq.com");//.setText(super.mItems.get(position).getText()); } } @Override public void onBindViewItemHolder(ItemViewHolder holder, int position) { if (holder instanceof AppItemViewHolder) { ((AppItemViewHolder) holder).textView.setText(super.mItems.get(position).getText()); ((AppItemViewHolder) holder).handleView .setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.ic_app)); } } @Override public void onBindViewHeaderHolder(ItemViewHolder holder, int position) { if (holder instanceof AppItemViewHolder) { ((AppItemViewHolder) holder).textView.setText(super.mItems.get(position).getText()); } } }; RecyclerView recyclerView = (RecyclerView) view.findViewById(android.R.id.list); recyclerView.setHasFixedSize(true); recyclerView.setAdapter(adapter); recyclerView.setItemAnimator(new DefaultItemAnimator()); // final int spanCount = getResources().getInteger(R.integer.grid_columns); final GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), 4); recyclerView.setLayoutManager(layoutManager); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { switch (adapter.getItemViewType(position)) { case RecyclerListAdapter.ITEM_VIEW_TYPE_CUSTOMER: return 4; case RecyclerListAdapter.ITEM_VIEW_TYPE_HEADER: return 4; case RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM: return 1; default: return 4; } } }); ItemTouchHelper.Callback callback = new CJTouchHelperCallback(adapter); mItemTouchHelper = new ItemTouchHelper(callback); mItemTouchHelper.attachToRecyclerView(recyclerView); adapter.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(RecyclerGridFragment.this.getActivity(), "?" + position + "", Toast.LENGTH_SHORT).show(); if (adapter.getItemViewType(position) == RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM) { try { ItemBean bean = new ItemBean(); bean.setText("?" + position + ""); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM); bean.setId(position / 10 + ""); bean.setpID(adapter.getItemBean(position).getpID()); adapter.addItem(adapter.getItemBean(position).getpID(), bean); } catch (NullPointerException e) { e.printStackTrace(); } } else { adapter.delItem(position + 1); } } }); ItemBean bean; List<ItemBean> list = new ArrayList<ItemBean>(); for (int i = 0; i < 80; i++) { bean = new ItemBean(); if (i % 10 == 0) { bean.setText("" + i / 10); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_HEADER); bean.setId(String.valueOf((i / 10))); } else { bean.setText("Item" + i / 10 + i % 10); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM); bean.setpID(String.valueOf((i / 10))); bean.setId(String.valueOf((i))); } list.add(bean); } bean = new ItemBean(); bean.setText(""); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_CUSTOMER); bean.setId(String.valueOf((10))); list.add(0, bean); adapter.addItems(list); final com.cjj.MaterialRefreshLayout swipeRefreshLayout; final Handler handler = new Handler(); swipeRefreshLayout = (com.cjj.MaterialRefreshLayout) view.findViewById(R.id.swipe_refresh_widget); swipeRefreshLayout.setWaveColor(0xf90fffff); swipeRefreshLayout.setIsOverLay(true); swipeRefreshLayout.setWaveShow(true); swipeRefreshLayout.setLoadMore(true); swipeRefreshLayout.setMaterialRefreshListener(new MaterialRefreshListener() { @Override public void onRefresh(final MaterialRefreshLayout materialRefreshLayout) { handler.postDelayed(new Runnable() { @Override public void run() { adapter.clear(); ItemBean bean; List<ItemBean> list = new ArrayList<ItemBean>(); for (int i = 0; i < 80; i++) { bean = new ItemBean(); if (i % 10 == 0) { bean.setText("" + i / 10); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_HEADER); bean.setId(String.valueOf((i / 10))); } else { bean.setText("" + i / 10 + i % 10); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM); bean.setpID(String.valueOf((i / 10))); bean.setId(String.valueOf((i))); } list.add(bean); } bean = new ItemBean(); bean.setText(""); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_CUSTOMER); bean.setId(String.valueOf((10))); list.add(0, bean); adapter.addItems(list); materialRefreshLayout.finishRefresh(); } }, 1000); } @Override public void onRefreshLoadMore(final MaterialRefreshLayout materialRefreshLayout) { super.onRefreshLoadMore(materialRefreshLayout); handler.postDelayed(new Runnable() { @Override public void run() { ArrayList list = new ArrayList<ItemBean>(); for (int i = 60; i < 90; i++) { ItemBean bean = new ItemBean(); if (i % 10 == 0) { bean.setText("" + i / 10); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_HEADER); bean.setId(String.valueOf((i / 10))); } else { bean.setText("" + i / 10 + i % 10); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM); bean.setpID(String.valueOf((i / 10))); bean.setId(String.valueOf((i))); } list.add(bean); } // bean=new ItemBean(); // bean.setText("" ); // bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_CUSTOMER); // bean.setId(String.valueOf((10))); // list.add(0,bean); adapter.addItems(list); materialRefreshLayout.finishRefreshLoadMore(); } }, 1000); } }); }
From source file:br.com.totvs.java3C.fluig.util.FluigAPI.java
public FluigAPI(ItensAmbienteFluig itensAmbienteFluig) { if (itensAmbienteFluig.getModalidade().equals("C")) { // Se o Fluig for "Compartilhado" HttpClient httpClient = new DefaultHttpClient(); try {//from w ww .j a v a2 s . c o m HttpGet httpGet = new HttpGet("http://" + itensAmbienteFluig.getIp() + ":" + itensAmbienteFluig.getPortaWeb() + "/monitor/report"); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody; responseBody = httpClient.execute(httpGet, responseHandler); try { jsonObject = new JSONObject(responseBody); goodDataAvailability = (String) jsonObject.getString("goodDataAvailability").trim(); memcachedAvailability = (String) jsonObject.getString("memcachedAvailability").trim(); openOfficeServerAvailability = (String) jsonObject.getString("openOfficeServerAvailability") .trim(); solrServerAvailability = (String) jsonObject.getString("solrServerAvailability").trim(); identityAvailability = (String) jsonObject.getString("identityAvailability").trim(); databaseAvailability = (String) jsonObject.getString("databaseAvailability").trim(); licenseServerAvailability = (String) jsonObject.getString("licenseServerAvailability").trim(); fluigAPIResults = new FluigAPIResults(goodDataAvailability, memcachedAvailability, openOfficeServerAvailability, solrServerAvailability, identityAvailability, databaseAvailability, licenseServerAvailability); } catch (NullPointerException e) { System.out.println("Nao foi possivel obter resposta JSON a partir do Fluig (null)."); System.exit(3); } catch (JSONException j) { System.out.println("JSON invalido: " + responseBody); System.exit(3); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { httpClient.getConnectionManager().shutdown(); } } }
From source file:org.fracturedatlas.athena.apa.indexing.IndexingApaAdapter.java
public void addToIndex(PTicket record) { if (record == null || record.getId() == null || indexingDisabled) { return;//from w w w . j av a2 s .c o m } logger.debug("Checking to see if [{}] is excluded from the index", record.getType()); if (excludedTypes.contains(record.getType())) { logger.debug("It is"); return; } logger.debug("It isn't"); Document doc = new Document(); StringBuilder documentText = new StringBuilder(); doc.add(new Field("_id", record.getIdAsString(), Field.Store.YES, Field.Index.ANALYZED)); doc.add(new Field("_type", record.getType(), Field.Store.YES, Field.Index.ANALYZED)); for (String key : record.getProps().keySet()) { List<String> vals = record.getProps().get(key); for (String val : vals) { addToDocument(doc, key, val); documentText.append(val).append(" "); } } addToDocument(doc, DOC_TEXT, documentText.toString()); try { IndexWriter indexWriter = getWriter(); indexWriter.addDocument(doc); indexWriter.optimize(); } catch (NullPointerException npe) { logger.error("Null pointer exception coming. Did you call initializeIndex() ?"); npe.printStackTrace(); } catch (IOException e) { logger.error("IOException when writing to index {}", e); e.printStackTrace(); } }
From source file:org.fracturedatlas.athena.apa.indexing.IndexingApaAdapter.java
public void addAllToIndex(Collection<PTicket> records) { if (records == null || records.size() == 0 || indexingDisabled) { return;/* www.j a v a 2 s . c o m*/ } config = new IndexWriterConfig(Version.LUCENE_32, analyzer); try { IndexWriter indexWriter = getWriter(); for (PTicket record : records) { if (excludedTypes.contains(record.getType())) { continue; } Document doc = new Document(); StringBuffer documentText = new StringBuffer(); doc.add(new Field("_id", record.getIdAsString(), Field.Store.YES, Field.Index.ANALYZED)); doc.add(new Field("_type", record.getType(), Field.Store.YES, Field.Index.ANALYZED)); for (String key : record.getProps().keySet()) { List<String> vals = record.getProps().get(key); for (String val : vals) { addToDocument(doc, key, val); documentText.append(val).append(" "); } } addToDocument(doc, DOC_TEXT, documentText.toString()); indexWriter.addDocument(doc); } indexWriter.optimize(); } catch (NullPointerException npe) { logger.error("Null pointer exception coming. Did you call initializeIndex() ?"); npe.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }