小编sag*_*age的帖子

如何最好地将模糊的ProgressBar放在屏幕上的ConstraintLayout上?

当我单击“登录”按钮时,会显示一个进度条。我通过在顶部添加工具栏对布局进行了修改,看来此工具栏现在使进度栏变得晦涩。

如何使此进度条在屏幕中心某处可见?

非常感谢您的帮助。

布局xml代码如下所示:

activity_login.xml

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:gravity="center"
android:orientation="vertical">

<android.support.v7.widget.Toolbar
    android:id="@+id/my_toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:layout_marginBottom="64dp"
    android:background="@android:color/white"
    android:elevation="4dp"
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
    app:layout_constraintBottom_toTopOf="@+id/edittext_username"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

<EditText
    android:id="@+id/edittext_username"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="24dp"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:drawablePadding="8dp"
    android:gravity="center_vertical"
    android:hint="@string/edittext_username"
    app:layout_constraintBottom_toTopOf="@+id/edittext_password"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="@+id/button_login" />

<EditText
    android:id="@+id/edittext_password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="24dp"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:drawablePadding="8dp"
    android:gravity="center_vertical"
    android:hint="@string/edittext_password"
    android:inputType="textPassword"
    app:layout_constraintBottom_toTopOf="@+id/button_login"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent" />

<Button
    android:id="@+id/button_login"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:text="@string/button_login"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent" />

<ProgressBar
    android:id="@+id/progressbar_login_progress"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:visibility="gone" />

</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

android android-layout progress-bar android-constraintlayout

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

哈士奇预提交挂钩未触发

我有一个问题husky。我希望 huskyeslint在 git commit 即将完成时运行并且更漂亮,以便它可以强制执行干净的编码检查。我已经设置eslintprettier集成了两者。手动使用时它们工作正常。eslint然而,如果违反其中一条规则,哈士奇允许提交。

我还将pre-commit.sample本地项目.git/hooks目录中的文件重命名为pre-commit.

这是我的package.json文件:

  "scripts": {
    "prettier-format": "prettier --config .prettierrc 'src/**/*.ts' 'test/**/*.ts' --write",
    "lint": "eslint . --ext .ts"
  },
  "husky": {
    "hooks": {
      "pre-commit": "npm run prettier-format && npm run lint"
    }
  },
  "devDependencies": {
    "husky": "^7.0.1"
  }
Run Code Online (Sandbox Code Playgroud)

请问这里可能是什么问题?非常感谢。

git husky

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

无法在 Spring Boot 中拦截和操作 HttpServletResponse

我需要Base64解码 Spring Boot 服务收到的每个 JSON 请求负载。Base64在使用 HTTPPOST方法发布之前,JSON 有效负载将在客户端进行编码。此外,我还需要Base64在呈现给调用客户端应用程序之前对 JSON 响应进行编码。

我需要通过使用处理程序拦截器来减少样板代码。我已经通过使用拦截器实现了操作的请求/传入分支,但尚未为响应分支实现这一点。我已经发布了下面的代码片段。拦截响应和 base64 编码的代码在拦截器类的 postHandle 方法中。

我在这里做错了什么?

拦截器类:

public class Base64ResponseEncodingInterceptor implements HandlerInterceptor {   
    private static final String DECODED_REQUEST_ATTRIB = "decodedRequest";
    private static final String POST = "POST";


    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView arg3) throws Exception {
          try {
              if (POST.equalsIgnoreCase(request.getMethod())) {
                    CharResponseWrapper res = new CharResponseWrapper(response);
                    res.getWriter();
                    byte[] encoded = Base64.encodeBase64(res.toString().getBytes());
                    byte[] encoded = Base64.encodeBase64(response.getHeader(ENCODED_RESPONSE_ATTRIB).getBytes());
                    response.getWriter().write(new String(encoded)); …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc spring-boot

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

Spring 批处理 JdbcPagingItemReader 未正确初始化,因为它未正确关闭

我需要扫描数据库中的一些实体并每 n 分钟更新一次过期(“isexpired”)标志。之后,我会将整个实体作为 json 发布到指定为该同一实体的属性的 url。

此代码运行批处理作业并更新数据库,但它一直显示以下错误,并且在 Springsource STS 中调试时,程序似乎在更新数据库之前不断循环多次:

INFO: Overriding bean definition for bean 'expireAndPostApiEntityJob': replacing [Generic bean: class [org.springframework.batch.core.configuration.xml.SimpleFlowFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Generic bean: class [org.springframework.batch.core.configuration.xml.JobParserJobFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]
Jan 19, 2015 4:46:56 PM org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
INFO: Loading properties file from class path resource [application.properties]
Jan 19, 2015 4:46:56 PM org.springframework.beans.factory.support.DefaultListableBeanFactory registerBeanDefinition
INFO: Overriding bean definition for bean 'itemReader': replacing …
Run Code Online (Sandbox Code Playgroud)

java spring spring-batch

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

spring boot + redis cache + @Cacheable适用于某些方法,而不适用于其他方法

我使用带有redis的spring boot作为缓存,通过减少查询RDBMS系统来提高应用程序性能.它工作正常,因为它准确地缓存另一个控制器的方法,但它不缓存下面的控制器:

@RequestMapping(method = RequestMethod.GET)
    @Cacheable("findByTaxOfficeId")
    private TaxPayerNameResponse findByTaxOfficeId(@RequestParam(required = true, value = "uid") String taxOfficeId) {
        StampDutyOffice stampDutyOffice = null;
Run Code Online (Sandbox Code Playgroud)

对于工作弹簧启动控制器,配置看起来相同.可以在下面找到正常工作的缓存Controller方法的示例:

 @RequestMapping(value = "/stampdutyoffice", method = RequestMethod.GET)
    @Cacheable("getTaxPayerNameByTinIdOrJtbIdReqParam2")
    public TaxPayerNameResponse2 getTaxPayerNameByTinIdOrJtbIdReqParam2(@RequestParam(required = true, value = "uid") String tinIdOrJtbIdStampDutyOffice) {
        return getTaxPayerNameByTinIdOrJtbId2(tinIdOrJtbIdStampDutyOffice);
    }
Run Code Online (Sandbox Code Playgroud)

请问有什么问题?在此先感谢您的帮助.

java spring caching redis spring-boot

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