我在找一个方向和这个一起走。我有一个卡片融合游戏(五王),已经运行了大约6个月;我的最新版本0.9.22已经稳定了3月份。然而,最近我收到了用户无法将丢弃物拖到丢弃堆中的报告,常见的线程似乎是三星S7和Android6.0。当你从手上拖动一张卡片时,你可以拖动的地方变成透明的,当你拖到它们上面时,它们会恢复正常(alpha=1)。你可以拖动的其他地方似乎工作正常,但丢弃堆没有变暗或变亮,这让我认为拖动事件侦听器不工作。
这是DiscardPileDragEventListener
class DiscardPileDragEventListener implements View.OnDragListener {
// This is the method that the system calls when it dispatches a drag event to the
// listener.
@Override
public boolean onDrag(final View v, final DragEvent event) {
//that we are not ready to accept the drag if not at the right point of the play
CardView cv = (CardView)v;
// Defines a variable to store the action type for the incoming event
final int action = event.getAction();
// Handles each of the expected events
switch(action) {
case DragEvent.ACTION_DRAG_STARTED:
// Determines if this View can accept the dragged data
if (cv.isAcceptDrag() && event.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
//fades out of the draw pile
cv.startAnimation(Utilities.instantFade(FiveKings.HALF_TRANSPARENT_ALPHA, FiveKings.HALF_TRANSPARENT_ALPHA));
// returns true to indicate that the View can accept the dragged data.
return true;
} else {
//remind user what they should be doing if in the first few rounds
((FiveKings) cv.getContext()).setShowHint(null, FiveKings.HandleHint.SHOW_HINT, FiveKings.GameDifficulty.EASY);
// Returns false. During the current drag and drop operation, this View will
// not receive events again until ACTION_DRAG_ENDED is sent.
return false;
}
case DragEvent.ACTION_DRAG_ENTERED:
cv.clearAnimation();
return true;
case DragEvent.ACTION_DRAG_LOCATION:
// Ignore the event
return true;
case DragEvent.ACTION_DRAG_EXITED:
cv.startAnimation(Utilities.instantFade(FiveKings.HALF_TRANSPARENT_ALPHA, FiveKings.HALF_TRANSPARENT_ALPHA));
return true;
case DragEvent.ACTION_DROP:
cv.clearAnimation();
// Gets the item containing the dragged data
ClipData.Item item = event.getClipData().getItemAt(0); //this is the View index to recover which card
// Gets the text data from the item.
String dragData = item.getText().toString();
//Handle exception here and return false (drop wasn't handled) if it wasn't found
int iView = -1;
try {
iView = Integer.parseInt(dragData);
}catch (NumberFormatException e) {
return false;
}
return ((FiveKings)cv.getContext()).discardedCard(iView);
case DragEvent.ACTION_DRAG_ENDED:
if (cv.isAcceptDrag()) cv.clearAnimation();
return true;
// An unknown action type was received.
default:
Log.e("DiscardPileDragEventListener", "Unknown action type received by OnDragListener.");
}
return false;
}
}下面是设置实际拖放卡的代码片段;在这个CardView中是ImageView的一个子类:
for (Card card : meld) {
//highlight wildcards unless no dragging (Computer turn, or Human final turn)
CardView cv = new CardView(this, card, iView, allowDragging ? highlightWildCardRank : null);
cv.setTag(iView); //allows us to pass the index into the dragData without dealing with messy object passing
...
cv.bringToFront();
cv.setClickable(false); //TODO:B: Allow selection by clicking for multi-drag?
if (allowDragging) {//no dragging of computer cards or Human cards after final turn
cv.setOnDragListener(new CardViewDragEventListener()); //needed per-card to reset the dragged card to normal visibility (alpha)
cv.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() != MotionEvent.ACTION_DOWN) return false;
// Create a new ClipData using the tag as a label, the plain text MIME type, and
// the string containing the View index. This will create a new ClipDescription object within the
// ClipData, and set its MIME type entry to "text/plain"
ClipData dragData = ClipData.newPlainText("Discard", v.getTag().toString());
View.DragShadowBuilder cardDragShadow = new CardViewDragShadowBuilder(v);
v.startAnimation(Utilities.instantFade(FiveKings.HALF_TRANSPARENT_ALPHA, FiveKings.HALF_TRANSPARENT_ALPHA));
// Starts the drag
v.startDrag(dragData, cardDragShadow, null, 0);
return true;
}//end onClick
});
}//end if allowDragging
...在onCreate中,我设置了丢弃堆onDragListener:
...
mDiscardPile.setOnDragListener(new DiscardPileDragEventListener());
...其中一个缺点是,我在丢弃堆的父视图中也有一个onDragListener,以便在将您的卡拖到丢弃堆中时提供一条消息。这在我的测试中运行得很好,但我只是想知道它是否有某种联系。
希望你能提出任何建议,告诉我该往哪个方向走。
发布于 2016-07-22 00:16:26
事实证明,三星推出了一个名为“S7游戏调谐器”的功能,并将其移植到S6和其他设备上。它会自动改变任何在市场上被标记为“游戏”的应用程序的分辨率。这是一个伟大的图形驱动游戏,但完全混乱的纸牌游戏,像我的拖放。请注意,即使您从未进入游戏调谐器应用程序,也会发生这种情况。
因此,如果您在游戏或应用程序中体验到这一点,请询问用户是否安装了游戏调谐器,并要求他们将分辨率设置为100% (他们可以在逐游戏的基础上做到这一点)。
更新Mar2017:我现在有99%的解决方案。即使没有安装游戏调谐器,三星也会升级游戏(显然达到75%)。因此,您必须安装游戏调谐器,然后重置决议100%,以使拖放工作正常。
我没有的1%就是为什么他们会做这样的蠢事。
发布于 2016-08-02 22:54:26
三星显示缩放选项:它缩小某些屏幕上的东西。
例如,在主屏幕上,打开文件夹时会看到更多的图标。
我相信三星最近(2016年7月)发布了一个OTA更新,其中有这个功能。如果此功能在设置/显示中可用,则意味着OTA更新已经安装,这似乎解决了拖放问题。
https://stackoverflow.com/questions/38044129
复制相似问题