小编Ken*_*nny的帖子

具有ArrayList的Android类Parcelable

我有一个Android项目,我有一个类.在那个班级是一个ArrayList<Choices>.我将获得一些XML,解析它,然后从中创建对象,我将传递给另一个活动.我正在为此选择Parcelable.

Parcelable是一个不错的选择吗?我做的一切都正确吗?我对Parcelable真的不熟悉.我的ArrayList是我在这个类中创建的另一个类.它是否会正确地将对象的ArrayList传递给Parcel,而不会扩展Parcelable和stuff?

import java.util.ArrayList;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.os.ParcelableCompat;

public class Question implements Parcelable{


String id;
String text;
String image;
ArrayList<Choices> CHOICES;


public Question(String id, String text, String image) {
    super();
    this.id = id;
    this.text = text;
    this.image = image;
}

public String getId() {
    return id;
}

public void setId(String id) {
    this.id = id;
}

public String getText() {
    return text;
}

public void setText(String text) {
    this.text = text;
}

public String getImage() { …
Run Code Online (Sandbox Code Playgroud)

android class arraylist parcelable

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

Unmarshalling Android Intent Parcelable时找不到类

我有一个ArrayList我在之间传递activities.在这里ArrayList,由一个class有四个变量的对象组成.其中的一个变量是另一种ArrayList<object>是从另一个class.

我已经实现Parcelable上都和我敢肯定我已经正确地完成了parcelable方法.以下是错误:

错误:

03-18 02:37:27.063: D/dalvikvm(3249): GC_FOR_ALLOC freed 82K, 6% free 3020K/3180K, paused 1ms, total 3ms
03-18 02:37:27.093: I/dalvikvm-heap(3249): Grow heap (frag case) to 3.626MB for 635808-byte allocation
03-18 02:37:27.103: D/dalvikvm(3249): GC_FOR_ALLOC freed 5K, 5% free 3635K/3804K, paused 10ms, total 10ms
03-18 02:37:27.173: D/(3249): HostConnection::get() New Host Connection established 0xb96396c0, tid 3249
03-18 02:37:27.243: W/EGL_emulation(3249): eglSurfaceAttrib not implemented
03-18 02:37:27.253: D/OpenGLRenderer(3249): Enabling debug mode 0
03-18 …
Run Code Online (Sandbox Code Playgroud)

android arraylist unmarshalling parcelable android-intent

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

离子 + 快车道 | Android“错误:包 android.support.v4.content 不存在”

我正在处理一个Ionic项目,但在构建 Android 时遇到了问题。我继承了这个项目,所以这就是为什么我不是 100% 熟悉Fastlane以及它如何构建 java 文件。此外,我使用 WSL2 并使用 sdkmanager 和以下已安装的软件包:

Installed packages:=====================] 100% Fetch remote repository...
Path                 | Version | Description                    | Location
-------              | ------- | -------                        | -------
build-tools;29.0.2   | 29.0.2  | Android SDK Build-Tools 29.0.2 | build-tools/29.0.2
emulator             | 30.8.4  | Android Emulator               | emulator
patcher;v4           | 1       | SDK Patch Applier v4           | patcher/v4
platform-tools       | 31.0.3  | Android SDK Platform-Tools     | platform-tools
platforms;android-29 | 5       | Android SDK Platform 29 …
Run Code Online (Sandbox Code Playgroud)

android cordova ionic-framework fastlane

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

Python (3.5) - urllib.request.urlopen - 进度条可用吗?

我正在尝试在万维网上搜索这个答案,但我觉得答案可能是否定的。我正在使用 Python 3.5 和一个库,该库被调用urllib.request的方法调用urllib.request.urlopen(url)以打开链接并下载文件。

由于文件超过 200MB,因此最好有某种进度衡量标准。我正在查看这里的 API ,并没有看到任何带有钩子的参数。

这是我的代码:

downloadURL = results[3] #got this from code earlier up
rel_path = account + '/' + eventID + '_' + title + '.mp4'

filename_abs_path = os.path.join(script_dir, rel_path)
print('>>> Downloading >>> ' + title)

# Download .mp4 from a url and save it locally under `file_name`:
with urllib.request.urlopen(downloadURL) as response, open(filename_abs_path, 'wb') as out_file:
    shutil.copyfileobj(response, out_file)
Run Code Online (Sandbox Code Playgroud)

如果他们认为我可能有一个进度条,或者唯一的方法是使用不同的库,任何人都可以提供见解吗?我希望保持代码非常简短和简单,我只需要一些正在下载的文件的指示。感谢您提供的任何帮助!

python urllib python-3.5

5
推荐指数
2
解决办法
5172
查看次数

ConnectionResetError:远程主机强制关闭现有连接

我正在编写一个脚本来下载一组文件.我成功完成了这项工作并且工作正常.现在我尝试添加下载进度的动态打印输出.

对于小型下载(顺便说一下是.mp4文件),例如5MB,进展很有效,文件成功关闭,从而生成完整且有效的下载.mp4文件.对于较大的文件,如250MB及以上,它无法正常工作,我收到以下错误:

在此输入图像描述

这是我的代码:

import urllib.request
import shutil
import os
import sys
import io

script_dir = os.path.dirname('C:/Users/Kenny/Desktop/')
rel_path = 'stupid_folder/video.mp4'
abs_file_path = os.path.join(script_dir, rel_path)
url = 'https://archive.org/download/SF145/SF145_512kb.mp4'
# Download the file from `url` and save it locally under `file_name`:

with urllib.request.urlopen(url) as response, open(abs_file_path, 'wb') as out_file:

    eventID = 123456

    resp = urllib.request.urlopen(url)
    length = resp.getheader('content-length')
    if length:
        length = int(length)
        blocksize = max(4096, length//100)
    else:
        blocksize = 1000000 # just made something up

    # print(length, blocksize)

    buf = io.BytesIO()
    size …
Run Code Online (Sandbox Code Playgroud)

python python-3.x

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

Zapier - Catch Hook - JSON 数组 - 循环数组中的每个项目

我需要使用 Zapier Webhook 获取一些传入的 JSON 数据(其中包含一个项目数组)、循环该数组并对每个元素执行操作。

以下是传入 JSON 数据的示例:

    {
            "first_name": "Bryan",
            "last_name": "Helmig",
            "age": 27,
            "data": [
                {
                    "title": "Two Down, One to Go",
                    "type": "Left"
                },
                {
                    "title": "Talk the Talk",
                    "type": "Right"
                },
                {
                    "title": "Know the Ropes",
                    "type": "Top"
                }
            ]
    }
Run Code Online (Sandbox Code Playgroud)

数组的大小是动态的。

问题是,当我在钩子中导入这些数据时,它给了我

data
    title: Two Down, One to Go
    type: Left
    title: Talk the Talk
    type: Right
    title: Know the Ropes
    type: Top
Run Code Online (Sandbox Code Playgroud)

所以,基本上它说这data只是所有这些东西组合在一起的一大串。

任何人都可以帮我弄清楚是否可以对此进行 Zap 循环并执行某些操作,例如,将数据插入到工作表中,对于数组中的每个项目?我知道“代码”操作,我选择了 JavaScript,我可以解析出字符串,但这似乎效率不高。另外,实际上,JSON 数组内的对象中会有大量数据。

编辑:解决了!答案如下

javascript json zapier

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

嵌套CSS网格是不好的做法吗?

我正在尝试使用组件驱动的前端框架(例如Angular),最后学习CSS Grid。

我的问题是筑巢 是坏习惯CSS Grids吗?

我在这里所做的是在我的main / root组件中,我使用了CSS网格来完成两件事:navbar和主要内容区域,因为navbar将出现在整个应用程序以及主要内容中。

如下所示,根层次上的网格,然后是<nav-bar>组件中的另一个网格。在主要内容区域中,我使用的每个/任何Angular组件中都会有更多的网格,可能是网格。

**********************    ******************************
*       Navbar       * => * img | nav         | logout *
**********************    ******************************
**********************
*                    *
*       Content      *
*                    *
**********************
Run Code Online (Sandbox Code Playgroud)

下面的示例代码:

app.component.html

<div class="container">

    <div class="item-navbar"></div>

    <div class="item-nav">
        <nav-bar></nav-bar>
    </div>

    <div class="item-content">
        <router-outlet></router-outlet>
    </div>

</div>

With this CSS: 
.container {
    display: grid;
    grid: ". nav ." 
        ". content ."
        / 3vh auto 3vh;
    row-gap: 1vh;
}

.item-navbar {
    grid-area: 1 / …
Run Code Online (Sandbox Code Playgroud)

html css grid css-grid angular

4
推荐指数
3
解决办法
844
查看次数

Goutte Scrape 登录 https 安全网站

因此,我尝试使用 Goutte 登录https网站,但出现以下错误:

cURL error 60: SSL certificate problem: unable to get local issuer certificate 500 Internal Server Error - RequestException 1 linked Exception: RingException

这是 Goutte 的创建者说要使用的代码:

use Goutte\Client;

$client = new Client();

$crawler = $client->request('GET', 'http://github.com/');
$crawler = $client->click($crawler->selectLink('Sign in')->link());
$form = $crawler->selectButton('Sign in')->form();
$crawler = $client->submit($form, array('login' => 'fabpot', 'password' =>     'xxxxxx'));
$crawler->filter('.flash-error')->each(function ($node) {
    print $node->text()."\n";
});
Run Code Online (Sandbox Code Playgroud)

或者这里是 Symfony 推荐的代码:

use Goutte\Client;

// make a real request to an external site
$client = new …
Run Code Online (Sandbox Code Playgroud)

ssl curl web-scraping symfony goutte

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

Symfony2响应

我正在尝试向Oauth的API发送响应.可悲的是,Symfony2文档在解释所有不同部分方面做得很差$response->headers->set(...);.

这是我在OauthController里面的响应部分:

    $response = new Response();

    $response->setStatusCode(200);
    $response->headers->set('Location', 'url=' . $auth_url);

    return $response->send();
Run Code Online (Sandbox Code Playgroud)

控制器必须有一个return声明,所以,我的代码看起来不错或如何header('Location: ' . $auth_url);从正常的PHP 复制?

谢谢!

php response symfony

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

角度-表单验证-无法读取未定义的属性“名称”

所以我有一个带有输入和其他内容的表格,我试图做一些角度验证,以确保输入的信息确实存在(不是空白)。为此,我正在使用一条if语句。

我收到的错误消息是:

Cannot read property 'name' of undefined

<input>如果将其保留为空白,似乎无法读取标签名称。当我填写时,该函数有效,但其他函数(和和)则不起作用。我只是试图使用一条if语句来查看它们是否已被填充。这是下面的html和angular代码:

reviewModal.view.html (shortened form version)

<div class="modal-content">
    <div role="alert" ng-show="vm.formError" class="alert alert-danger">{{ vm.formError }}</div>
    <form id="addReview" name="addReview" role="form" ng-submit="vm.onSubmit()" class="form-horizontal">
        <label for"name" class="col-xs-2 col-sm-2 control-label">Name</label>
            <div class="col-xs-10 col-sm-10">
                <input id="name" name="name" ng-model="vm.formData.name" class="form-control">
            </div>
        <button type="submit" class="btn btn-primary">Submit review</button>
    </form>
</div>
Run Code Online (Sandbox Code Playgroud)

reviewModal.controller.js

(function() {

    angular
        .module('loc8rApp')
        .controller('reviewModalCtrl', reviewModalCtrl);

    reviewModalCtrl.$inject = ['$uibModalInstance', 'locationData'];
    function reviewModalCtrl($uibModalInstance, locationData) {
        var vm = this;
        vm.locationData = locationData;

        vm.onSubmit = function() { …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

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

Mongoose geoNear maxDistance结果

我正在使用node.js和mongoose.我的数据库中有4个带lng/lat坐标的对象.在现实生活中,这些位置彼此相差1或2英里.

module.exports.locationsListByDistance = function(req, res) {
    var lng = parseFloat(req.query.lng);
    var lat = parseFloat(req.query.lat);
    var point = {
        type: "Point",
        coordinates: [lng, lat]
    };
    var geoOptions =  {
        spherical: true,
        maxDistance: 20 / 3963,
        num: 10
    };
    Loc.geoNear(point, geoOptions, function(err, results, stats) {
        var locations;
        console.log('Geo Results', results);
        console.log('Geo stats', stats);
        if (err) {
            console.log('geoNear error:', err);
            sendJsonResponse(res, 404, err);
        } else {
            locations = buildLocationList(req, res, results, stats);
            sendJsonResponse(res, 200, locations);
        }
    });
};
Run Code Online (Sandbox Code Playgroud)

这是我的代码.当Loc.geoNear运行时,在回调函数 …

mongoose mongodb node.js

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

AngularFire Observables / Subscribe - 不在同一范围内设置类变量

我正在使用 Firebase 构建一个 Ionic 应用程序,因此使用 AngularFire2。在 Angularfire2 中,您可以进行身份​​验证,但它是一个 observable,必须订阅才能获取用户对象。问题是我似乎无法设置,this.user = user因为它似乎不在.subscribe同一范围内。

这是一个例子,我有一个auth.ts和一个app.component.ts。在我的服务中,我进行身份验证,

auth.ts

export class AuthService {

// user: Observable<firebase.User>;
user: object = {
    displayName: null,
    email: null,
    emailVerified: null,
    photoUrl: null,
    uid: null
};

constructor(private facebook: Facebook,
            private googlePlus: GooglePlus,
            private platform: Platform,
            private afAuth: AngularFireAuth) {

    // this.user = afAuth.authState;
    afAuth.authState.subscribe((user: firebase.User) => {

        if (!user) {
            this.user = null;
            return;
        }
        this.user =  {
            displayName: user.displayName,
            email: user.email,
            emailVerified: …
Run Code Online (Sandbox Code Playgroud)

rxjs firebase ionic-framework angularfire2 angular

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