我使用此代码从服务器下载excel文件.
$.ajax({
headers: CLIENT.authorize(),
url: '/server/url',
type: 'POST',
contentType: "application/json; charset=utf-8",
data: JSON.stringify(jsonData),
success: function (data) {
alert('Data size: ' + data.length);
var blob = new Blob([data], { type: "application/vnd.ms-excel" });
alert('BLOB SIZE: ' + data.length);
var URL = window.URL || window.webkitURL;
var downloadUrl = URL.createObjectURL(blob);
document.location = downloadUrl;
},
});
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,尽管数据和blob大小相同,但是时刻document.location被分配我被提示下载almoste两倍大的excel文件.当我尝试打开它时,excel抱怨错误的文件格式,打开的文件包含很多垃圾,即使所需的文本仍然存在.
是什么导致了这个以及如何避免它?
我有一个在 FragmentStateAdapter 中有多个片段的 viewpager2。每当我尝试打开一个新片段,然后使用 viewpager2 返回到当前片段时,都会出现异常:
Expected the adapter to be 'fresh' while restoring state.
Run Code Online (Sandbox Code Playgroud)
FragmentStateAdapter 似乎无法正确恢复其状态,因为它期望它为空。
我能做些什么来解决这个问题?
到目前为止,我只能使用导航组件成功导航到对话框并返回。问题是,我必须在对话框中做一些事情并将结果返回到调用对话框的片段。
一种方法是使用共享视图模型。但为此,我必须使用 .of(activity) ,即使我不再需要它,它也会让我的应用程序单例占用内存。
另一种方法是覆盖 show(fragmentManager, id) 方法,访问片段管理器,并从中访问前一个片段,然后可以将其设置为目标片段。我在实现回调接口之前使用过 targetFragment 方法,因此我的对话框可以将结果通知 targetFragment。但是在导航组件方法中,它感觉很笨拙,可能会在某一时刻停止工作。
还有其他方法可以做我想做的事吗?也许有办法解决第一种方法的问题?
当我使用我的着色器时,我得到以下结果:


一个问题是镜面光是变形的,你可以看到球形三角形,另一个是,我可以看到镜面反射,我不应该(第二张图像).一个spehere光在顶点着色器中完成,另一个在片段中完成.
以下是我的顶点灯光着色器的样子:Vertex:
// Material data.
uniform vec3 uAmbient;
uniform vec3 uDiffuse;
uniform vec3 uSpecular;
uniform float uSpecIntensity;
uniform float uTransparency;
uniform mat4 uWVP;
uniform mat3 uN;
uniform vec3 uSunPos;
uniform vec3 uEyePos;
attribute vec4 attrPos;
attribute vec3 attrNorm;
varying vec4 varColor;
void main(void)
{
vec3 N = uN * attrNorm;
vec3 L = normalize(uSunPos);
vec3 H = normalize(L + uEyePos);
float df = max(0.0, dot(N, L));
float sf = max(0.0, dot(N, H));
sf = pow(sf, uSpecIntensity);
vec3 col = …Run Code Online (Sandbox Code Playgroud) 所以我有以下代码:
When("SMS with location update command is received") {
every {
context.getString(R.string.location_sms, any(), any(), any(), any())
} returns "loc"
mainServiceViewModel.handleSms(SmsMessage("123", "location"))
Then("SMS with location is sent to specified phone number") {
verify(exactly = 1) {
smsRepository.sendSms("+123", "loc")
}
}
}
When("motion is detected") {
Then("information SMS is sent to specified phone number") {
verify(exactly = 1) {
smsRepository.sendSms("+123", any())
}
}
}
Run Code Online (Sandbox Code Playgroud)
问题在于,尽管第二个案例没有执行任何操作,但这两个案例都通过了。我预计第二种情况会失败,因为甚至没有调用 sendSms 方法。
我在FMOD示例文件夹中找到了一个名为nativeactivity的示例,但不幸的是它使用了一些java代码:
package org.fmod.nativeactivity;
public class Example extends android.app.NativeActivity
{
static
{
System.loadLibrary("fmodex");
System.loadLibrary("main");
}
}
Run Code Online (Sandbox Code Playgroud)
Android.mk看起来像这样:
LOCAL_PATH := $(call my-dir)
#
# FMOD Ex Shared Library
#
include $(CLEAR_VARS)
LOCAL_MODULE := fmodex
LOCAL_SRC_FILES := libfmodex.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/inc
include $(PREBUILT_SHARED_LIBRARY)
#
# Example Library
#
include $(CLEAR_VARS)
LOCAL_MODULE := main
LOCAL_SRC_FILES := main.c
LOCAL_LDLIBS := -llog -landroid
LOCAL_SHARED_LIBRARIES := fmodex
LOCAL_STATIC_LIBRARIES := android_native_app_glue
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)
Run Code Online (Sandbox Code Playgroud)
没有java部分可以吗?如果是这样,我需要改变什么?
我在OpenGL 2.1中使用win32线程.我想要实现的是渲染简单的图像说"加载",而在后台整个3D场景正在加载.它现在有效,但我有一个问题,有时我的立方体贴图纹理的一部分从Mozilla Firefox浏览器中获取数据(如何发生这种情况???)并忽略那个带有纹理的小盒子,它只是一个精灵和它应该在哪里:

这种情况发生在我尝试加载程序时的三分之一.这是我的线程的样子:
WindowsThread::WindowsThread(HGLRC graphicsContext, HDC deviceContext) :
graphicsContext_(graphicsContext),
deviceContext_(deviceContext),
running_(false),
task_(0),
mode_(WT_NORMAL)
{
handle_ = CreateThread(0, 0,
(unsigned long (__stdcall *)(void *)) this->staticRun,
(void*) this, CREATE_SUSPENDED, &id_);
if (handle_ == 0) {
LOGE("Unable to create thread.");
return;
}
if (!SetThreadPriority(handle_, THREAD_PRIORITY_NORMAL)) {
LOGE("Unable to set thread priority for thread.");
return;
}
}
WindowsThread::~WindowsThread() {
finishTask();
running_ = false;
WaitForSingleObject(handle_, INFINITE);
CloseHandle(handle_);
wglDeleteContext(graphicsContext_);
}
void WindowsThread::start() {
running_ = true;
if (!ResumeThread(handle_)) {
LOGW("Unable to resume thread.");
}
} …Run Code Online (Sandbox Code Playgroud) 我正在开发需要特殊权限的系统应用程序。出于某种原因,我无法获得 CLEAR_APP_USER_DATA 的许可,但我可以使用 INSTALL_PACKAGES、DELETE_PACKAGES 等。什么可能导致这种情况?
显现:
uses-permission android:name="android.permission.CLEAR_APP_USER_DATA"/>
uses-permission android:name="android.permission.CLEAR_APP_CACHE"/>
uses-permission android:name="android.permission.INSTALL_PACKAGES"/>
uses-permission android:name="android.permission.DELETE_PACKAGES"/>
uses-permission android:name="android.permission.CHANGE_CONFIGURATION"/>
uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
Run Code Online (Sandbox Code Playgroud)
我删除了“<”,因为它不会显示其余的行。
我使用权限的代码:
String apkPackage = intent.getExtras().getString(context.getString(R.string.key_package));
if (apkPackage != null) {
PackageManager pm = context.getPackageManager();
Class<?>[] types = new Class[] {String.class, IPackageDataObserver.class};
try {
Method methodClearUserData = pm.getClass().getMethod("clearApplicationUserData", types);
methodClearUserData.invoke(pm, new Object[] {apkPackage, null});
Method methodDeleteCache = pm.getClass().getMethod("deleteApplicationCacheFiles", types);
methodDeleteCache.invoke(pm, new Object[] {apkPackage, null});
} catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
Log.w(TAG, "Unable to invoke clear method.", e); …Run Code Online (Sandbox Code Playgroud) 我收到了多个应使用 Lottie 库按顺序播放的动画文件
我目前正在尝试做的是重用相同的 LottieAnimationView 并在第一个动画完成时设置下一个动画。代码如下所示:
private fun playFirstAnimation() {
binding.animation.setAnimation(R.raw.progress_1)
binding.animation.repeatCount = 2
binding.animation.addAnimatorListener(object : Animator.AnimatorListener {
override fun onAnimationRepeat(animation: Animator?) = Unit
override fun onAnimationCancel(animation: Animator?) = Unit
override fun onAnimationStart(animation: Animator?) = Unit
override fun onAnimationEnd(animation: Animator?) {
binding.animation.removeAnimatorListener(this)
notifyFirstAnimationFinished()
playSecondAnimation()
}
})
binding.animation.playAnimation()
}
private fun playSecondAnimation() {
binding.animation.setAnimation(R.raw.progress_2)
binding.animation.repeatCount = 0
binding.animation.addAnimatorListener(object : Animator.AnimatorListener {
override fun onAnimationRepeat(animation: Animator?) = Unit
override fun onAnimationCancel(animation: Animator?) = Unit
override fun onAnimationStart(animation: Animator?) = Unit
override fun …Run Code Online (Sandbox Code Playgroud) 我最近遇到了一个非常奇怪的问题。我的布局中有一个地图视图,它使用数据绑定进行了膨胀。在我将 ViewPager2 添加到我的布局后,我遇到了这个问题:
java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class androidx.recyclerview.widget.RecyclerView$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/0x1. Make sure other views do not use the same id.
Run Code Online (Sandbox Code Playgroud)
但是只有当您首先打开第一个片段并转到下一个片段,然后按返回时才会发生这种情况。
似乎它与视图状态有关,但是我可以做些什么来解决这个问题?
这是一个示例片段代码:
class TestFragment(override val layoutRes: Int = R.layout.fragment_test) : BaseFragment() {
lateinit var binding: FragmentTestBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? …Run Code Online (Sandbox Code Playgroud) android android-mapview android-databinding android-viewpager2
android ×5
c++ ×2
opengl ×2
android-architecture-navigation ×1
android-ndk ×1
bdd ×1
fmod ×1
glsl ×1
javascript ×1
jquery ×1
kotest ×1
kotlin ×1
mockk ×1
system ×1
unit-testing ×1