我在具有多个ImageView的垂直ScrollView中使用LinearLayout,当我单击一个图像视图时,我从(活动1)到全屏库(活动2)执行过渡动画,该库具有视图分页器,用户可以向右/向左滑动..现在,当用户滑动到库中的另一个图像并按下当前可见图像(活动2)时,将恢复(再次使用过渡动画)到活动1中的起始位置,问题是图像已恢复直到它到达旧位置然后消失并显示不同的图像(因为这已经太复杂而无法讨论)我附加了一个图像.
Activity1布局:
<LinearLayout>
<ImageView />
<ImageView />
<ImageView />
<ImageView />
<ImageView />
<ImageView />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
Acivity2(图库)布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/animation_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/placeholder"
android:transitionName="@string/transition_article_image_gallery"
android:layout_centerInParent="true"
/>
<ViewPager
android:id="@+id/gallery_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
点击活动1中的任何图片:
public void openGallery(int position, ArrayList<String> images, View view)
{
Intent intent = new Intent(getActivity(), GalleryActivity.class);
intent.putStringArrayListExtra(GalleryActivity.EXTRA_GALLERY_IMAGES, images);
intent.putExtra(GalleryActivity.EXTRA_POSITION, position);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
getActivity(),
new Pair<>(view, TARGET_ELEMENT_TRANSITION_NAME_ATTRIB_VALUE)
);
ActivityCompat.startActivity(getActivity(), intent, options.toBundle());
} else {
getActivity().startActivity(intent); …
Run Code Online (Sandbox Code Playgroud) 我正在尝试通过脚本获取此网址: http: //api.alarabiya.net/sections/2/
但是收到的 JSON 响应比我直接在浏览器中打开它时要小得多,
请注意,我通过 CURL 尝试了这个 url,并设置了浏览器的相同 USER-AGENT 以及浏览器中使用的所有请求标头,但我仍然得到较小的响应。
这是仅使用 file_get_contents 的示例
<?php
echo file_get_contents("http://api.alarabiya.net/sections/2/");
?>
Run Code Online (Sandbox Code Playgroud)
我的问题是使用 file_get_contents 时是否有请求大小限制,或者 PHP 的内存无法处理它,或者到底是什么问题?
当我在 shell 中将其卷曲时,它给了我与 php 中相同的 o/p(修剪后的输出)。
我的网站上有一个以彗星为主导的聊天脚本
我的服务器配置是带有PHP-FPM的NGINX,我也在不同的端口上安装了apache.
当我尝试在Apache上运行聊天脚本时,我将缓冲区(我的输出缓冲区大小为1 KB)当我用1024个字符填充它时,它会自动刷新它在apache中.
但在nginx中却没有.
我的代码与此非常相似
<?php
// this is to fill the buffer and start output; and it works on apache normally
echo str_repeat(" ",1024);
while($condition){
// Some code here...
$messages = getMessagesFromDatabase();
if($messages){
echo "output"; // output works on apache but not nginx
flush();
ob_flush();
}
usleep(500000); // 0.5 Second
}
?>
Run Code Online (Sandbox Code Playgroud)
在我的nginx配置中,我关闭了gzip,关闭了proxy_buffering,
有没有办法避免在nginx中缓冲,我在stackoverflow中搜索了很多,但我无法达成解决方案
请注意:我不想在我的所有php配置中关闭缓冲我只想在聊天脚本中发生这种情况
我有一个db如下:
score:0
timeScore:86400
totalScore:0
time:1234567777 // Any time stamp
Run Code Online (Sandbox Code Playgroud)
现在每次用户投票
增量($ inc)得分+1然后我将timeScore更新为例如 (86400 / nowTimestamp() - time + 1 )
然后我将totalScore更新为(timeScore + score)
例如:第二次更新后的最终值:
score:1
timeScore:86400
totalScore:86401
time:1234567777
Run Code Online (Sandbox Code Playgroud)
问题是,在我的外部计算期间,可能是另一个用户在分数中添加+1并计算总数并在我更新数据之前写入其值,因此会出现数据损坏.
现在我如何解决这个问题或如何使其安全?
我创建了一个小库,用于将视图放置在现有视图的旁边/上方/下方(例如,“帮助”箭头或类似的东西),
MainView.getLocationOnScreen(..);
Run Code Online (Sandbox Code Playgroud)
确定主视图将在附近放置同级视图的位置。
通常,我使用以下方法通过以下方法确定主视图的顶部(Y),然后使用以下方法确定状态栏的高度:
protected boolean isTranslucentStaturBar()
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = ((Activity) mainActionView.getContext()).getWindow();
--> return // SOME EXPRESSION TO DETERMINE IF THE STATUS BAR IS TRANSLUCENT <--- ?????
// I Need to know what expression I need to write here
// i.e. How to ready the flag: WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
}
return false;
}
protected int getStatusBarHeight() {
if (isTranslucentStaturBar()) {
return 0;
}
int result = 0;
int resourceId = mainActionView.getContext().getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > …
Run Code Online (Sandbox Code Playgroud)