Exemple #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_item_info);

    mainLayout = (RelativeLayout) findViewById(R.id.infoRelativeLayout);

    nameView = (EditText) findViewById(R.id.infoItemName);
    dayView = (EditText) findViewById(R.id.infoDay);
    monthView = (EditText) findViewById(R.id.infoMonth);
    yearView = (EditText) findViewById(R.id.infoYear);
    quantityView = (EditText) findViewById(R.id.infoQuantityEdit);
    commentsView = (EditText) findViewById(R.id.infoComment);

    completionBar = (SeekBar) findViewById(R.id.infoCompletionEdit);

    completionUpdate = (TextView) findViewById(R.id.infoCompletionDisplay);

    if (quantity == 1) {
      mainLayout.removeView(completionBar);
      mainLayout.removeView(completionUpdate);
    } else {
      completionBar.setMax(quantity);
      completionBar.setProgress(completion);
      completionUpdate.setText("" + completion + "/" + quantity);
    }
  }
Exemple #2
0
 private void clearViews(int idx) {
   switch (idx) {
     case CALLTAB:
       layoutViews.removeView(layoutCall);
       break;
     case LOGTAB:
       layoutViews.removeView(layoutLog);
       break;
   }
 }
Exemple #3
0
  private void drawStaticLayout() {

    // Handling from XML
    buttonSound = (ImageView) findViewById(R.id.buttonSound);
    if (!AppSettings.soundIsOn) {
      buttonSound.setImageResource(R.drawable.sound_icon_off);
    } else {
      buttonSound.setImageResource(R.drawable.sound_icon_on);
    }
    buttonRestart = (ImageButton) findViewById(R.id.buttonRestart);

    layout.removeView(buttonSound);
    layout.removeView(buttonRestart);

    layout.addView(buttonSound);
  }
 private void cleanupCameraButton() {
   if (mCameraButton == null) return;
   RelativeLayout galleryRoot =
       (RelativeLayout) ((Activity) mActivity).findViewById(R.id.gallery_root);
   if (galleryRoot == null) return;
   galleryRoot.removeView(mCameraButton);
   mCameraButton = null;
 }
 private void clearActionbarContent() {
   if (!myContentLists.isEmpty()) {
     for (View v : myContentLists) {
       mActionbarContent.removeView(v);
     }
     myContentLists.clear();
   }
 }
 private void attachSubscriberView(Subscriber subscriber) {
   RelativeLayout.LayoutParams layoutParams =
       new RelativeLayout.LayoutParams(
           getResources().getDisplayMetrics().widthPixels,
           getResources().getDisplayMetrics().heightPixels);
   mSubscriberViewContainer.removeView(mSubscriber.getView());
   mSubscriberViewContainer.addView(mSubscriber.getView(), layoutParams);
   subscriber.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
 }
 private void unsubscribeFromStream(Stream stream) {
   mStreams.remove(stream);
   if (mSubscriber.getStream().getStreamId().equals(stream.getStreamId())) {
     mSubscriberViewContainer.removeView(mSubscriber.getView());
     mSubscriber = null;
     if (!mStreams.isEmpty()) {
       subscribeToStream(mStreams.get(0));
     }
   }
 }
  @Override
  protected void onDestroy() {
    if (webView != null) {
      RelativeLayout rootView = (RelativeLayout) findViewById(R.id.rootView);
      rootView.removeView(webView);
      webView.removeAllViews();
      webView.destroy();
    }
    tts.unbindTtsService();

    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    super.onDestroy();
  }
  @Override
  public void onDisconnected(Session session) {
    Log.i(LOGTAG, "Disconnected from the session.");
    if (mPublisher != null) {
      // mPublisherViewContainer.removeView(mPublisher.getView());
    }

    if (mSubscriber != null) {
      mSubscriberViewContainer.removeView(mSubscriber.getView());
    }

    mPublisher = null;
    mSubscriber = null;
    mStreams.clear();
    mSession = null;
  }
 public void stopCamera() {
   if (!flagPreviewInitialized) {
     return;
   }
   if (mCamera != null) {
     mPreview.stopCameraPreview();
     mPreview.setCamera(null, null);
     cameraLayout.removeView(mPreview);
     removeView(cameraLayout);
     cameraLayout = null;
     this.cameraInstanceManager.releaseCamera(mCamera);
   }
   if (mCameraHandlerThread != null) {
     mCameraHandlerThread.quit();
     mCameraHandlerThread = null;
   }
   flagPreviewInitialized = false;
 }
        @Override
        public void handleMessage(Message msg) {

          switch (msg.what) {
            case ADD_SELECT_VIEW:
              if (removed) {
                proj_main_layout.addView(proj_select_view);
                removed = false;
              }
              break;
            case RM_SELECT_VIEW:
              if (!removed) {
                proj_main_layout.removeView(proj_select_view);
                removed = true;
              }
              break;
          }
        }
Exemple #12
0
 // 设置标记
 private void setMarker(RelativeLayout group, int i, int j) {
   int childCount = group.getChildCount();
   if (marksMap.get(dates[i][j]) != null) {
     if (childCount < 2) {
       RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(-2, -2);
       params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
       params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
       params.setMargins(0, 5, 5, 0);
       ImageView markView = new ImageView(getContext());
       markView.setImageResource(marksMap.get(dates[i][j]));
       markView.setLayoutParams(params);
       group.addView(markView);
     }
   } else {
     if (childCount > 1) {
       group.removeView(group.getChildAt(1));
     }
   }
 }
  private void setZoomLayout(SharedPreferences options) {
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);

    int colorMode = Options.getColorMode(options);
    int mode = ZOOM_COLOR_NORMAL;

    if (colorMode == Options.COLOR_MODE_GREEN_ON_BLACK) {
      mode = ZOOM_COLOR_GREEN;
    } else if (colorMode == Options.COLOR_MODE_RED_ON_BLACK) {
      mode = ZOOM_COLOR_RED;
    }

    // the zoom buttons
    if (zoomLayout != null) {
      activityLayout.removeView(zoomLayout);
    }

    zoomLayout = new LinearLayout(this);
    zoomLayout.setOrientation(LinearLayout.HORIZONTAL);
    zoomDownButton = new ImageButton(this);
    zoomDownButton.setImageDrawable(getResources().getDrawable(zoomDownId[mode]));
    zoomDownButton.setBackgroundColor(Color.TRANSPARENT);
    zoomLayout.addView(
        zoomDownButton,
        (int) (80 * metrics.density),
        (int) (50 * metrics.density)); // TODO: remove hardcoded values
    zoomWidthButton = new ImageButton(this);
    zoomWidthButton.setImageDrawable(getResources().getDrawable(zoomWidthId[mode]));
    zoomWidthButton.setBackgroundColor(Color.TRANSPARENT);
    zoomLayout.addView(zoomWidthButton, (int) (58 * metrics.density), (int) (50 * metrics.density));
    zoomUpButton = new ImageButton(this);
    zoomUpButton.setImageDrawable(getResources().getDrawable(zoomUpId[mode]));
    zoomUpButton.setBackgroundColor(Color.TRANSPARENT);
    zoomLayout.addView(zoomUpButton, (int) (80 * metrics.density), (int) (50 * metrics.density));
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.CENTER_HORIZONTAL);
    lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    setZoomButtonHandlers();
    activityLayout.addView(zoomLayout, lp);
  }
  /**
   * @brief getDrawer method
   * @param v
   * @detail This method is called when the options button is clicked to inflate the drawer layout
   *     which contains buttons for resetView,snapShot and rateUs
   */
  public void getDrawer(View v) {
    final Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(vibr);

    if (check) {

      myLayout.removeAllViewsInLayout();
      myLayout.removeView(hiddenInfo);
      home.setVisibility(0);
      text.setVisibility(0);
      check = false;

    } else {
      home.setVisibility(4);
      text.setVisibility(4);
      myLayout.addView(hiddenInfo);

      check = true;
    }
  }
  //
  // And one more utility function to close the lists if they are expanded
  // (for tablet case where detail view is not being destroyed/recreated)
  //  pass in the layout, startID and length.
  //
  private void CloseList(RelativeLayout layout, int startID, int listLength) {

    // is there valid data?
    if (listLength == 0) return;

    // does the start ID exist already?
    if (layout.findViewById(startID) != null) {
      // close it on up
      for (int i = 0; i < listLength; i++) {
        layout.removeView(layout.findViewById(startID + i));
      }

      // and now fix up the reviews/trailers layouts (put reviews right after trailers)
      TextView reviewsView = (TextView) layout.findViewById(R.id.detail_reviews);
      RelativeLayout.LayoutParams params =
          (RelativeLayout.LayoutParams) reviewsView.getLayoutParams();
      params.addRule(RelativeLayout.BELOW, R.id.detail_trailers);
      reviewsView.setLayoutParams(params);
    }
  }
Exemple #16
0
 void setKeyboardVisibility(Configuration c) {
   boolean landscape = (c.orientation == Configuration.ORIENTATION_LANDSCAPE);
   if (landscape != prevLandscape || keyboard == null) {
     // Must recreate KeyboardView on orientation change because it
     // caches the x,y for its preview popups
     // http://code.google.com/p/android/issues/detail?id=4559
     if (keyboard != null) mainLayout.removeView(keyboard);
     keyboard = new SmallKeyboard(this, undoEnabled, redoEnabled);
     keyboard.setId(R.id.keyboard);
     RelativeLayout.LayoutParams lp =
         new RelativeLayout.LayoutParams(
             RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
     RelativeLayout.LayoutParams glp =
         new RelativeLayout.LayoutParams(
             RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
     if (landscape) {
       lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
       lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
       lp.addRule(RelativeLayout.ABOVE, R.id.statusBar);
       glp.addRule(RelativeLayout.ABOVE, R.id.statusBar);
       glp.addRule(RelativeLayout.LEFT_OF, R.id.keyboard);
     } else {
       lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
       lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
       lp.addRule(RelativeLayout.ABOVE, R.id.statusBar);
       glp.addRule(RelativeLayout.ABOVE, R.id.keyboard);
     }
     mainLayout.updateViewLayout(gameView, glp);
     mainLayout.addView(keyboard, lp);
   }
   keyboard.setKeys(
       (c.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO)
           ? (maybeUndoRedo + maybeMenu)
           : lastKeys,
       lastArrowMode);
   prevLandscape = landscape;
   mainLayout.requestLayout();
 }
        @Override
        public boolean onTouch(View v, MotionEvent event) {
          ImageView victim1 = (ImageView) findViewById(R.id.imgVictim1);
          if (event.getAction() == MotionEvent.ACTION_DOWN) {
            victim1.setAlpha(0f);

            Random rand = new Random();
            TextView msg = new TextView(HomeActivity.this);

            msg.setText(R.string.txt_lifted);
            msg.setTextSize(25);
            msg.setTypeface(Typeface.DEFAULT_BOLD);
            msg.setX(rand.nextInt(layout.getWidth() - (layout.getWidth() / 100 * 20)));
            msg.setY(rand.nextInt(layout.getHeight() - (layout.getHeight() / 100 * 10)));
            msg.setRotation(rand.nextInt(90) - 45);

            textViewList.add(msg);
            layout.addView(msg);

            if (textViewList.size() > 10) {
              layout.removeView(textViewList.get(0));
              textViewList.remove(textViewList.get(0));
            }

            int idNextPlayed = soundIdList.get(rand.nextInt(soundIdList.size() - 1));
            while (idLastPlayed == idNextPlayed) {
              idNextPlayed = soundIdList.get(rand.nextInt(soundIdList.size() - 1));
            }
            soundPool.play(idNextPlayed, 1, 1, 1, 0, 1);
            idLastPlayed = idNextPlayed;
          }
          if (event.getAction() == MotionEvent.ACTION_UP) {
            victim1.setAlpha(1f);
          }
          return true;
        }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);
    switch (item.getItemId()) {
      case R.id.help_view:
        final Dialog dialog = new Dialog(ClientActivity.this);
        dialog.setContentView(R.layout.dialog);
        dialog.setTitle("Instructions");
        dialog.setCancelable(true);
        TextView tv = (TextView) dialog.findViewById(R.id.TextView01);
        String a =
            "1. One person to select 'Start Session' option on the menu<br />"
                + "2. Rest to select 'Join Session' <br />"
                + "3. Start drawing<br />"
                + "4. Use Menu button to access 'Save', 'Reset Canvas', 'Cursor'"
                + "and 'Logout' options<br />"
                + "<p >"
                + "NOTE: <br />"
                + "* Back button on phone disabled. Logout from menu to exit app</p> ";
        Spanned txt = Html.fromHtml(a);
        tv.setText(txt);
        Button button = (Button) dialog.findViewById(R.id.Button01);
        button.setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                // TODO Auto-generated method stub

                dialog.cancel();
                // finish();

              }
            });
        dialog.show();
        break;
      case R.id.save_item:
        rl.setDrawingCacheEnabled(true);
        // d.setDrawingCacheEnabled(true);
        Bitmap b = rl.getDrawingCache();
        try {
          if (!APP_FILE_PATH.exists()) {
            if (APP_FILE_PATH.mkdirs()) Log.d("DIR Created AT", String.valueOf(APP_FILE_PATH));
            else Log.d("DIR NOT Created AT", String.valueOf(APP_FILE_PATH));
          }
          final DateFormat formatter = new SimpleDateFormat("hh-mm-ss-SSS");
          String str =
              "/sdcard/CrowdInput/image_"
                  + formatter.format(Calendar.getInstance().getTime())
                  + ".jpg";
          b.compress(CompressFormat.JPEG, 95, new FileOutputStream(str));
          // b.compress(CompressFormat.JPEG, 95, new
          // FileOutputStream("/sdcard/CrowdInput/client"+fileno+".jpg"));
          handler.post(
              new Runnable() {
                @Override
                public void run() {

                  //                  	 //serverStatus.setText("Listening on IP: " + SERVERIP);
                  //           DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy
                  // hh:mm:ss.SSS");
                  Toast.makeText(
                          ClientActivity.this,
                          "Image saved in file : "
                              + "/sdcard/CrowdInput/image_"
                              + formatter.format(Calendar.getInstance().getTime())
                              + ".jpg",
                          Toast.LENGTH_LONG)
                      .show();
                  fileno++;
                }
              });

        } catch (FileNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        /*
        try {
        		b.compress(CompressFormat.JPEG, 95, new FileOutputStream("/sdcard/CrowdInput/client.jpg"));
        	} catch (FileNotFoundException e) {
        		// TODO Auto-generated catch block
        		e.printStackTrace();
        	}*/
        break;
      case R.id.erase_view:
        resetflag = 1;
        handler.post(
            new Runnable() {
              @Override
              public void run() {

                //               	 //serverStatus.setText("Listening on IP: " + SERVERIP);
                Toast.makeText(ClientActivity.this, "Canvas Reset", Toast.LENGTH_SHORT).show();
              }
            });
        // for(int i=0;i<_graphics.size();i++)
        //    _graphics.remove(i);
        //    path = new SPath();
        //    d.invalidate();
        /*Iterator it = _graphics.iterator();
        while(it.hasNext())
        	it.remove();*/

        for (Path p : _graphics) p.rewind();
        _graphics.clear();
        d.postInvalidate();

        // resetflag=0;
        break;
        /*
        for(int i=0;i<_graphics.size();i++)
               _graphics.remove(i);
        	//path.reset();
               path = new SPath();
               d.invalidate();
               break;*/
      case R.id.cursor:
        if (cursor_id % 2 == 0) {
          handler.post(
              new Runnable() {
                @Override
                public void run() {

                  //                   	 //serverStatus.setText("Listening on IP: " + SERVERIP);
                  Toast.makeText(ClientActivity.this, "Showing Cursor", Toast.LENGTH_SHORT).show();
                }
              });
          // create a new tranparent view for Cursor
          cv = new CursorView(this, getLocalIpAddress());
          Log.d("CURSOR", "working");
          cv.setBackgroundColor(Color.TRANSPARENT);
          rl.addView(cv);
        } else {
          handler.post(
              new Runnable() {
                @Override
                public void run() {

                  //                   	 //serverStatus.setText("Listening on IP: " + SERVERIP);
                  Toast.makeText(ClientActivity.this, "Exiting Cursor Mode", Toast.LENGTH_LONG)
                      .show();
                }
              });

          cv.deletefromIPlist();
          rl.removeView(cv);
        }
        cursor_id++;
        break;
      case R.id.exit:
        // android.os.Process.killProcess(android.os.Process.myPid());
        System.exit(1);
        break;
    }
    return true;
  }
 @Override
 public void onFloatPlayerPop() {
   // TODO Auto-generated method stub
   videoLayout.removeView(mMoboVideoView);
 }
  //
  //  Utility function to expand or contract a reviews or trailers list.
  //  Takes in the source view (one of the two textviews)
  //  Also takes in a insertListBelowThisID (expand below this) and an insertListAboveThisID (expand
  // above this ID)
  //  Takes in a startID (use this ID to start for created views)
  //  Takes in a drawable which is prepended to text (if it is not 0). Also note a non-zero drawable
  //     indicates a play function and thus is clickable. Thus we will set this text blue (to
  // indicate it is clickable)
  //  And a flag to keep text single line (ellipsize) or not.
  //  And data - this contains the text to show - note it must be valid even when removing views
  //  This routine is *not* generic and is meant to be used for the very specific purpose
  //  of only the trailers/review layout.
  //
  private void ToggleList(
      View v,
      int insertListBelowThisID,
      int insertListAboveThisID,
      int startID,
      int drawableID,
      Boolean bSingleLine,
      ArrayList<String> data) {

    // Get the detail fragment view (one up from view passed in)...
    ViewParent parent = v.getParent();
    RelativeLayout detailLayout = (RelativeLayout) parent;

    // does the start ID exist already?
    if (detailLayout.findViewById(startID) != null) {
      // list is already expanded
      // remove all the textviews
      for (int i = 0; i < data.size(); i++) {
        detailLayout.removeView(detailLayout.findViewById(startID + i));
      }

      // does a view below exist?
      if (insertListAboveThisID != 0) {
        // now shift up the view below...
        // find the bottow reference view first
        TextView viewbottom =
            (TextView)
                detailLayout.findViewById(
                    insertListAboveThisID); // find the view to move (the bottom one)
        RelativeLayout.LayoutParams params =
            (RelativeLayout.LayoutParams) viewbottom.getLayoutParams(); // get its params
        params.addRule(
            RelativeLayout.BELOW, insertListBelowThisID); // reset params to follow the view above
        viewbottom.setLayoutParams(params); // and set it
      }
      // all done removing a view
    } else {
      // expand all the views
      for (int i = 0; i < data.size(); i++) {
        TextView newtext = new TextView(this); // create the textview
        newtext.setText(
            Html.fromHtml(data.get(i))); // set the text from data array - process html tags
        newtext.setId(startID + i); // set the ID (so we can process clicks and destroy it)
        newtext.setClickable(true); // make it clickable (reviews we will ignore click)
        // and listen for a click
        newtext.setOnClickListener(trailers_listener); // and put on a listener
        if (drawableID != 0) {
          newtext.setCompoundDrawablesWithIntrinsicBounds(drawableID, 0, 0, 0);
          // and set color blue
          newtext.setTextColor(Color.BLUE);
        }

        // create a layout params file for this new textview
        RelativeLayout.LayoutParams params =
            new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        params.setMargins(TEXT_MARGIN, TEXT_MARGIN, TEXT_MARGIN, TEXT_MARGIN); // set margins.
        params.setMarginStart(START_BUTTON_TEXT_MARGIN); // extra start.
        newtext.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14F); // set the size

        // is this single line?
        if (bSingleLine == true) {
          newtext.setEllipsize(TextUtils.TruncateAt.END);
        }

        // if this is the first of the new views, set it to be below the top view
        // (insertListBelowThisID)
        if (i == 0) {
          params.addRule(RelativeLayout.BELOW, insertListBelowThisID);
        } else {
          // set the view to follow the last one
          params.addRule(RelativeLayout.BELOW, startID + i - 1);
        }

        // and add the view!
        detailLayout.addView(newtext, params);

        // fix up reviews
        // is there a view below which needs to be shifted?
        if (insertListAboveThisID != 0) {
          // get the view
          TextView viewbottom = (TextView) detailLayout.findViewById(insertListAboveThisID);
          RelativeLayout.LayoutParams bottomparams =
              (RelativeLayout.LayoutParams) viewbottom.getLayoutParams();
          // set it to be below the last of the expanded list
          bottomparams.addRule(RelativeLayout.BELOW, startID + data.size() - 1);
          // and update the params
          viewbottom.setLayoutParams(bottomparams);
        }
      }
    }
  }
Exemple #21
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_chat);

    Intent intent = getIntent();
    dialog = (QBDialog) intent.getSerializableExtra(EXTRA_DIALOG);

    messagesContainer = (ListView) findViewById(R.id.messagesContainer);
    messageEditText = (EditText) findViewById(R.id.messageEdit);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    companionLabel = (TextView) findViewById(R.id.companionLabel);

    container = (RelativeLayout) findViewById(R.id.container);
    if (dialog.getType() == QBDialogType.GROUP) {
      TextView meLabel = (TextView) findViewById(R.id.meLabel);
      container.removeView(meLabel);
      container.removeView(companionLabel);
    } else if (dialog.getType() == QBDialogType.PRIVATE) {
      Integer opponentID = ChatService.getInstance().getOpponentIDForPrivateDialog(dialog);
      companionLabel.setText(
          ChatService.getInstance().getDialogsUsers().get(opponentID).getLogin());
    }

    sendButton = (Button) findViewById(R.id.chatSendButton);
    sendButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            String messageText = messageEditText.getText().toString();
            if (!TextUtils.isEmpty(messageText)) {
              sendChatMessage(messageText);
            }
          }
        });

    keyboardHandleLayout = (KeyboardHandleRelativeLayout) findViewById(R.id.sizeNotifierLayout);
    keyboardHandleLayout.listener = this;
    stickersFrame = findViewById(R.id.frame);
    stickerButton = (ImageView) findViewById(R.id.stickers_button);

    stickerButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (isStickersFrameVisible) {
              showKeyboard();
              stickerButton.setImageResource(R.drawable.ic_action_insert_emoticon);
            } else {
              if (keyboardHandleLayout.isKeyboardVisible()) {
                keyboardHandleLayout.hideKeyboard(
                    ChatActivity.this,
                    new KeyboardHandleRelativeLayout.OnKeyboardHideCallback() {
                      @Override
                      public void onKeyboardHide() {
                        stickerButton.setImageResource(R.drawable.ic_action_keyboard);
                        setStickersFrameVisible(true);
                      }
                    });
              } else {
                stickerButton.setImageResource(R.drawable.ic_action_keyboard);
                setStickersFrameVisible(true);
              }
            }
          }
        });
    updateStickersFrameParams();
    stickersFragment = (StickersFragment) getSupportFragmentManager().findFragmentById(R.id.frame);
    if (stickersFragment == null) {
      stickersFragment =
          new StickersFragment.Builder()
              .setStickerPlaceholderColorFilterRes(android.R.color.darker_gray)
              .build();
      getSupportFragmentManager().beginTransaction().replace(R.id.frame, stickersFragment).commit();
    }
    stickersFragment.setOnStickerSelectedListener(stickerSelectedListener);
    stickersFragment.setOnEmojiBackspaceClickListener(
        new OnEmojiBackspaceClickListener() {
          @Override
          public void onEmojiBackspaceClicked() {
            KeyEvent event =
                new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL);
            messageEditText.dispatchKeyEvent(event);
          }
        });
    setStickersFrameVisible(isStickersFrameVisible);

    if (isSessionActive()) {
      initChat();
    }

    ChatService.getInstance().addConnectionListener(chatConnectionListener);
  }
 public void deleteMarker(RelativeLayout cell) {
   if (cell.getChildCount() > 1) {
     cell.removeView(cell.getChildAt(1));
   }
 }
 @Override
 public void onDestroyView() {
   adViewRectangleContainer.removeView(adViewRectangle);
   super.onDestroyView();
 }
  // *************************      Initialize Question       *********************************
  private void initQuestion() {
    Log.i("fullCClassName", className);
    if (numberOfQuestionsRemaining < 1) {
      Intent intent = new Intent(NegativeCoordActivity.this, ResultActivity.class);
      intent.putExtra("Score", scoreTotal);
      intent.putExtra("ClassName", className);
      intent.putExtra("Level", 3);
      startActivity(intent);
      finish();
    } else {

      if (firstQuestion == false) {
        numberOfQuestionsRemaining--;

        Random randScore = new Random();
        int low = 0;
        int high = 0;
        if (seconds <= 5) {
          low = 40;
          high = 50;
        }
        if (seconds > 5 && seconds <= 7) {
          low = 30;
          high = 40;
        }
        if (seconds > 7) {
          low = 10;
          high = 30;
        }
        score = randScore.nextInt(high - low + 1) + low;
        scoreTotal = scoreTotal + score;
        scoreText.setText(Integer.toString(score));
        scoreText.startAnimation(scoreTextAnimmation);
        timerHandler.removeCallbacks(timerRunnable);
      }
      firstQuestion = false;
      seconds = 0;
      timerHandler.postDelayed(timerRunnable, 0);

      ProgressBarAnimation anim =
          new ProgressBarAnimation(scoreBar, scoreBar.getProgress(), scoreTotal);
      anim.setDuration(300);
      scoreBar.startAnimation(anim);

      if (STAR_ONE_ENABLED == 0) {
        if (scoreBar.getProgress() >= (scoreBar.getMax() / 2)) {
          StarView star1 =
              new StarView(
                  this,
                  scoreLayout,
                  new RelativeLayout.LayoutParams(starOne.getWidth(), starOne.getHeight()),
                  starOne);
          scoreLayout.addView(star1);
          star1.translateAndShine(new ImageView(this));
          STAR_ONE_ENABLED = 1;
        }
      }
      if (STAR_TWO_ENABLED == 0) {
        if (scoreBar.getProgress() >= ((scoreBar.getMax() * 1.7) - scoreBar.getMax())) {
          StarView star2 =
              new StarView(
                  this,
                  scoreLayout,
                  new RelativeLayout.LayoutParams(starTwo.getWidth(), starTwo.getHeight()),
                  starTwo);
          scoreLayout.addView(star2);
          star2.translateAndShine(new ImageView(this));
          STAR_TWO_ENABLED = 1;
        }
      }
      if (STAR_THREE_ENABLED == 0) {
        if (scoreBar.getProgress() >= ((scoreBar.getMax() * 1.8) - scoreBar.getMax())) {
          StarView star3 =
              new StarView(
                  this,
                  scoreLayout,
                  new RelativeLayout.LayoutParams(starThree.getWidth(), starThree.getHeight()),
                  starThree);
          scoreLayout.addView(star3);
          star3.translateAndShine(new ImageView(this));
          STAR_THREE_ENABLED = 1;
        }
      }
      // *****  Type of Question  *****

      // Init question
      Random random = new Random();
      int randomCoordX = random.nextInt(8) - 4;
      int randomCoordY = random.nextInt(8) - 4;
      question = new QuestionCoord(randomCoordX, randomCoordY);

      // Move Lines
      if (numberOfQuestionsRemaining > (numberOfQuestions / 2)) {
        marker.setVisibility(View.INVISIBLE);

        // Positive
        questionCoordX.setText(question.getxString());
        questionCoordY.setText(question.getyString());

        currentLineXcoord = 0;
        currentLineYcoord = 0;
        setLinePositions(glv);

        coordNumbersX.setText("x");
        coordNumbersY.setText("y");

      }
      // Drag Number Panels Positive
      else {
        if (numberOfQuestionsRemaining == (numberOfQuestions / 2)) {
          gridLayout.removeView(lineX);
          gridLayout.removeView(lineY);

          questionCoordX.setText("x");
          questionCoordY.setText("y");

          initNumberPadAndAnswePanel();
          initSwitches();
        }

        marker.setVisibility(View.INVISIBLE);

        // Match x&y to question x&y
        AxisX x = null;
        AxisY y = null;
        for (int i = 0; i < glv.getAxisXlines().size(); i++) {
          if (glv.getAxisXlines().get(i).xNumber == question.getXNumber()) {
            x = glv.getAxisXlines().get(i);
          }
          if (glv.getAxisYlines().get(i).yNumber == question.getYNumber()) {
            y = glv.getAxisYlines().get(i);
          }
        }
        marker.setX(((int) x.x) - marker.getWidth() / 2);
        marker.setY(((int) y.y) - marker.getHeight() / 2);
        scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f);
        scaleIn.setDuration(300);
        scaleIn.setStartOffset(200);
        scaleIn.setInterpolator(new OvershootInterpolator());
        scaleIn.setFillAfter(true);
        scaleIn.setAnimationListener(
            new AnimationListener() {
              @Override
              public void onAnimationEnd(Animation arg0) {}

              @Override
              public void onAnimationRepeat(Animation animation) {}

              @Override
              public void onAnimationStart(Animation animation) {
                marker.setVisibility(View.VISIBLE);
              }
            });
        marker.startAnimation(scaleIn);

        coordNumbersX.setText("x");
        coordNumbersY.setText("y");
      }
    }
  }