小编sho*_*hoe的帖子

实现RealmModel而不是在Realm中扩展RealmObject有什么好处?

Realm,为了能够持久化对象,它必须实现RealmModel或扩展RealmObject.使用一个比另一个好吗?

它在领域文档中所说的全部是:

扩展RealmObject基类的另一种方法是实现RealmModel接口并添加@RealmClass注释.

然后,可以通过静态方法获得RealmObject上可用的所有方法.

java android realm

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

==自定义类的重载并不总是被调用

我有一个自定义运算符全局定义如下:

func ==(lhs: Item!, rhs: Item!)->Bool {
    return lhs?.dateCreated == rhs?.dateCreated
}
Run Code Online (Sandbox Code Playgroud)

如果我执行此代码:

let i1 = Item()
let i2 = Item()
let date = Date()
i1.dateCreated = date
i2.dateCreated = date
let areEqual = i1 == i2
Run Code Online (Sandbox Code Playgroud)

areEqual是假的.在这种情况下,我确信我的自定义操作符没有触发.但是,如果我将此代码添加到操场中:

//same function
func ==(lhs: Item!, rhs: item!)->Bool {
    return lhs?.dateCreated == rhs?.dateCreated
}

//same code
let i1 = Item()
let i2 = Item()
let date = Date()
i1.dateCreated = date
i2.dateCreated = date
let areEqual = i1 == i2
Run Code Online (Sandbox Code Playgroud)

areEqual 是的 …

swift

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

这个"StickyScrollView"实现如何将视图粘贴到ScrollView的顶部?

通常粘性标头的工作原理是,某些可滚动数据被分成多个部分,每个部分都有自己的标题,当您向下滚动时,后续部分的标题会替换顶部的标题ScrollView.

我需要的是在每个相应的部分中有额外的粘性标题.例如,如果header1卡在顶部,它的第一部分的标题 - header1a- 卡在它下面,但是当我们到达部分时1b,1b's标题将被替换1a's,但留header1在同一个地方; 当我们最终到达部分时2,header2将替换上一部分中当前卡住的标题 - header1header1b.

这是一个ScrollView以一维方式实现粘性标头的实现:https:
//github.com/emilsjolander/StickyScrollViewItems

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;

import java.util.ArrayList;

/**
 *
 * @author Emil Sj?lander - sjolander.emil@gmail.com
 *
 */
public class StickyScrollView extends ScrollView {

    /**
     * Tag for views that …
Run Code Online (Sandbox Code Playgroud)

android

8
推荐指数
2
解决办法
1811
查看次数

当我更改Button中文本的大小时,为什么相邻的按钮会移动

以下是每个Button文本具有相同大小的文本时的布局:

在此输入图像描述

当我增加右下角Button文本的大小时,这是布局:

在此输入图像描述

这里发生了什么?为什么"0"的Button移动低于Buttons它附近的两个?

这是布局:

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

    <TextView
            android:id="@+id/input_textview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textColorHint="@color/hint_color"
            android:singleLine="true"
            android:textSize="40sp"/>

    <GridLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:columnCount="3">

        <Button
            android:id="@+id/the_1_button"
            android:background="@android:color/white"
            android:text="1"/>

        <Button
            android:id="@+id/the_2_button"
            android:background="@android:color/white"
            android:text="2"/>

        <Button
            android:id="@+id/the_3_button"
            android:background="@android:color/white"
            android:text="3"/>

        <Button
            android:id="@+id/the_4_button"
            android:background="@android:color/white"
            android:text="4"/>

        <Button
            android:id="@+id/the_5_button"
            android:background="@android:color/white"
            android:text="5"/>

        <Button
            android:id="@+id/the_6_button"
            android:background="@android:color/white"
            android:text="6"/>

        <Button
            android:id="@+id/the_7_button"
            android:background="@android:color/white"
            android:text="7"/>

        <Button
            android:id="@+id/the_8_button"
            android:background="@android:color/white"
            android:text="8"/>

        <Button
            android:id="@+id/the_9_button"
            android:background="@android:color/white"
            android:text="9"/>

        <ImageButton
            android:id="@+id/the_backspace_button"
            style="@style/Widget.AppCompat.Button"
            android:background="@android:color/white"
            android:src="@drawable/ic_backspace"/>

        <Button
            android:id="@+id/the_0_button"
            android:background="@android:color/white"
            android:text="0"/> …
Run Code Online (Sandbox Code Playgroud)

android android-layout

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

启动Apache ZooKeeper服务器时获取永久EndOfStreamExceptions

ZooKeeper工作得非常好,但后来我注意到我java.net.ConnectException在打开的cli窗口中得到了一个永久物.现在,当我尝试启动ZooKeeper使用zkServer.cmdI永久获取EndOfStreamExceptions并且服务器永远不会启动.这是cli输出:

c:\zookeeper\bin>zkServer.cmd

c:\zookeeper\bin>call "C:\Program Files\Java\jdk1.8.0_71"\bin\java "-Dzookeeper.log.dir=c:\zookeeper\bin\.." "-Dzookeeper.root.logger=INFO,CONSOLE" -cp "c:\zookeeper\bin\..\build\classes;c:\zookeeper\bin\..\build\lib\*;c:\zookeeper\bin\..\*;c:\zookeeper\bin\..\lib\*;c:\zookeeper\bin\..\conf" org.apache.zookeeper.server.quorum.QuorumPeerMain "c:\zookeeper\bin\..\conf\zoo.cfg"
[myid:] - INFO  [main:QuorumPeerConfig@124] - Reading configuration from: c:\zookeeper\bin\..\conf\zoo.cfg
[myid:] - INFO  [main:QuorumPeer$QuorumServer@149] - Resolved hostname: 127.0.0.1 to address: /127.0.0.1
[myid:] - ERROR [main:QuorumPeerConfig@301] - Invalid configuration, only one server specified (ignoring)
[myid:] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
[myid:] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 12
[myid:] - WARN  [main:QuorumPeerMain@113] - Either no config or no quorum defined in …
Run Code Online (Sandbox Code Playgroud)

apache apache-zookeeper

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

获取致命信号11(SIGSEGV),使用Realm编写代码1

看起来这个错误是由本机代码中的错误引起的,这是由于Realm库 - 基于在librealm-jni.so错误下方的"构建指纹"中看到该短语.我有最新版本的Realm安装 - 1.2.0.

这是错误代码:

Fatal signal 11 (SIGSEGV), code 1, fault addr 0x14c in tid 7837 (ator.app)
Run Code Online (Sandbox Code Playgroud)

这是"构建指纹:"

    Build fingerprint: 'generic/vbox86p/vbox86p:5.0/LRX21M/buildbot11172321:userdebug/test-keys'
26643-26643/? I/DEBUG: Revision: '0'
26643-26643/? I/DEBUG: ABI: 'x86'
26643-26643/? I/DEBUG: pid: 7837, tid: 7837, name: ator.app  >>> com.lockedout.app <<<
26643-26643/? I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x14c
26643-26643/? I/DEBUG:     eax 00000148  ebx ffffffff  ecx 7470d340  edx 00000002
26643-26643/? I/DEBUG:     esi 00000000  edi 00000002
26643-26643/? I/DEBUG:     xcs 00000023  xds …
Run Code Online (Sandbox Code Playgroud)

android realm

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

对入站规则的更改不会更新到实例

AWS管理控制台中,我有一个实例。当我转到该实例的描述并单击时,view inbound rules我得到:

80  tcp 0.0.0.0/0       ?
22  tcp 24.47.137.69/32 ?
443 tcp 0.0.0.0/0       ?
Run Code Online (Sandbox Code Playgroud)

如果我转到该实例的安全组——只有一个——并删除端口 443 规则,它会从安全组中删除,但是当我返回实例页面并view inbound rules再次单击时,我得到同样的结果:

80  tcp 0.0.0.0/0       ?
22  tcp 24.47.137.69/32 ?
443 tcp 0.0.0.0/0       ?
Run Code Online (Sandbox Code Playgroud)

知道为什么实例的入站规则在它的安全组是时没有更新吗?

amazon-ec2 amazon-web-services aws-security-group

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

如何获取Realm对象的非托管版本

根据这个答案,从现有托管对象获取非托管对象所需的全部操作是:

let unmanagedObject = Object(value: existingObject)
Run Code Online (Sandbox Code Playgroud)

但是,当我这样做时existingObject,托管域对象的任何字段本身都是复制后的托管域对象.我该怎么做才能使副本的所有子对象都不受管理?

realm ios

6
推荐指数
0
解决办法
831
查看次数

Android`@ BindingAdapter` setter未被调用

这是我的BindingAdapter

public class Bindings{
    @BindingAdapter({"font"})
    public static void setFont(TextView textView, String fontName) {
        textView.setTypeface(FontCache.getInstance(textView.getContext()).get(fontName));
    }
}
Run Code Online (Sandbox Code Playgroud)

*我尝试使用“ bind:font”,“ android:font”和“ app:font”代替了“ font”作为注释参数,并在布局中进行了所有相应的更改,但BindingAdapter仍然没有叫

这是我使用BindingAdapter(bind_layout.xml)的布局:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto">

    <data></data>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            font="@{`fontawesome-webfront`}"
            android:text="@string/double_left"/>
    </LinearLayout>
</layout>
Run Code Online (Sandbox Code Playgroud)

*此布局包含在使用以下方式设置的“活动”布局中 DatabindingUtils.setContentView

这是活动的布局,其中包含bind_layout.xml:

public class ACreateSemester extends AppCompatActivity {
    private List<CreateItemView> mCreateItemViews;
    private LinearLayout mItemContainer;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        DataBindingUtil.setContentView(this,R.layout.a_create_items);
        mItemContainer = (LinearLayout) findViewById(R.id.item_container);
        mItemContainer.addView(new CreateItemView(this, Item.getDefaultItem()));
    }

}
Run Code Online (Sandbox Code Playgroud)

我在这里引用的三个文件是完整列出的。 …

android android-layout

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

分辨率中心崩溃报告中的执行顺序错误

我的应用程序被应用程序商店拒绝,因为有一个按钮导致它在iPad上按下时崩溃.我没有iPad,这个bug在任何iPad模拟器上都是不可复制的.以下是决议中心发给我的崩溃报告:

{"app_name":"xxx","timestamp":"2018-05-23 14:18:37.70 -0700","app_version":"0.4.5","slice_uuid":"f7e0571c-a2a9-313c-ab7b-9a9109670ff2","adam_id":1387669409,"build_version":"1","bundleID":"com.b.xxx","share_with_app_devs":false,"is_first_party":false,"bug_type":"109","os_version":"iPhone OS 11.3.1 (15E302)","incident_id":"D5ADA937-9FAF-479B-A925-7B127B5E0C44","name":"xxx"}
Incident Identifier: D5ADA937-9FAF-479B-A925-7B127B5E0C44
CrashReporter Key:   cac3035154ad4b589b77fd30cfea229fc2cfaf20
Hardware Model:      xxx
Process:             xxx [1949]
Path:                /private/var/containers/Bundle/Application/FD86FF84-2DDF-4DFA-B23D-703D4A08316B/xxx.app/xxx
Identifier:          com.b.xxx
Version:             1 (0.4.5)
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.b.xxx [1153]


Date/Time:           2018-05-23 14:18:37.5753 -0700
Launch Time:         2018-05-23 14:18:31.9754 -0700
OS Version:          iPhone OS 11.3.1 (15E302)
Baseband Version:    6.55.00
Report Version:      104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000180b03644
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating …
Run Code Online (Sandbox Code Playgroud)

crash ios swift

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