Example usage for android.util Log wtf

List of usage examples for android.util Log wtf

Introduction

In this page you can find the example usage for android.util Log wtf.

Prototype

public static int wtf(String tag, Throwable tr) 

Source Link

Document

What a Terrible Failure: Report an exception that should never happen.

Usage

From source file:org.jivesoftware.spark.util.DummySSLSocketFactory.java

public Socket createSocket(InetAddress inaddr, int i) throws IOException {
    AsyncTask<Object, Void, Object> socketCreationTask = new AsyncTask<Object, Void, Object>() {
        @Override//from  w  ww .  j av  a  2  s  . c  om
        protected Object doInBackground(Object... params) {
            Object ret;
            try {
                ret = factory.createSocket((InetAddress) params[0], (int) params[1]);
            } catch (Exception e) {
                Log.wtf("F6 :" + getClass().getName(), e);
                ret = e;
            }
            return ret;
        }
    };
    //It's necessary to run the task in an executor because the main one is already full and if we
    // add this one a livelock will occur
    ExecutorService socketCreationExecutor = Executors.newFixedThreadPool(1);
    socketCreationTask.executeOnExecutor(socketCreationExecutor, inaddr, i);
    Object returned;
    try {
        returned = socketCreationTask.get();
    } catch (InterruptedException | ExecutionException e) {
        Log.wtf("F7 :" + getClass().getName(), e);
        throw new IOException("Failure intentionally provoked. See log above.");
    }

    if (returned instanceof Exception) {
        throw (IOException) returned;
    } else {
        return (Socket) returned;
    }
}

From source file:com.skalski.raspberrycontrol.Activity_GPIO.java

Handler getClientHandler() {

    return new Handler() {
        @Override//from w  w  w  .jav  a2  s.com
        public void handleMessage(Message msg) {
            super.handleMessage(msg);

            JSONObject root;
            JSONArray gpios;
            gpioArray = new ArrayList<Custom_GPIOAdapter>();
            gpioLayout.setRefreshing(false);

            Log.i(LOGTAG, LOGPREFIX + "new message received from server");

            try {

                root = new JSONObject(msg.obj.toString());

                if (root.has(TAG_ERROR)) {

                    String err = getResources().getString(R.string.com_msg_3) + root.getString(TAG_ERROR);
                    Log.e(LOGTAG, LOGPREFIX + root.getString(TAG_ERROR));
                    toast_connection_error(err);

                } else {

                    gpios = root.getJSONArray(TAG_GPIOSTATE);

                    for (int i = 0; i < gpios.length(); i++) {

                        JSONObject gpioss = gpios.getJSONObject(i);

                        int gpio = gpioss.getInt(TAG_GPIO);
                        int value = gpioss.getInt(TAG_VALUE);
                        String direction = gpioss.getString(TAG_DIRECTION);

                        gpioArray.add(new Custom_GPIOAdapter(gpio, value, direction));
                    }

                    if (gpios.length() == 0) {
                        Log.w(LOGTAG, LOGPREFIX + "can't find exported GPIO's on server side");
                        toast_connection_error(getResources().getString(R.string.error_msg_8));
                    }

                    if (gpioPinout.getDrawable().getConstantState() == getResources()
                            .getDrawable(R.drawable.gpio_unknown).getConstantState()) {
                        if (root.has(TAG_REVISION)) {
                            String revision;
                            revision = root.getString(TAG_REVISION);

                            Log.i(LOGTAG, LOGPREFIX + "set new GPIO layout image");

                            if (revision.equals("0002") || revision.equals("0003")) {

                                gpioPinout.setImageResource(R.drawable.gpio_pinout_1);

                            } else if (revision.equals("0004") || revision.equals("0005")
                                    || revision.equals("0006") || revision.equals("0007")
                                    || revision.equals("0008") || revision.equals("0009")
                                    || revision.equals("000d") || revision.equals("000e")
                                    || revision.equals("000f")) {

                                gpioPinout.setImageResource(R.drawable.gpio_pinout_2);

                            } else if (revision.equals("0010") || revision.equals("0011")) {

                                gpioPinout.setImageResource(R.drawable.gpio_pinout_3);

                            } else {
                                Log.wtf(LOGTAG, LOGPREFIX + "your Raspberry Pi board is weird");
                            }
                        }
                    }
                }

            } catch (Exception ex) {
                Log.e(LOGTAG, LOGPREFIX + "received invalid JSON object");
                toast_connection_error(getResources().getString(R.string.error_msg_2));
            }

            setListAdapter(new Custom_GPIOArrayAdapter(getApplicationContext(), gpioArray));
        }
    };
}

From source file:de.jadehs.jadehsnavigator.fragment.InfoSysFragment.java

@Override
public void processFinish(ArrayList<InfoSysItem> items) {
    Log.wtf(TAG, "Starting processFinish");
    try {/* w  w w .  j ava 2  s. co  m*/
        getActivity().findViewById(R.id.progressContainer).setVisibility(View.GONE); // Hides loading icon
        if (items.size() > 0) {
            ListView lv = (ListView) getActivity().findViewById(R.id.listInfoSys);

            InfoSysItemAdapter adapter = new InfoSysItemAdapter(getActivity(), items);

            lv.setAdapter(adapter);
        }
        TextView txtLastUpdate = (TextView) getActivity().findViewById(R.id.txtLastUpdate);
        txtLastUpdate.setText("Letzte Aktualisierung: " + calendarHelper.getDateRightNow(true));
    } catch (Exception ex) {
        Log.wtf(TAG, "ERROR", ex);
    }
}

From source file:com.dubsar_dictionary.SecureClient.SecureSocketFactory.java

private javax.net.ssl.SSLSocketFactory makeSocketFactory() {
    try {//  www .  j  a va  2 s  .  c  o m
        OpenSSLContextImpl sslContext = new OpenSSLContextImpl();
        if (sTrustManagerFactory != null)
            sslContext.engineInit(null, sTrustManagerFactory.getTrustManagers(), null);
        else
            sslContext.engineInit(null, null, null);
        return sslContext.engineGetSocketFactory();
    } catch (KeyManagementException e) {
        Log.wtf(TAG, e);
        return (javax.net.ssl.SSLSocketFactory) javax.net.ssl.SSLSocketFactory.getDefault(); // Fallback
    }
}

From source file:com.github.notizklotz.derbunddownloader.download.IssueDownloadService.java

@ServiceAction
public void downloadIssue(int day, int month, int year) {
    Log.i(LOG_TAG, "Handling download intent");
    try {//  w  ww .java2 s.co  m
        boolean connected;
        final boolean wifiOnly = Settings.isWifiOnly(getApplicationContext());
        if (wifiOnly) {
            connected = waitForWifiConnection();
            if (!connected) {
                notifyUser(getText(R.string.download_wifi_connection_failed),
                        getText(R.string.download_wifi_connection_failed_text), R.drawable.ic_stat_newspaper);
            }
        } else {
            NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
            connected = activeNetworkInfo != null && activeNetworkInfo.isConnected();
            if (!connected) {
                notifyUser(getText(R.string.download_connection_failed),
                        getText(R.string.download_connection_failed_text), R.drawable.ic_stat_newspaper);
            }
        }

        if (connected) {
            if (!checkUserAccount()) {
                notifyUser(getText(R.string.download_login_failed),
                        getText(R.string.download_login_failed_text), R.drawable.ic_stat_newspaper);
            } else {
                final LocalDate issueDate = new LocalDate(day, month, year);
                fetchThumbnail(issueDate);

                final CountDownLatch downloadDoneSignal = new CountDownLatch(1);
                receiver = new DownloadCompletedBroadcastReceiver(downloadDoneSignal);
                registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));

                try {
                    String title = startDownload(issueDate, wifiOnly);
                    downloadDoneSignal.await();
                    notifyUser(title, getString(R.string.download_completed), R.drawable.ic_stat_newspaper);
                } catch (InterruptedException e) {
                    Log.wtf(LOG_TAG, "Interrupted while waiting for the downloadDoneSignal");
                }
            }
        }
    } catch (Exception e) {
        notifyUser(getText(R.string.download_service_error),
                getText(R.string.download_service_error_text) + " " + e.getMessage(),
                R.drawable.ic_stat_newspaper);
    } finally {
        cleanup();
    }
}

From source file:com.xandy.calendar.agenda.AgendaFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    int screenWidth = mActivity.getResources().getDisplayMetrics().widthPixels;
    View v = inflater.inflate(R.layout.agenda_fragment, null);

    mAgendaListView = (AgendaListView) v.findViewById(R.id.agenda_events_list);
    mAgendaListView.setClickable(true);/*from   w w w  .  jav  a  2s  .c om*/

    if (savedInstanceState != null) {
        long instanceId = savedInstanceState.getLong(BUNDLE_KEY_RESTORE_INSTANCE_ID, -1);
        if (instanceId != -1) {
            mAgendaListView.setSelectedInstanceId(instanceId);
        }
    }

    View eventView = v.findViewById(R.id.agenda_event_info);
    if (!mShowEventDetailsWithAgenda) {
        eventView.setVisibility(View.GONE);
    }

    View topListView;
    // Set adapter & HeaderIndexer for StickyHeaderListView
    StickyHeaderListView lv = (StickyHeaderListView) v.findViewById(R.id.agenda_sticky_header_list);
    if (lv != null) {
        Adapter a = mAgendaListView.getAdapter();
        lv.setAdapter(a);
        if (a instanceof HeaderViewListAdapter) {
            mAdapter = (AgendaWindowAdapter) ((HeaderViewListAdapter) a).getWrappedAdapter();
            lv.setIndexer(mAdapter);
            lv.setHeaderHeightListener(mAdapter);
        } else if (a instanceof AgendaWindowAdapter) {
            mAdapter = (AgendaWindowAdapter) a;
            lv.setIndexer(mAdapter);
            lv.setHeaderHeightListener(mAdapter);
        } else {
            Log.wtf(TAG, "Cannot find HeaderIndexer for StickyHeaderListView");
        }

        // Set scroll listener so that the date on the ActionBar can be set while
        // the user scrolls the view
        lv.setOnScrollListener(this);
        lv.setHeaderSeparator(getResources().getColor(R.color.agenda_list_separator_color), 1);
        topListView = lv;
    } else {
        topListView = mAgendaListView;
    }

    // Since using weight for sizing the two panes of the agenda fragment causes the whole
    // fragment to re-measure when the sticky header is replaced, calculate the weighted
    // size of each pane here and set it

    if (!mShowEventDetailsWithAgenda) {
        ViewGroup.LayoutParams params = topListView.getLayoutParams();
        params.width = screenWidth;
        topListView.setLayoutParams(params);
    } else {
        ViewGroup.LayoutParams listParams = topListView.getLayoutParams();
        listParams.width = screenWidth * 4 / 10;
        topListView.setLayoutParams(listParams);
        ViewGroup.LayoutParams detailsParams = eventView.getLayoutParams();
        detailsParams.width = screenWidth - listParams.width;
        eventView.setLayoutParams(detailsParams);
    }
    return v;
}

From source file:org.mozilla.gecko.home.RemoteTabsPanel.java

/**
 * Get whatever <code>Action</code> is required to continue healthy syncing
 * of Remote Tabs./*from   w  ww  .  j  a  v a2 s  . c om*/
 * <p>
 * A Firefox Account can be in many states, from healthy to requiring a
 * Fennec upgrade to continue use. If we have a Firefox Account, but the
 * state seems corrupt, the best we can do is ask for a password, which
 * resets most of the Account state. The health of a Sync account is
 * essentially opaque in this respect.
 * <p>
 * A null Account means there is no Account (Sync or Firefox) on the device.
 *
 * @param account
 *            Android Account (Sync or Firefox); may be null.
 */
private Action getActionNeeded(Account account) {
    if (account == null) {
        return null;
    }

    if (SyncConstants.ACCOUNTTYPE_SYNC.equals(account.type)) {
        return Action.None;
    }

    if (!FxAccountConstants.ACCOUNT_TYPE.equals(account.type)) {
        Log.wtf(LOGTAG, "Non Sync, non Firefox Android Account returned by AccountLoader; returning null.");
        return null;
    }

    final State state = FirefoxAccounts.getFirefoxAccountState(getActivity());
    if (state == null) {
        Log.wtf(LOGTAG, "Firefox Account with null state found; offering needs password.");
        return Action.NeedsPassword;
    }

    final Action actionNeeded = state.getNeededAction();
    if (actionNeeded == null) {
        Log.wtf(LOGTAG, "Firefox Account with non-null state but null action needed; offering needs password.");
        return Action.NeedsPassword;
    }

    return actionNeeded;
}

From source file:com.thelastcrusade.soundstream.components.ConnectFragment.java

private ConnectionService getConnectionService() {
    ConnectionService connectionService = null;
    try {/*from  w  w  w. j a va 2 s.  c om*/
        connectionService = this.connectionServiceLocator.getService();
    } catch (ServiceNotBoundException e) {
        Log.wtf(TAG, e);
    }
    return connectionService;
}

From source file:de.spiritcroc.ownlog.ui.fragment.ImportLogFragment.java

private void promptSelectStrategy() {
    switch (mImportStrategy) {
    case LATEST://from w w w.  j a va2  s .c om
        mImportStrategySelection = 0;
        break;
    case IF_NEW:
        mImportStrategySelection = 1;
        break;
    case OVERWRITE:
        mImportStrategySelection = 2;
        break;
    default:
        Log.wtf(TAG, "promptSelectStrategy: unhandled selection " + mImportStrategy);
    }
    new AlertDialog.Builder(getActivity()).setTitle(R.string.import_dialog_strategy_title)
            .setSingleChoiceItems(R.array.import_strategies, mImportStrategySelection,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            mImportStrategySelection = which;
                        }
                    })
            .setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    switch (mImportStrategySelection) {
                    case 0:
                        mImportStrategy = ImportItemInfo.Strategy.LATEST;
                        break;
                    case 1:
                        mImportStrategy = ImportItemInfo.Strategy.IF_NEW;
                        break;
                    case 2:
                        mImportStrategy = ImportItemInfo.Strategy.OVERWRITE;
                        break;
                    default:
                        Log.wtf(TAG, "promptSelectStrategy: unhandled selection " + mImportStrategySelection);
                    }
                    if (mAdapter != null) {
                        mAdapter.notifyDataSetChanged();
                    }
                }
            }).setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // Only close
                }
            }).show();
}

From source file:gxu.software_engineering.market.android.ui.EditUserInfoBoxFragment.java

@Override
public void onClick(DialogInterface dialog, int which) {
    String value = resolveValue(v);
    if (value == null) {
        Toast.makeText(getActivity(), R.string.password_wrong, Toast.LENGTH_SHORT).show();
        return;//from   w  w w.  j  av a2  s  .c  om
    }
    ContentValues user = null;
    try {
        user = new UpdateUserInfo().execute(value).get();
    } catch (Exception e) {
        Toast.makeText(getActivity(), R.string.optr_fail, Toast.LENGTH_SHORT).show();
        Log.wtf("wrong with wait the asnytask reslt!!!", e);
    }
    if (user == null) {
        Toast.makeText(getActivity(), R.string.optr_fail, Toast.LENGTH_SHORT).show();
    } else {
        getActivity().getContentResolver().insert(Uri.parse(C.BASE_URI + C.USERS), user);
        if (type == C.PASSWORD) {
            app.getPrefs().edit().putString(C.user.PASSWORD, value).commit();
        }
        Toast.makeText(getActivity(), R.string.optr_ok, Toast.LENGTH_SHORT).show();
    }
}