Example usage for java.lang NullPointerException getLocalizedMessage

List of usage examples for java.lang NullPointerException getLocalizedMessage

Introduction

In this page you can find the example usage for java.lang NullPointerException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:cz.tsystems.portablecheckin.MainActivity.java

public void showData(Intent intent) {
    app.dismisProgressDialog();// w w w  .j  a  va  2  s.com
    String action = intent.getAction();
    String serviceAction = null;
    if (action.equalsIgnoreCase("recivedData")) {
        try {
            Bundle b = intent.getExtras().getBundle("requestData");
            if (b == null)
                return;
            serviceAction = b.getString("ACTION");
            if (serviceAction == null)
                return;
            Log.d("SHOWDATA", intent.getExtras().toString());
        } catch (NullPointerException e) {
            app.getDialog(getActivity(), "error", e.getLocalizedMessage(),
                    PortableCheckin.DialogType.SINGLE_BUTTON).show();
        }
        if (serviceAction.equalsIgnoreCase("CheckinOrderList"))
            showPlanZakazky();
        else if (serviceAction.equalsIgnoreCase("DataForCheckIn"))
            loadCheckinData();
    }
}

From source file:com.synox.android.ui.activity.Uploader.java

private void prepareStreamsToUpload() {
    try {//from  w  w w .  j a v a2  s.  c  om
        if (getIntent().getAction().equals(Intent.ACTION_SEND)) {
            mStreamsToUpload = new ArrayList<>();
            mStreamsToUpload.add(getIntent().getParcelableExtra(Intent.EXTRA_STREAM));
        } else if (getIntent().getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
            mStreamsToUpload = getIntent().getParcelableArrayListExtra(Intent.EXTRA_STREAM);
        }
    } catch (NullPointerException npe) {
        Log_OC.e(this.getClass().getName(), "Unknown error occurred. Message: " + npe.getLocalizedMessage());
    }
}

From source file:au.com.addstar.objects.Plugin.java

public Plugin setLatestVer() {

    try {//from  w ww  .  ja  va  2s .c o m
        if (latestFile == null)
            return this;
        try (JarFile jar = new JarFile(latestFile);) {
            String descriptorFileName = "plugin.yml";
            if (type != null) {
                switch (type) {
                case BUKKIT:
                    descriptorFileName = "plugin.yml";
                    break;
                case BUNGEE:
                    descriptorFileName = "bungee.yml";
                    break;
                default:
                    descriptorFileName = "plugin.yml";
                }
            }
            JarEntry je = jar.getJarEntry(descriptorFileName);
            if (je == null)
                je = jar.getJarEntry("plugin.yml");
            JarEntry sv = jar.getJarEntry("spigot.ver");
            if (sv != null) {
                try (InputStream svstream = jar.getInputStream(sv);
                        InputStreamReader reader = new InputStreamReader(svstream);
                        BufferedReader bs = new BufferedReader(reader);) {
                    spigotVersion = bs.readLine();
                    bs.close();
                    reader.close();
                    svstream.close();
                }
            } else {
                if (spigotVersion != null)
                    addSpigotVer(spigotVersion);
            }
            try (InputStream stream = jar.getInputStream(je);) {
                PluginDescriptionFile pdf = new PluginDescriptionFile(stream);
                pdfVersion = pdf.getVersion();
            } catch (NullPointerException e) {
                System.out.println("Plugin: " + this.getName() + " File: " + jar.getName()
                        + " does not appear to be a valid plugin (" + latestFile.getAbsolutePath() + ")");
                pdfVersion = null;
            }
        }

        if (spigotVersion != null && !spigotVersion.equals(pdfVersion)) {
            version = spigotVersion;
        } else {
            version = pdfVersion;
        }

        lastUpdated = new Date(latestFile.lastModified());
    } catch (ZipException e) {

    } catch (IOException | InvalidDescriptionException e) {
        System.out.println(e.getLocalizedMessage());
    }
    return this;
}

From source file:it.geosolutions.geocollect.android.core.mission.PendingMissionListActivity.java

/**
 * Since the triggering intent is launched by the activity and not bay a Fragment the child Fragments will not receive the result We override the
 * default onActivityResult() to propagate the result to the child Fragments
 *//*from  w ww.j  a  va 2  s . c o  m*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == LoginActivity.REQUEST_LOGIN) {

        if (resultCode == RESULT_CANCELED) {
            // user cancelled to enter credentials
            Toast.makeText(getBaseContext(), getString(R.string.login_canceled), Toast.LENGTH_LONG).show();
            finish();
            return;
        }
    }
    if (requestCode == LogoutActivity.REQUEST_LOGOUT) {
        if (resultCode == LogoutActivity.LOGGED_OUT) {
            // there is a notification in LogoutActivity already
            startActivityForResult(new Intent(this, LoginActivity.class), LoginActivity.REQUEST_LOGIN);
            return;
        }
    }

    if (requestCode == PendingMissionListActivity.SPATIAL_QUERY) {
        shouldStartMap = false;
        if (data != null && data.hasExtra(KEY_MAP_RESULT)) {

            onNavItemSelected(data.getIntExtra(KEY_MAP_RESULT, 900));

            return;
        }
    }

    navConf = getNavDrawerConfiguration();
    mDrawerList.setAdapter(navConf.getBaseAdapter());

    Log.d(TAG, "navdrawer updated");
    navConf.getBaseAdapter().notifyDataSetChanged();

    // We need to explicitly call the child Fragments onActivityResult()
    for (Fragment fragment : getSupportFragmentManager().getFragments()) {
        try {
            fragment.onActivityResult(requestCode, resultCode, data);
        } catch (NullPointerException npe) {
            // TODO This is ABS bug, need to switch to ActionBarCompat
            Log.e(TAG, npe.getLocalizedMessage(), npe);
        }
    }
}

From source file:com.synox.android.ui.activity.Uploader.java

public void uploadFiles() {
    try {//from  w  ww . j a  v  a 2 s .c o m

        // ArrayList for files with path in external storage
        ArrayList<String> local = new ArrayList<>();
        ArrayList<String> remote = new ArrayList<>();

        // this checks the mimeType
        for (Parcelable mStream : mStreamsToUpload) {

            Uri uri = (Uri) mStream;
            String data = null;
            String filePath = "";

            if (uri != null) {
                if (uri.getScheme().equals("content")) {
                    String mimeType = getContentResolver().getType(uri);

                    if (mimeType.contains("image")) {
                        String[] CONTENT_PROJECTION = { Images.Media.DATA, Images.Media.DISPLAY_NAME,
                                Images.Media.MIME_TYPE, Images.Media.SIZE };
                        Cursor c = getContentResolver().query(uri, CONTENT_PROJECTION, null, null, null);
                        c.moveToFirst();
                        int index = c.getColumnIndex(Images.Media.DATA);
                        data = c.getString(index);
                        filePath = mUploadPath + c.getString(c.getColumnIndex(Images.Media.DISPLAY_NAME));

                    } else if (mimeType.contains("video")) {
                        String[] CONTENT_PROJECTION = { Video.Media.DATA, Video.Media.DISPLAY_NAME,
                                Video.Media.MIME_TYPE, Video.Media.SIZE, Video.Media.DATE_MODIFIED };
                        Cursor c = getContentResolver().query(uri, CONTENT_PROJECTION, null, null, null);
                        c.moveToFirst();
                        int index = c.getColumnIndex(Video.Media.DATA);
                        data = c.getString(index);
                        filePath = mUploadPath + c.getString(c.getColumnIndex(Video.Media.DISPLAY_NAME));

                    } else if (mimeType.contains("audio")) {
                        String[] CONTENT_PROJECTION = { Audio.Media.DATA, Audio.Media.DISPLAY_NAME,
                                Audio.Media.MIME_TYPE, Audio.Media.SIZE };
                        Cursor c = getContentResolver().query(uri, CONTENT_PROJECTION, null, null, null);
                        c.moveToFirst();
                        int index = c.getColumnIndex(Audio.Media.DATA);
                        data = c.getString(index);
                        filePath = mUploadPath + c.getString(c.getColumnIndex(Audio.Media.DISPLAY_NAME));

                    } else {
                        Cursor cursor = getContentResolver().query(uri,
                                new String[] { MediaStore.MediaColumns.DISPLAY_NAME }, null, null, null);
                        cursor.moveToFirst();
                        int nameIndex = cursor.getColumnIndex(cursor.getColumnNames()[0]);
                        if (nameIndex >= 0) {
                            filePath = mUploadPath + cursor.getString(nameIndex);
                        }
                    }

                } else if (uri.getScheme().equals("file")) {
                    filePath = Uri.decode(uri.toString()).replace(uri.getScheme() + "://", "");
                    if (filePath.contains("mnt")) {
                        String splitedFilePath[] = filePath.split("/mnt");
                        filePath = splitedFilePath[1];
                    }
                    final File file = new File(filePath);
                    data = file.getAbsolutePath();
                    filePath = mUploadPath + file.getName();
                } else {
                    throw new SecurityException();
                }
                if (data == null) {
                    mRemoteCacheData.add(filePath);
                    CopyTmpFileAsyncTask copyTask = new CopyTmpFileAsyncTask(this);
                    Object[] params = { uri, filePath, mRemoteCacheData.size() - 1, getAccount().name,
                            getContentResolver() };
                    mNumCacheFile++;
                    showWaitingCopyDialog();
                    copyTask.execute(params);
                } else {
                    remote.add(filePath);
                    local.add(data);
                }
            } else {
                throw new SecurityException();
            }

            Intent intent = new Intent(getApplicationContext(), FileUploader.class);
            intent.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_MULTIPLE_FILES);
            intent.putExtra(FileUploader.KEY_LOCAL_FILE, local.toArray(new String[local.size()]));
            intent.putExtra(FileUploader.KEY_REMOTE_FILE, remote.toArray(new String[remote.size()]));
            intent.putExtra(FileUploader.KEY_ACCOUNT, getAccount());
            startService(intent);

            //Save the path to shared preferences
            SharedPreferences.Editor appPrefs = PreferenceManager
                    .getDefaultSharedPreferences(getApplicationContext()).edit();
            appPrefs.putString("last_upload_path", mUploadPath);
            appPrefs.apply();

            finish();
        }

    } catch (SecurityException e) {
        String message = String.format(getString(R.string.uploader_error_forbidden_content),
                getString(R.string.app_name));
        Toast.makeText(this, message, Toast.LENGTH_LONG).show();
    } catch (NullPointerException npe) {
        Log_OC.e(this.getClass().getName(), "Unknown error occurred. Message: " + npe.getLocalizedMessage());
    }
}

From source file:org.noise_planet.noisecapture.CalibrationLinearityActivity.java

private void initSelectedGraph() {
    try {/*from  www . ja  v  a2 s . c om*/
        switch (viewPager.getCurrentItem()) {
        case PAGE_SCATTER_CHART:
            initScatter();
            break;
        case PAGE_LINE_CHART:
            initLine();
            break;
        case PAGE_BAR_CHART:
            initBar();
            break;
        }
    } catch (NullPointerException ex) {
        // May arise while measuring
        LOGGER.error(ex.getLocalizedMessage(), ex);
    }
}

From source file:org.noise_planet.noisecapture.CalibrationLinearityActivity.java

private void updateSelectedGraph() {
    try {//from  ww w. j  av a 2 s.  c o m
        switch (viewPager.getCurrentItem()) {
        case PAGE_SCATTER_CHART:
            updateScatterChart();
            break;
        case PAGE_LINE_CHART:
            updateLineChart();
            break;
        case PAGE_BAR_CHART:
            updateBarChart();
            break;
        }
    } catch (NullPointerException ex) {
        // May arise while measuring
        LOGGER.error(ex.getLocalizedMessage(), ex);
    }
}

From source file:it.geosolutions.geobatch.flow.file.FileBasedFlowManager.java

public void postEvent(FileSystemEvent event) {
    try {/*from w  ww.  ja  v  a  2 s  .c  o  m*/
        if (!eventMailBox.offer(event)) {
            if (LOGGER.isErrorEnabled()) {
                LOGGER.error("--------------------------------------------------------------------");
                LOGGER.error("Unable to add the event to the eventMailBox. (Flow id:" + this.getId()
                        + ").\nEvent source: " + event.getSource() + "\nMailBox size: " + eventMailBox.size()
                        + "\nPlease check your configuration.");
                LOGGER.error("--------------------------------------------------------------------");
            }
        }
    } catch (NullPointerException npe) {
        if (LOGGER.isErrorEnabled()) {
            LOGGER.error("Unable to add a null event to the flow manager (id:" + this.getId()
                    + ") eventMailBox.\nMessage is:" + npe.getLocalizedMessage(), npe);
        }
        throw npe;
    }
}

From source file:nl.cyso.vcloud.client.vCloudClient.java

public void listVApps(String org, String vdc) {
    this.vccPreCheck();

    Vdc vdcObj = this.getVDC(org, vdc);

    try {/*  www  .  j  av  a2 s. c o  m*/
        Formatter.printInfoLine("This virtual data center contains:\n");
        for (ReferenceType vappRef : vdcObj.getVappRefs()) {
            Vapp vapp = Vapp.getVappByReference(this.vcc, vappRef);
            Formatter.printInfoLine(
                    String.format("%-20s - %s", vappRef.getName(), vapp.getResource().getDescription()));

            for (VAppNetworkConfigurationType vn : vapp.getVappNetworkConfigurations()) {
                StringBuilder i = new StringBuilder();

                try {
                    List<IpRangeType> vips = vn.getConfiguration().getIpScope().getIpRanges().getIpRange();

                    for (IpRangeType ip : vips) {
                        i.append(String.format(" %s - %s ", ip.getStartAddress(), ip.getEndAddress()));
                    }
                } catch (NullPointerException e) {
                    i.append("?");
                }
                Formatter.printInfoLine(String.format("\t%-10s (%s)", vn.getNetworkName(), i.toString()));
            }
        }
    } catch (VCloudException e) {
        Formatter.printErrorLine("An error occured while retrieving vApps");
        Formatter.printErrorLine(e.getLocalizedMessage());
        System.exit(1);
    }
}

From source file:nl.cyso.vcloud.client.vCloudClient.java

public void listVDCs(String org) {
    this.vccPreCheck();

    Organization orgObj = this.getOrganization(org);

    try {/*from w  w w  . j  a va 2  s  . com*/
        Formatter.printInfoLine("This organization contains:\n\n");
        for (ReferenceType vdcRef : orgObj.getVdcRefs()) {
            Vdc vdc = Vdc.getVdcByReference(this.vcc, vdcRef);
            Formatter.printInfoLine(
                    String.format("%-20s - %s", vdcRef.getName(), vdc.getResource().getDescription()));

            for (ReferenceType netRef : vdc.getAvailableNetworkRefs()) {
                OrgVdcNetwork net = OrgVdcNetwork.getOrgVdcNetworkByReference(this.vcc, netRef);

                StringBuilder i = new StringBuilder();
                try {
                    List<IpRangeType> ips = net.getResource().getConfiguration().getIpScope().getIpRanges()
                            .getIpRange();
                    for (IpRangeType ip : ips) {
                        i.append(String.format(" %s - %s ", ip.getStartAddress(), ip.getEndAddress()));
                    }
                } catch (NullPointerException e) {
                    i.append("?");
                }

                Formatter.printInfoLine(
                        String.format("\t%-10s (%s)", net.getResource().getName(), i.toString()));
            }
        }
    } catch (VCloudException e) {
        Formatter.printErrorLine("An error occured while retrieving virtual data centers");
        Formatter.printErrorLine(e.getLocalizedMessage());
        System.exit(1);
    }
}