Example usage for java.lang NoSuchMethodException printStackTrace

List of usage examples for java.lang NoSuchMethodException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:com.oe.phonegap.plugins.AutoRecordVideo.java

/**
 * Creates a JSONObject that represents a File from the Uri
 *
 * @param data the Uri of the audio/image/video
 * @return a JSONObject that represents a File
 * @throws IOException/*from  ww w  .  j av  a  2  s . c om*/
 */
private JSONObject createMediaFile(Uri data) {
    File fp = webView.getResourceApi().mapUriToFile(data);
    JSONObject obj = new JSONObject();

    Class webViewClass = webView.getClass();
    PluginManager pm = null;
    try {
        Method gpm = webViewClass.getMethod("getPluginManager");
        pm = (PluginManager) gpm.invoke(webView);
    } catch (NoSuchMethodException e) {
    } catch (IllegalAccessException e) {
    } catch (InvocationTargetException e) {
    }
    if (pm == null) {
        try {
            Field pmf = webViewClass.getField("pluginManager");
            pm = (PluginManager) pmf.get(webView);
        } catch (NoSuchFieldException e) {
        } catch (IllegalAccessException e) {
        }
    }

    FileUtils filePlugin = (FileUtils) pm.getPlugin("File");
    LocalFilesystemURL url = filePlugin.filesystemURLforLocalPath(fp.getAbsolutePath());

    try {
        // File properties
        obj.put("name", fp.getName());
        obj.put("fullPath", fp.toURI().toString());
        if (url != null) {
            obj.put("localURL", url.toString());
        }
        // Because of an issue with MimeTypeMap.getMimeTypeFromExtension() all .3gpp files
        // are reported as video/3gpp. I'm doing this hacky check of the URI to see if it
        // is stored in the audio or video content store.
        if (fp.getAbsoluteFile().toString().endsWith(".3gp")
                || fp.getAbsoluteFile().toString().endsWith(".3gpp")) {
            if (data.toString().contains("/audio/")) {
                obj.put("type", AUDIO_3GPP);
            } else {
                obj.put("type", VIDEO_3GPP);
            }
        } else {
            obj.put("type", FileHelper.getMimeType(Uri.fromFile(fp), cordova));
        }

        obj.put("lastModifiedDate", fp.lastModified());
        obj.put("size", fp.length());
    } catch (JSONException e) {
        // this will never happen
        e.printStackTrace();
    }
    return obj;
}

From source file:nonjsp.application.BuildComponentFromTagImpl.java

public void applyAttributesToComponentInstance(UIComponent child, Attributes attrs) {
    int attrLen, i = 0;
    String attrName, attrValue;//from   w  w w  .  j a  v  a  2s  .c  o  m

    attrLen = attrs.getLength();
    for (i = 0; i < attrLen; i++) {
        attrName = mapAttrNameToPropertyName(attrs.getLocalName(i));
        attrValue = attrs.getValue(i);

        // First, try to set it as a bean property
        try {
            PropertyUtils.setNestedProperty(child, attrName, attrValue);
        } catch (NoSuchMethodException e) {
            // If that doesn't work, see if it requires special
            // treatment
            try {
                if (attrRequiresSpecialTreatment(attrName)) {
                    handleSpecialAttr(child, attrName, attrValue);
                } else {
                    // If that doesn't work, this will.
                    child.getAttributes().put(attrName, attrValue);
                }
            } catch (IllegalAccessException innerE) {
                innerE.printStackTrace();
                log.trace(innerE.getMessage());
            } catch (IllegalArgumentException innerE) {
                innerE.printStackTrace();
                log.trace(innerE.getMessage());
            } catch (InvocationTargetException innerE) {
                innerE.printStackTrace();
                log.trace(innerE.getMessage());
            } catch (NoSuchMethodException innerE) {
                innerE.printStackTrace();
                log.trace(innerE.getMessage());
            }
        } catch (IllegalArgumentException e) {
            try {
                if (attrRequiresSpecialTreatment(attrName)) {
                    handleSpecialAttr(child, attrName, attrValue);
                } else {
                    // If that doesn't work, this will.
                    child.getAttributes().put(attrName, attrValue);
                }
            } catch (IllegalAccessException innerE) {
                innerE.printStackTrace();
                log.trace(innerE.getMessage());
            } catch (IllegalArgumentException innerE) {
                innerE.printStackTrace();
                log.trace(innerE.getMessage());
            } catch (InvocationTargetException innerE) {
                innerE.printStackTrace();
                log.trace(innerE.getMessage());
            } catch (NoSuchMethodException innerE) {
                innerE.printStackTrace();
                log.trace(innerE.getMessage());
            }
        } catch (InvocationTargetException e) {
            e.printStackTrace();
            log.trace(e.getMessage());
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            log.trace(e.getMessage());
        }
    }

    // cleanup: make sure we have the necessary required attributes
    if (child.getId() == null) {
        String gId = "foo" + Util.generateId();
        child.setId(gId);
    }

}

From source file:com.example.leelay.galleyviewpager.GalleyViewPager.java

void setViewPagerObserver(PagerAdapter pagerObserver, DataSetObserver observer) {
    Class<? extends PagerAdapter> aClass = pagerObserver.getClass();
    try {/*from  w w  w  .ja  va 2s .c o  m*/
        Method setViewPagerObserver = aClass.getDeclaredMethod("setViewPagerObserver", DataSetObserver.class);
        setViewPagerObserver.setAccessible(true);
        setViewPagerObserver.invoke(pagerObserver, observer);
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

}

From source file:cn.trinea.android.common.view.CycleViewPager.java

/**
 * Set a PagerAdapter that will supply views for this pager as needed.
 *
 * @param adapter Adapter to use/*  w  w w  .  j  a  v a 2  s .c  om*/
 */
public void setAdapter(PagerAdapter adapter) {
    Method unreg = null;
    Method reg = null;
    if (mAdapter != null) {
        try {
            unreg = mAdapter.getClass().getMethod("unregisterDataSetObserver", DataSetObserver.class);
            reg = mAdapter.getClass().getMethod("registerDataSetObserver", DataSetObserver.class);
        } catch (NoSuchMethodException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    if (mAdapter != null && unreg != null) {
        try {
            unreg.invoke(mAdapter, mObserver);
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        //mAdapter.unregisterDataSetObserver(mObserver);
        mAdapter.startUpdate(this);
        for (int i = 0; i < mItems.size(); i++) {
            final ItemInfo ii = mItems.get(i);
            mAdapter.destroyItem(this, ii.position, ii.object);
        }
        mAdapter.finishUpdate(this);
        mItems.clear();
        removeNonDecorViews();
        mCurItem = 0;
        scrollTo(0, 0);
    }

    final PagerAdapter oldAdapter = mAdapter;
    mAdapter = adapter;

    if (mAdapter != null && reg != null) {
        if (mObserver == null) {
            mObserver = new PagerObserver();
        }
        try {
            reg.invoke(mAdapter, mObserver);
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        //mAdapter.registerDataSetObserver(mObserver);
        mPopulatePending = false;
        mFirstLayout = true;
        if (mRestoredCurItem >= 0) {
            mAdapter.restoreState(mRestoredAdapterState, mRestoredClassLoader);
            setCurrentItemInternal(mRestoredCurItem, false, true);
            mRestoredCurItem = -1;
            mRestoredAdapterState = null;
            mRestoredClassLoader = null;
        } else {
            populate();
        }
    }

    if (mAdapterChangeListener != null && oldAdapter != adapter) {
        mAdapterChangeListener.onAdapterChanged(oldAdapter, adapter);
    }

    /*wjji@lewatek.com 2014.7.7 begin*/
    if (mSupportCycle && adapter.getCount() > mOffscreenPageLimit) {
        mOffscreenPageLimit = adapter.getCount();
    }
    /*wjji@lewatek.com 2014.7.7 end*/
}

From source file:org.apache.cordova.AndroidWebView.java

/**
 * Initialize webview.// w w w  .  j  av  a2 s.c  o  m
 */
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
private void setup() {
    this.setInitialScale(0);
    this.setVerticalScrollBarEnabled(false);
    if (shouldRequestFocusOnInit()) {
        this.requestFocusFromTouch();
    }
    // Enable JavaScript
    WebSettings settings = this.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);

    // Set the nav dump for HTC 2.x devices (disabling for ICS, deprecated entirely for Jellybean 4.2)
    try {
        Method gingerbread_getMethod = WebSettings.class.getMethod("setNavDump", new Class[] { boolean.class });

        String manufacturer = android.os.Build.MANUFACTURER;
        Log.d(TAG, "CordovaWebView is running on device made by: " + manufacturer);
        if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB
                && android.os.Build.MANUFACTURER.contains("HTC")) {
            gingerbread_getMethod.invoke(settings, true);
        }
    } catch (NoSuchMethodException e) {
        Log.d(TAG, "We are on a modern version of Android, we will deprecate HTC 2.3 devices in 2.8");
    } catch (IllegalArgumentException e) {
        Log.d(TAG, "Doing the NavDump failed with bad arguments");
    } catch (IllegalAccessException e) {
        Log.d(TAG, "This should never happen: IllegalAccessException means this isn't Android anymore");
    } catch (InvocationTargetException e) {
        Log.d(TAG, "This should never happen: InvocationTargetException means this isn't Android anymore.");
    }

    //We don't save any form data in the application
    settings.setSaveFormData(false);
    settings.setSavePassword(false);

    // Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist
    // while we do this
    if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
        Level16Apis.enableUniversalAccess(settings);
    // Enable database
    // We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16
    String databasePath = this.cordova.getActivity().getApplicationContext()
            .getDir("database", Context.MODE_PRIVATE).getPath();
    settings.setDatabaseEnabled(true);
    settings.setDatabasePath(databasePath);

    //Determine whether we're in debug or release mode, and turn on Debugging!
    try {
        final String packageName = this.cordova.getActivity().getPackageName();
        final PackageManager pm = this.cordova.getActivity().getPackageManager();
        ApplicationInfo appInfo;

        appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);

        if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0
                && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
            setWebContentsDebuggingEnabled(true);
        }
    } catch (IllegalArgumentException e) {
        Log.d(TAG, "You have one job! To turn on Remote Web Debugging! YOU HAVE FAILED! ");
        e.printStackTrace();
    } catch (NameNotFoundException e) {
        Log.d(TAG, "This should never happen: Your application's package can't be found.");
        e.printStackTrace();
    }

    settings.setGeolocationDatabasePath(databasePath);

    // Enable DOM storage
    settings.setDomStorageEnabled(true);

    // Enable built-in geolocation
    settings.setGeolocationEnabled(true);

    // Enable AppCache
    // Fix for CB-2282
    settings.setAppCacheMaxSize(5 * 1048576);
    String pathToCache = this.cordova.getActivity().getApplicationContext()
            .getDir("database", Context.MODE_PRIVATE).getPath();
    settings.setAppCachePath(pathToCache);
    settings.setAppCacheEnabled(true);

    // Fix for CB-1405
    // Google issue 4641
    this.updateUserAgentString();

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
    if (this.receiver == null) {
        this.receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                updateUserAgentString();
            }
        };
        this.cordova.getActivity().registerReceiver(this.receiver, intentFilter);
    }
    // end CB-1405

    pluginManager = new PluginManager(this, this.cordova);
    jsMessageQueue = new NativeToJsMessageQueue(this, cordova);
    exposedJsApi = new AndroidExposedJsApi(pluginManager, jsMessageQueue);
    resourceApi = new CordovaResourceApi(this.getContext(), pluginManager);
    exposeJsInterface();
}

From source file:com.skytree.epubtest.BookViewActivity.java

@SuppressLint("NewApi")
public int getRawHeight() {
    int width = 0, height = 0;
    final DisplayMetrics metrics = new DisplayMetrics();
    Display display = getWindowManager().getDefaultDisplay();
    Method mGetRawH = null, mGetRawW = null;

    try {/*from   ww w.j  a  v  a2s  .  c  o  m*/
        // For JellyBeans and onward
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
            display.getRealMetrics(metrics);
            width = metrics.widthPixels;
            height = metrics.heightPixels;
        } else {
            mGetRawH = Display.class.getMethod("getRawHeight");
            mGetRawW = Display.class.getMethod("getRawWidth");
            try {
                width = (Integer) mGetRawW.invoke(display);
                height = (Integer) mGetRawH.invoke(display);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
                return 0;
            } catch (IllegalAccessException e) {
                e.printStackTrace();
                return 0;
            } catch (InvocationTargetException e) {
                e.printStackTrace();
                return 0;
            }
        }
        return height;
    } catch (NoSuchMethodException e3) {
        e3.printStackTrace();
        return 0;
    }
}

From source file:com.skytree.epubtest.BookViewActivity.java

@SuppressLint("NewApi")
public int getRawWidth() {
    int width = 0, height = 0;
    final DisplayMetrics metrics = new DisplayMetrics();
    Display display = getWindowManager().getDefaultDisplay();
    Method mGetRawH = null, mGetRawW = null;

    try {//  w  ww .j a  va 2 s . co  m
        // For JellyBeans and onward
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
            display.getRealMetrics(metrics);

            width = metrics.widthPixels;
            height = metrics.heightPixels;
        } else {
            mGetRawH = Display.class.getMethod("getRawHeight");
            mGetRawW = Display.class.getMethod("getRawWidth");

            try {
                width = (Integer) mGetRawW.invoke(display);
                height = (Integer) mGetRawH.invoke(display);
            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return 0;
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return 0;
            } catch (InvocationTargetException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return 0;
            }
        }
        return width;
    } catch (NoSuchMethodException e3) {
        e3.printStackTrace();
        return 0;
    }
}