Example usage for java.lang IllegalArgumentException printStackTrace

List of usage examples for java.lang IllegalArgumentException printStackTrace

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.allmycode.flags.MyActivity.java

public void go(View view) {
    Intent intent = null;/*from   w ww  .java  2 s  .com*/
    String targetActivityName = "com.allmycode.flags";
    intent = new Intent();
    String fromEditText = targetActivity.getText().toString().trim();
    String other = (fromEditText.contains("Other")) ? ".other" : "";
    targetActivityName += other;
    targetActivityName += ".FlagsDemoActivity";
    targetActivityName += fromEditText;
    Log.i(CLASSNAME, "Target activity: >>" + targetActivityName + "<<");
    intent.setClassName("com.allmycode.flags" + other, targetActivityName);
    String allFlags = flags.getText().toString();
    int flagsValue = 0;
    if (allFlags != "" && allFlags != null) {

        TextUtils.SimpleStringSplitter splitter = new TextUtils.SimpleStringSplitter('|');
        splitter.setString(allFlags);
        boolean existErrors = false;
        for (String flagName : splitter) {

            Log.i(CLASSNAME, ">>" + flagName + "<<");

            flagName = flagName.trim();
            if (!flagName.equals("") && flagName != null) { // BARRY
                                                            // need
                                                            // both?
                if (isHex(flagName)) {
                    Log.i(CLASSNAME, flagName + " is hex");
                    flagsValue |= Integer.parseInt(flagName.substring(2), 16);
                } else if (isDec(flagName)) {
                    Log.i(CLASSNAME, flagName + " is decimal");
                    flagsValue |= Integer.parseInt(flagName);
                } else {
                    Field flagsField = null;
                    try {
                        Log.i(CLASSNAME, "About to do reflection>>" + flagName + "<<");
                        flagsField = Intent.class.getField(flagName);
                        Log.i(CLASSNAME, Integer.toString(flagsField.getInt(this)));
                        flagsValue |= flagsField.getInt(this);
                    } catch (SecurityException ex) {
                        existErrors = true;
                        ex.printStackTrace();
                    } catch (NoSuchFieldException ex) {
                        existErrors = true;
                        ex.printStackTrace();
                    } catch (IllegalAccessException ex) {
                        existErrors = true;
                        ex.printStackTrace();
                    }
                    try {
                        Log.i(CLASSNAME, Integer.toHexString(flagsValue));
                        if (flagsValue != 0) {
                            intent.addFlags(flagsValue);
                        }
                    } catch (IllegalArgumentException e) {
                        existErrors = true;
                        e.printStackTrace();
                    }
                }
            }
        }
        if (flagsValue != 0) {
            intent.addFlags(flagsValue);
        }
        intent.putExtra("existErrors", existErrors);

        Log.i(CLASSNAME, "About to start " + intent.toString());
        startActivity(intent);
    }
}

From source file:me.drakeet.meizhi.ui.MainActivity.java

private void startPictureActivity(Meizhi meizhi, View transitView) {
        Intent intent = PictureActivity.newIntent(MainActivity.this, meizhi.url, meizhi.desc);
        ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this,
                transitView, PictureActivity.TRANSIT_PIC);
        try {//from   w w w . j  a  v a 2  s.  c  om
            ActivityCompat.startActivity(MainActivity.this, intent, optionsCompat.toBundle());
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            startActivity(intent);
        }
    }

From source file:com.racoon.ampdroid.views.CurrentPlaylistView.java

@SuppressLint("InflateParams")
@Override//from  w  ww . j a  v a 2 s.  c o m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    controller = Controller.getInstance();
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.current_playlist, null);
    playlist = (ListView) root.findViewById(R.id.playNow_listview);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        playlist.setFastScrollAlwaysVisible(true);
    }
    seekBar = (SeekBar) root.findViewById(R.id.playNow_seekbar);
    songTitle = (TextView) root.findViewById(R.id.playNow_song);
    songArtist = (TextView) root.findViewById(R.id.playNow_artist);
    duration = (TextView) root.findViewById(R.id.playNow_duration);
    currentDuration = (TextView) root.findViewById(R.id.playNow_duration_current);
    togglePlayButton = (ImageButton) root.findViewById(R.id.playlist_play_pause);

    ArrayList<String> list = new ArrayList<String>();
    for (Song s : controller.getPlayNow()) {
        list.add(s.toString());
    }
    Log.d("songs:", list.toString());
    CurrentlyPlayingPlaylistArrayAdapter adapter = new CurrentlyPlayingPlaylistArrayAdapter(
            getActivity().getApplicationContext(), list, controller.getPlayNow());
    playlist.setAdapter(adapter);
    playlist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
            try {
                MainActivity main = (MainActivity) getActivity();
                main.play(position);
                updateSongData();
            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SecurityException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalStateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

    });
    updateSongData();
    setHasOptionsMenu(true);
    return root;
}

From source file:de.gobro.andreas.pa.pa_cleint_java.SendTouch.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_send_touch);
    View v = findViewById(R.id.main_view);
    v.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);

    maxPoints = 10;//ww  w  .j  ava 2 s .  c om

    size = new Point();

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);

    size.x = metrics.widthPixels;
    size.y = metrics.heightPixels;

    serializer = Xml.newSerializer();

    new Thread() {
        public void run() {
            try {
                Intent intent = getIntent();
                //clientSocket = new Socket("192.168.43.245",15000);
                clientSocket = new Socket(intent.getStringExtra(MainActivity.IP_FIELD), 15000);
                //TODO checkt, if connection is etabished

                out = clientSocket.getOutputStream();
                //            xml with
                //            http://www.ibm.com/developerworks/opensource/library/x-android/index.html#N102B3

                serializer.setOutput(out, "UTF-8");

                serializer.startTag("", "pa_smart_gui");
                serializer.startTag("", "init");
                serializer.startTag("", "maxTouch");
                serializer.text(maxPoints.toString());
                serializer.endTag("", "maxTouch");
                serializer.endTag("", "init");
                serializer.flush();

            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalStateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (UnknownHostException e) {
                // TODO Auto-generated catch block
                Log.d("net", "some error !!!!2");
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                Log.d("net", "some conection error");
                e.printStackTrace();
                finish();

            }

        }
    }.start();
}

From source file:playground.sergioo.networkBusLaneAdder2012.gui.BusLaneAdderPanel.java

public String getLabelText(playground.sergioo.visualizer2D2012.LayersWindow.Labels label) {
    try {//from  ww  w  .j a  va2s. c  o m
        return (String) NetworkTwoNodesPainterManager.class.getMethod("refresh" + label.getText(), new Class[0])
                .invoke(((NetworkPainter) getPrincipalLayer().getPainter()).getNetworkPainterManager(),
                        new Object[0]);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }
    return "";
}

From source file:com.jifeng.touchgallery.GalleryWidget.GalleryViewPager.java

@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
    try {//from w  ww.  j ava  2s.  co m
        float endX = 0;
        float endY = 0;
        if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
            // super.onInterceptTouchEvent(event);

            endX = event.getX();
            endY = event.getY();

            if (isAClick(startX, endX, startY, endY)) {
                if (mOnItemClickListener != null) {
                    mOnItemClickListener.onItemClicked(mCurrentView, getCurrentItem());
                }
            } else {
                super.onInterceptTouchEvent(event);
            }
        }

        if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
            startX = event.getX();
            startY = event.getY();
        }

        float[] difference = handleMotionEvent(event);

        if (mCurrentView.pagerCanScroll()) {

            return super.onInterceptTouchEvent(event);

        } else {
            if (difference != null && mCurrentView.onRightSide && difference[0] < 0) // move right
            {
                return super.onInterceptTouchEvent(event);
            }
            if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) // move left
            {
                return super.onInterceptTouchEvent(event);
            }
            if (difference == null && (mCurrentView.onLeftSide || mCurrentView.onRightSide)) {
                return super.onInterceptTouchEvent(event);
            }
        }
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        //   Log.i("11111", e.toString());
        e.printStackTrace();
    }
    return false;
}

From source file:com.jifeng.touchgallery.GalleryWidget.GalleryViewPager.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    try {//from   www  .  j a  va 2s .c  om
        if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
            // super.onInterceptTouchEvent(event);

            float endX = event.getX();
            float endY = event.getY();
            if (isAClick(startX, endX, startY, endY)) {
                if (mOnItemClickListener != null) {
                    mOnItemClickListener.onItemClicked(mCurrentView, getCurrentItem());
                }
                // launchFullPhotoActivity(imageUrls);// WE HAVE A CLICK!!
            } else {
                super.onTouchEvent(event);
            }
        }

        if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
            startX = event.getX();
            startY = event.getY();
        }

        /*
         * if ((event.getAction() & MotionEvent.ACTION_MASK) ==
         * MotionEvent.ACTION_UP) { super.onTouchEvent(event); }
         */

        float[] difference = handleMotionEvent(event);

        if (mCurrentView.pagerCanScroll()) {
            return super.onTouchEvent(event);
        } else {
            if (difference != null && mCurrentView.onRightSide && difference[0] < 0) // move right
            {
                return super.onTouchEvent(event);
            }
            if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) // move left
            {
                return super.onTouchEvent(event);
            }
            if (difference == null && (mCurrentView.onLeftSide || mCurrentView.onRightSide)) {
                return super.onTouchEvent(event);
            }
        }
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        //   Log.i("11111", e.toString());
        e.printStackTrace();
    }
    return false;
}

From source file:edu.mit.mobile.android.livingpostcards.CardListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    getActivity().getMenuInflater().inflate(R.menu.activity_card_view, menu);

    final Cursor c = mAdapter.getCursor();
    if (c == null) {
        return;/*from  w ww  . ja v  a 2s  .co  m*/
    }

    final String myUserUri = Authenticator.getUserUri(getActivity());

    final boolean isEditable = PrivatelyAuthorable.canEdit(myUserUri, c);

    menu.findItem(R.id.delete).setVisible(isEditable);
    menu.findItem(R.id.edit).setVisible(isEditable);

    menu.setHeaderTitle(Card.getTitle(getActivity(), c));
    Drawable icon;
    try {
        String iconUrl = c.getString(c.getColumnIndexOrThrow(Card.COL_COVER_PHOTO));
        if (iconUrl == null || iconUrl.length() == 0) {
            iconUrl = c.getString(c.getColumnIndexOrThrow(Card.COL_THUMBNAIL));
        }
        icon = mImageCache.loadImage(0, Uri.parse(iconUrl), (int) (133 * mDensity), (int) (100 * mDensity));

        if (icon != null) {
            menu.setHeaderIcon(new InsetDrawable(icon, (int) (5 * mDensity)));
        }
    } catch (final IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (final IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:com.orange.essentials.otb.ui.OtbTermsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    mView = inflater.inflate(R.layout.otb_terms, container, false);
    LinearLayout llayout = (LinearLayout) mView.findViewById(R.id.otb_terms_layout);
    TextView headerTv = (TextView) llayout.findViewById(R.id.otb_header_tv_text);
    headerTv.setText(R.string.otb_home_terms_content);
    List<Term> terms = TrustBadgeManager.INSTANCE.getTerms();

    for (Term term : terms) {
        View layoutToAdd = null;/*from w ww.j  a  v a 2  s .co m*/
        if (term.getTermType() == TermType.VIDEO
                && Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
            layoutToAdd = View.inflate(getActivity(), R.layout.otb_terms_video, null);
            TextView titleTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_video_title);
            final AutoResizingFrameLayout anchorView = (AutoResizingFrameLayout) layoutToAdd
                    .findViewById(R.id.videoSurfaceContainer);
            if (mVideoViews == null) {
                mVideoViews = new ArrayList<>();
            }
            mVideoViews.add(anchorView);
            SurfaceView videoSurface = (SurfaceView) layoutToAdd.findViewById(R.id.videoSurface);

            titleTv.setText(term.getTitleId());

            SurfaceHolder videoHolder = videoSurface.getHolder();
            MediaPlayer player = new MediaPlayer();
            if (mPlayers == null) {
                mPlayers = new ArrayList<>();
            }
            mPlayers.add(player);
            final VideoControllerView controller = new VideoControllerView(getContext());
            VideoCallback videoCallback = new VideoCallback(player, controller, anchorView);
            videoHolder.addCallback(videoCallback);
            anchorView.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    controller.show();
                    return false;
                }
            });
            try {
                player.setAudioStreamType(AudioManager.STREAM_MUSIC);
                player.setDataSource(getContext(), Uri.parse(getString(term.getContentId())));
                player.setOnPreparedListener(videoCallback);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (SecurityException e) {
                e.printStackTrace();
            } catch (IllegalStateException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else if (term.getTermType() == TermType.TEXT) {//TermType.TEXT
            layoutToAdd = View.inflate(getActivity(), R.layout.otb_terms_text, null);
            TextView titleTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_text_title);
            TextView contentTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_text_content);
            titleTv.setText(term.getTitleId());
            contentTv.setText(Html.fromHtml(getString(term.getContentId())));
            contentTv.setMovementMethod(LinkMovementMethod.getInstance());
            contentTv.setLinkTextColor(getResources().getColor(R.color.colorAccent));
        }
        if (null != layoutToAdd) {
            llayout.addView(layoutToAdd);
        }
        if (terms.indexOf(term) != terms.size() - 1) {
            View.inflate(getActivity(), R.layout.otb_separator, llayout);
        }
    }

    return mView;
}

From source file:net.itransformers.topologyviewer.menu.handlers.graphTools.searchMenuHandlers.SearchByIpMenuHandler.java

@Override
public void actionPerformed(ActionEvent e) {

    //                Map<String, Map<String, GraphMLMetadata<G>>> test1 = graphmlLoader();

    //        String key = JOptionPane.showInputDialog(frame, "Choose IP", JOptionPane.QUESTION_MESSAGE);
    final String ip = JOptionPane.showInputDialog(frame, "Enter IP", "Value", JOptionPane.QUESTION_MESSAGE);

    GraphViewerPanel viewerPanel = (GraphViewerPanel) frame.getTabbedPane().getSelectedComponent();
    Set<String> foundVertexes;
    foundVertexes = viewerPanel.FindNodeByKey("RoutePrefixes", new Object() {
        @Override/*from   w  w w  . j  a va  2s.  com*/
        public boolean equals(Object obj) {
            String s = (String) obj;
            String[] ipRanges = s.split(",");
            for (String ipRangeNotTrimmed : ipRanges) {
                String ipRange = ipRangeNotTrimmed.trim();
                if (ipRange.equals("") || ipRange.equals("0.0.0.0/0"))
                    continue;
                try {
                    SubnetUtils subnet = new SubnetUtils(ipRange);
                    if (subnet.getInfo().isInRange(ip)) {
                        return true;
                    }
                } catch (IllegalArgumentException iae) {
                    logger.error("Can not parse ip or ip range:" + ipRange + ", ip:" + ip);
                    System.out.println("Can not parse ip or ip range:" + ipRange + ", ip:" + ip);
                    iae.printStackTrace();
                    continue;
                }
            }
            return false;
        }
    });
    if (!foundVertexes.isEmpty()) {
        Iterator it = foundVertexes.iterator();
        if (foundVertexes.size() == 1) {
            Object element = it.next();
            System.out.println("Redrawing around " + element.toString());
            viewerPanel.SetPickedState(element.toString());
            viewerPanel.Animator(element.toString());
        } else {
            JOptionPane.showMessageDialog(frame, "Multiple Nodes with ip " + ip + " found :\n" + foundVertexes,
                    "Error", JOptionPane.ERROR_MESSAGE);
        }
    } else {
        JOptionPane.showMessageDialog(frame, "Can not find node with ip " + ip, "Error",
                JOptionPane.ERROR_MESSAGE);
    }
}