DragEventListener在三星S7(6.0)上不起作用

作品1217

我正在寻找与此相关的方向。我有一个纸牌融合游戏(五个国王),已经玩了大约6个月了;我的最新版本0.9.22自3月以来一直保持稳定。但是,最近我收到用户无法将丢弃物拖到丢弃物堆的报告,并且常见的线程似乎是带有Android 6.0的Samsung S7。当您从手中拖动卡片时,可以拖动的位置将变为透明,并且当您在其上拖动时,它们将恢复为正常(alpha = 1)。您可以拖动的其他地方似乎还可以,但是丢弃堆不会变暗或变亮,这使我认为Drag Event侦听器无法正常工作。

这是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中,我设置了Discard Pile onDragListener:

...
        mDiscardPile.setOnDragListener(new DiscardPileDragEventListener());
...

一件麻烦事是,我在“丢弃桩”的父视图中也有一个onDragListener,以在您将卡拖动到“丢弃桩”时提供一条消息。在我的测试中,此方法效果很好,但我只是想知道它是否与某种原因有关。

希望对朝哪个方向提出任何建议。

作品1217

事实证明,三星为S7引入了一项称为Game Tuner的功能,并将其反向移植到S6和其他设备。它会自动更改市场上任何已标记为“游戏”的已安装应用的分辨率。这对于图形驱动的游戏非常有用,但是通过拖放完全像我的纸牌游戏一样搞砸了。请注意,即使您从未进入Game Tuner应用程序,也会发生这种情况。

因此,如果您在游戏或应用程序上遇到这种情况,请询问用户是否安装了Game Tuner,并要求他们将“分辨率”设置为100%(他们可以逐个游戏地做到这一点)。

2017年3月更新:我现在有99%的解决方案。即使没有安装游戏调谐器,三星也可以扩展游戏(显然达到了75%)。因此,您必须安装Game Tuner,然后将“分辨率”重置为100%,以使拖放正常工作。

我没有的1%是为什么他们会做这样的愚蠢的事情。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

DragEventListener在三星S7(6.0)上不起作用

来自分类Dev

Ping 在三星设备上不起作用

来自分类Dev

OnKeyListener()在三星Galaxy S3上不起作用

来自分类Dev

设置警报的Call_withSpeaker在三星4.2.2上不起作用

来自分类Dev

Deep Link在三星手机上不起作用(当我尝试从Default Messenger开启时)

来自分类Dev

axios 在三星 Tizen 电视上不起作用,但在模拟器中运行良好

来自分类Dev

compressionMinSize在Tomcat 6上不起作用

来自分类Dev

MPMoviePlayerViewController在iOS 7上不起作用

来自分类Dev

Sudo在CentOS 7上不起作用

来自分类Dev

禁用相机快门声音,AudioManager 在三星中不起作用

来自分类Dev

AFNetworking 2.0.3在iOS 6上不起作用

来自分类Dev

ES6类在Chrome 47上不起作用

来自分类Dev

ACCESS_COARSE_LOCATION在Android 6上不起作用

来自分类Dev

iPhone NSURLSessionTask在iOS 6上不起作用

来自分类Dev

IPv6在14.04上不起作用

来自分类Dev

为什么CGContextSetRGBStrokeColor在ios7上不起作用?

来自分类Dev

Celery Daemon在Centos 7上不起作用

来自分类Dev

安装在Windows 7上不起作用

来自分类Dev

XAMPP中的.htaccess文件在Windows 7上不起作用

来自分类Dev

UAAppReviewManager评分功能在iOS 7上不起作用

来自分类Dev

.htaccess在xampp上不起作用(Windows 7)

来自分类Dev

Rsyslog的imfile插件在CentOS 7上不起作用?

来自分类Dev

在CentOS7上不起作用“ Vagrant halt”命令

来自分类Dev

永久链接在Nginx centos 7上不起作用

来自分类Dev

Laravel 7 Auth在托管站点上不起作用

来自分类Dev

为什么'ipconfig'在Windows 7上不起作用

来自分类Dev

LeftBarButtonItem在iOS7上不起作用

来自分类Dev

XAMPP中的.htaccess文件在Windows 7上不起作用

来自分类Dev

procontroll库在Windows 7、64位上不起作用

Related 相关文章

  1. 1

    DragEventListener在三星S7(6.0)上不起作用

  2. 2

    Ping 在三星设备上不起作用

  3. 3

    OnKeyListener()在三星Galaxy S3上不起作用

  4. 4

    设置警报的Call_withSpeaker在三星4.2.2上不起作用

  5. 5

    Deep Link在三星手机上不起作用(当我尝试从Default Messenger开启时)

  6. 6

    axios 在三星 Tizen 电视上不起作用,但在模拟器中运行良好

  7. 7

    compressionMinSize在Tomcat 6上不起作用

  8. 8

    MPMoviePlayerViewController在iOS 7上不起作用

  9. 9

    Sudo在CentOS 7上不起作用

  10. 10

    禁用相机快门声音,AudioManager 在三星中不起作用

  11. 11

    AFNetworking 2.0.3在iOS 6上不起作用

  12. 12

    ES6类在Chrome 47上不起作用

  13. 13

    ACCESS_COARSE_LOCATION在Android 6上不起作用

  14. 14

    iPhone NSURLSessionTask在iOS 6上不起作用

  15. 15

    IPv6在14.04上不起作用

  16. 16

    为什么CGContextSetRGBStrokeColor在ios7上不起作用?

  17. 17

    Celery Daemon在Centos 7上不起作用

  18. 18

    安装在Windows 7上不起作用

  19. 19

    XAMPP中的.htaccess文件在Windows 7上不起作用

  20. 20

    UAAppReviewManager评分功能在iOS 7上不起作用

  21. 21

    .htaccess在xampp上不起作用(Windows 7)

  22. 22

    Rsyslog的imfile插件在CentOS 7上不起作用?

  23. 23

    在CentOS7上不起作用“ Vagrant halt”命令

  24. 24

    永久链接在Nginx centos 7上不起作用

  25. 25

    Laravel 7 Auth在托管站点上不起作用

  26. 26

    为什么'ipconfig'在Windows 7上不起作用

  27. 27

    LeftBarButtonItem在iOS7上不起作用

  28. 28

    XAMPP中的.htaccess文件在Windows 7上不起作用

  29. 29

    procontroll库在Windows 7、64位上不起作用

热门标签

归档