Search in sources :

Example 1 with QANullException

use of cn.jeesoft.qa.error.QANullException in project QuickAndroid by ImKarl.

the class QACore method getImage.

/**
     * 获取全局网络请求管理类
     */
public static final QAImage getImage() throws QANullException {
    if (StaticImage == null) {
        synchronized (QAImage.class) {
            if (StaticImage == null) {
                QAImage image = null;
                try {
                    Drawable imageLoading = getConfig().getDrawable(QAConfig.Http.IMAGE_LOADING);
                    Drawable imageLoadfail = getConfig().getDrawable(QAConfig.Http.IMAGE_LOADFAIL);
                    if (imageLoading == null || imageLoadfail == null) {
                        image = new DefaultImage(new QAPrivateCheck() {

                            @Override
                            public boolean check() {
                                return true;
                            }
                        }, getApp().getApplication(), imageLoading, imageLoadfail);
                    }
                } catch (Exception e) {
                }
                if (image == null) {
                    int imageLoadingRes = getConfig().getInt(QAConfig.Http.IMAGE_LOADING);
                    int imageLoadfailRes = getConfig().getInt(QAConfig.Http.IMAGE_LOADFAIL);
                    image = new DefaultImage(new QAPrivateCheck() {

                        @Override
                        public boolean check() {
                            return true;
                        }
                    }, getApp().getApplication(), imageLoadingRes, imageLoadfailRes);
                }
                StaticImage = image;
            }
        }
    }
    if (StaticImage == null) {
        throw new QANullException("QAImage create Failed.");
    }
    return StaticImage;
}
Also used : QAImage(cn.jeesoft.qa.libcore.image.QAImage) DefaultImage(cn.jeesoft.qa.libcore.image.DefaultImage) Drawable(android.graphics.drawable.Drawable) QANullException(cn.jeesoft.qa.error.QANullException) QAInstantiationException(cn.jeesoft.qa.error.QAInstantiationException) QANullException(cn.jeesoft.qa.error.QANullException) QACheckException(cn.jeesoft.qa.error.QACheckException) QAException(cn.jeesoft.qa.error.QAException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with QANullException

use of cn.jeesoft.qa.error.QANullException in project QuickAndroid by ImKarl.

the class QAJsonArray method copy.

private <T> QAJsonArray copy(JSONTokener copyFrom) {
    if (copyFrom == null) {
        throw new QANullException("'json source' can not be NULL.");
    }
    Object object = null;
    try {
        object = copyFrom.nextValue();
        copy((JSONArray) object);
    } catch (JSONException e) {
        throw new QAJsonException(QAException.CODE_FORMAT, e);
    } catch (ClassCastException e) {
        throw new QAJsonException(QAException.CODE_CLASSCAST, String.valueOf(object) + " cannot be cast to JSONArray");
    }
    return this;
}
Also used : QAJsonException(cn.jeesoft.qa.error.QAJsonException) JSONException(org.json.JSONException) QANullException(cn.jeesoft.qa.error.QANullException)

Example 3 with QANullException

use of cn.jeesoft.qa.error.QANullException in project QuickAndroid by ImKarl.

the class QAJsonObject method copy.

private <T> QAJsonObject copy(JSONTokener copyFrom) {
    if (copyFrom == null) {
        throw new QANullException("'json source' can not be NULL.");
    }
    Object object = null;
    try {
        object = copyFrom.nextValue();
        copy((JSONObject) object);
    } catch (JSONException e) {
        throw new QAJsonException(QAException.CODE_FORMAT, e);
    } catch (ClassCastException e) {
        throw new QAJsonException(QAException.CODE_CLASSCAST, String.valueOf(object) + " cannot be cast to JSONArray");
    }
    return this;
}
Also used : QAJsonException(cn.jeesoft.qa.error.QAJsonException) JSONException(org.json.JSONException) QANullException(cn.jeesoft.qa.error.QANullException) JSONObject(org.json.JSONObject)

Aggregations

QANullException (cn.jeesoft.qa.error.QANullException)3 QAJsonException (cn.jeesoft.qa.error.QAJsonException)2 JSONException (org.json.JSONException)2 Drawable (android.graphics.drawable.Drawable)1 QACheckException (cn.jeesoft.qa.error.QACheckException)1 QAException (cn.jeesoft.qa.error.QAException)1 QAInstantiationException (cn.jeesoft.qa.error.QAInstantiationException)1 DefaultImage (cn.jeesoft.qa.libcore.image.DefaultImage)1 QAImage (cn.jeesoft.qa.libcore.image.QAImage)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 JSONObject (org.json.JSONObject)1