Example usage for java.lang NullPointerException getMessage

List of usage examples for java.lang NullPointerException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:info.magnolia.cms.core.MetaData.java

/**
 * Part of metadata, same as name of actual storage node. This value is unique at the hierarchy level context.
 *
 * @return String value of the requested metadata
 *///from   ww w.  ja  v a 2 s . co  m
public String getLabel() {
    try {
        return this.node.getName();
    } catch (NullPointerException e) {
        if (log.isDebugEnabled())
            log.debug("MetaData has not been created or this node does not support MetaData"); //$NON-NLS-1$
    } catch (RepositoryException e) {
        log.error(e.getMessage(), e);
    }
    return StringUtils.EMPTY;
}

From source file:com.sfs.dao.GadgetPreferencesDAOImpl.java

/**
 * Loads a gadgetspreferences bean based on the submitted userDN If
 * successful the bean is passed to the persistOrder function.
 *
 * @param userDN the user dn//from   ww w. j  a  v a2s. c om
 *
 * @return true, if refresh order
 *
 * @throws SFSDaoException the SFS dao exception
 */
public final boolean refreshOrder(final String userDN) throws SFSDaoException {
    boolean success = false;

    GadgetsPreferencesBean gadgetsPreferences = null;
    try {
        gadgetsPreferences = this.load(userDN);
    } catch (Exception e) {
        dataLogger.error("Error loading gadget preferences: " + e.getMessage());
    }
    if (gadgetsPreferences != null) {
        try {
            success = this.persistOrder(gadgetsPreferences);
        } catch (NullPointerException npe) {
            dataLogger.error("The gadget order cannot be refreshed: " + npe.getMessage());
        }
    }
    return success;
}

From source file:org.apache.roller.weblogger.ui.rendering.velocity.deprecated.OldWeblogPageModel.java

/** Encapsulates UserManager.getPageByName() */
public ThemeTemplateWrapper getUsersPageByName(WeblogWrapper wrapper, String pageName) {
    Weblog website = wrapper.getPojo();/*w ww.j  av  a2  s .co m*/
    ThemeTemplateWrapper page = null;
    try {
        if (website == null)
            throw new NullPointerException("website is null");

        if (pageName == null)
            throw new NullPointerException("pageName is null");

        page = ThemeTemplateWrapper.wrap(website.getTheme().getTemplateByName(pageName));
    } catch (NullPointerException npe) {
        mLogger.warn(npe.getMessage());
    } catch (WebloggerException e) {
        mLogger.error("ERROR getting user's page by name: " + e.getMessage(), e);
    }
    return page;
}

From source file:org.sakaiproject.gcalendar.impl.SakaiGCalendarImpl.java

/**
 * Maps some of the Google event fields to a Calendar Event.
 * @param event/*  ww  w  .jav  a2  s.  com*/
 * @return
 */
private CalendarEventEdit createEventFromGoogleCalendarEvent(Event event) {
    SakaiGCalendarEventImpl calEvent = new SakaiGCalendarEventImpl();
    calEvent.setId(event.getId());
    calEvent.setDescription(event.getDescription());
    calEvent.setDisplayName(event.getSummary());
    calEvent.setLocation(event.getLocation());
    // Handle event start and end times.
    try {
        calEvent.setRange(
                TimeService.newTimeRange(TimeService.newTime(event.getStart().getDateTime().getValue()),
                        TimeService.newTime(event.getEnd().getDateTime().getValue())));
    } catch (NullPointerException ex) {
        M_log.error("Unexpected error with Google Calendar event. " + ex.getMessage());
    }

    return calEvent;
}

From source file:de.dmarcini.submatix.pclogger.gui.ProgramProperetysDialog.java

/**
 * Alle sprachabhngigen String setzen Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui
 * //from w  w w  . j av  a2  s .  c om
 * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 03.08.2012
 * @return alles ok?
 */
public int setLanguageStrings() {
    try {
        setTitle(LangStrings.getString("ProgramProperetysDialog.title.text"));
        databaseDirLabel.setText(LangStrings.getString("ProgramProperetysDialog.databaseDirLabel.text"));
        logfileLabel.setText(LangStrings.getString("ProgramProperetysDialog.logFileLabel.text"));
        databaseDirTextField.setToolTipText(
                LangStrings.getString("ProgramProperetysDialog.databaseDirTextField.tooltiptext"));
        logfileNameTextField.setToolTipText(
                LangStrings.getString("ProgramProperetysDialog.logfileNameTextField.tooltiptext"));
        moveDataCheckBox.setText(LangStrings.getString("ProgramProperetysDialog.moveDataCheckBox.text"));
        moveDataCheckBox
                .setToolTipText(LangStrings.getString("ProgramProperetysDialog.moveDataCheckBox.tooltiptext"));
        btnCancel.setText(LangStrings.getString("ProgramProperetysDialog.btnCancel.text"));
        btnCancel.setToolTipText(LangStrings.getString("ProgramProperetysDialog.btnCancel.tooltiptext"));
        btnOk.setText(LangStrings.getString("ProgramProperetysDialog.btnOk.text"));
        btnOk.setToolTipText(LangStrings.getString("ProgramProperetysDialog.btnOk.tooltiptext"));
        ((TitledBorder) (pahtsPanel.getBorder()))
                .setTitle(" " + LangStrings.getString("ProgramProperetysDialog.pathBorderTitle.text") + " ");
        ((TitledBorder) (unitsPanel.getBorder()))
                .setTitle(" " + LangStrings.getString("ProgramProperetysDialog.unitsBorderTitle.text") + " ");
        defaultUnitsLabel.setText(LangStrings.getString("ProgramProperetysDialog.defaultUnitsLabel.text"));
        metricUnitsLabel.setText(LangStrings.getString("ProgramProperetysDialog.metricUnitsLabel.text"));
        imperialUnitsLabel.setText(LangStrings.getString("ProgramProperetysDialog.imperialUnitsLabel.text"));
        approveLogButtonText = LangStrings.getString("ProgramProperetysDialog.approveLogButtonText.text");
        approveLogButtonTooltip = LangStrings.getString("ProgramProperetysDialog.approveLogButtonTooltip.text");
        fileChooserLogTitle = LangStrings.getString("ProgramProperetysDialog.fileChooserLogTitle.text");
        approveDirButtonText = LangStrings.getString("ProgramProperetysDialog.approveDirButtonText.text");
        approveDirButtonTooltip = LangStrings.getString("ProgramProperetysDialog.approveDirButtonTooltip.text");
        fileChooserDirTitle = LangStrings.getString("ProgramProperetysDialog.fileChooserDirTitle.text");
        fileChooserExportDirTitle = LangStrings
                .getString("ProgramProperetysDialog.fileChooserExportDirTitle.text");
        exportDirLabel.setText(LangStrings.getString("ProgramProperetysDialog.exportDirLabel.text"));
        exportDirTextField.setToolTipText(
                LangStrings.getString("ProgramProperetysDialog.exportDirTextField.tooltiptext"));
        defaultUnitsRadioButton = new JRadioButton(
                LangStrings.getString("ProgramPropertysDialog.defaultUnitsRadioButton.text")); //$NON-NLS-1$
        metricUnitsRadioButton = new JRadioButton(
                LangStrings.getString("ProgramPropertysDialog.metricUnitsRadioButton.text"));
        imperialUnitsRadioButton = new JRadioButton(
                LangStrings.getString("ProgramPropertysDialog.imperialUnitsRadioButton.text"));
    } catch (NullPointerException ex) {
        System.out.println("ERROR set language strings <" + ex.getMessage() + "> ABORT!");
        return (-1);
    } catch (MissingResourceException ex) {
        System.out.println(
                "ERROR set language strings - the given key can be found <" + ex.getMessage() + "> ABORT!");
        return (0);
    } catch (ClassCastException ex) {
        System.out.println("ERROR set language strings <" + ex.getMessage() + "> ABORT!");
        return (0);
    }
    return (1);
}

From source file:com.flexive.core.stream.BinaryDownloadProtocol.java

/**
 * {@inheritDoc}/*from   w  w  w.  j a v a 2 s . c om*/
 */
@Override
public DataPacket<BinaryDownloadPayload> processPacket(DataPacket<BinaryDownloadPayload> dataPacket)
        throws StreamException {
    if (dataPacket.isExpectResponse() && dataPacket.isExpectStream()) {
        String mimeType;
        int datasize;

        final BinaryDescriptor.PreviewSizes previewSize = BinaryDescriptor.PreviewSizes
                .fromSize(dataPacket.getPayload().getSize());
        try {
            con = Database.getNonTXDataSource(dataPacket.getPayload().getDivision()).getConnection();
            bin = loadBinaryDescriptor(dataPacket, previewSize);

            if (dataPacket.getPayload().isForceImage() && previewSize == BinaryDescriptor.PreviewSizes.ORIGINAL
                    && !bin.getMimeType().startsWith("image")) {
                // choose biggest preview size if an image is required, but the binary is no image
                bin = loadBinaryDescriptor(dataPacket, BinaryDescriptor.PreviewSizes.SCREENVIEW);
            }
        } catch (NullPointerException e) {
            //FX-782, loadBinaryDescriptor failed
            return new DataPacket<BinaryDownloadPayload>(new BinaryDownloadPayload(true, "ex.stream.notFound"),
                    false);
        } catch (FxNotFoundException e) {
            LOG.error("Failed to lookup content storage for division #" + dataPacket.getPayload().getDivision()
                    + ": " + e.getLocalizedMessage());
            return new DataPacket<BinaryDownloadPayload>(new BinaryDownloadPayload(true, "ex.stream.notFound"),
                    false);
        } catch (SQLException e) {
            throw new StreamException("Database connection error: " + e.getMessage(), e);
        }
        if (bin == null || !bin.isBinaryFound())
            return new DataPacket<BinaryDownloadPayload>(new BinaryDownloadPayload(true, "ex.stream.notFound"),
                    false);
        mimeType = bin.getMimeType();
        datasize = bin.getSize();
        _buffer = new byte[4096];
        if (!mimeType.startsWith("image")) {
            try {
                pre_read = bin.read(_buffer, 0, 100);
            } catch (IOException e) {
                //silently ignore
            }
            String tmp = FxMediaEngine.detectMimeType(_buffer);
            if (tmp.startsWith("image"))
                mimeType = tmp;
        } else
            pre_read = 0;
        return new DataPacket<BinaryDownloadPayload>(new BinaryDownloadPayload(mimeType, datasize), false);
    }
    return null;
}

From source file:com.bzcentre.dapiPush.DapiReceiver.java

@Override
public Object[] invoke(Map<String, Object> request) {
    NginxClojureRT.log.info(TAG + " is invoked...");
    String chk_token;// www  . ja v  a 2s . c o  m
    String user_id;
    String invitations;
    String return_code = "";
    String dummy_header = "http://www.dummy.com/dummy?"; // full url for URLEncodedUtils
    String payload;
    String provider;
    MsgCounter msgCounter = new MsgCounter();
    @SuppressWarnings("unused")
    Integer isModerator;
    String query;
    String dapiToken = newBzToken(service_seed);
    int push_status = NGX_HTTP_FORBIDDEN;

    GsonBuilder gBuilder = new GsonBuilder();
    gBuilder.registerTypeAdapter(new TypeToken<Receipient>() {
    }.getType(), new ReceipientTypeAdapter());
    Gson g = gBuilder.disableHtmlEscaping().serializeNulls().create();
    List<String[]> undeliverables = new ArrayList<>();
    Set<String> deliverables = new HashSet<>();

    String msg = "";
    errMsg = null;

    String requestMethod;

    // Supported request map constants can be find in the MiniConstants file
    requestMethod = request.get(REQUEST_METHOD).toString();
    if (requestMethod.equals(GET) && request.containsKey(QUERY_STRING)) {
        try {
            msg = dummy_header + request.get(QUERY_STRING).toString();
        } catch (NullPointerException e) {
            errMsg = "NullPointerException" + e.getMessage();
        }
    } else if (requestMethod.equals(POST)) {
        if (request.containsKey(BODY)) {
            InputStream body = (InputStream) request.get(BODY);
            BufferedReader bReader = new BufferedReader(new InputStreamReader(body));
            StringBuilder sbfFileContents = new StringBuilder();
            //read file line by line
            try {
                while ((msg = bReader.readLine()) != null) {
                    sbfFileContents.append(msg);
                }
                msg = dummy_header + sbfFileContents.toString();
            } catch (IOException e) {
                errMsg = "IOException" + e.getMessage();
            } catch (NullPointerException e) {
                errMsg = "Null Content, Error :" + e.getMessage();
            }
        } else {
            errMsg = "NO BODY";
        }
    }

    if (errMsg != null) {
        NginxClojureRT.log.info(TAG + "http parse error:" + errMsg);
        return new Object[] { NGX_HTTP_BAD_REQUEST, ArrayMap.create(CONTENT_TYPE, "text/plain"), //headers map
                "{\"method\":\"" + requestMethod + " \", \"message\":\"" + errMsg + "\"}" //response body can be string, File or Array/Collection of string or File
        };
    }
    // invitations is a base64+URLencoded string
    try {
        NginxClojureRT.log.debug(TAG + "msg get from body:\n" + msg);

        final Map<String, Object> queryMap = convertQueryStringToMap(msg);
        PushNotificationResponse<SimpleApnsPushNotification> apnsProxyResponse;
        chk_token = queryMap.get("dapiToken").toString();
        user_id = queryMap.get("user_id").toString();

        invitations = queryMap.get("invitations").toString();
        invitations = StringUtils.newStringUtf8(Base64.decodeBase64(invitations));
        NginxClojureRT.log.debug(TAG + "after base64 decode:\n" + invitations);

        if (chk_token.equals(dapiToken)) { // Hoicoi Token validation
            List<Receipient> invitees;
            NginxClojureRT.log.info(TAG + "Parsing invitees from json..." + invitations);
            invitees = g.fromJson(invitations, new TypeToken<ArrayList<Receipient>>() {
            }.getType());

            NginxClojureRT.log.info(TAG + "user " + user_id + " is sending " + invitees.size()
                    + " push token(s) to user(s) " + g.toJson(invitees.get(0).getPayload().getAcme7()));
            // receipient={"fcm_token","apns_token","payload"}
            // payload class is as APNS message payload defined, FCM needs to map to it.
            msgCounter.countdown = invitees.size();
            NginxClojureRT.log.info(TAG + "msgCounter[countdown,apns,fcm]:" + msgCounter.list());
            for (Receipient receipient : invitees) {
                return_code = "";
                payload = g.toJson(receipient.getPayload());
                //                  isModerator= receipient.getIsMdr();

                // default state sent_request, ApnsProxy will validate the result and make state update
                if (receipient.getApns_Token() != null && !receipient.getApns_Token().isEmpty()
                        && payload != null) {
                    query = "INSERT INTO `notification_push_blacklist` (`provider`,`user_id`,`to_token`) VALUES ('apns',"
                            + receipient.getPayload().getAcme8() + ",'" + receipient.getApns_Token() + "')";
                    try {
                        stmt.executeUpdate(query);
                    } catch (SQLException e) {
                        if (e.getErrorCode() != 1062) { // code 1062=duplicate entry
                            NginxClojureRT.log.info(TAG + "apns query exception near line 186: "
                                    + e.getMessage() + " when\n" + query);
                        }
                    }

                    provider = "apns";
                    switch (inBlackList(receipient.getPayload().getAcme8(), receipient.getApns_Token())) {
                    case "sent_request":
                    case "false":

                        apnsProxyResponse = apnsProxy.apnsPush(receipient.getApns_Token(), payload);

                        if (apnsProxyResponse.isAccepted()) {
                            NginxClojureRT.log.info(TAG + "Pushing notification to user "
                                    + receipient.getPayload().getAcme8() + " through APNS.");

                            MessageProcessor.pushBlackList(receipient.getApns_Token(), "whiteList", null);
                            deliverables.add(receipient.getPayload().getAcme8());
                            push_status = (push_status == NGX_HTTP_FORBIDDEN ? NGX_HTTP_NO_CONTENT
                                    : push_status); //status 204
                            return_code = "apns_pushOK";
                            msgCounter.countdown--;
                            msgCounter.apns++;
                        } else {
                            String reason = apnsProxyResponse.getRejectionReason();
                            Date timestamp = apnsProxyResponse.getTokenInvalidationTimestamp();
                            push_status = NGX_HTTP_NOT_FOUND;

                            if (reason.equals("BadDeviceToken") || reason.equals("Unregistered")) {
                                MessageProcessor.pushBlackList(receipient.getApns_Token(), reason, timestamp);
                            } else {
                                MessageProcessor.pushBlackList(receipient.getApns_Token(), "whiteList", null);
                            }

                            String[] undeliverable = { provider, receipient.getApns_Token(),
                                    receipient.getPayload().getAcme8() };
                            undeliverables.add(undeliverable);
                            msgCounter.countdown--;
                        }
                        break;
                    case "inactive":
                        push_status = NGX_HTTP_NOT_FOUND;// status 404, to indicate that the user removes the app.
                        return_code = "Unregistered";
                        String[] undeliverable = { provider, receipient.getApns_Token(),
                                receipient.getPayload().getAcme8() };
                        undeliverables.add(undeliverable);
                        msgCounter.countdown--;
                        NginxClojureRT.log.info(TAG + "Already in blacklist:" + receipient.getApns_Token());
                        break;
                    default:
                        msgCounter.countdown--;
                        return_code = "apns_blacklist_null_exception";
                        NginxClojureRT.log.info(TAG + "APNS BlackList check return null!");
                        break;
                    }
                }

                if (receipient.getFcm_Token() != null && receipient.getFcm_Token().isEmpty()
                        && payload != null) {
                    //                     Timestamp timestamp = new Timestamp(System.currentTimeMillis());
                    query = "INSERT INTO `notification_push_blacklist` (`provider`,`user_id`,`to_token`) VALUES ('fcm',"
                            + receipient.getPayload().getAcme8() + ",'" + receipient.getFcm_Token() + "')";
                    try {
                        stmt.executeUpdate(query);
                    } catch (SQLException e) {
                        if (e.getClass().getName().equals("com.mysql.jdbc.CommunicationsException")) {
                            rebuildDBConnection("stmt", query);
                        }

                        if (e.getErrorCode() != 1062) { // code 1062=duplicate entry
                            NginxClojureRT.log.info(TAG + "odbc query exception near line 223 => Code:"
                                    + e.getErrorCode() + " : " + e.getMessage() + "\n" + query);
                        }
                    }

                    provider = "fcm";
                    String responseType = inBlackList(receipient.getPayload().getAcme8(),
                            receipient.getFcm_Token());
                    switch (responseType) {
                    case "sent_request":
                    case "false":
                        msgCounter.countdown--;
                        if (fcmProxy.fcmPush(receipient.getFcm_Token(), payload)) {
                            deliverables.add(receipient.getPayload().getAcme8());
                            push_status = (push_status == NGX_HTTP_FORBIDDEN ? NGX_HTTP_NO_CONTENT
                                    : push_status); //status 204
                            return_code = "fcm_pushOK";
                            msgCounter.fcm++;
                            break;
                        } else {
                            String response = inBlackList(receipient.getPayload().getAcme8(),
                                    receipient.getFcm_Token());
                            if (!response.equals("inactive")) {
                                NginxClojureRT.log.info("TAG"
                                        + "Some thing wrong with the fcmPush. Expecting inactive but ... ->"
                                        + response);
                                break;
                            } else {
                                msgCounter.countdown++; // if is inactive, continue inactive block, so add the counter back.
                            }
                        }
                    case "inactive":
                        push_status = NGX_HTTP_NOT_FOUND;// status 404, to indicate that the user removes the app.
                        return_code = "Unregistered";
                        String[] undeliverable = { provider, receipient.getFcm_Token(),
                                receipient.getPayload().getAcme8() };
                        undeliverables.add(undeliverable);
                        msgCounter.countdown--;
                        if (responseType.equals("inactive"))
                            NginxClojureRT.log.info(TAG + "Already in blacklist:" + receipient.getFcm_Token());
                        break;
                    default:
                        msgCounter.countdown--;
                        return_code = "fcm_blacklist_null_exception";
                        NginxClojureRT.log.info(TAG + "FCM BlackList nullException!");
                        break;
                    }
                }
                NginxClojureRT.log.info(TAG + "msgCounter[countdown,apns,fcm]:" + msgCounter.list());
                if (msgCounter.countdown == 0) {
                    NginxClojureRT.log.info(TAG + "There are " + (msgCounter.apns + msgCounter.fcm)
                            + " notification(s) ha(s)(ve) been successfully pushed to user(s) "
                            + g.toJson(deliverables) + " for => "
                            + invitees.get(0).getPayload().getAps().getAlert().getBody());
                    return wrapupPushResult(receipient.getPayload().getAcme8(), push_status, return_code,
                            deliverables, msgCounter, undeliverables);
                }
            }
        } else {
            return_code = "InvalidToken";
            errMsg = "HoiCoi Token is not valid<br>" + chk_token + "<br>" + dapiToken;
        }
    } catch (IllegalArgumentException | JsonParseException | IllegalStateException | NullPointerException
            | ClassCastException | URISyntaxException e) {
        return_code = e.getClass().getName();
        errMsg = e.getMessage();
        e.printStackTrace();
    }

    return new Object[] { NGX_HTTP_FORBIDDEN, ArrayMap.create(CONTENT_TYPE, "text/plain"), //headers map
            "{\"code\":\"" + (return_code.isEmpty() ? "future_not_response" : return_code)
                    + "\", \"message\":\"Should return from the Future response.\"}" //response body can be string, File or Array/Collection of string or File
    };
}

From source file:de.juwimm.cms.content.panel.PanDocuments.java

private void btnDeleteActionPerformed(ActionEvent e) {
    try {//  ww w.  ja  v  a  2s .  c om
        DocumentSlimValue currDoc = null;
        String acc = bgrp.getSelection().getActionCommand();
        int rowInModel = tblDocumentsModel.getRowForDocument(Integer.valueOf(acc));
        if (rowInModel >= 0) {
            currDoc = (DocumentSlimValue) tblDocumentsModel.getValueAt(rowInModel, 4);
        }
        String tmp = acc;
        if (currDoc != null && currDoc.getDocumentName() != null
                && !"".equalsIgnoreCase(currDoc.getDocumentName())) {
            tmp += " (" + currDoc.getDocumentName() + ")";
        }
        /*
        if (currDoc != null && (currDoc.getUseCountLastVersion() + currDoc.getUseCountPublishVersion()) > 0) {
           JOptionPane.showMessageDialog(this,
          SwingMessages.getString("panel.content.documents.deleteButInUse", tmp), 
          SwingMessages.getString("panel.content.documents.deleteDocument"), 
          JOptionPane.WARNING_MESSAGE);
           return;
        }
        */
        int ret = JOptionPane.showConfirmDialog(this,
                Messages.getString("panel.content.documents.deleteThisDocument", tmp),
                Messages.getString("panel.content.documents.deleteDocument"), JOptionPane.WARNING_MESSAGE,
                JOptionPane.YES_NO_OPTION);
        if (ret == JOptionPane.YES_OPTION) {
            comm.removeDocument(Integer.valueOf(acc).intValue());
            loadThumbs(((CboModel) this.cboRegion.getSelectedItem()).getRegionId());
        }
    } catch (NullPointerException ex) {
    } catch (Exception ex) {
        if (ex.getMessage().contains("validation exception")) {
            JOptionPane.showConfirmDialog(this, rb.getString("panel.content.documents.delete.exception"),
                    rb.getString("panel.content.documents.deleteDocument"), JOptionPane.DEFAULT_OPTION,
                    JOptionPane.ERROR_MESSAGE);
        } else {
            log.warn("exception on delete document");
            if (log.isDebugEnabled()) {
                log.debug(ex);
            }
        }
    }
}

From source file:hku.fyp14017.blencode.ui.fragment.LookFragment.java

public void sendPocketPaintIntent(int selectedPosition, Intent intent) {

    if (!LookController.getInstance().checkIfPocketPaintIsInstalled(intent, getActivity())) {
        return;//from   w  ww. j  a  va 2  s  . co  m
    }

    selectedLookData = lookDataList.get(selectedPosition);

    Bundle bundleForPocketPaint = new Bundle();

    try {
        File tempCopy = StorageHandler.getInstance()
                .makeTempImageCopy(lookDataList.get(selectedPosition).getAbsolutePath());

        bundleForPocketPaint.putString(Constants.EXTRA_PICTURE_PATH_POCKET_PAINT, tempCopy.getAbsolutePath());
        bundleForPocketPaint.putInt(Constants.EXTRA_X_VALUE_POCKET_PAINT, 0);
        bundleForPocketPaint.putInt(Constants.EXTRA_Y_VALUE_POCKET_PAINT, 0);
        intent.putExtras(bundleForPocketPaint);

        intent.addCategory("android.intent.category.LAUNCHER");
        startActivityForResult(intent, LookController.REQUEST_POCKET_PAINT_EDIT_IMAGE);
    } catch (IOException ioException) {
        Log.e(TAG, Log.getStackTraceString(ioException));
    } catch (NullPointerException e) {
        Log.e(TAG, e.getMessage());
    }

}

From source file:hku.fyp14017.blencode.ui.fragment.LookFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    listView = getListView();//  ww w .j  a  va2s .  co  m

    if (listView != null) {
        registerForContextMenu(listView);
    }

    if (savedInstanceState != null) {
        selectedLookData = (LookData) savedInstanceState
                .getSerializable(LookController.BUNDLE_ARGUMENTS_SELECTED_LOOK);

        boolean uriIsSet = savedInstanceState.getBoolean(LookController.BUNDLE_ARGUMENTS_URI_IS_SET);
        if (uriIsSet) {
            String defLookName = getString(hku.fyp14017.blencode.R.string.default_look_name);
            lookFromCameraUri = UtilCamera.getDefaultLookFromCameraUri(defLookName);
        }
    }
    try {
        lookDataList = ProjectManager.getInstance().getCurrentSprite().getLookDataList();
    } catch (NullPointerException e) {
        Log.e(TAG, e.getMessage());
    }

    if (ProjectManager.getInstance().getCurrentSpritePosition() == 0) {
        TextView emptyViewHeading = (TextView) getActivity()
                .findViewById(hku.fyp14017.blencode.R.id.fragment_look_text_heading);
        emptyViewHeading.setTextSize(TypedValue.COMPLEX_UNIT_SP, 60.0f);
        emptyViewHeading.setText(hku.fyp14017.blencode.R.string.backgrounds);
        TextView emptyViewDescription = (TextView) getActivity()
                .findViewById(hku.fyp14017.blencode.R.id.fragment_look_text_description);
        emptyViewDescription.setText(hku.fyp14017.blencode.R.string.fragment_background_text_description);
    }

    adapter = new LookAdapter(getActivity(), hku.fyp14017.blencode.R.layout.fragment_look_looklist_item,
            hku.fyp14017.blencode.R.id.fragment_look_item_name_text_view, lookDataList, false);
    adapter.setOnLookEditListener(this);
    setListAdapter(adapter);
    ((LookAdapter) adapter).setLookFragment(this);

    Utils.loadProjectIfNeeded(getActivity());
}