小编Den*_*mus的帖子

使用新的Google相册应用选择照片已损坏

我的应用程序可以从库中选择照片.我想要从这个选择中获取文件路径.

这是创建选择照片的意图的代码:

    Intent photoPickerIntent = new Intent(Intent.ACTION_PICK,
        MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    photoPickerIntent.setType("image/*");
    startActivityForResult(photoPickerIntent, INTENT_REQUEST_CODE_SELECT_PHOTO);
Run Code Online (Sandbox Code Playgroud)

这是从URI获取文件路径的代码:

    Cursor cursor = null;
    String path = null;
    try {
        String[] projection = { MediaStore.Images.Media.DATA };
        cursor = context.getContentResolver().query(contentUri, projection, null, null, null);
        int columnIndex = cursor.getColumnIndexOrThrow(projection[0]);
        cursor.moveToFirst();
        path = cursor.getString(columnIndex);
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
    return path;
Run Code Online (Sandbox Code Playgroud)

在昨天更新Google相册应用之前,一切都运转良好.path解析URI后现在为null.

URI类似于: content://com.google.android.apps.photos.contentprovider/0/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F75209/ACTUAL

我还试图用Intent.ACTION_GET_CONTENT动作创建意图 - 没有运气.

android android-intent android-gallery google-photos

47
推荐指数
2
解决办法
2万
查看次数

将两个图像与乘法和%不透明度混合在一起

我正在尝试使用类似Multiply的混合模式将两个图像与Android混合在一起.

// Prepare -------------------------------

// Create source images
Bitmap img1 = ...
Bitmap img2 = ...

// Create result image
Bitmap result = ...
Canvas canvas = new Canvas();
canvas.setBitmap(result);

// Get proper display reference
BitmapDrawable drawable = new BitmapDrawable(getResources(), result);
ImageView imageView = (ImageView)findViewById(R.id.imageBlend1);
imageView.setImageDrawable(drawable);


// Apply -------------------------------

// Draw base
canvas.drawBitmap(img1, 0, 0, null);

// Draw overlay
Paint paint = new Paint();
paint.setXfermode(new PorterDuffXfermode(Mode.MULTIPLY));
paint.setShader(new BitmapShader(img2, TileMode.CLAMP, TileMode.CLAMP));

canvas.drawRect(0, 0, img2.getWidth(), img2.getHeight(), paint);
Run Code Online (Sandbox Code Playgroud)

这是有效的,但是我无法控制所做的乘法"量" - 它始终是一个完全的乘法传递.理想情况下,0%乘法与基本图像(img1)相同而没有任何变化,但100%乘法将是我得到的上述代码的结果.

paint.setAlpha() 似乎不适用于此. …

android blending porter-duff

9
推荐指数
1
解决办法
1万
查看次数

什么是关闭genymotion模拟器的正确方法?

有趣的事情 - 我一直关闭模拟器的窗口(右上角的X,是的)关闭它.

现在我感到有兴趣,如果在此期间模拟器中没有任何损坏.

令人惊讶的是,没有任何东西可以用Google搜索.

android genymotion

7
推荐指数
1
解决办法
3263
查看次数

请解释这个颜色混合模式公式,以便我可以在PHP/ImageMagick中复制它

我一直在尝试使用ImageMagick复制Photoshops颜色混合模式.我在在线指南中找到了以下公式,但我不知道它们的含义.我只需要交换某些频道吗?

Paint Shop Pro

FARBE

photoshop blending colors imagemagick

6
推荐指数
2
解决办法
4921
查看次数

在 Kotlin 中使用 TypeAdapter 实现 TypeAdapterFactory

我正在尝试用 Kotlin 语言为我的 android 项目实现一些特定的 GSON TypeAdapter。

我面临的问题是编译错误,无法推断类型:Type inference failed: 'T' cannot capture 'in (T..T?'. Type parameter has an upper bound 'Enum<T>' that cannot be satisfied capturing 'in' projection

代码如下:

  class SmartEnumTypeAdapterFactory(fallbackKey: String) : TypeAdapterFactory {

     private val fallbackKey = fallbackKey.toLowerCase(Locale.US)

     override fun <T : Any> create(gson: Gson?, type: TypeToken<T>): TypeAdapter<T>? {
        val rawType = type.rawType
        return if (!rawType.isEnum) null else SmartEnumTypeAdapter(rawType)
     }

     class SmartEnumTypeAdapter<T : Enum<T>>(classOfT: Class<T>) : TypeAdapter<T>() {

        override fun write(out: JsonWriter?, value: T) {
           TODO("not …
Run Code Online (Sandbox Code Playgroud)

android gson kotlin

5
推荐指数
1
解决办法
2505
查看次数

kotlin 注释处理:检查给定的 TypeElement 是否来自 kotlin-class

我正在实现注释处理库,该库使用基于具有特定注释的类的 java 诗人生成代码。

为了使用 kotlin 编写的类,我在示例项目中切换到 kapt 而不是 apt。它适用于带注释的 java 类就好了。Bun kotlin 类有一种不同的方法来访问类字段:应该使用 getter 和 setter。

有没有办法确定给定的类(更具体地说 - 不是类而是 TypeElement - 因为这是在编译之前发生的)是 java-class 还是用 kotlin 编写的?基于此,我可以编写生成字段访问或 getter-used 访问的代码。

java kotlin kapt

2
推荐指数
1
解决办法
1319
查看次数