com.socks.jiandan.view.imageloader.ImageLoadProxy Java Examples

The following examples show how to use com.socks.jiandan.view.imageloader.ImageLoadProxy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JDApplication.java    From JianDan with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    StrictModeUtil.init();
    super.onCreate();
    refWatcher = LeakCanary.install(this);
    mContext = this;
    ImageLoadProxy.initImageLoader(this);

    if (BuildConfig.DEBUG) {
        Logger.init().hideThreadInfo().setMethodCount(1).setLogLevel(LogLevel.FULL);
    }

    Stetho.initialize(
            Stetho.newInitializerBuilder(this)
                    .enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
                    .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this))
                    .build());

}
 
Example #2
Source File: BaseFragment.java    From JianDan_OkHttpWithVolley with Apache License 2.0 5 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();
    JDApplication.getRefWatcher(getActivity()).watch(this);
    RequestManager.cancelAll(this);
    ImageLoadProxy.getImageLoader().clearMemoryCache();
}
 
Example #3
Source File: ImageDetailActivity.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
@Override
protected void onDestroy() {
    super.onDestroy();
    if (connection != null && connection.isConnected()) {
        connection.disconnect();
    }

    if (img.getVisibility() == View.VISIBLE) {
        ImageLoadProxy.getImageLoader().cancelDisplayTask(img);
    }
}
 
Example #4
Source File: FreshNewsAdapter.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
public FreshNewsAdapter(Activity activity, LoadFinishCallBack loadFinisCallBack, LoadResultCallBack loadResultCallBack, boolean isLargeMode) {
    this.mActivity = activity;
    this.isLargeMode = isLargeMode;
    this.mLoadFinisCallBack = loadFinisCallBack;
    this.mLoadResultCallBack = loadResultCallBack;
    mFreshNews = new ArrayList<>();

    int loadingResource = isLargeMode ? R.drawable.ic_loading_large : R.drawable.ic_loading_small;
    options = ImageLoadProxy.getOptions4PictureList(loadingResource);
}
 
Example #5
Source File: BaseFragment.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();
    JDApplication.getRefWatcher(getActivity()).watch(this);
    RequestManager.cancelAll(this);
    ImageLoadProxy.getImageLoader().clearMemoryCache();
}
 
Example #6
Source File: JDApplication.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    StrictModeUtil.init();
    super.onCreate();
    refWatcher = LeakCanary.install(this);
    mContext = this;
    ImageLoadProxy.initImageLoader(this);

    if (BuildConfig.DEBUG) {
        Logger.init().hideThreadInfo().setMethodCount(1).setLogLevel(LogLevel.FULL);
    }
}
 
Example #7
Source File: ImageDetailActivity.java    From JianDanRxJava with Apache License 2.0 5 votes vote down vote up
@Override
protected void onDestroy() {
    super.onDestroy();
    if (connection != null && connection.isConnected()) {
        connection.disconnect();
    }

    if (img.getVisibility() == View.VISIBLE) {
        ImageLoadProxy.getImageLoader().cancelDisplayTask(img);
    }
}
 
Example #8
Source File: JDApplication.java    From JianDanRxJava with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    StrictModeUtil.init();
    super.onCreate();
    mContext = this;

    refWatcher = LeakCanary.install(this);
    ImageLoadProxy.initImageLoader(this);
    initHttpClient();
    SPHelper.init(mContext);
    KLog.init(BuildConfig.DEBUG);
}
 
Example #9
Source File: FreshNewsAdapter.java    From JianDanRxJava with Apache License 2.0 5 votes vote down vote up
public FreshNewsAdapter(BaseActivity activity, LoadFinishCallBack<Object> loadFinisCallBack, LoadResultCallBack loadResultCallBack) {
    this.mActivity = activity;
    this.isLargeMode = SPHelper.getBoolean(SettingFragment.ENABLE_FRESH_BIG, true);
    this.mLoadFinisCallBack = loadFinisCallBack;
    this.mLoadResultCallBack = loadResultCallBack;
    mFreshNews = new ArrayList<>();

    int loadingResource = isLargeMode ? R.drawable.ic_loading_large : R.drawable.ic_loading_small;
    options = ImageLoadProxy.getOptions4PictureList(loadingResource);
}
 
Example #10
Source File: ImageDetailActivity.java    From JianDan with Apache License 2.0 5 votes vote down vote up
@Override
protected void onDestroy() {
    super.onDestroy();
    if (connection != null && connection.isConnected()) {
        connection.disconnect();
    }

    if (img.getVisibility() == View.VISIBLE) {
        ImageLoadProxy.getImageLoader().cancelDisplayTask(img);
    }
}
 
Example #11
Source File: FreshNewsAdapter.java    From JianDan with Apache License 2.0 5 votes vote down vote up
public FreshNewsAdapter(Activity activity, LoadFinishCallBack loadFinisCallBack, LoadResultCallBack loadResultCallBack, boolean isLargeMode) {
    this.mActivity = activity;
    this.isLargeMode = isLargeMode;
    this.mLoadFinisCallBack = loadFinisCallBack;
    this.mLoadResultCallBack = loadResultCallBack;
    mFreshNews = new ArrayList<>();

    int loadingResource = isLargeMode ? R.drawable.ic_loading_large : R.drawable.ic_loading_small;
    options = ImageLoadProxy.getOptions4PictureList(loadingResource);
}
 
Example #12
Source File: BaseFragment.java    From JianDan with Apache License 2.0 5 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();
    JDApplication.getRefWatcher(getActivity()).watch(this);
    RequestManager.cancelAll(this);
    ImageLoadProxy.getImageLoader().clearMemoryCache();
}
 
Example #13
Source File: ImageDetailActivity.java    From JianDan_OkHttpWithVolley with Apache License 2.0 5 votes vote down vote up
@Override
protected void onDestroy() {
    super.onDestroy();
    if (connection != null && connection.isConnected()) {
        connection.disconnect();
    }

    if (img.getVisibility() == View.VISIBLE) {
        ImageLoadProxy.getImageLoader().cancelDisplayTask(img);
    }
}
 
Example #14
Source File: FreshNewsAdapter.java    From JianDan_OkHttpWithVolley with Apache License 2.0 5 votes vote down vote up
public FreshNewsAdapter(Activity activity, LoadFinishCallBack loadFinisCallBack, LoadResultCallBack loadResultCallBack, boolean isLargeMode) {
    this.mActivity = activity;
    this.isLargeMode = isLargeMode;
    this.mLoadFinisCallBack = loadFinisCallBack;
    this.mLoadResultCallBack = loadResultCallBack;
    mFreshNews = new ArrayList<>();

    int loadingResource = isLargeMode ? R.drawable.ic_loading_large : R.drawable.ic_loading_small;
    options = ImageLoadProxy.getOptions4PictureList(loadingResource);
}
 
Example #15
Source File: JDApplication.java    From JianDan_OkHttpWithVolley with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    StrictModeUtil.init();
    super.onCreate();
    refWatcher = LeakCanary.install(this);
    mContext = this;
    ImageLoadProxy.initImageLoader(this);

    if (BuildConfig.DEBUG) {
        Logger.init().hideThreadInfo().setMethodCount(1).setLogLevel(LogLevel.FULL);
    }
}
 
Example #16
Source File: PictureFragment.java    From JianDan with Apache License 2.0 4 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();
    //清除内存缓存,避免由于内存缓存造成的图片显示不完整
    ImageLoadProxy.getImageLoader().clearMemoryCache();
}
 
Example #17
Source File: BaseFragment.java    From JianDanRxJava with Apache License 2.0 4 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();
    JDApplication.getRefWatcher(getActivity()).watch(this);
    ImageLoadProxy.getImageLoader().clearMemoryCache();
}
 
Example #18
Source File: PictureAdapter.java    From JianDanRxJava with Apache License 2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(final PictureViewHolder holder, final int position) {

    final Picture picture = mPictures.get(position);
    String picUrl = picture.getPics()[0];

    if (picUrl.endsWith(".gif")) {
        holder.img_gif.setVisibility(View.VISIBLE);
        //非WIFI网络情况下,GIF图只加载缩略图,详情页才加载真实图片
        if (!isWifiConnected) {
            picUrl = picUrl.replace("mw600", "small").replace("mw1200", "small").replace
                    ("large", "small");
        }
    } else {
        holder.img_gif.setVisibility(View.GONE);
    }

    holder.progress.setProgress(0);
    holder.progress.setVisibility(View.VISIBLE);

    ImageLoadProxy.displayImageList(picUrl, holder.img, R.drawable.ic_loading_large, new
                    SimpleImageLoadingListener() {
                        @Override
                        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                            super.onLoadingComplete(imageUri, view, loadedImage);
                            holder.progress.setVisibility(View.GONE);
                        }
                    },
            (imageUri, view, current, total) -> holder.progress.setProgress((int) (current * 100f / total)));

    if (TextUtil.isNull(picture.getText_content().trim())) {
        holder.tv_content.setVisibility(View.GONE);
    } else {
        holder.tv_content.setVisibility(View.VISIBLE);
        holder.tv_content.setText(picture.getText_content().trim());
    }

    holder.img.setOnClickListener(v -> IntentHelper.toImageDetailActivity(mActivity, picture));

    holder.tv_author.setText(picture.getComment_author());
    holder.tv_time.setText(String2TimeUtil.dateString2GoodExperienceFormat(picture.getComment_date()));
    holder.tv_like.setText(picture.getVote_positive());
    holder.tv_comment_count.setText(picture.getComment_counts());

    //用于恢复默认的文字
    holder.tv_like.setTypeface(Typeface.DEFAULT);
    holder.tv_like.setTextColor(mActivity.getResources().getColor(
            secondary_text_default_material_light));
    holder.tv_support_des.setTextColor(mActivity.getResources().getColor(
            secondary_text_default_material_light));

    holder.tv_unlike.setText(picture.getVote_negative());
    holder.tv_unlike.setTypeface(Typeface.DEFAULT);
    holder.tv_unlike.setTextColor(mActivity.getResources().getColor(
            secondary_text_default_material_light));
    holder.tv_un_support_des.setTextColor(mActivity.getResources().getColor(
            secondary_text_default_material_light));

    holder.img_share.setOnClickListener(v -> new MaterialDialog.Builder(mActivity)
            .items(R.array.picture_dialog)
            .backgroundColor(mActivity.getResources().getColor(JDApplication.COLOR_OF_DIALOG))
            .contentColor(JDApplication.COLOR_OF_DIALOG_CONTENT)
            .itemsCallback((dialog, view, which, text) -> {

                switch (which) {
                    case 0:
                        ShareUtil.sharePicture(mActivity, picture
                                .getPics()[0]);
                        break;
                    case 1:
                        FileUtil.savePicture(picture
                                .getPics()[0], mSaveFileCallBack);
                        break;
                }
            })
            .show());

    holder.ll_comment.setOnClickListener(v -> {
        Intent intent = new Intent(mActivity, CommentListActivity.class);
        intent.putExtra(BaseActivity.DATA_THREAD_KEY, "comment-" + picture.getComment_ID());
        mActivity.startActivity(intent);
    });

    setAnimation(holder.card, position);

}
 
Example #19
Source File: PictureFragment.java    From JianDan_OkHttpWithVolley with Apache License 2.0 4 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();
    //清除内存缓存,避免由于内存缓存造成的图片显示不完整
    ImageLoadProxy.getImageLoader().clearMemoryCache();
}
 
Example #20
Source File: PictureFragment.java    From JianDan_OkHttp with Apache License 2.0 4 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();
    //清除内存缓存,避免由于内存缓存造成的图片显示不完整
    ImageLoadProxy.getImageLoader().clearMemoryCache();
}
 
Example #21
Source File: AutoLoadRecyclerView.java    From JianDanRxJava with Apache License 2.0 2 votes vote down vote up
/**
 * 如果需要显示图片,需要设置这几个参数,快速滑动时,暂停图片加载
 *
 * @param pauseOnScroll
 * @param pauseOnFling
 */
public void setOnPauseListenerParams(boolean pauseOnScroll, boolean pauseOnFling) {
    addOnScrollListener(new AutoLoadScrollListener(ImageLoadProxy.getImageLoader(), pauseOnScroll, pauseOnFling));
}
 
Example #22
Source File: AutoLoadRecyclerView.java    From JianDan with Apache License 2.0 2 votes vote down vote up
/**
 * 如果需要显示图片,需要设置这几个参数,快速滑动时,暂停图片加载
 *
 * @param pauseOnScroll
 * @param pauseOnFling
 */
public void setOnPauseListenerParams(boolean pauseOnScroll, boolean pauseOnFling) {
    addOnScrollListener(new AutoLoadScrollListener(ImageLoadProxy.getImageLoader(), pauseOnScroll, pauseOnFling));
}
 
Example #23
Source File: AutoLoadRecyclerView.java    From JianDan_OkHttp with Apache License 2.0 2 votes vote down vote up
/**
 * 如果需要显示图片,需要设置这几个参数,快速滑动时,暂停图片加载
 *
 * @param pauseOnScroll
 * @param pauseOnFling
 */
public void setOnPauseListenerParams(boolean pauseOnScroll, boolean pauseOnFling) {
    addOnScrollListener(new AutoLoadScrollListener(ImageLoadProxy.getImageLoader(), pauseOnScroll, pauseOnFling));
}
 
Example #24
Source File: AutoLoadRecyclerView.java    From JianDan_OkHttpWithVolley with Apache License 2.0 2 votes vote down vote up
/**
 * 如果需要显示图片,需要设置这几个参数,快速滑动时,暂停图片加载
 *
 * @param pauseOnScroll
 * @param pauseOnFling
 */
public void setOnPauseListenerParams(boolean pauseOnScroll, boolean pauseOnFling) {
    addOnScrollListener(new AutoLoadScrollListener(ImageLoadProxy.getImageLoader(), pauseOnScroll, pauseOnFling));
}