Search in sources :

Example 1 with CircleProgressView

use of org.qii.weiciyuan.support.lib.CircleProgressView in project weiciyuan by qii.

the class ContainerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.gallery_container_layout, container, false);
    progressView = (CircleProgressView) view.findViewById(R.id.loading);
    wait = (TextView) view.findViewById(R.id.wait);
    error = (TextView) view.findViewById(R.id.error);
    Bundle bundle = getArguments();
    String url = bundle.getString("url");
    boolean animateIn = bundle.getBoolean("animationIn");
    bundle.putBoolean("animationIn", false);
    String path = FileManager.getFilePathFromUrl(url, FileLocationMethod.picture_large);
    if (ImageUtility.isThisBitmapCanRead(path) && TaskCache.isThisUrlTaskFinished(url)) {
        displayPicture(path, animateIn);
    } else {
        GalleryAnimationActivity activity = (GalleryAnimationActivity) getActivity();
        activity.showBackgroundImmediately();
        progressView.setVisibility(View.VISIBLE);
        wait.setVisibility(View.VISIBLE);
        TimeLineBitmapDownloader.getInstance().download(this, url, FileLocationMethod.picture_large, downloadCallback);
    }
    return view;
}
Also used : Bundle(android.os.Bundle) CircleProgressView(org.qii.weiciyuan.support.lib.CircleProgressView) TextView(android.widget.TextView) View(android.view.View)

Example 2 with CircleProgressView

use of org.qii.weiciyuan.support.lib.CircleProgressView in project weiciyuan by qii.

the class GalleryActivity method handlePage.

private void handlePage(int position, View contentView, boolean fromInstantiateItem) {
    final PhotoView imageView = (PhotoView) contentView.findViewById(R.id.image);
    imageView.setVisibility(View.INVISIBLE);
    if (SettingUtility.allowClickToCloseGallery()) {
        imageView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {

            @Override
            public void onPhotoTap(View view, float x, float y) {
                if (rect == null || imageView == null || (!(imageView.getDrawable() instanceof BitmapDrawable))) {
                    GalleryActivity.this.finish();
                    return;
                }
                animateClose(imageView);
            }
        });
    }
    WebView gif = (WebView) contentView.findViewById(R.id.gif);
    gif.setBackgroundColor(getResources().getColor(R.color.transparent));
    gif.setVisibility(View.INVISIBLE);
    WebView large = (WebView) contentView.findViewById(R.id.large);
    large.setBackgroundColor(getResources().getColor(R.color.transparent));
    large.setVisibility(View.INVISIBLE);
    large.setOverScrollMode(View.OVER_SCROLL_NEVER);
    if (Utility.doThisDeviceOwnNavigationBar(GalleryActivity.this)) {
        imageView.setPadding(0, 0, 0, Utility.dip2px(NAVIGATION_BAR_HEIGHT_DP_UNIT));
        //webview has a bug, padding is ignored
        gif.setPadding(0, 0, 0, Utility.dip2px(NAVIGATION_BAR_HEIGHT_DP_UNIT));
        large.setPadding(0, 0, 0, Utility.dip2px(NAVIGATION_BAR_HEIGHT_DP_UNIT));
    }
    TextView wait = (TextView) contentView.findViewById(R.id.wait);
    TextView readError = (TextView) contentView.findViewById(R.id.error);
    String path = FileManager.getFilePathFromUrl(urls.get(position), FileLocationMethod.picture_large);
    boolean shouldDownLoadPicture = !fromInstantiateItem || (fromInstantiateItem && Utility.isWifi(GalleryActivity.this));
    //sometime picture is not downloaded completely, but android already can read it....
    if (ImageUtility.isThisBitmapCanRead(path) && taskMap.get(urls.get(position)) == null && TaskCache.isThisUrlTaskFinished(urls.get(position))) {
        wait.setVisibility(View.INVISIBLE);
        readPicture(imageView, gif, large, readError, urls.get(position), path);
    } else if (shouldDownLoadPicture) {
        final CircleProgressView spinner = (CircleProgressView) contentView.findViewById(R.id.loading);
        spinner.setVisibility(View.VISIBLE);
        if (taskMap.get(urls.get(position)) == null) {
            wait.setVisibility(View.VISIBLE);
            PicSimpleBitmapWorkerTask task = new PicSimpleBitmapWorkerTask(imageView, gif, large, spinner, wait, readError, urls.get(position), taskMap);
            taskMap.put(urls.get(position), task);
            task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
        } else {
            PicSimpleBitmapWorkerTask task = taskMap.get(urls.get(position));
            task.setWidget(imageView, gif, spinner, wait, readError);
        }
    }
}
Also used : BitmapDrawable(android.graphics.drawable.BitmapDrawable) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) CircleProgressView(org.qii.weiciyuan.support.lib.CircleProgressView) PhotoView(uk.co.senab.photoview.PhotoView) PhotoView(uk.co.senab.photoview.PhotoView) TextView(android.widget.TextView) WebView(android.webkit.WebView) CircleProgressView(org.qii.weiciyuan.support.lib.CircleProgressView)

Aggregations

View (android.view.View)2 TextView (android.widget.TextView)2 CircleProgressView (org.qii.weiciyuan.support.lib.CircleProgressView)2 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Bundle (android.os.Bundle)1 WebView (android.webkit.WebView)1 ImageView (android.widget.ImageView)1 PhotoView (uk.co.senab.photoview.PhotoView)1 PhotoViewAttacher (uk.co.senab.photoview.PhotoViewAttacher)1