小编Rel*_*elm的帖子

如何使用jQuery获取当前时间

以下返回以微秒为单位的时间,例如4565212462.

alert( $.now() );
Run Code Online (Sandbox Code Playgroud)

如何将其转换为人类可读的时间格式,例如 (小时:分钟:秒)

time jquery datetime unix-timestamp microtime

127
推荐指数
8
解决办法
45万
查看次数

Ajax上传图片

Q.1我想将此表单转换为ajax但似乎我的ajax代码缺少某些东西.提交时根本不做任何事情.

Q2.我还希望在选择文件时不要等待提交时触发更改.

这是JS.

$('#imageUploadForm').on('submit',(function(e) {
    e.preventDefault()
    $.ajax({
        type:'POST',
        url: $(this).attr('action'),
        data:$(this).serialize(),
        cache:false
    });
}));
Run Code Online (Sandbox Code Playgroud)

和PHP的HTMl.

<form name="photo" id="imageUploadForm" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"];?>" method="post">
    <input type="file" style="widows:0; height:0" id="ImageBrowse" hidden="hidden" name="image" size="30"/>
    <input type="submit" name="upload" value="Upload" />
    <img width="100" style="border:#000; z-index:1;position: relative; border-width:2px; float:left" height="100px" src="<?php echo $upload_path.$large_image_name.$_SESSION['user_file_ext'];?>" id="thumbnail"/>
</form>
Run Code Online (Sandbox Code Playgroud)

html php ajax jquery

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

如何检查Firebase应用是否已在Android上初始化

通过以下内容,第一次调用它时可以正常工作,但随后的"FirebaseApp名称[DEFAULT]已经存在!"的调用失败了.

public FirebaseDatabase conn(Context c) {
         FirebaseOptions options = new FirebaseOptions.Builder()
                .setApiKey("key")
                .setDatabaseUrl("url")
                .setApplicationId("ID")
                .build();


        /////I tried Try and Catch with no success//////
        FirebaseApp app = FirebaseApp.initializeApp(c, options);

        /// for this : FirebaseApp app = FirebaseApp.initializeApp(c, options, "some_app");
        //// will fail with "FirebaseApp name some_app already exists!"
        return FirebaseDatabase.getInstance(app);
}
Run Code Online (Sandbox Code Playgroud)

以上所有内容都是尝试连接到第二个Firebase应用程序.

java android google-api firebase firebase-realtime-database

41
推荐指数
6
解决办法
3万
查看次数

如何捕获Firebase Auth特定的异常

使用Firebase,如何捕获特定异常并优雅地告诉用户?例如:

FirebaseAuthInvalidCredentialsException:电子邮件地址格式错误.

我正在使用下面的代码使用电子邮件和密码注册用户,但我不是那么高级的java.

mAuth.createUserWithEmailAndPassword(email, pwd)
    .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {

    @Override
    public void onComplete(@NonNull Task<AuthResult> task) {
        if (!task.isSuccessful()) {
            //H.toast(c, task.getException().getMessage());
            Log.e("Signup Error", "onCancelled", task.getException());
        } else {
            FirebaseUser user = mAuth.getCurrentUser();
            String uid = user.getUid();
        }
    }    
});
Run Code Online (Sandbox Code Playgroud)

java android exception firebase firebase-authentication

35
推荐指数
7
解决办法
3万
查看次数

Firebase Cloud Firestore:无效的集合引用.集合引用必须具有奇数个段

我有以下代码并收到错误:

Invalid collection reference. Collection references must have an odd number of segments
Run Code Online (Sandbox Code Playgroud)

和代码:

private void setAdapter() {
        FirebaseFirestore db = FirebaseFirestore.getInstance();
        db.collection("app/users/" + uid + "/notifications").get().addOnCompleteListener(task -> {
            if (task.isSuccessful()) {
                for (DocumentSnapshot document : task.getResult()) {
                    Log.d("FragmentNotifications", document.getId() + " => " + document.getData());
                }
            } else {
                Log.w("FragmentNotifications", "Error getting notifications.", task.getException());
            }
        });
    }
Run Code Online (Sandbox Code Playgroud)

java android firebase google-cloud-firestore

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

Android:如何以编程方式设置layout_constraintRight_toRightOf"parent"

我在ConstrainLayout中有一个视图如下.

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:maxWidth="260dp"
        android:textColor="#FFF"
        android:textSize="16sp"
        app:layout_constraintLeft_toLeftOf="@+id/parent"
        app:layout_constraintTop_toBottomOf="@id/message_date"
        android:id="@+id/text_main"
        />
Run Code Online (Sandbox Code Playgroud)

我想根据某些条件将视图更改为app:layout_constraintLeft_toLeftOf="@+id/parent"layout_constraintLeft_toRightOf="@+id/parent"在recycleViewHolder中以编程方式.

android android-support-library android-constraintlayout

29
推荐指数
3
解决办法
3万
查看次数

Firebase:setPersistenceEnabled和keepSynced有什么区别?

我以为我使用以下所有聊天对话数据的时间都可以随时离线使用.以某种方式不是,所有节点都从服务器加载.

FirebaseDatabase.getInstance().setPersistenceEnabled(true);
Run Code Online (Sandbox Code Playgroud)

然后,根据DOCS:

持久性行为:通过启用持久性,我们在线同步的任何数据都将持久保存到磁盘并可脱机使用,即使我们重新启动应用程序也是如此.这意味着我们的应用程序将使用存储在缓存中的本地数据在线工作.

如果数据已经脱机可用 setPersistenceEnabled(true);,我为什么需要keepSynced(true)

DatabaseReference r = FirebaseDatabase.getInstance().getReference("chat/roomid");
r.keepSynced(true);
Run Code Online (Sandbox Code Playgroud)

android persistence firebase firebase-realtime-database

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

打字稿:如何解决'rxjs/Rx没有导出成员'SubscriptionLike'

我在这里尝试按照这个示例https://www.youtube.com/watch?v=gxCu5TEmxXE,但在做的时候tsc -p,我收到了一个错误.我需要导入一些东西吗?

错误:

node_modules/@angular/common/src/location/location.d.ts(1,10): error TS2305: Module '"...functions/node_modules/rxjs/Rx"' has no exported member 'SubscriptionLike'.

TS文件

import "zone.js/dist/zone-node";
import * as functions from "firebase-functions";
import * as express from "express"
import { renderModuleFactory } from "@angular/platform-server"
import * as fs from "fs"

const document = fs.readFileSync(__dirname + "/dist-server/index.html", "utf8");
const AppServerModuleNgFactory = require(__dirname + "/dist-server/main.bundle");

const app = express();
app.get("**", (req, res) => {
    const url = req.path;
    renderModuleFactory(AppServerModuleNgFactory, { document, url }).then(html => {
        res.send(html);
    });
}); …
Run Code Online (Sandbox Code Playgroud)

javascript firebase typescript google-cloud-functions angular

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

Android:如何通过父级剪辑视图,如CSS overflow:hidden

我的意见如下:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/global_legal_gap"
    android:clipToPadding="true"
    android:clipChildren="true"
    android:baselineAligned="false"
    android:background="@drawable/post_sound_bg"
    android:foreground="?attr/selectableItemBackgroundBorderless"
    android:orientation="horizontal">

    <RelativeLayout
        android:layout_width="@dimen/post_sound_card_height"
        android:layout_height="@dimen/post_sound_card_height">

        <com.facebook.drawee.view.SimpleDraweeView
            android:id="@+id/album_art"
            android:layout_width="@dimen/post_sound_card_height"
            android:layout_height="@dimen/post_sound_card_height"
            fresco:backgroundImage="@drawable/music_placeholder" />

        <RelativeLayout
            android:id="@+id/play_icon_control"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentBottom="true"
            android:visibility="gone">

            <View
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_centerInParent="true"
                android:layout_margin="3dp" />
        </RelativeLayout>
    </RelativeLayout>
<LinearLayout>
Run Code Online (Sandbox Code Playgroud)

作为家长表示RelativeLayout,我使用的是android:clipToPadding="true"android:clipChildren="true",但这个父视图的孩子还在外面突出.

或者我是这样做的吗?我如何实现像CSS这样的东西overflow:hidden

css java xml android android-view

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

Android:如何在Emoji View中以编程方式打开软键盘

正如我所看到的,在android上显示默认表情符号的方法是在输入文本上使用以下内容.

android:inputType="textMultiLine|textShortMessage"
Run Code Online (Sandbox Code Playgroud)

当我搜索时,我无法通过Java找到一种方法.我想要做的是,当软键盘打开时,让用户选项卡按钮在表情符号视图和普通键盘视图之间切换.

自定义表情符号键盘.

我已经实现了这一点,但是使用Emojis已经在设备上发布kik-kat会更好更轻.

谷歌确实在这些观点之间切换.

在Google Allo上,按下editText切换视图中的表情符号图标.

java keyboard android android-softkeyboard emoji

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