小编Bir*_*ani的帖子

Android Studio 3.5重构问题

我刚刚用android studio 3.5更新了我的工作室,现在当我尝试重构AndroidManifest.xml文件时,它会将我的所有应用程序权限重构到文件的底部。

有人遇到过这个问题吗?这个重构问题有解决方案吗?

重构之前:

在此处输入图片说明

重构后:

在此处输入图片说明

它适用于我的所有项目文件。

为何重要:

在此处输入图片说明

android android-manifest android-studio

148
推荐指数
4
解决办法
6739
查看次数

将 kotlin 数据类转换为 json 字符串

我有一个带有此类定义的数据类

data class AccountInfoResponse(
    @SerializedName("userprofile") val userprofiles: ArrayList<UserProfile>,
    @SerializedName("userpatients") val userpatients: ArrayList<UserPatient>
)

class UserPatient (
    @SerializedName("sex") val sex: String,
    @SerializedName("date of birth") val date_of_birth: String,
    @SerializedName("address") val address: String,
    @SerializedName("patientID") val patientId: Int,
    @SerializedName("first name") val first_name: String,
    @SerializedName("clinicName") val clinic_name: String,
    @SerializedName("clinicID") val clinicId: Int,
    @SerializedName("mobile") val mobile: String,
    @SerializedName("last name") val last_name: String
)
Run Code Online (Sandbox Code Playgroud)

我需要将这个类转换为这样的 json 字符串

{"userpatients":[{"sex":"male","date of birth":"2010-01-03","image":"","clinics":[1],"primary_provider":[{"clinic":1,"patient":1,"providers":1}],"role":"patient","last name":"John","address":"300 east main st.  San Jose, Ca 95014","first name":"John","username":"John","email":"sameh88@ensofia.com","mobile":"+88083918427"}],"userpatients":[{"sex":"female","date of birth":"2000-01-01","address":"fawal st1","patientID":1,"first name":"john","clinicName":"light house peds","clinicID":1,"mobile":"8056688042","last name":"john"}]}
Run Code Online (Sandbox Code Playgroud)

android json gson kotlin

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

如何从 Flutter Web 中的 Uint8List 获取视频缩略图?

我正在开发的应用程序允许用户创建带有文本、图像和视频的社交帖子,例如 Facebook。我正在研究 PWA 部分,但遇到了这个问题。为了从存储中选择视频,我需要创建要在 UI 中显示的视频缩略图。

我能够选择视频,Uint8List因为它在所有平台上都受支持,但我无法从中获取缩略图。我尝试了很多库,但都File用作输入。

有什么办法可以完成这件事吗?

我正在使用以下代码来获取视频文件的 Uint8List ...

使用的库:file_picker_cross

final filePicker = FilePickerCross(type: FileTypeCross.video);
await filePicker.pick();
final imageBytes = filePicker.toUint8List();
// TODO: get video thumbnail from [imageBytes]
Run Code Online (Sandbox Code Playgroud)

flutter flutter-web

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

有没有办法显示事务期间 PostgreSQL 数据库中更改的所有内容?

我经常需要在大型PostgreSQL数据库上的单个事务中执行复杂的 sql 脚本,我想验证事务期间更改的所有内容。

“手动”验证每个表上的每个条目需要很长时间。

在脚本之前和之后将数据库diff转储为纯 sql 并在转储上使用并不是一个真正的选择,因为每个转储都是关于50G数据的。

有没有办法显示在单个事务中添加、删除或修改的所有数据?

postgresql diff transactions

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

如何在Koin中提供基类?

例如我有以下课程:

abstract class BaseClass()

class SpecificClass : BaseClass()
Run Code Online (Sandbox Code Playgroud)

现在,我想SpecificClass通过依赖注入提供,但我也想在同一个图中koin提供基类。BaseClass

需要明确的是,我想做一些类似的事情:

class Someclass {
    ...
    private specificClass: SpecificClass by inject()
    ...
}

class Someclass {
    ...
    private baseClass: BaseClass by inject() 
    // where this BaseClass is just the the same instace of the SpecificClass in the dependency graph
    ...
}
Run Code Online (Sandbox Code Playgroud)

我该如何让我的模块做到这一点?如何将实现实例注入到基类引用中?

kotlin koin

6
推荐指数
1
解决办法
2940
查看次数

如何在 Dart 中将映射写入 YAML 文件

我在 Dart 中有一张键值对的映射。我想将其转换YAML并写入文件。

我尝试使用YAMLdart 库中的包,但它只提供YAML从文件加载数据的方法。没有提及如何将其写回文件YAML

这是一个例子:

void main() {
  var map = {
    "name": "abc",
    "type": "unknown",
    "internal":{
      "name": "xyz"
    }
  };
  print(map);
}
Run Code Online (Sandbox Code Playgroud)

预期输出: example.yaml

name: abc
type: unknown
internal:
  name: xyz
Run Code Online (Sandbox Code Playgroud)

如何将 dart 映射转换为 YAML 并将其写入文件?

yaml dart dart-io

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

带有水果蛋糕的 Laravel CORS

我用laravel后端制作了反应项目......我有一个CORS问题,我像下面的链接一样做所有事情,用水果蛋糕。

API 的 Laravel 6 CORS 策略问题, 但仍然无法正常工作。

cors.php:

        'paths' => ['api/*'],

    /*
    * Matches the request method. `[*]` allows all methods.
    */
    'allowed_methods' => ['*'],

    /*
     * Matches the request origin. `[*]` allows all origins.
     */
    'allowed_origins' => ['*'],

    /*
     * Matches the request origin with, similar to `Request::is()`
     */
    'allowed_origins_patterns' => [],

    /*
     * Sets the Access-Control-Allow-Headers response header. `[*]` allows all headers.
     */
    'allowed_headers' => ['*'],

    /*
     * Sets the Access-Control-Expose-Headers …
Run Code Online (Sandbox Code Playgroud)

cors laravel reactjs laravel-middleware react-redux

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

Jetpack Compose 中列和行的 Expanded 和 LayoutSize.Expand 之间的区别

我在 Android Studio Canary 1 上尝试 Jetpack Compose,并向Columnui 添加了可组合项。Column有一个名为的属性modifier,我们可以在其中传递不同的修饰符。我使用了Expanded修饰符,导致Column占用了所有可用空间。

另外,Column具有mainAxisSizecrossAxisSize属性,所以我也尝试了它们并将其设置为LayoutSize.Expand旨在扩展我认为的给定轴。这也导致Column占用了所有可用空间。查看下面的示例:

1.使用LayoutSize.Expand

Column(mainAxisSize = LayoutSize.Expand,
crossAxisSize = LayoutSize.Expand) {
    Text("Jetpack",modifier = ExpandedHeight)
    Text("Compose",modifier = ExpandedHeight)
}
Run Code Online (Sandbox Code Playgroud)

输出:

在此输入图像描述

2. 使用扩展

Column(modifier = Expanded) {
    Text("Jetpack",modifier = ExpandedHeight)
    Text("Compose",modifier = ExpandedHeight)
}
Run Code Online (Sandbox Code Playgroud)

输出:

在此输入图像描述

观察发现以下代码提供相同的输出。Expanded那么and 和之间LayoutSize.Expand 有什么区别呢?ColumnRow

android android-jetpack-compose

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

隐藏软键盘在 Android 9.0 Pie 中不起作用

我有这段代码用于在android中隐藏软键盘:

public void hideKeyboard() {
    if (getActivity() != null) {
        View view = getActivity().getCurrentFocus();
        if (view != null) {
            InputMethodManager manager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            if (manager != null) {
                manager.hideSoftInputFromWindow(view.getWindowToken(), 0);
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

除了 Android 9.0 之外,它在其他 Android 版本上运行良好。在Android 9.0中,它没有任何作用,并且软键盘不隐藏。

android android-9.0-pie

3
推荐指数
1
解决办法
1809
查看次数

Dart 2.14 中 Enum 接口的用例是什么

我正在查看Dart SDK 的变更日志,并在Dart SDK v2.14的发行说明中注意到这一点:

在此输入图像描述

我找不到任何关于此的文档!我可以在哪里使用这个?我尝试实施它,但没有成功!

dart

3
推荐指数
1
解决办法
1043
查看次数

ImageView 中不需要的填充或边距

我对 android 到 android 开发是全新的,只是使用 xml 来构建布局。我编写了以下代码来打印 hello ubuntu 并在其中插入图像。但图像似乎有不需要的上下填充或边距(不确定它叫什么),看起来很奇怪。请任何人帮我删除它。这是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:background="@color/colorAccent"
    android:orientation="vertical"
    android:padding="10dp">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="8dp"
        android:layout_margin="8dp"
        android:text="Hello Ubuntu (16.06LTS)"
        android:background="@color/colorPrimary"/>

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="0dp"
        android:src="@mipmap/Ubuntu"
        android:layout_margin="0dp"/>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

截图如下(见右侧预览):

1

android android-layout android-studio

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

How to open Settings panel in Android Q programmatically?

As per Android Q new features, there is a inline settings panel showing key connectivity settings that lets the user modify different connectivity settings such as airplane mode, wifi, volume, NFC and internet connectivity.

How can I open that settings panel programmatically from my app? like in screenshot below.

在此处输入图片说明

android android-settings android-10.0

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