Пример #1
0
 /** 设置触摸对话框外面,对话框是否消失 */
 public EasyDialog setTouchOutsideDismiss(boolean touchOutsideDismiss) {
   this.touchOutsideDismiss = touchOutsideDismiss;
   if (touchOutsideDismiss) {
     rlOutsideBackground.setOnTouchListener(outsideBackgroundListener);
   } else {
     rlOutsideBackground.setOnTouchListener(null);
   }
   return this;
 }
Пример #2
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Typeface myTypeface = Typeface.createFromAsset(this.getAssets(), "fonts/" + "digital.ttf");
    TextView dialvalue = (TextView) findViewById(R.id.dialvalue);
    dialvalue.setTypeface(myTypeface);

    RelativeLayout dial = (RelativeLayout) findViewById(R.id.DialContainer);

    dial.setOnTouchListener(
        new View.OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub

            v.startAnimation(
                AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate_indefinitely));

            return false;
          }
        });

    // Start animating the image

  }
Пример #3
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.bigadventure);

    bigadventure_tv = (TextView) findViewById(R.id.bigadventure_textview);
    topview = (ImageView) findViewById(R.id.bigadventure_topview);
    bottomview = (ImageView) findViewById(R.id.bigadventure_bottomview);
    relativeLayout = (RelativeLayout) findViewById(R.id.big_rl);
    shakeChange = new ShakeChange(BigAdventure.this, bigadventure_tv, 2, topview, bottomview);
    textRead = new TextRead(BigAdventure.this, 2);

    linearLayout = (LinearLayout) findViewById(R.id.linearlayout_bottom);

    // 设置触摸监听器,在触摸时调用
    relativeLayout.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View view, MotionEvent motionEvent) {
            shakeChange.StartAnimation();
            new Handler()
                .postDelayed(
                    new Runnable() {
                      @Override
                      public void run() {
                        try {
                          bigadventure_tv.setText(textRead.LineRead());
                        } catch (IOException e) {
                          e
                              .printStackTrace(); // To change body of catch statement use File |
                                                  // Settings | File Templates.
                        }
                      }
                    },
                    1000);
            return false; // To change body of implemented methods use File | Settings | File
                          // Templates.
          }
        });
    /*b_backbutton = (Button)findViewById(R.id.b_backButton);
    b_sharebutton = (Button)findViewById(R.id.b_shareButton);

    b_backbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            BigAdventure.this.finish();
        }
    });

    b_sharebutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent=new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(Intent.createChooser(intent, "请选择"));
        }
    });*/

  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState, R.layout.view_pager_multi_fragment_demo);

    viewPager = (ViewPager) findViewById(R.id.view_pager);
    indexText = (TextView) findViewById(R.id.view_pager_index);
    viewPagerContainer = (RelativeLayout) findViewById(R.id.pager_layout);
    viewPager.setAdapter(new MyPagerAdapter());
    // to cache all page, or we will see the right item delayed
    viewPager.setOffscreenPageLimit(TOTAL_COUNT);
    viewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.page_margin));
    viewPager.setOnPageChangeListener(new MyOnPageChangeListener());

    viewPagerContainer.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // dispatch the events to the ViewPager, to solve the problem that we can swipe only the
            // middle view.
            return viewPager.dispatchTouchEvent(event);
          }
        });
    indexText.setText(new StringBuilder().append("1/").append(TOTAL_COUNT));
  }
  private void init() {
    if (null == mAdapter) {
      // print(true, "init() " + coverList.size());
      mAdapter =
          new AlbumFragmentPagerAdapter(
              getActivity().getSupportFragmentManager(), coverList.size(), "", mPager);

      mAdapter.setOnGetItem(
          new OnGetItem() {

            @Override
            public ImageFragment onGetNewItem(int position) {
              // 生成新的 cover 图片实例
              return ImageFragment.newInstance(coverList.get(position).getId(), true);
            }
          });

      mPager.setAdapter(mAdapter);
      mPager.setPageMargin(mPagerMargin);
      mPager.setOffscreenPageLimit(3);
      // set container touch event assign to pager's touch event
      mContainer.setOnTouchListener(mOnTouchListener);

      // set container to refresh when pager's page changed
      mPager.setOnPageChangeListener(mOnPageChangeListener);
      mPager.setOnTouchListener(mOnTouchListener);
      // 设置选中的页面
      mPager.setCurrentItem(selectedPosition);
    } else {
      mAdapter.notifyDataSetChanged();
    }
  }
Пример #6
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_level4background);

    myVideoView = (VideoView) findViewById(R.id.videoView);
    myVideoView.setVideoPath("android.resource://" + getPackageName() + "/" + R.raw.level4);
    myVideoView.start();
    myVideoView.setOnCompletionListener(
        new MediaPlayer.OnCompletionListener() {

          @Override
          public void onCompletion(MediaPlayer mp) {
            CallNextActivity();
          }
        });

    RelativeLayout levelbg4 = (RelativeLayout) findViewById(R.id.levelbg4);

    levelbg4.setOnTouchListener(
        new RelativeLayout.OnTouchListener() {
          public boolean onTouch(View v, MotionEvent m) {

            handletouch(m);

            return true;
          }
        });
  }
Пример #7
0
  // Convention: Player 1 will always have X
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initializeSoundClips();
    final RelativeLayout parent = (RelativeLayout) findViewById(R.id.parent);
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    // Create the adView
    adView = new AdView(this, AdSize.BANNER, "a150f19509627e7");

    // Initiate a generic request to load it with an ad
    adView.loadAd(new AdRequest());
    // parent.addView(adView);

    dialog1 = createDialog("Player 1", 1);
    singlePlayer = getIntent().getBooleanExtra("SINGLE", false);
    if (!singlePlayer) {
      dialog2 = createDialog("Player 2", 2);
      dialog2.show();
    } else {
      player2Name = "Device";
      TextView view = (TextView) findViewById(R.id.header);
      view.setText(player1Name + " vs " + player2Name);
    }
    dialog1.show();

    parent.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent ev) {
            if (!init) init();
            if (end) return true;
            if (computerWorking) return true;
            if (fill(ev)) {
              playSound(currentPlayer == 1 ? player1Sound : player2Sound);
              switchPlayers();
              end = verifyEnd();
              if (end) {
                TextView view = (TextView) findViewById(R.id.info);
                if (currentPlayer != 0) {
                  view.setText((currentPlayer == 1 ? player2Name : player1Name) + " wins.");
                  playSound(winnerSound);
                } else {
                  view.setText("Match Tied.");
                  playSound(tieSound);
                }
                Button reset = (Button) findViewById(R.id.clear);
                reset.setText("New Game");
                System.out.println("game Ends here");
              }
              // FOR DEVICE
              else if (singlePlayer) {
                playComputerMove();
              }
            }
            return true;
          }
        });
  }
Пример #8
0
 private void addSlideLayoutTouchListener() {
   footerWrapper.setOnTouchListener(
       new View.OnTouchListener() {
         @Override
         public boolean onTouch(View v, MotionEvent event) {
           getSlideLayout().setTouchEnabled(true);
           return false;
         }
       });
 }
Пример #9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // remove title bar
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    // remove notification bar
    this.getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    layout = new RelativeLayout(this);
    layout.setBackgroundColor(0xFFFFFF00);
    layout.setOnTouchListener(
        new View.OnTouchListener() {

          @Override
          public boolean onTouch(View view, MotionEvent event) {
            // TODO Auto-generated method stub
            int action = event.getAction();
            PointerCoords curCoord = new PointerCoords();
            event.getPointerCoords(0, curCoord);
            Calendar calendar = Calendar.getInstance();
            long curTime = calendar.getTimeInMillis();
            switch (action) {
              case MotionEvent.ACTION_DOWN:
                xTouchDown = event.getAxisValue(MotionEvent.AXIS_X); // curCoord.x;
                yTouchDown = curCoord.y;
                timeTouchDown = curTime;
                cntDataPoint = 0;
                break;
                //				case MotionEvent.ACTION_MOVE:
              default:
                int dt = (int) (curTime - timeTouchDown);
                if (dt < HANDEDNESSTIMEOUT) {
                  Log.d(
                      LOGTAG,
                      "["
                          + cntDataPoint++
                          + "] "
                          + dt
                          + ": "
                          + event.getOrientation(0)
                          + ", "
                          + (event.getAxisValue(MotionEvent.AXIS_X) - xTouchDown));
                }
                break;
                //				case MotionEvent.ACTION_UP:
                //					break;
            }
            return true;
          }
        });

    setContentView(layout);
  }
Пример #10
0
  public Call(Context context) {
    super(context);
    color = xacInteractiveCanvas.fgColorGreen;

    CallManager.setPhone(this);

    appLayout = new RelativeLayout(context);
    appLayout.setBackgroundColor(xacInteractiveCanvas.bgColorGreen);

    //		dispatchButtons(context);
    layoutViews = new RelativeLayout(context);
    appLayout.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View view, MotionEvent event) {
            posture = xacPostureSenseFeatureMaker.calculatePosture();
            if (posture != xacPostureSenseFeatureMaker.NOWATCH) {
              return false;
            }

            return true;
          }
        });
    layoutViews.setId(42);
    appLayout.addView(layoutViews);

    dispatchViews(context);

    layoutCallScreen = new RelativeLayout(context);
    layoutCallScreen.setBackgroundColor(0xDD000000);
    layoutCallScreen.setBackgroundResource(R.drawable.call_out);
    layoutCallScreen.setOnTouchListener(
        new View.OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {

            posture = xacPostureSenseFeatureMaker.calculatePosture();
            if (posture == xacPostureSenseFeatureMaker.NONE) {
              if (event.getAction() == MotionEvent.ACTION_UP) {
                layoutCallScreen.setBackgroundColor(0xDD000000);
                appLayout.removeView(layoutCallScreen);
                isCalling = false;
                isInApp = false;
              }
            } else if (posture == xacPostureSenseFeatureMaker.NOWATCH) {
              doTouch(event);
            }

            return true;
          }
        });

    sup = "5 missed calls from Tiffany";
  }
 private void showDialog() {
   RelativeLayout dialog =
       (RelativeLayout) getActivity().findViewById(R.id.relativeLayout_dialog_fullscreen);
   dialog.setVisibility(View.VISIBLE);
   dialog.setOnTouchListener(
       new View.OnTouchListener() {
         @Override
         public boolean onTouch(View v, MotionEvent event) {
           return true;
         }
       });
 }
Пример #12
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);

    final CoordinatorLayout.LayoutParams layoutParams =
        (CoordinatorLayout.LayoutParams) commentFrame.getLayoutParams();

    commentFrame.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });

    behavior = (HideablePartBehavior) layoutParams.getBehavior();
    behavior.setChangeCallback(this);

    root.setResizeCallback(
        new IgnorantCoordinatorLayout.ResizeCallback() {
          @Override
          public void onSizeChanged(int w, int h, int oldw, int oldh) {
            commentFrame.post(
                new Runnable() {
                  @Override
                  public void run() {
                    behavior.sync(commentFrame);
                  }
                });
          }
        });

    instrumentsLayout.removeAllViews();

    LayoutInflater inflater = getLayoutInflater(savedInstanceState);
    for (final TextChanger changer : instruments) {
      View button = inflater.inflate(R.layout.include_instrument_button, instrumentsLayout, false);
      ((ImageView) button.findViewById(R.id.icon)).setImageResource(changer.getImageResource());
      button.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              changer.onSelect(CommentEditFragment.this, text);
              selectedInstrument = instruments.indexOf(changer);
            }
          });
      instrumentsLayout.addView(button);
    }
  }
Пример #13
0
  private void setListener() {

    rl_back.setOnTouchListener(context);
    rl_refresh.setOnTouchListener(context);
    rl_font.setOnTouchListener(context);
    rl_cache.setOnTouchListener(context);
    rl_image.setOnTouchListener(context);
    rl_down.setOnTouchListener(context);
  }
Пример #14
0
  public void addTextTag(String content, int x, int y) {
    if (tagViewList == null) tagViewList = new ArrayList<View>();
    LayoutInflater mInflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View view = mInflater.inflate(R.layout.imageview_tag, null);
    TextView text = (TextView) view.findViewById(R.id.tag_text);
    RelativeLayout layout = (RelativeLayout) view.findViewById(R.id.tag_layout);
    text.setText(content);

    layout.setOnTouchListener(
        new OnTouchListener() {
          int startx = 0;
          int starty = 0;

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            if (v.getId() == R.id.tag_layout) {
              switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                  startx = (int) event.getRawX();
                  starty = (int) event.getRawY();
                  break;

                case MotionEvent.ACTION_MOVE:
                  int x = (int) event.getRawX();
                  int y = (int) event.getRawY();
                  int dx = x - startx;
                  int dy = y - starty;

                  setPosition(v, dx, dy);

                  startx = (int) event.getRawX();
                  starty = (int) event.getRawY();
                  break;
              }
            }
            return true;
          }
        });

    this.addView(layout);
    setPosition(layout, x, y);
    tagViewList.add(layout);
  }
Пример #15
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lexicon);

    text = (TextView) findViewById(R.id.lexicon_text);

    DBHelper dbHelper = new DBHelper(Lexicon.this, "dic.db", null, 1);
    final SQLiteDatabase db = dbHelper.getReadableDatabase();

    final Cursor cursor =
        db.query("dicInfo", new String[] {"word,explain"}, null, null, null, null, null);

    if (cursor.moveToFirst()) {
      cursor.move(i);
      String word = cursor.getString(0);
      String explain = cursor.getString(1);
      String result = word + "\n" + explain;
      text.setText(result);
    } else {

    }

    mLastButton = (Button) findViewById(R.id.last_button);
    mLastButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            query("last", cursor);
          }
        });

    mNextButton = (Button) findViewById(R.id.next_button);
    mNextButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            query("next", cursor);
          }
        });

    RelativeLayout lexion = (RelativeLayout) findViewById(R.id.lexicon);
    lexion.setOnTouchListener(this);
  }
Пример #16
0
  @Override
  public void setOnTouchListener(OnTouchListener listener) {
    if (exoVideoSurfaceView != null) {
      exoVideoSurfaceView.setOnTouchListener(listener);
    }

    if (videoView != null) {
      videoView.setOnTouchListener(listener);
    }

    // Sets the onTouch listener for the shutters
    shutterLeft.setOnTouchListener(listener);
    shutterRight.setOnTouchListener(listener);
    shutterTop.setOnTouchListener(listener);
    shutterBottom.setOnTouchListener(listener);

    super.setOnTouchListener(listener);
  }
  @Override
  protected void initViewsAndEvents(View rootView) {
    mTitle.setText("附近的人");
    mTitleRight.setVisibility(View.GONE);
    mIcon.setImageResource(R.drawable.icon_head);
    //        toggleShowLoading(true,"loading");
    for (int i = 0; i < mImgs.length; i++) {
      Info info = new Info();
      info.setPortraitId(mImgs[i]);
      info.setAge(((int) Math.random() * 25 + 16) + "岁");
      info.setName(mNames[(int) (Math.random() * mNames.length)]);
      info.setSex(i % 3 == 0 ? false : true);
      info.setDistance(Math.round((Math.random() * 10) * 100) / 100);
      mDatas.put(i, info);
    }
    /** 将Viewpager所在容器的事件分发交给ViewPager */
    ryContainer.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return viewPager.dispatchTouchEvent(event);
          }
        });
    ViewpagerAdapter mAdapter = new ViewpagerAdapter();
    viewPager.setAdapter(mAdapter);
    // 设置缓存数为展示的数目
    viewPager.setOffscreenPageLimit(mImgs.length);
    viewPager.setPageMargin(getResources().getDimensionPixelOffset(R.dimen.viewpager_margin));
    // 设置切换动画
    viewPager.setPageTransformer(true, new ZoomOutPageTransformer());
    viewPager.addOnPageChangeListener(this);
    setViewPagerSpeed(250);

    new Handler()
        .postDelayed(
            new Runnable() {
              @Override
              public void run() {
                radarViewGroup.setDatas(mDatas);
              }
            },
            1500);
    radarViewGroup.setiRadarClickListener(this);
  }
Пример #18
0
  // 给每一个控件设置监听器
  private void setViewOnclickListener() {
    ViewOnClickListener viewOnClickListener = new ViewOnClickListener();
    return_bt.setOnClickListener(viewOnClickListener);
    music_play_bt.setOnClickListener(viewOnClickListener);
    music_album_iv.setOnClickListener(viewOnClickListener);
    btn_love.setOnClickListener(viewOnClickListener);
    songlist_lv.setOnItemClickListener(new MusicListItemClickListener()); // 列表监听
    songlist_lv.setOnItemLongClickListener(new ListItemLongClickListener()); // 长按删除

    bottombar_layout.setOnClickListener(viewOnClickListener);
    bottombar_layout.setOnTouchListener(
        new OnTouchListener() {
          // 捕获bottombar_layout的触摸事件,并传递给GestureDetector
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            myGestureDetector.onTouchEvent(event);
            return false;
          }
        });
  }
  @Override
  protected View onPlannerCreateView(
      LayoutInflater layoutInflater, ViewGroup container, Bundle savedInstanceState) {
    mUserProfile = PlannerApplication.getUserProfile();
    mRootView = (ViewGroup) layoutInflater.inflate(R.layout.fragment_useraccout, container, false);
    mSpinner = (RelativeLayout) mRootView.findViewById(R.id.rl_spinner);
    mSpinner.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });
    initView();
    if (mUserProfile == null) {
      mRootView.setVisibility(View.GONE);
    } else {
      setupRootView();
    }
    getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

    return mRootView;
  }
Пример #20
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    textView1 = (TextView) findViewById(R.id.textView1);
    textView2 = (TextView) findViewById(R.id.textView2);
    textView3 = (TextView) findViewById(R.id.textView3);
    textView4 = (TextView) findViewById(R.id.textView4);
    textView5 = (TextView) findViewById(R.id.textView5);

    layout_joystick = (RelativeLayout) findViewById(R.id.layout_joystick);

    js = new JoyStickClass(getApplicationContext(), layout_joystick, R.drawable.jaune);
    js.setStickSize(150, 150);
    js.setLayoutSize(500, 500);
    js.setLayoutAlpha(150);
    js.setStickAlpha(100);
    js.setOffset(90);
    js.setMinimumDistance(50);

    layout_joystick.setOnTouchListener(
        new OnTouchListener() {
          public boolean onTouch(View arg0, MotionEvent arg1) {
            js.drawStick(arg1);
            if (arg1.getAction() == MotionEvent.ACTION_DOWN
                || arg1.getAction() == MotionEvent.ACTION_MOVE) {
              textView1.setText("X : " + String.valueOf(js.getX()));
              textView2.setText("Y : " + String.valueOf(js.getY()));
              textView3.setText("Angle : " + String.valueOf(js.getAngle()));
              textView4.setText("Distance : " + String.valueOf(js.getDistance()));

              int direction = js.get8Direction();
              if (direction == JoyStickClass.STICK_UP) {
                textView5.setText("Direction : Up");
              } else if (direction == JoyStickClass.STICK_UPRIGHT) {
                textView5.setText("Direction : Up Right");
              } else if (direction == JoyStickClass.STICK_RIGHT) {
                textView5.setText("Direction : Right");
              } else if (direction == JoyStickClass.STICK_DOWNRIGHT) {
                textView5.setText("Direction : Down Right");
              } else if (direction == JoyStickClass.STICK_DOWN) {
                textView5.setText("Direction : Down");
              } else if (direction == JoyStickClass.STICK_DOWNLEFT) {
                textView5.setText("Direction : Down Left");
              } else if (direction == JoyStickClass.STICK_LEFT) {
                textView5.setText("Direction : Left");
              } else if (direction == JoyStickClass.STICK_UPLEFT) {
                textView5.setText("Direction : Up Left");
              } else if (direction == JoyStickClass.STICK_NONE) {
                textView5.setText("Direction : Center");
              }
            } else if (arg1.getAction() == MotionEvent.ACTION_UP) {
              textView1.setText("X :");
              textView2.setText("Y :");
              textView3.setText("Angle :");
              textView4.setText("Distance :");
              textView5.setText("Direction :");
            }
            return true;
          }
        });
  }
Пример #21
0
  @Override
  public void onCreate() {
    super.onCreate();

    Log.d(LOGTAG, "VideoHeadService - onCreate");

    endCallButton = new ImageButton(getApplicationContext());
    videoFlyHead = new RelativeLayout(getApplicationContext());
    mStreams = new ArrayList<Stream>();
    windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);

    videoFlyHead =
        (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.activity_video_fly, null, true);

    mLoadingSub = (ProgressBar) videoFlyHead.findViewById(R.id.loadingSpinner);
    mSubscriberViewContainer = (RelativeLayout) videoFlyHead.findViewById(R.id.subscriber);

    mViewGroupLayout =
        (LinearLayout) LayoutInflater.from(this).inflate(R.layout.activity_video_controls, null);
    videoFlyHead.addView(mViewGroupLayout);

    endCallButton = (ImageButton) mViewGroupLayout.findViewById(R.id.button_end_call);
    endCallButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            endCallButtonClicked(v);
          }
        });

    JSONObject json = null;

    Log.d("VideoCallActivity", "Created using MainActivity sessionID and token ID");
    sessionConnect(MainActivity.sessionId, MainActivity.token);

    final WindowManager.LayoutParams params =
        new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
            PixelFormat.TRANSLUCENT);

    videoFlyHead.setOnTouchListener(
        new View.OnTouchListener() {
          private int initialX;
          private int initialY;
          private float initialTouchX;
          private float initialTouchY;

          // Used to make the Head movable.
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
              case MotionEvent.ACTION_DOWN:
                initialX = params.x;
                initialY = params.y;
                initialTouchX = event.getRawX();
                initialTouchY = event.getRawY();
                return true;
              case MotionEvent.ACTION_UP:
                return true;
              case MotionEvent.ACTION_MOVE:
                params.x = initialX + (int) (event.getRawX() - initialTouchX);
                params.y = initialY + (int) (event.getRawY() - initialTouchY);
                windowManager.updateViewLayout(videoFlyHead, params);
                return true;
            }
            return false;
          }
        });
    windowManager.addView(videoFlyHead, params);
  }
Пример #22
0
  /**
   * Add player to a given view (most likely the root view). This should also be applied last, since
   * it will insert an overlaying view.
   */
  private void addControls() {
    // Inflate the overlay from XML specification and set the initial view
    // to be invisible.
    LayoutInflater inflater = getLayoutInflater();
    RelativeLayout ctrl_overlay =
        (RelativeLayout) inflater.inflate(R.layout.play_controls_yt, null);
    Animation animation = new AlphaAnimation(1.0f, 0.0f);
    animation.setFillAfter(true);
    ctrl_overlay.startAnimation(animation);
    ctrl_overlay.setVisibility(View.INVISIBLE);

    // Set the onTouch event listener such that it will hide and
    ctrl_overlay.setOnTouchListener(
        new View.OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // write code to add other controls and what not (the fade in /
            // fade out)
            if (!hasBeenTouched) {
              (new ShowControls(v)).call();
              Log.i("Main Activity", "control overlay has been touched");
              hasBeenTouched = true;
            } else {
              (new HideControls(v)).call();
              hasBeenTouched = false;
              Log.i(
                  "Main Activity", "controlOverlay has been pressed but has already been touched");
            }
            return false;
          }
        });
    /*
     * Get the references to all the controls we will be using in the Player
     */
    ImageButton play = (ImageButton) (((ViewGroup) ctrl_overlay.getChildAt(0)).getChildAt(0));
    ImageButton rewind = (ImageButton) (((ViewGroup) ctrl_overlay.getChildAt(0)).getChildAt(1));
    ImageButton pause = (ImageButton) (((ViewGroup) ctrl_overlay.getChildAt(0)).getChildAt(2));
    pb = (ProgressBar) (((ViewGroup) ctrl_overlay.getChildAt(0)).getChildAt(3));

    /*
     * For each control that we will be using for the Player we will define
     * the on touch events.
     */
    play.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (!hasBeenTouched) {
              (new ShowControls((View) v.getParent().getParent())).call();
              Log.i("Main Activity", "playPause has been pressed");
              hasBeenTouched = true;
            } else {
              /*
               * Play the video... really I'm just settting a flag and
               * hoping that the play-loop code above notices it.
               */
              playerControlPause = false;
              Log.i("Main Activity", "playPause has been pressed but has already been touched");
            }
          }
        });

    rewind.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (!hasBeenTouched) {
              (new ShowControls((View) v.getParent().getParent())).call();
              Log.i("Main Activity", "rewind has been pressed");
              hasBeenTouched = true;
            } else {
              /*
               * reset the video... not a true rewind
               */
              if (root.getTimePlayed() >= root.getDuration()) {
                root.reset();
                root.getSubject().reset();
                startPlayback();
              } else {
                playbackReset = true;
              }
              pb.setProgress(0);
              Log.i("Main Activity", "rewind has been pressed but has already been touched");
            }
          }
        });

    pause.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (!hasBeenTouched) {
              (new ShowControls((View) v.getParent().getParent())).call();
              Log.i("Main Activity", "fastForward has been pressed");
              hasBeenTouched = true;
            } else {
              /*
               * Set the falg to pause and hope that the playloop notices
               * what is going on.
               */
              playerControlPause = true;
              Log.i("Main Activity", "fastforward has been pressed but has already been touched");
            }
          }
        });

    pb.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (!hasBeenTouched) {
              (new ShowControls((View) v.getParent().getParent())).call();
              Log.i("Main Activity", "seekBar has been pressed");
              hasBeenTouched = true;
            } else {
              /*
               * Really don't need to do anything but display the
               * controls... so yeah.
               */
            }
          }
        });

    /*
     * Apply the (totally pimp'd out) controls to the page
     */
    ctrl_overlay.setId(CONTROL_ID);
    this.rootView.addView(ctrl_overlay);
  }
Пример #23
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    String strUrl;

    setTitle(R.string.app_name);
    super.onCreate(savedInstanceState);

    WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    multicastLock = wifi.createMulticastLock("multicastLock");
    multicastLock.setReferenceCounted(true);
    multicastLock.acquire();

    getWindow().requestFeature(Window.FEATURE_PROGRESS);
    getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);

    setContentView(R.layout.main);
    mthis = this;

    settings = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);

    SharedSettings.getInstance(this).loadPrefSettings();
    SharedSettings.getInstance().savePrefSettings();

    playerStatus = (RelativeLayout) findViewById(R.id.playerStatus);
    playerStatusText = (TextView) findViewById(R.id.playerStatusText);
    playerHwStatus = (TextView) findViewById(R.id.playerHwStatus);

    player = (MediaPlayer) findViewById(R.id.playerView);

    strUrl =
        settings.getString("connectionUrl", "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov");

    player.getSurfaceView().setZOrderOnTop(true); // necessary
    SurfaceHolder sfhTrackHolder = player.getSurfaceView().getHolder();
    sfhTrackHolder.setFormat(PixelFormat.TRANSPARENT);

    HashSet<String> tempHistory = new HashSet<String>();
    tempHistory.add("rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov");
    tempHistory.add("http://hls.cn.ru/streaming/2x2tv/tvrec/playlist.m3u8");
    tempHistory.add("rtsp://rtmp.infomaniak.ch/livecast/latele");

    player.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View view, MotionEvent motionEvent) {
            switch (motionEvent.getAction() & MotionEvent.ACTION_MASK) {
              case MotionEvent.ACTION_DOWN:
                {
                  if (player.getState() == PlayerState.Paused) player.Play();
                  else if (player.getState() == PlayerState.Started) player.Pause();
                }
            }

            return true;
          }
        });

    edtIpAddressHistory = settings.getStringSet("connectionHistory", tempHistory);

    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    edtIpAddress = (AutoCompleteTextView) findViewById(R.id.edit_ipaddress);
    edtIpAddress.setText(strUrl);

    edtIpAddress.setOnEditorActionListener(
        new OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
              InputMethodManager in =
                  (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
              in.hideSoftInputFromWindow(
                  edtIpAddress.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
              return true;
            }
            return false;
          }
        });

    btnHistory = (Button) findViewById(R.id.button_history);

    // Array of choices
    btnHistory.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            InputMethodManager in =
                (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            in.hideSoftInputFromWindow(
                MainActivity.edtIpAddress.getApplicationWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);

            if (edtIpAddressHistory.size() <= 0) return;

            String urlHistory[] = {
              "rtsp://russiatoday.fms.visionip.tv/rt/Russia_al_yaum_1000k_1/1000k_1",
              "rtsp://www.tvarm.ru:1935/live/myStream1.sdp",
              "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov",
              "rtsp://live240.impek.com/brtvhd",
              "http://tv.life.ru/lifetv/480p/index.m3u8"
            };

            MainActivity.edtIpAddressAdapter =
                new ArrayAdapter<String>(
                    MainActivity.this,
                    R.layout.history_item,
                    new ArrayList<String>(edtIpAddressHistory));
            MainActivity.edtIpAddress.setAdapter(MainActivity.edtIpAddressAdapter);
            MainActivity.edtIpAddress.showDropDown();
          }
        });

    btnShot = (Button) findViewById(R.id.button_shot);

    // Array of choices
    btnShot.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            if (player != null) {
              Log.e("SDL", "getVideoShot()");

              SharedSettings sett = SharedSettings.getInstance();
              if (sett.decoderType != 0) {
                Toast.makeText(
                        getApplicationContext(), "For Software Decoder Only!", Toast.LENGTH_SHORT)
                    .show();
                return;
              }

              // VideoShot frame = player.getVideoShot(200, 200);
              VideoShot frame = player.getVideoShot(-1, -1);
              if (frame == null) return;

              // get your custom_toast.xml ayout
              LayoutInflater inflater = getLayoutInflater();

              View layout =
                  inflater.inflate(
                      R.layout.videoshot_view,
                      (ViewGroup) findViewById(R.id.videoshot_toast_layout_id));

              ImageView image = (ImageView) layout.findViewById(R.id.videoshot_image);
              image.setImageBitmap(
                  getFrameAsBitmap(frame.getData(), frame.getWidth(), frame.getHeight()));

              // Toast...
              if (toastShot != null) toastShot.cancel();

              toastShot = new Toast(getApplicationContext());
              toastShot.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
              toastShot.setDuration(Toast.LENGTH_SHORT);
              toastShot.setView(layout);
              toastShot.show();
            }
          }
        });

    btnConnect = (Button) findViewById(R.id.button_connect);
    btnConnect.setOnClickListener(this);

    btnRecord = (Button) findViewById(R.id.button_record);
    btnRecord.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            is_record = !is_record;

            if (is_record) {
              // start recording
              if (player != null) {
                int record_flags =
                    PlayerRecordFlags.forType(PlayerRecordFlags.PP_RECORD_AUTO_START)
                        | PlayerRecordFlags.forType(
                            PlayerRecordFlags.PP_RECORD_SPLIT_BY_TIME); // 1 - auto start
                int rec_split_time = 30;
                player.RecordSetup(getRecordPath(), record_flags, rec_split_time, 0, "");
                player.RecordStart();
              }
            } else {
              // stop recording
              if (player != null) {
                player.RecordStop();
              }
            }

            ImageView ivLed = (ImageView) findViewById(R.id.led);
            if (ivLed != null)
              ivLed.setImageResource((is_record ? R.drawable.led_red : R.drawable.led_green));
            btnRecord.setText(is_record ? "Stop Record" : "Start Record");
          }
        });

    RelativeLayout layout = (RelativeLayout) findViewById(R.id.main_view);
    layout.setOnTouchListener(
        new OnTouchListener() {
          public boolean onTouch(View v, MotionEvent event) {
            InputMethodManager inputManager =
                (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            if (getWindow() != null
                && getWindow().getCurrentFocus() != null
                && getWindow().getCurrentFocus().getWindowToken() != null)
              inputManager.hideSoftInputFromWindow(
                  getWindow().getCurrentFocus().getWindowToken(), 0);
            return true;
          }
        });

    playerStatusText.setText("DEMO VERSION");
    setShowControls();
  }
Пример #24
0
  public View getAdapterView(
      final Context context, final AdInfo adInfo, int itemWidth, int itemHeight) {
    // 对小屏手机进行屏幕判断
    int displaySize = SDKUtils.getDisplaySize(context);

    // 整体布局
    RelativeLayout whole_layout = null;

    GradientDrawable click_bg_grad =
        new GradientDrawable(
            Orientation.TOP_BOTTOM,
            new int[] {
              Color.parseColor("#FFD700"), Color.parseColor("#FFB90F"), Color.parseColor("#FFD700")
            });

    // 广告数据布局
    RelativeLayout r_layout = null;
    try {
      whole_layout = new RelativeLayout(context);
      if (itemWidth == 0 || itemHeight == 0) {
        itemWidth = ((Activity) context).getWindowManager().getDefaultDisplay().getWidth();
        // item的默认高度
        if (displaySize == 320) {
          itemHeight = 55;
        } else if (displaySize == 240) {
          itemHeight = 40;
        } else if (displaySize == 720) {
          itemHeight = 120;
        } else if (displaySize == 1080) {
          itemHeight = 180;
        } else {
          itemHeight = 100;
        }
      }
      whole_layout.setLayoutParams(new ListView.LayoutParams(itemWidth, itemHeight));

      r_layout = new RelativeLayout(context);

      int item_whole_bg_id =
          context.getResources().getIdentifier("item_bg", "drawable", context.getPackageName());

      if (item_whole_bg_id != 0) {
        r_layout.setLayoutParams(
            new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        r_layout.setBackgroundResource(item_whole_bg_id);
      }
      //			r_layout.setPadding(0, 0, 0, 0);

      // 图标
      ImageView app_icon = new ImageView(context);
      app_icon.setId(1);
      app_icon.setScaleType(ImageView.ScaleType.FIT_CENTER);

      app_icon.setImageDrawable(new BitmapDrawable(adInfo.getAdIcon()));
      app_icon.setPadding(5, 5, 5, 5);

      RelativeLayout.LayoutParams icon_img_params = null;
      if (displaySize == 320) {
        app_icon.setPadding(4, 4, 4, 4);
        icon_img_params = new RelativeLayout.LayoutParams(50, 50);
      } else if (displaySize == 240) {
        app_icon.setPadding(2, 2, 2, 2);
        icon_img_params = new RelativeLayout.LayoutParams(36, 36);
      } else if (displaySize == 720) {
        app_icon.setPadding(8, 8, 8, 8);
        icon_img_params = new RelativeLayout.LayoutParams(100, 100);
      } else if (displaySize == 1080) {
        app_icon.setPadding(10, 10, 10, 10);
        icon_img_params = new RelativeLayout.LayoutParams(140, 140);
      } else {
        app_icon.setPadding(5, 5, 5, 5);
        icon_img_params = new RelativeLayout.LayoutParams(75, 75);
      }
      icon_img_params.addRule(RelativeLayout.CENTER_VERTICAL);
      icon_img_params.leftMargin = 5;

      // 加载所有文字内容的整体布局
      LinearLayout layout = new LinearLayout(context);
      layout.setLayoutParams(
          new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
      layout.setOrientation(LinearLayout.VERTICAL);

      int item_text_bg_id =
          context
              .getResources()
              .getIdentifier("item_text_bg", "drawable", context.getPackageName());
      if (item_text_bg_id != 0) {
        //				layout.setBackgroundResource(item_text_bg_id);
      }
      layout.setId(2);

      // 加载广告名称和广告大小的布局
      RelativeLayout title_size_layout = new RelativeLayout(context);

      // 广告名称
      TextView app_name = new TextView(context);
      app_name.setId(2);
      app_name.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

      app_name.setText(adInfo.getAdName());
      app_name.setTextSize(18);
      app_name.setTextColor(Color.BLACK);
      app_name.setPadding(10, 0, 0, 0);

      // 广告大小
      TextView app_size = new TextView(context);
      app_size.setText(adInfo.getFilesize() + "M");
      app_size.setTextSize(12);
      app_size.setTextColor(Color.GRAY);
      app_size.setPadding(5, 0, 5, 0);

      RelativeLayout.LayoutParams params4 =
          new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      params4.addRule(RelativeLayout.ALIGN_TOP, app_name.getId());
      params4.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

      title_size_layout.addView(app_name);
      title_size_layout.addView(app_size, params4);

      // 广告语
      TextView content = new TextView(context);
      content.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      content.setText(adInfo.getAdText());
      content.setPadding(10, 0, 0, 0);
      content.setTextColor(Color.GRAY);

      layout.addView(title_size_layout);
      layout.addView(content);

      // 下载按钮
      LinearLayout down_layout = new LinearLayout(context);
      down_layout.setOrientation(LinearLayout.HORIZONTAL);
      down_layout.setGravity(Gravity.CENTER);
      down_layout.setId(3);

      // 直接加载下载图标的布局
      RelativeLayout down_img_layout = new RelativeLayout(context);
      int down_layout_width = 75;
      if (displaySize == 320) {
        down_layout_width = 45;
      } else if (displaySize == 240) {
        down_layout_width = 30;
      } else if (displaySize == 720) {
        down_layout_width = 100;
      } else if (displaySize == 1080) {
        down_layout_width = 150;
      }
      down_img_layout.setLayoutParams(
          new LinearLayout.LayoutParams(down_layout_width, LayoutParams.FILL_PARENT));

      ImageView downImage = new ImageView(context);
      int down_bg_id =
          context.getResources().getIdentifier("down_ico", "drawable", context.getPackageName());

      if (down_bg_id != 0) {
        downImage.setImageResource(down_bg_id);
      }

      // 下载按钮的点击半透明遮罩效果布局
      final LinearLayout d_layout = new LinearLayout(context);
      d_layout.setLayoutParams(
          new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
      //			d_layout.setBackgroundColor(Color.argb(80, 0, 0, 0));
      //			d_layout.setBackgroundColor(Color.parseColor("#AAFFD700"));
      d_layout.setBackgroundDrawable(click_bg_grad);
      d_layout.setVisibility(View.INVISIBLE);

      RelativeLayout.LayoutParams down_img_params =
          new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      down_img_params.addRule(RelativeLayout.CENTER_IN_PARENT);

      down_img_layout.addView(d_layout);
      down_img_layout.addView(downImage, down_img_params);

      // 竖直分隔线
      int line_size = 4;
      if (displaySize == 240) {
        line_size = 2;
      }
      LinearLayout line_layout_2 = new LinearLayout(context);
      line_layout_2.setLayoutParams(
          new LinearLayout.LayoutParams(line_size, LayoutParams.FILL_PARENT));

      // 颜色渐变
      GradientDrawable grad =
          new GradientDrawable(
              Orientation.LEFT_RIGHT,
              new int[] {
                Color.parseColor("#cccccc"),
                Color.parseColor("#ffffff"),
                Color.parseColor("#cccccc")
              });
      line_layout_2.setBackgroundDrawable(grad);

      down_layout.addView(line_layout_2);
      down_layout.addView(down_img_layout);

      down_img_layout.setOnTouchListener(
          new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
              switch (event.getAction()) {
                  // 点击时,ListView的item产生被点击效果(半透明遮罩)
                case MotionEvent.ACTION_DOWN:
                  d_layout.setVisibility(View.VISIBLE);
                  break;
                  // 离开点击区域,ListView的item点击效果消失
                case MotionEvent.ACTION_CANCEL:
                  d_layout.setVisibility(View.INVISIBLE);
                  break;
                  // 点击后抬起时,ListView的item点击效果消失
                case MotionEvent.ACTION_UP:
                  d_layout.setVisibility(View.INVISIBLE);
                  break;
              }
              return false;
            }
          });

      down_img_layout.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              AppConnect.getInstance(context).downloadAd(context, adInfo.getAdId());
            }
          });

      RelativeLayout.LayoutParams params2 =
          new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
      params2.addRule(RelativeLayout.RIGHT_OF, app_icon.getId());
      params2.addRule(RelativeLayout.LEFT_OF, down_layout.getId());
      params2.addRule(RelativeLayout.CENTER_VERTICAL);

      RelativeLayout.LayoutParams params3 =
          new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
      //			params3.addRule(RelativeLayout.RIGHT_OF, layout.getId());
      params3.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

      //			int width = ((Activity)context).getWindowManager().getDefaultDisplay().getWidth()-83;
      // 点击效果的半透明遮罩布局
      final LinearLayout l_layout = new LinearLayout(context);
      l_layout.setLayoutParams(
          new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
      //			l_layout.setBackgroundColor(Color.argb(80, 0, 0, 0));//黑色
      //			l_layout.setBackgroundColor(Color.argb(80, 30, 144, 255));//淡蓝色
      //			l_layout.setBackgroundColor(Color.parseColor("#AAFFD700"));
      l_layout.setBackgroundDrawable(click_bg_grad);
      l_layout.setVisibility(View.INVISIBLE);

      r_layout.addView(l_layout);
      r_layout.addView(app_icon, icon_img_params);
      r_layout.addView(down_layout, params3);
      r_layout.addView(layout, params2);

      whole_layout.addView(r_layout);

      r_layout.setOnTouchListener(
          new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
              switch (event.getAction()) {
                  // 点击时,ListView的item产生被点击效果(半透明遮罩)
                case MotionEvent.ACTION_DOWN:
                  l_layout.setVisibility(View.VISIBLE);
                  break;
                  // 离开点击区域,ListView的item点击效果消失
                case MotionEvent.ACTION_CANCEL:
                  l_layout.setVisibility(View.INVISIBLE);
                  break;
                  // 点击后抬起时,ListView的item点击效果消失
                case MotionEvent.ACTION_UP:
                  l_layout.setVisibility(View.INVISIBLE);
                  break;
              }
              return false;
            }
          });

      r_layout.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              AppDetail.getInstanct().showAdDetail(context, adInfo);
            }
          });

    } catch (Exception e) {
      e.printStackTrace();
    }
    return whole_layout;
  }
Пример #25
0
 public XRelativeLayout(Context context) {
   super(context);
   super.setOnTouchListener(mOnTouchListener);
 }
Пример #26
0
 public void setOnTouchListener(OnTouchListener listener) {
   mUserInfoRl.setOnTouchListener(listener);
   mSettingRl.setOnTouchListener(listener);
   mLogoutRl.setOnTouchListener(listener);
 }
Пример #27
0
 @Override
 public void setOnTouchListener(OnTouchListener listener) {
   videoViewImpl.setOnTouchListener(listener);
   super.setOnTouchListener(listener);
 }
Пример #28
0
 public XRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
   super(context, attrs, defStyle);
   super.setOnTouchListener(mOnTouchListener);
 }
Пример #29
0
  private void setListener() {
    xListView.setXListViewListener(
        new IXListViewListener() {

          @Override
          public void onRefresh() {
            // TODO Auto-generated method stub
            if (rl_message_commment.isSelected()) {
              if (Utils.isNetworkConnected(context)) {
                comments_page = 1;
                xListView.setPullLoadEnable(true);
                HashMap<String, Object> taskParams = new HashMap<String, Object>();
                taskParams.put("instance", context.toString());
                Task task = new Task(TaskID.WEIBO_COMMENT_TIMELINE, taskParams);
                MainService.addTask(task);
              } else {
                Utils.showNetWorkErrorToast(context);
                xListView.stopRefresh();
              }
            } else {
              if (Utils.isNetworkConnected(context)) {
                statuses_page = 1;
                xListView.setPullLoadEnable(true);
                HashMap<String, Object> taskParams = new HashMap<String, Object>();
                taskParams.put("instance", context.toString());
                Task task = new Task(TaskID.WEIBO_MENTION_TIMELINE, taskParams);
                MainService.addTask(task);
              } else {
                Utils.showNetWorkErrorToast(context);
                xListView.stopRefresh();
              }
            }
          }

          @Override
          public void onLoadMore() {
            // TODO Auto-generated method stub
            if (rl_message_commment.isSelected()) {
              if (Utils.isNetworkConnected(context)) {
                HashMap<String, Object> taskParams = new HashMap<String, Object>();
                taskParams.put("instance", context.toString());
                Task task = new Task(TaskID.WEIBO_COMMENT_TIMELINE_MORE, taskParams);
                MainService.addTask(task);
              } else {
                Utils.showNetWorkErrorToast(context);
                xListView.stopLoadMore();
              }
            } else {
              if (Utils.isNetworkConnected(context)) {
                HashMap<String, Object> taskParams = new HashMap<String, Object>();
                taskParams.put("instance", context.toString());
                Task task = new Task(TaskID.WEIBO_MENTION_TIMELINE_MORE, taskParams);
                MainService.addTask(task);
              } else {
                Utils.showNetWorkErrorToast(context);
                xListView.stopLoadMore();
              }
            }
          }
        });

    rl_message_commment.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            txt_message_comment_tab.setTextColor(0xffdd3737);
            txt_message_mention_tab.setTextColor(0xff838181);
            rl_message_commment.setSelected(true);
            rl_message_statuse.setSelected(false);
            initData();
          }
        });

    rl_message_statuse.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            txt_message_mention_tab.setTextColor(0xffdd3737);
            txt_message_comment_tab.setTextColor(0xff838181);
            rl_message_statuse.setSelected(true);
            rl_message_commment.setSelected(false);
            initData();
          }
        });

    rl_back.setOnTouchListener(context);
  }