我们正在尝试将图像预加载到缓存中以便以后加载它们(图像位于应用程序的Asset文件夹中)
我们尝试了什么:
Glide.with(this)
.load(pictureUri)
.diskCacheStrategy(DiskCacheStrategy.ALL);
Glide.with(this)
.load(picture_uri)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.preload();
Run Code Online (Sandbox Code Playgroud)
问题:只有当我们尝试加载/显示图像时才会缓存图像:必须先将它们加载到内存中,以便它们看起来更快.
Glide.with(this)
.load(picture_uri)
.into(imageView);
Run Code Online (Sandbox Code Playgroud)
我们还尝试使用GlideModule来增加CacheMemory大小:
public class GlideModule implements com.bumptech.glide.module.GlideModule {
@Override
public void applyOptions(Context context, GlideBuilder
builder.setMemoryCache(new LruResourceCache(100000));
}
@Override
public void registerComponents(Context context, Glide glide) {
}
}
Run Code Online (Sandbox Code Playgroud)
在清单中:
<meta-data android:name=".GlideModule" android:value="GlideModule"/>
Run Code Online (Sandbox Code Playgroud)
到目前为止没有任何工作.任何的想法?
我们尝试使用不可见的1 dp imageView,但结果是一样的:
for(Drawing drawing: getDrawingsForTab(tab)){
Glide.with(this)
.load(drawing.getImage().toUri())
.dontAnimate()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(mPreloadCacheIv);
for(Picture picture : getPictures()){
Glide.with(this)
.load(picture.getPicture().toUri())
.dontAnimate()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(mPreloadCacheIv);
}
}
Run Code Online (Sandbox Code Playgroud) 一方面我有一个带有两个ImageView的布局:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/image_cross2"
android:layout_width="wrap_content"
android:layout_height="@dimen/image_size"
android:layout_gravity="top"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/image_cross1"
android:layout_width="wrap_content"
android:layout_height="@dimen/image_size"
android:layout_gravity="top"
android:scaleType="centerCrop" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
另一方面,我有一个图像资源列表:
static int mImages[] = new int[] {
R.drawable.artistes,
R.drawable.couple1,
R.drawable.couple2,
R.drawable.couple3,
R.drawable.enfant,
R.drawable.manege,
R.drawable.manege2,
R.drawable.metropolitain,
R.drawable.panoramique,
R.drawable.sacrecoeur };
Run Code Online (Sandbox Code Playgroud)
我还有一个由Handler + postDelayed()制作的调度程序,用计时器一个接一个地显示图像.这工作正常
我的问题是关于从一个图像视图到另一个图像视图的过渡动画,知道我每次都要清理图像视图以避免OutOfMemoryExceptions:
现在我在schduled回调方法中这样做:
if (mIndex == mImages.length) {
mIndex = 0; // repeat
}
if (mIndex % 2 != 0) { // pair
mImageCross2.setImageResource(mImages[mIndex++]);
Utils.crossfade(mImageCross2, mImageCross1, 1000/*duration*/);
mImageCross1.setImageResource(0);
} else {
mImageCross1.setImageResource(mImages[mIndex++]);
Utils.crossfade(mImageCross1, mImageCross2, 1000); …
Run Code Online (Sandbox Code Playgroud) 要将数据传输到其他应用程序,我一直在使用隐式意图,如下例所示:
Intent intent = new Intent();
intent.setAction("com.example.OpenURL");
intent.putExtra("URL_TO_OPEN", url_string);
sendOrderedBroadcastAsUser(intent);
Intent intent = new Intent();
intent.setAction("com.example.CreateUser");
intent.putExtra("Username", uname_string);
intent.putExtra("Password", pw_string);
sendBroadcast(intent);
Intent intent = new Intent();
intent.setAction("com.example.BackupUserData");
intent.setData(file_uri);
intent.addFlags(FLAG_GRANT_READ_URI_PERMISSION);
sendBroadcast(intent);
Run Code Online (Sandbox Code Playgroud)
但是在Android 5.0中不再推荐这种行为
http://developer.android.com/about/versions/android-5.0-changes.html
绑定到服务
Context.bindService()方法现在需要显式的Intent,如果给定隐式intent,则抛出异常.要确保您的应用是安全的,请在启动或绑定服务时使用明确的意图,并且不要为服务声明意图过滤器.
从android源代码更准确地说是"ContextImpl"类:
private void validateServiceIntent(Intent service) {
if (service.getComponent() == null && service.getPackage() == null) {
if (getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.LOLLIPOP) {
IllegalArgumentException ex = new IllegalArgumentException(
"Service Intent must be explicit: " + service);
throw ex;
} else {
Log.w(TAG, "Implicit intents with startService are not …
Run Code Online (Sandbox Code Playgroud) 正如标题中的解释,我正在尝试将Materialise集成到我的Angular 2项目中.
该项目由" AngularCli " 生成
我正在使用" Webpack "和" Scss "
我找到的tuto都是不同的我不明白如何使用scss:
我的角度cli json:
{ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "project": { "name": "accident-chain-web-angular", "ejected": true }, "apps": [ { "root": "src", "outDir": "dist", "assets": [ "assets", "favicon.ico" ], "index": "index.html", "main": "main.ts", "polyfills": "polyfills.ts", "test": "test.ts", "tsconfig": "tsconfig.app.json", "testTsconfig": "tsconfig.spec.json", "prefix": "app", "styles": [ "assets/scss/main.scss" ], "scripts": [], "environmentSource": "environments/environment.ts", "environments": { "dev": "environments/environment.ts", "preprod": "environments/environment.preprod.ts", "prod": "environments/environment.prod.ts" } } ], "e2e": { "protractor": { "config": …
我正在尝试找到一个解决方案,使用一个快速应用程序拥有多个swaggerUi文档.
我正在使用 :
"typescript": "^2.5.2",
"swagger-tools": "^0.10.1",
"express": "^4.15.3",
"express-openapi": "^1.0.1",
Run Code Online (Sandbox Code Playgroud)
我的swagger doc文件部分是使用项目文件架构生成的.
我怎样才能做到这一点 ?
编辑---
现在我正在这样初始化swaggerUi:
const openapi = Openapi.initialize({
paths: openApiPaths,
expressApp,
swaggerApiDoc,
});
const openApiSpec: any = openapi.apiDoc;
app.use(swaggerUI(openApiSpec));
Run Code Online (Sandbox Code Playgroud)
哪里openApiPaths
包含paths:{}
swagger doc
我添加和删除这样的片段:
加
getSherlockActivity().getSupportFragmentManager()
.beginTransaction()
.setCustomAnimations(R.anim.slide_in_bottom, R.anim.slide_out_top, R.anim.slide_in_top, R.anim.slide_out_bottom)
.add(R.id.fragment_explore, fragment)
.addToBackStack(null)
.commit();
ActivityMain.BACKSTACK_EXPLORE.add(fragment);
Run Code Online (Sandbox Code Playgroud)
去掉
Fragment depopFragment = BACKSTACK_EXPLORE.get(BACKSTACK_EXPLORE.size() - 1);
getSupportFragmentManager().beginTransaction()
.setCustomAnimations(R.anim.slide_in_top, R.anim.slide_out_bottom, R.anim.slide_in_bottom, R.anim.slide_out_top)
.remove(depopFragment)
.commit();
BACKSTACK_EXPLORE.remove(depopFragment);
Run Code Online (Sandbox Code Playgroud)
有一个快速幻灯片动画.片段来自底部并返回底部.
我的问题是当你按下后退按钮(删除片段)时,在动画结束之前,你触摸后面出现的活动.
它给了我一个简单的致命信号11错误(更常见于三星galaxy s3)
任何的想法 ?
java error-handling android android-fragments actionbarsherlock
我正在构建一个基于angular2(angularcli生成),webpack,scss和面向模块的项目.
对于http请求,我决定创建一个由身份验证服务使用的服务.
所有在CoreModule中引用
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {RequestOptions, XHRBackend} from '@angular/http';
// Services
import {HttpService} from './services/http.service';
import {AuthService} from './services/auth/auth.service';
export function httpInterceptor(backend: XHRBackend,
defaultOptions: RequestOptions) {
return new HttpService(backend, defaultOptions);
}
@NgModule({
imports: [
CommonModule
],
providers: [
AuthService,
{
provide: HttpService,
useFactory: httpInterceptor,
deps: [XHRBackend, RequestOptions]
}
]
})
export class CoreModule {
}
Run Code Online (Sandbox Code Playgroud)
还有我的AppModule:
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {Router} from '@angular/router';
import 'materialize-css';
// Components
import …
Run Code Online (Sandbox Code Playgroud) 我试图用业力做测试,但得到一个错误:
ERROR in ./src/test.ts
Module build failed: Error: AotPlugin was detected but it was an instance of the wrong class.
This likely means you have several @ngtools/webpack packages installed. You can check this with `npm ls @ngtools/webpack`, and then remove the extra copies.
Run Code Online (Sandbox Code Playgroud)
当我执行cmd时,我得到了这个结果:
+-- @angular/cli@1.1.1
| `-- @ngtools/webpack@1.4.1
`-- @ngtools/webpack@1.5.1
Run Code Online (Sandbox Code Playgroud)
在我,package.json
我只有@ngtools/webpack": "^1.5.1
1.4.1来自哪里?
这就是我配置swagger的方式:
const openapi = Openapi.initialize({
paths: openApiPaths,
app,
apiDoc,
});
const openApiSpec = openapi.apiDoc;
console.log(openApiSpec);
app.use(swaggerUI(openApiSpec));
Run Code Online (Sandbox Code Playgroud)
如何将基本路径更改/docs/
为/projectName/docs/
?
我没有找到任何相关的答案
编辑
我的api doc在它自己的文件中描述如下:
export const apiDoc = {
'x-express-openapi-additional-middleware': [checkBodyValidity],
swagger: '2.0',
basePath: '/api/v1',
info: {
title: 'Documentation Rest API',
version: 'v1',
},
paths: {},
definitions: {}
}
Run Code Online (Sandbox Code Playgroud)
CheckBodyValidity是一种检查请求参数有效性的中间件(与我的问题无关):
export const checkBodyValidity: any = (req, res, next) => {}
Run Code Online (Sandbox Code Playgroud)
Swagger在名为openapiSetup的文件中初始化如下:
export async function init(app: any): Promise<any> {
[...]
const openapi = Openapi.initialize({
paths: openApiPaths,
app,
apiDoc,
});
const …
Run Code Online (Sandbox Code Playgroud) 是否可以使用io套接字执行类似的操作:
socket.on('event.here', async (data) => {
const result:any = await webservice();
}
Run Code Online (Sandbox Code Playgroud)
我不太确定该怎么做?
android ×4
java ×4
angular ×3
node.js ×3
typescript ×3
webpack ×3
angular-cli ×2
swagger ×2
animation ×1
express ×1
image ×1
intentfilter ×1
materialize ×1
ng-modules ×1
openapi ×1
promise ×1
sass ×1
service ×1
socket.io ×1