• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BitmapRegionTileSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.android.photos.BitmapRegionTileSource的典型用法代码示例。如果您正苦于以下问题:Java BitmapRegionTileSource类的具体用法?Java BitmapRegionTileSource怎么用?Java BitmapRegionTileSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BitmapRegionTileSource类属于com.android.photos包,在下文中一共展示了BitmapRegionTileSource类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onClick

import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
@Override
public void onClick(final WallpaperPickerActivity a) {
    a.setWallpaperButtonEnabled(false);
    final BitmapRegionTileSource.UriBitmapSource bitmapSource =
            new BitmapRegionTileSource.UriBitmapSource(a.getContext(), mUri);
    a.setCropViewTileSource(bitmapSource, true, false, null, new Runnable() {

        @Override
        public void run() {
            if (bitmapSource.getLoadingState() == BitmapSource.State.LOADED) {
                a.selectTile(mView);
                a.setWallpaperButtonEnabled(true);
            } else {
                ViewGroup parent = (ViewGroup) mView.getParent();
                if (parent != null) {
                    parent.removeView(mView);
                    Toast.makeText(a.getContext(), R.string.image_load_fail,
                            Toast.LENGTH_SHORT).show();
                }
            }
        }
    });
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:24,代码来源:WallpaperPickerActivity.java


示例2: onClick

import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
@Override
public void onClick(WallpaperPickerActivity a) {
    BitmapRegionTileSource.ResourceBitmapSource bitmapSource =
            new BitmapRegionTileSource.ResourceBitmapSource(
                    mResources, mResId, BitmapRegionTileSource.MAX_PREVIEW_SIZE);
    bitmapSource.loadInBackground();
    BitmapRegionTileSource source = new BitmapRegionTileSource(a, bitmapSource);
    CropView v = a.getCropView();
    v.setTileSource(source, null);
    Point wallpaperSize = WallpaperCropActivity.getDefaultWallpaperSize(
            a.getResources(), a.getWindowManager());
    RectF crop = WallpaperCropActivity.getMaxCropRect(
            source.getImageWidth(), source.getImageHeight(),
            wallpaperSize.x, wallpaperSize.y, false);
    v.setScale(wallpaperSize.x / crop.width());
    v.setTouchEnabled(false);
    a.setSystemWallpaperVisiblity(false);
}
 
开发者ID:Phonemetra,项目名称:TurboLauncher,代码行数:19,代码来源:WallpaperPickerActivity.java


示例3: addReusableBitmap

import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
@Thunk void addReusableBitmap(TileSource src) {
    synchronized (mReusableBitmaps) {
        if (Utilities.ATLEAST_KITKAT && src instanceof BitmapRegionTileSource) {
            Bitmap preview = ((BitmapRegionTileSource) src).getBitmap();
            if (preview != null && preview.isMutable()) {
                mReusableBitmaps.add(preview);
            }
        }
    }
}
 
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:11,代码来源:WallpaperCropActivity.java


示例4: onClick

import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
@Override
public void onClick(WallpaperPickerActivity a) {
    String imageFilename = a.getSavedImages().getImageFilename(mDbId);
    File file = new File(a.getFilesDir(), imageFilename);
    BitmapRegionTileSource.FilePathBitmapSource bitmapSource =
            new BitmapRegionTileSource.FilePathBitmapSource(file.getAbsolutePath(), 1024);
    a.setCropViewTileSource(bitmapSource, false, true, null);
}
 
开发者ID:Phonemetra,项目名称:TurboLauncher,代码行数:9,代码来源:SavedWallpaperImages.java


示例5: init

import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
protected void init() {
    setContentView(R.layout.wallpaper_cropper);

    mCropView = (CropView) findViewById(R.id.cropView);
    mProgressView = findViewById(R.id.loading);

    Intent cropIntent = getIntent();
    final Uri imageUri = cropIntent.getData();

    if (imageUri == null) {
        Log.e(LOGTAG, "No URI passed in intent, exiting WallpaperCropActivity");
        finish();
        return;
    }

    // Action bar
    // Show the custom action bar view
    final ActionBar actionBar = getActionBar();
    actionBar.setCustomView(R.layout.actionbar_set_wallpaper);
    actionBar.getCustomView().setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    boolean finishActivityWhenDone = true;
                    cropImageAndSetWallpaper(imageUri, null, finishActivityWhenDone);
                }
            });
    mSetWallpaperButton = findViewById(R.id.set_wallpaper_button);

    // Load image in background
    final BitmapRegionTileSource.UriBitmapSource bitmapSource =
            new BitmapRegionTileSource.UriBitmapSource(getContext(), imageUri);
    mSetWallpaperButton.setEnabled(false);
    Runnable onLoad = new Runnable() {
        public void run() {
            if (bitmapSource.getLoadingState() != BitmapSource.State.LOADED) {
                Toast.makeText(getContext(), R.string.wallpaper_load_fail,
                        Toast.LENGTH_LONG).show();
                finish();
            } else {
                mSetWallpaperButton.setEnabled(true);
            }
        }
    };
    setCropViewTileSource(bitmapSource, true, false, null, onLoad);
}
 
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:47,代码来源:WallpaperCropActivity.java


示例6: handleMessage

import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
/**
 * This is called on {@link #mLoaderThread}
 */
@Override
public boolean handleMessage(Message msg) {
    if (msg.what == MSG_LOAD_IMAGE) {
        final LoadRequest req = (LoadRequest) msg.obj;
        try {
            req.src.loadInBackground(new InBitmapProvider() {

                @Override
                public Bitmap forPixelCount(int count) {
                    Bitmap bitmapToReuse = null;
                    // Find the smallest bitmap that satisfies the pixel count limit
                    synchronized (mReusableBitmaps) {
                        int currentBitmapSize = Integer.MAX_VALUE;
                        for (Bitmap b : mReusableBitmaps) {
                            int bitmapSize = b.getWidth() * b.getHeight();
                            if ((bitmapSize >= count) && (bitmapSize < currentBitmapSize)) {
                                bitmapToReuse = b;
                                currentBitmapSize = bitmapSize;
                            }
                        }

                        if (bitmapToReuse != null) {
                            mReusableBitmaps.remove(bitmapToReuse);
                        }
                    }
                    return bitmapToReuse;
                }
            });
        } catch (SecurityException securityException) {
            if (isActivityDestroyed()) {
                // Temporarily granted permissions are revoked when the activity
                // finishes, potentially resulting in a SecurityException here.
                // Even though {@link #isDestroyed} might also return true in different
                // situations where the configuration changes, we are fine with
                // catching these cases here as well.
                return true;
            } else {
                // otherwise it had a different cause and we throw it further
                throw securityException;
            }
        }

        req.result = new BitmapRegionTileSource(getContext(), req.src, mTempStorageForDecoding);
        runOnUiThread(new Runnable() {

            @Override
            public void run() {
                if (req == mCurrentLoadRequest) {
                    onLoadRequestComplete(req,
                            req.src.getLoadingState() == BitmapSource.State.LOADED);
                } else {
                    addReusableBitmap(req.result);
                }
            }
        });
        return true;
    }
    return false;
}
 
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:63,代码来源:WallpaperCropActivity.java


示例7: init

import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
protected void init() {
    setContentView(R.layout.wallpaper_cropper);

    mCropView = (CropView) findViewById(R.id.cropView);

    Intent cropIntent = getIntent();
    final Uri imageUri = cropIntent.getData();

    if (imageUri == null) {
        Log.e(LOGTAG, "No URI passed in intent, exiting WallpaperCropActivity");
        finish();
        return;
    }

    // Action bar
    // Show the custom action bar view
    final ActionBar actionBar = getActionBar();
    actionBar.setCustomView(R.layout.actionbar_set_wallpaper);
    actionBar.getCustomView().setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    boolean finishActivityWhenDone = true;
                    cropImageAndSetWallpaper(imageUri, null, finishActivityWhenDone);
                }
            });
    mSetWallpaperButton = findViewById(R.id.set_wallpaper_button);

    // Load image in background
    final BitmapRegionTileSource.UriBitmapSource bitmapSource =
            new BitmapRegionTileSource.UriBitmapSource(this, imageUri, 1024);
    mSetWallpaperButton.setEnabled(false);
    Runnable onLoad = new Runnable() {
        public void run() {
            if (bitmapSource.getLoadingState() != BitmapSource.State.LOADED) {
                Toast.makeText(WallpaperCropActivity.this,
                        getString(R.string.wallpaper_load_fail),
                        Toast.LENGTH_LONG).show();
                finish();
            } else {
                mSetWallpaperButton.setEnabled(true);
            }
        }
    };
    setCropViewTileSource(bitmapSource, true, false, onLoad);
}
 
开发者ID:Phonemetra,项目名称:TurboLauncher,代码行数:47,代码来源:WallpaperCropActivity.java


示例8: setCropViewTileSource

import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
public void setCropViewTileSource(
        final BitmapRegionTileSource.BitmapSource bitmapSource, final boolean touchEnabled,
        final boolean moveToLeft, final Runnable postExecute) {
    final Context context = WallpaperCropActivity.this;
    final View progressView = findViewById(R.id.loading);
    final AsyncTask<Void, Void, Void> loadBitmapTask = new AsyncTask<Void, Void, Void>() {
        protected Void doInBackground(Void...args) {
            if (!isCancelled()) {
                bitmapSource.loadInBackground();
            }
            return null;
        }
        protected void onPostExecute(Void arg) {
            if (!isCancelled()) {
                progressView.setVisibility(View.INVISIBLE);
                if (bitmapSource.getLoadingState() == BitmapSource.State.LOADED) {
                    mCropView.setTileSource(
                            new BitmapRegionTileSource(context, bitmapSource), null);
                    mCropView.setTouchEnabled(touchEnabled);
                    if (moveToLeft) {
                        mCropView.moveToLeft();
                    }
                }
            }
            if (postExecute != null) {
                postExecute.run();
            }
        }
    };
    // We don't want to show the spinner every time we load an image, because that would be
    // annoying; instead, only start showing the spinner if loading the image has taken
    // longer than 1 sec (ie 1000 ms)
    progressView.postDelayed(new Runnable() {
        public void run() {
            if (loadBitmapTask.getStatus() != AsyncTask.Status.FINISHED) {
                progressView.setVisibility(View.VISIBLE);
            }
        }
    }, 1000);
    loadBitmapTask.execute();
}
 
开发者ID:Phonemetra,项目名称:TurboLauncher,代码行数:42,代码来源:WallpaperCropActivity.java


示例9: init

import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
protected void init() {
    setContentView(R.layout.wallpaper_cropper);

    mCropView = (CropView) findViewById(R.id.cropView);
    mProgressView = findViewById(R.id.loading);

    Intent cropIntent = getIntent();
    final Uri imageUri = cropIntent.getData();

    if (imageUri == null) {
        Log.e(LOGTAG, "No URI passed in intent, exiting WallpaperCropActivity");
        finish();
        return;
    }

    // Action bar
    // Show the custom action bar view
    final ActionBar actionBar = getActionBar();
    actionBar.setCustomView(R.layout.actionbar_set_wallpaper);
    actionBar.getCustomView().setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    actionBar.hide();
                    boolean finishActivityWhenDone = true;
                    // Never fade on finish because we return to the app that started us (e.g.
                    // Photos), not the home screen.
                    boolean shouldFadeOutOnFinish = false;
                    cropImageAndSetWallpaper(imageUri, null, finishActivityWhenDone,
                            shouldFadeOutOnFinish);
                }
            });
    mSetWallpaperButton = findViewById(R.id.set_wallpaper_button);

    // Load image in background
    final BitmapRegionTileSource.UriBitmapSource bitmapSource =
            new BitmapRegionTileSource.UriBitmapSource(getContext(), imageUri);
    mSetWallpaperButton.setEnabled(false);
    Runnable onLoad = new Runnable() {
        public void run() {
            if (bitmapSource.getLoadingState() != BitmapSource.State.LOADED) {
                Toast.makeText(getContext(), R.string.wallpaper_load_fail,
                        Toast.LENGTH_LONG).show();
                finish();
            } else {
                mSetWallpaperButton.setEnabled(true);
            }
        }
    };
    setCropViewTileSource(bitmapSource, true, false, null, onLoad);
}
 
开发者ID:RunasSudo,项目名称:FLauncher,代码行数:52,代码来源:WallpaperCropActivity.java


示例10: setCropViewTileSource

import com.android.photos.BitmapRegionTileSource; //导入依赖的package包/类
public void setCropViewTileSource(
        final BitmapRegionTileSource.BitmapSource bitmapSource, final boolean touchEnabled,
        final boolean moveToLeft, final Runnable postExecute) {
    final Context context = WallpaperCropActivity.this;
    final View progressView = findViewById(R.id.loading);
    final AsyncTask<Void, Void, Void> loadBitmapTask = new AsyncTask<Void, Void, Void>() {
        protected Void doInBackground(Void...args) {
            if (!isCancelled()) {
                try {
                    bitmapSource.loadInBackground();
                } catch (SecurityException securityException) {
                    if (isDestroyed()) {
                        // Temporarily granted permissions are revoked when the activity
                        // finishes, potentially resulting in a SecurityException here.
                        // Even though {@link #isDestroyed} might also return true in different
                        // situations where the configuration changes, we are fine with
                        // catching these cases here as well.
                        cancel(false);
                    } else {
                        // otherwise it had a different cause and we throw it further
                        throw securityException;
                    }
                }
            }
            return null;
        }
        protected void onPostExecute(Void arg) {
            if (!isCancelled()) {
                progressView.setVisibility(View.INVISIBLE);
                if (bitmapSource.getLoadingState() == BitmapSource.State.LOADED) {
                    mCropView.setTileSource(
                            new BitmapRegionTileSource(context, bitmapSource), null);
                    mCropView.setTouchEnabled(touchEnabled);
                    if (moveToLeft) {
                        mCropView.moveToLeft();
                    }
                }
            }
            if (postExecute != null) {
                postExecute.run();
            }
        }
    };
    // We don't want to show the spinner every time we load an image, because that would be
    // annoying; instead, only start showing the spinner if loading the image has taken
    // longer than 1 sec (ie 1000 ms)
    progressView.postDelayed(new Runnable() {
        public void run() {
            if (loadBitmapTask.getStatus() != AsyncTask.Status.FINISHED) {
                progressView.setVisibility(View.VISIBLE);
            }
        }
    }, 1000);
    loadBitmapTask.execute();
}
 
开发者ID:AndroidDeveloperLB,项目名称:LB-Launcher,代码行数:56,代码来源:WallpaperCropActivity.java



注:本文中的com.android.photos.BitmapRegionTileSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DelegatingDataSource类代码示例发布时间:2022-05-22
下一篇:
Java UserManager类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap