void setMode(int mode) {
    if (mMode == mode) {
      return;
    }
    View slideshowPanel = findViewById(R.id.slideShowContainer);
    View normalPanel = findViewById(R.id.abs);

    Window win = getWindow();
    mMode = mode;
    if (mode == MODE_SLIDESHOW) {
      slideshowPanel.setVisibility(View.VISIBLE);
      normalPanel.setVisibility(View.GONE);

      win.addFlags(
          WindowManager.LayoutParams.FLAG_FULLSCREEN
              | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

      mImageView.clear();
      mActionIconPanel.setVisibility(View.GONE);

      slideshowPanel.getRootView().requestLayout();

      // The preferences we want to read:
      //   mUseShuffleOrder
      //   mSlideShowLoop
      //   mAnimationIndex
      //   mSlideShowInterval

      mUseShuffleOrder = mPrefs.getBoolean(PREF_SHUFFLE_SLIDESHOW, false);
      mSlideShowLoop = mPrefs.getBoolean(PREF_SLIDESHOW_REPEAT, false);
      mAnimationIndex = getPreferencesInteger(mPrefs, "pref_gallery_slideshow_transition_key", 0);
      mSlideShowInterval =
          getPreferencesInteger(mPrefs, "pref_gallery_slideshow_interval_key", 3) * 1000;
    } else {
      slideshowPanel.setVisibility(View.GONE);
      normalPanel.setVisibility(View.VISIBLE);

      win.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
      if (mFullScreenInNormalMode) {
        win.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
      } else {
        win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
      }

      if (mGetter != null) {
        mGetter.cancelCurrent();
      }

      if (mShowActionIcons) {
        Animation animation = new AlphaAnimation(0F, 1F);
        animation.setDuration(500);
        mActionIconPanel.setAnimation(animation);
        mActionIconPanel.setVisibility(View.VISIBLE);
      }

      ImageViewTouchBase dst = mImageView;
      for (ImageViewTouchBase ivt : mSlideShowImageViews) {
        ivt.clear();
      }

      mShuffleOrder = null;

      // mGetter null is a proxy for being paused
      if (mGetter != null) {
        setImage(mCurrentPosition, true);
      }
    }
  }
 private void getScreenBitmap() {
   mView.getRootView().destroyDrawingCache();
   mView.getGlobalVisibleRect(mRect, point);
   realheight = mView.getHeight();
   realwidth = mView.getWidth();
   dst.set(0, 0, realwidth, realheight);
   int w = Math.round(realwidth * BITMAP_RATIO);
   int h = Math.round(realheight * BITMAP_RATIO);
   w = w & ~0x03;
   h = h & ~0x03;
   if (w <= 0 || h <= 0) return;
   if (bitmap == null || bitmap.getWidth() != w || bitmap.getHeight() != h) {
     bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
     mMatrix.setScale(BITMAP_RATIO, BITMAP_RATIO);
     mMatrix.invert(mDrawMatrix);
     src.set(0, 0, w, h);
   }
   float dx = -(Math.min(0, mView.getLeft()) + mRect.left);
   float dy = (-point.y);
   mCanvas.restoreToCount(1);
   mCanvas.setBitmap(bitmap);
   mCanvas.setMatrix(mMatrix);
   mCanvas.translate(dx, dy);
   mCanvas.save();
   mView.getRootView().draw(mCanvas);
 }
Example #3
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final Activity activity = getActivity();

    mToast = Toast.makeText(activity, "", Toast.LENGTH_SHORT);
    mToast.setGravity(Gravity.CENTER, 0, 0);

    mRecyclerView = (TwoWayView) view.findViewById(R.id.list);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLongClickable(true);

    mPositionText = (TextView) view.getRootView().findViewById(R.id.position);
    mCountText = (TextView) view.getRootView().findViewById(R.id.count);

    mStateText = (TextView) view.getRootView().findViewById(R.id.state);
    updateState(SCROLL_STATE_IDLE);

    final ItemClickSupport itemClick = ItemClickSupport.addTo(mRecyclerView);

    itemClick.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(RecyclerView parent, View child, int position, long id) {
            mToast.setText("Item clicked: " + position);
            mToast.show();
          }
        });

    itemClick.setOnItemLongClickListener(
        new OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(RecyclerView parent, View child, int position, long id) {
            mToast.setText("Item long pressed: " + position);
            mToast.show();
            return true;
          }
        });

    mRecyclerView.setOnScrollListener(
        new RecyclerView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(int scrollState) {
            updateState(scrollState);
          }

          @Override
          public void onScrolled(int i, int i2) {
            mPositionText.setText("First: " + mRecyclerView.getFirstVisiblePosition());
            mCountText.setText("Count: " + mRecyclerView.getChildCount());
          }
        });

    final Drawable divider = getResources().getDrawable(R.drawable.divider);
    mRecyclerView.addItemDecoration(new DividerItemDecoration(divider));

    mRecyclerView.setAdapter(new SimpleAdapter(activity, mRecyclerView, mLayoutId));
  }
Example #4
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(R.anim.fadein, R.anim.fadeout);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
    setContentView(R.layout.main);
    View LLView = findViewById(R.id.LLMainPage);
    View root = LLView.getRootView();
    root.setBackgroundColor(Color.WHITE);

    Start = (Button) findViewById(R.id.btnStartPractice);
    // Version =(TextView)findViewById(R.id.txtMainpgVersion);
    Start.setOnClickListener(this);

    ConfigureVersion();
    tracker = GoogleAnalyticsTracker.getInstance();
    // Start the tracker in manual dispatch mode...
    tracker.startNewSession("UA-32911832-1", this);

    tracker.trackPageView("/ApplicationStart");
    tracker.dispatch();

    // testing the cache HERE
    // LocalCache cache = ((LocalCache)getApplicationContext());

    // List<QuestionLookupItem> items = cache.getQuestionsIds();

    // if(items != null){

    // Toast.makeText(getBaseContext(),
    //        "Your query returned " + String.valueOf(items.size()) + " records.",
    //        Toast.LENGTH_LONG).show();
    // }
  }
 @Override
 public boolean sendKeyEvent(KeyEvent event) {
   // BaseInputConnection.sendKeyEvent() dispatches the key event to the main thread.
   // In order to ensure events are processed in the proper order, we must block the
   // IC thread until the main thread finishes processing the key event
   super.sendKeyEvent(event);
   final View v = getView();
   if (v == null) {
     return false;
   }
   final Handler icHandler = mEditableClient.getInputConnectionHandler();
   final Handler mainHandler = v.getRootView().getHandler();
   if (icHandler.getLooper() != mainHandler.getLooper()) {
     // We are on separate IC thread but the event is queued on the main thread;
     // wait on IC thread until the main thread processes our posted Runnable. At
     // that point the key event has already been processed.
     mainHandler.post(
         new Runnable() {
           @Override
           public void run() {
             InputThreadUtils.sInstance.endWaitForUiThread();
           }
         });
     InputThreadUtils.sInstance.waitForUiThread(icHandler);
   }
   return false; // seems to always return false
 }
  private void showContextMenuFromView(
      final View openingView,
      int feedItem,
      FeedContextMenu.OnFeedContextMenuItemClickListener listener) {
    if (!isContextMenuShowing) {
      isContextMenuShowing = true;
      contextMenuView = new FeedContextMenu(openingView.getContext());
      contextMenuView.bindToItem(feedItem);
      contextMenuView.addOnAttachStateChangeListener(this);
      contextMenuView.setOnFeedMenuItemClickListener(listener);

      ((ViewGroup) openingView.getRootView().findViewById(android.R.id.content))
          .addView(contextMenuView);

      contextMenuView
          .getViewTreeObserver()
          .addOnPreDrawListener(
              new ViewTreeObserver.OnPreDrawListener() {
                @Override
                public boolean onPreDraw() {
                  contextMenuView.getViewTreeObserver().removeOnPreDrawListener(this);
                  setupContextMenuInitialPosition(openingView);
                  performShowAnimation();
                  return false;
                }
              });
    }
  }
  @Override
  public void onClick(View v) {

    View rootView = v.getRootView();
    EditText textToAdd = (EditText) rootView.findViewById(R.id.text_to_add);
    ListView groceryList = (ListView) rootView.findViewById(R.id.grocery_list);
    ArrayAdapter<String> groceryAdapter = (ArrayAdapter<String>) groceryList.getAdapter();

    String groceryItem = textToAdd.getText().toString();
    if (groceryItem.length() != 0) {
      groceryAdapter.add(groceryItem);
      dbService.writeToDatabase(groceryItem, groceryAdapter.getCount());
      groceryAdapter.notifyDataSetChanged();
      textToAdd.setText("");
    } else {
      AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);

      alertDialogBuilder
          .setTitle("Groceries must not be blank")
          .setCancelable(false)
          .setPositiveButton(
              "Ok",
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                }
              });
      ;

      AlertDialog alertDialog = alertDialogBuilder.create();

      alertDialog.show();
    }
  }
Example #8
0
 private boolean findDropDownPosition(View anchor, android.view.WindowManager.LayoutParams p) {
   anchor.getLocationOnScreen(mDrawingLocation);
   p.x = mDrawingLocation[0];
   p.y = mDrawingLocation[1] + anchor.getMeasuredHeight();
   boolean onTop = false;
   View root = anchor.getRootView();
   int delta = (p.y + p.height) - root.getWindowTop() - root.getHeight();
   if (delta > 0) {
     if (p.y != anchor.getWindowBottom()) {
       ScrollView scrollView =
           (ScrollView) anchor.findParentViewOfType(android / widget / ScrollView);
       if (scrollView != null) {
         int bottom = anchor.getWindowBottom() + p.height;
         if (bottom > scrollView.getChildAt(scrollView.getChildCount() - 1).getWindowBottom())
           onTop = true;
         else if (bottom > scrollView.getWindowBottom()) {
           boolean enabled = scrollView.isVerticalScrollBarEnabled();
           if (enabled) scrollView.setVerticalScrollBarEnabled(false);
           scrollView.smoothScrollBy(0, delta);
           if (enabled) scrollView.setVerticalScrollBarEnabled(enabled);
           p.y -= delta;
         } else {
           onTop = true;
         }
       } else {
         onTop = true;
       }
     } else {
       onTop = true;
     }
     if (onTop) p.y -= anchor.getMeasuredHeight() + p.height;
   }
   return onTop;
 }
 @Override
 public boolean onKeyMultiple(int keyCode, int repeatCount, final KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_UNKNOWN) {
     // KEYCODE_UNKNOWN means the characters are in KeyEvent.getCharacters()
     View view = getView();
     if (view != null) {
       InputThreadUtils.sInstance.runOnIcThread(
           view.getRootView().getHandler(),
           mEditableClient,
           new Runnable() {
             @Override
             public void run() {
               // Don't call GoannaInputConnection.commitText because it can
               // post a key event back to onKeyMultiple, causing a loop
               GoannaInputConnection.super.commitText(event.getCharacters(), 1);
             }
           });
     }
     return true;
   }
   while ((repeatCount--) != 0) {
     if (!processKey(keyCode, event, true) || !processKey(keyCode, event, false)) {
       return false;
     }
   }
   return true;
 }
Example #10
0
 /**
  * Invoke this method to change the currently focused window.
  *
  * @param view A view that belongs to the view hierarchy/window that has focus, or null to remove
  *     focus
  */
 public void setFocusedWindow(View view) {
   mFocusLock.writeLock().lock();
   try {
     mFocusedWindow = view == null ? null : view.getRootView();
   } finally {
     mFocusLock.writeLock().unlock();
   }
   fireFocusChangedEvent();
 }
Example #11
0
 /**
  * Invoke this method to register a new view hierarchy.
  *
  * @param view A view that belongs to the view hierarchy/window to register
  * @name name The name of the view hierarchy/window to register
  * @see #removeWindow(View)
  */
 public void addWindow(View view, String name) {
   mWindowsLock.writeLock().lock();
   try {
     mWindows.put(view.getRootView(), name);
   } finally {
     mWindowsLock.writeLock().unlock();
   }
   fireWindowsChangedEvent();
 }
Example #12
0
 /**
  * Invoke this method to unregister a view hierarchy.
  *
  * @param view A view that belongs to the view hierarchy/window to unregister
  * @see #addWindow(View, String)
  */
 public void removeWindow(View view) {
   mWindowsLock.writeLock().lock();
   try {
     mWindows.remove(view.getRootView());
   } finally {
     mWindowsLock.writeLock().unlock();
   }
   fireWindowsChangedEvent();
 }
  public void onAnimationUpdate(final ValueAnimator animation) {
    final long currentTime = System.currentTimeMillis();
    if (mStartTime == -1) {
      mStartFrame = sGlobalFrameCounter;
      mStartTime = currentTime;
    }

    final long currentPlayTime = animation.getCurrentPlayTime();
    boolean isFinalFrame = Float.compare(1f, animation.getAnimatedFraction()) == 0;

    if (!mHandlingOnAnimationUpdate
        && sVisible
        &&
        // If the current play time exceeds the duration, or the animated fraction is 1,
        // the animation will get finished, even if we call setCurrentPlayTime -- therefore
        // don't adjust the animation in that case
        currentPlayTime < animation.getDuration()
        && !isFinalFrame) {
      mHandlingOnAnimationUpdate = true;
      long frameNum = sGlobalFrameCounter - mStartFrame;
      // If we haven't drawn our first frame, reset the time to t = 0
      // (give up after MAX_DELAY ms of waiting though - might happen, for example, if we
      // are no longer in the foreground and no frames are being rendered ever)
      if (frameNum == 0 && currentTime < mStartTime + MAX_DELAY && currentPlayTime > 0) {
        // The first frame on animations doesn't always trigger an invalidate...
        // force an invalidate here to make sure the animation continues to advance
        mTarget.getRootView().invalidate();
        animation.setCurrentPlayTime(0);
        // For the second frame, if the first frame took more than 16ms,
        // adjust the start time and pretend it took only 16ms anyway. This
        // prevents a large jump in the animation due to an expensive first frame
      } else if (frameNum == 1
          && currentTime < mStartTime + MAX_DELAY
          && !mAdjustedSecondFrameTime
          && currentTime > mStartTime + IDEAL_FRAME_DURATION
          && currentPlayTime > IDEAL_FRAME_DURATION) {
        animation.setCurrentPlayTime(IDEAL_FRAME_DURATION);
        mAdjustedSecondFrameTime = true;
      } else {
        if (frameNum > 1) {
          mTarget.post(
              new Runnable() {
                public void run() {
                  animation.removeUpdateListener(FirstFrameAnimatorHelper.this);
                }
              });
        }
        if (DEBUG) print(animation);
      }
      mHandlingOnAnimationUpdate = false;
    } else {
      if (DEBUG) print(animation);
    }
  }
  /**
   * Positions the popup window on screen. When the popup window is too tall to fit under the
   * anchor, a parent scroll view is seeked and scrolled up to reclaim space. If scrolling is not
   * possible or not enough, the popup window gets moved on top of the anchor.
   *
   * <p>The height must have been set on the layout parameters prior to calling this method.
   *
   * @param anchor the view on which the popup window must be anchored
   * @param p the layout parameters used to display the drop down
   * @return true if the popup is translated upwards to fit on screen
   */
  private boolean findDropDownPosition(
      View anchor, WindowManager.LayoutParams p, int xoff, int yoff) {
    anchor.getLocationInWindow(mDrawingLocation);
    p.x = mDrawingLocation[0] + xoff;
    p.y = mDrawingLocation[1] + anchor.getMeasuredHeight() + yoff;

    boolean onTop = false;

    p.gravity = Gravity.LEFT | Gravity.TOP;

    anchor.getLocationOnScreen(mScreenLocation);
    final Rect displayFrame = new Rect();
    anchor.getWindowVisibleDisplayFrame(displayFrame);

    final View root = anchor.getRootView();
    if (mScreenLocation[1] + anchor.getMeasuredHeight() + yoff + mPopupHeight > displayFrame.bottom
        || p.x + mPopupWidth - root.getWidth() > 0) {
      // if the drop down disappears at the bottom of the screen. we try to
      // scroll a parent scrollview or move the drop down back up on top of
      // the edit box
      int scrollX = anchor.getScrollX();
      int scrollY = anchor.getScrollY();
      Rect r =
          new Rect(
              scrollX,
              scrollY,
              scrollX + mPopupWidth,
              scrollY + mPopupHeight + anchor.getMeasuredHeight());
      anchor.requestRectangleOnScreen(r, true);

      // now we re-evaluate the space available, and decide from that
      // whether the pop-up will go above or below the anchor.
      anchor.getLocationInWindow(mDrawingLocation);
      p.x = mDrawingLocation[0] + xoff;
      p.y = mDrawingLocation[1] + anchor.getMeasuredHeight() + yoff;

      // determine whether there is more space above or below the anchor
      anchor.getLocationOnScreen(mScreenLocation);

      onTop =
          (displayFrame.bottom - mScreenLocation[1] - anchor.getMeasuredHeight() - yoff)
              < (mScreenLocation[1] - yoff - displayFrame.top);
      if (onTop) {
        p.gravity = Gravity.LEFT | Gravity.BOTTOM;
        p.y = root.getHeight() - mDrawingLocation[1] - yoff;
      } else {
        p.y = mDrawingLocation[1] + anchor.getMeasuredHeight() + yoff;
      }
    }

    p.gravity |= Gravity.DISPLAY_CLIP_VERTICAL;

    return onTop;
  }
  @Override
  public void onGlobalLayout() {
    Log.d(TAG, "onGlobalLayout");
    if (!softKeyboardListeningEnabled) {
      return;
    }
    Rect r = new Rect();
    decorView.getWindowVisibleDisplayFrame(r);

    int screenHeight = decorView.getRootView().getHeight();
    int heightDifference = screenHeight - (r.bottom - r.top);
    int resourceId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
      heightDifference -= activity.getResources().getDimensionPixelSize(resourceId);
    }
    int orientation = activity.getResources().getConfiguration().orientation;

    int id = activity.getResources().getIdentifier("config_showNavigationBar", "bool", "android");
    if (id > 0) {
      if (activity.getResources().getBoolean(id)) {
        int navbarResId =
            activity
                .getResources()
                .getIdentifier(
                    orientation == Configuration.ORIENTATION_PORTRAIT
                        ? "navigation_bar_height"
                        : "navigation_bar_height_landscape",
                    "dimen",
                    "android");
        if (navbarResId > 0) {
          heightDifference -= activity.getResources().getDimensionPixelSize(navbarResId);
        }
      }
    }

    if (heightDifference > 100) {
      Log.d(TAG, "onGlobalLayout: " + heightDifference);
      softwareKeyboardShowing = true;
      keyboardHeight = heightDifference;
      Log.d(TAG, "onGlobalLayout: " + "showing");

      showInternal();
    } else {
      Log.d(TAG, "onGlobalLayout: " + heightDifference);
      Log.d(TAG, "onGlobalLayout: " + "dismiss?");
      // dismiss not wirk
      softwareKeyboardShowing = false;
      // keyboard showing or not?
      dismissed = true;
      dismissInternally();
    }
  }
  void focusInLocked(View view) {
    if (DEBUG) Log.v(TAG, "focusIn: " + view);

    if (mCurRootView != view.getRootView()) {
      // This is a request from a window that isn't in the window with
      // IME focus, so ignore it.
      if (DEBUG) Log.v(TAG, "Not IME target window, ignoring");
      return;
    }

    mNextServedView = view;
    scheduleCheckFocusLocked(view);
  }
  /** Private method for grabbing a "screenshot" of screen content */
  private void drawOffscreenBitmap() {
    // Grab global visible rect for later use
    // mView.getGlobalVisibleRect(mRectVisibleGlobal);

    // Calculate scaled off-screen bitmap width and height
    int width = Math.round(mView.getWidth() * BITMAP_SCALE_FACTOR);
    int height = Math.round(mView.getHeight() * BITMAP_SCALE_FACTOR);

    // Width and height must be > 0
    width = Math.max(width, 1);
    height = Math.max(height, 1);

    // Allocate new off-screen bitmap only when needed
    if (mBitmap == null || mBitmap.getWidth() != width || mBitmap.getHeight() != height) {
      mBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
      mAllocationBitmap = Allocation.createFromBitmap(mRS, mBitmap);
      mAllocationBitmapTmp = Allocation.createFromBitmap(mRS, mBitmap);
      mSizeStruct.width = width;
      mSizeStruct.height = height;
      // Due to adjusting width into multiple of 4 calculate scale matrix
      // only here
      mMatrixScale.setScale((float) width / mView.getWidth(), (float) height / mView.getHeight());
      mMatrixScale.invert(mMatrixScaleInv);
    }

    // Translate values for off-screen drawing
    // int dx = -(Math.min(0, mView.getLeft()) + mRectVisibleGlobal.left);
    // int dy = -(Math.min(0, mView.getTop()) + mRectVisibleGlobal.top);
    //
    // Replaced dx and dy with View.getLocationInWindow() coordinates
    // because translate was bad for using BlurLinearLayout and
    // BlurRelativeLayout as children for other Views than root View.
    mView.getLocationInWindow(mLocationInWindow);
    // Restore canvas to its original state
    mCanvas.restoreToCount(1);
    mCanvas.setBitmap(mBitmap);
    // Using scale matrix will make draw call to match
    // resized off-screen bitmap size
    mCanvas.setMatrix(mMatrixScale);
    // Off-screen bitmap does not cover the whole screen
    // Use canvas translate to match its position on screen
    mCanvas.translate(-mLocationInWindow[0], -mLocationInWindow[1]);
    // Clip rect is the same as we have
    // TODO: Why does this not work on API 18?
    // mCanvas.clipRect(mRectVisibleGlobal);
    // Save current canvas state
    mCanvas.save();
    // Start drawing from the root view
    mView.getRootView().draw(mCanvas);
  }
Example #18
0
 @Override
 public void onGlobalLayout() {
   Rect r = new Rect();
   View rootNode = this.getWindow().getDecorView();
   rootNode.getWindowVisibleDisplayFrame(r);
   DisplayMetrics dm = getResources().getDisplayMetrics();
   int state, sih = Math.min(rootNode.getRootView().getHeight(), dm.heightPixels) - r.bottom;
   if (sih <= 240) {
     state = Configuration.SOFT_INPUT_STATE_CLOSE;
   } else {
     state = Configuration.SOFT_INPUT_STATE_OPEN;
     softInputHeight = sih;
   }
   onSoftInputState(state);
 }
  private boolean processKey(int keyCode, KeyEvent event, boolean down) {
    if (GamepadUtils.isSonyXperiaGamepadKeyEvent(event)) {
      event = GamepadUtils.translateSonyXperiaGamepadKeys(keyCode, event);
      keyCode = event.getKeyCode();
    }

    if (keyCode > KeyEvent.getMaxKeyCode() || !shouldProcessKey(keyCode, event)) {
      return false;
    }
    event = translateKey(keyCode, event);
    keyCode = event.getKeyCode();

    View view = getView();
    if (view == null) {
      InputThreadUtils.sInstance.sendEventFromUiThread(
          ThreadUtils.getUiHandler(), mEditableClient, GoannaEvent.createKeyEvent(event, 0));
      return true;
    }

    // KeyListener returns true if it handled the event for us. KeyListener is only
    // safe to use on the UI thread; therefore we need to pass a proxy Editable to it
    KeyListener keyListener = TextKeyListener.getInstance();
    Handler uiHandler = view.getRootView().getHandler();
    Editable uiEditable =
        InputThreadUtils.sInstance.getEditableForUiThread(uiHandler, mEditableClient);
    boolean skip = shouldSkipKeyListener(keyCode, event);
    if (down) {
      mEditableClient.setSuppressKeyUp(true);
    }
    if (skip
        || (down && !keyListener.onKeyDown(view, uiEditable, keyCode, event))
        || (!down && !keyListener.onKeyUp(view, uiEditable, keyCode, event))) {
      InputThreadUtils.sInstance.sendEventFromUiThread(
          uiHandler,
          mEditableClient,
          GoannaEvent.createKeyEvent(event, TextKeyListener.getMetaState(uiEditable)));
      if (skip && down) {
        // Usually, the down key listener call above adjusts meta states for us.
        // However, if we skip that call above, we have to manually adjust meta
        // states so the meta states remain consistent
        TextKeyListener.adjustMetaAfterKeypress(uiEditable);
      }
    }
    if (down) {
      mEditableClient.setSuppressKeyUp(false);
    }
    return true;
  }
 /** 初始化 */
 private void init() {
   params = view.getLayoutParams();
   if (null != view.getParent()) {
     parentView = (ViewGroup) view.getParent();
   } else {
     parentView = (ViewGroup) view.getRootView().findViewById(android.R.id.content);
   }
   int count = parentView.getChildCount();
   for (int index = 0; index < count; index++) {
     if (view == parentView.getChildAt(index)) {
       viewIndex = index;
       break;
     }
   }
   currentView = view;
 }
 private void possiblyResizeChildOfContent() {
   int usableHeightNow = computeUsableHeight();
   if (usableHeightNow != usableHeightPrevious) {
     int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
     int heightDifference = usableHeightSansKeyboard - usableHeightNow;
     if (heightDifference > (usableHeightSansKeyboard / 4)) {
       // keyboard probably just became visible
       frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
     } else {
       // keyboard probably just became hidden
       frameLayoutParams.height = usableHeightSansKeyboard;
     }
     mChildOfContent.requestLayout();
     usableHeightPrevious = usableHeightNow;
   }
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_statistic_return, container, false);

    Button exitButton = (Button) rootView.getRootView().findViewById(R.id.exit_button);
    exitButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            getActivity().finish();
          }
        });
    // setup view
    return rootView;
  }
  private void setPitchBarPosition(double frequency) {
    View pitchBar = (View) findViewById(R.id.tune_view_current_pitch);
    int margin = 20;
    double leftDP = NoteCalculator.getPitchBarPosition(frequency, 560);

    Transition moveTransition = new ChangeBounds();
    moveTransition.setDuration(300);
    moveTransition.setInterpolator(new LinearInterpolator());

    TransitionManager.beginDelayedTransition((ViewGroup) pitchBar.getRootView(), moveTransition);

    ViewGroup.MarginLayoutParams params =
        (ViewGroup.MarginLayoutParams) (pitchBar.getLayoutParams());
    Log.d(TAG, String.format("Current: %d New: %f", params.leftMargin, leftDP));
    params.setMargins((int) leftDP, 0, 0, 0);
    pitchBar.setLayoutParams(params);
  }
 private void possiblyResizeChildOfContent() {
   int usableHeightNow = computeUsableHeight();
   if (usableHeightNow != usableHeightPrevious) {
     int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
     int heightDifference = usableHeightSansKeyboard - usableHeightNow;
     if (heightDifference > (usableHeightSansKeyboard / 4)) {
       // keyboard probably just became visible
       isKeybordShow = true;
       //                mChildOfContent.setPadding(0,0,0,bottomPadding);
     } else {
       // keyboard probably just became
       isKeybordShow = false;
       //                mChildOfContent.setPadding(0,0,0,bottomPadding +
       // (ApiCompatibleUtil.hasLollipop() ? navigationBarHeight : 0));
     }
     frameLayoutParams.height = usableHeightNow;
     mChildOfContent.requestLayout();
     usableHeightPrevious = usableHeightNow;
   }
 }
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   if (view != null) {
     ViewParent oldParent = (ViewParent) view.getRootView();
     if (oldParent != container && oldParent != null) {
       ((ViewGroup) oldParent).removeView(view);
     }
   } else {
     view = LayoutInflater.from(getActivity()).inflate(R.layout.news_details, container, false);
     handleButtonsEvents();
     applyFonts();
   }
   Bundle bundle = getArguments();
   if (bundle != null) {
     newsItem = (NewsItem) bundle.getSerializable("newsItem");
   }
   initViews(view);
   getData();
   return view;
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.customisepage);

    View LLView = findViewById(R.id.LLCustomise);
    View root = LLView.getRootView();
    root.setBackgroundColor(Color.WHITE);

    seekbar = (SeekBar) findViewById(R.id.seekBarQuestions);
    NumberOfQuestions = (TextView) findViewById(R.id.TextViewNumberOfQuestions);
    btnCustomise = (Button) findViewById(R.id.btnCustomise);
    txtDifficulty = (TextView) findViewById(R.id.txtDifficulty);
    txtTopic = (TextView) findViewById(R.id.txtTopic);
    txtTypeofQuestion = (TextView) findViewById(R.id.txtTypeofQuestion);
    btnStartTest = (Button) findViewById(R.id.btnStartTest);
    FinalResult = (TextView) findViewById(R.id.textViewFinalAnswer);
    cache = ((LocalCache) getApplicationContext());

    seekbar.setMax(MAXIMUMQUESTIONS);
    seekbar.setProgress(10);
    NumberOfQuestions.setText(
        "You selected"
            + " "
            + "10"
            + " "
            + "Questions"
            + ", your search criteria may not return records and does not necessarily have all types of questions");

    seekbar.setOnSeekBarChangeListener(this);
    NumberOfQuestions.setOnClickListener(this);
    btnCustomise.setOnClickListener(this);
    btnStartTest.setOnClickListener(this);
    FinalResult.setVisibility(View.INVISIBLE);

    ConfigureDifficulty();
    ConfigureTopics();
    ConfigureTypeOfQuestion();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.multiplechoicemultipleanswer);

    QuestionHeaderBox = (WebView) findViewById(R.id.MQuestionHeaderBox);
    Table = (TableLayout) findViewById(R.id.MQtable);
    BtnContinue = (Button) findViewById(R.id.MContinue);
    BtnReason = (Button) findViewById(R.id.MultipleChoiceMultipleShowReason);

    BtnContinue.setOnClickListener(this);
    BtnContinue.setTag(2); // I am using this to identify the continue button
    BtnContinue.setVisibility(View.INVISIBLE);

    BtnReason.setOnClickListener(this);
    BtnReason.setTag(3); // I am using this to identify the Reason Button
    BtnReason.setVisibility(View.INVISIBLE);

    View LLView = findViewById(R.id.LLMultipleMultiple);
    View root = LLView.getRootView();
    root.setBackgroundColor(Color.BLACK);

    cache = ((LocalCache) getApplicationContext());

    WebSettings websettings = QuestionHeaderBox.getSettings();
    websettings.setJavaScriptEnabled(true);
    websettings.setSavePassword(false);
    websettings.setSaveFormData(false);
    websettings.setSupportZoom(true);
    websettings.setBuiltInZoomControls(true);

    Bundle getBasket = getIntent().getExtras();
    Integer _id = getBasket.getInt("_id");

    GetQuestion(_id);
    GetAnswers(_id);
  }
        @Override
        public void handleMessage(Message msg) {
          FragmentActivity activity = getActivity();
          switch (msg.what) {
            case Constants.MESSAGE_STATE_CHANGE:
              switch (msg.arg1) {
                case BluetoothChatService.STATE_CONNECTED:
                  setStatus(getString(R.string.title_connected_to, mConnectedDeviceName));
                  mConversationArrayAdapter.clear();
                  break;
                case BluetoothChatService.STATE_CONNECTING:
                  setStatus(R.string.title_connecting);
                  break;
                case BluetoothChatService.STATE_NOT_CONNECTED:
                  setStatus(R.string.title_not_connected);
                  break;
              }
              break;
            case Constants.MESSAGE_WRITE:
              byte[] writeBuf = (byte[]) msg.obj;
              // construct a string from the buffer
              String writeMessage = new String(writeBuf);
              mConversationArrayAdapter.add("Me:  " + writeMessage);
              break;

            case Constants.MESSAGE_READ:
              String readMessage = (String) msg.obj;
              mConversationArrayAdapter.add(mConnectedDeviceName + ":  " + readMessage);

              TelemetryData data = new TelemetryData(readMessage);

              View ownView = getView();
              if (ownView == null) {
                break;
              }
              View rootView = ownView.getRootView();
              if (rootView != null) {
                TextView view = (TextView) rootView.findViewById(R.id.voltage);
                view.setText(data.getVoltageString() + "V");

                view = (TextView) rootView.findViewById(R.id.current);
                view.setText(data.getCurrentString() + "A");

                view = (TextView) rootView.findViewById(R.id.mbtemp);
                view.setText(data.getBoardTemperature() + "\u00B0 C");

                view = (TextView) rootView.findViewById(R.id.battemp);
                view.setText(data.getBatteryTemperature() + "\u00B0 C");

                view = (TextView) rootView.findViewById(R.id.inclination);
                view.setText(data.getInclinationString() + "\u00B0");

                view = (TextView) rootView.findViewById(R.id.rps);
                view.setText(data.getRPSString() + " RPS");

                view = (TextView) rootView.findViewById(R.id.power);
                view.setText(data.getWattSeconds() + "ws");

                view = (TextView) rootView.findViewById(R.id.buzzer);
                view.setText(data.getBuzzer() ? "BUZZER" : "-");
              }

              // Update graph, if possible
              // TODO: TESTING CODE
              try {
                if (((CheckBox) getView().findViewById(R.id.checkbox_chart)).isChecked()) {
                  int divisor = 1;
                  switch (graphItemIndex) {
                    case 0:
                    case 1:
                    case 4:
                      divisor = 10;
                      break;
                    case 5:
                      divisor = 100;
                  }
                  graphControl.addDataPoint(
                      graphIndex++,
                      Double.parseDouble(readMessage.split(",")[graphItemIndex]) / divisor,
                      ((CheckBox) getView().findViewById(R.id.checkbox_scroll)).isChecked());
                }
              } catch (Exception e) {
                Log.e(TAG, "Exception updating graph", e);
              }

              break;

            case Constants.MESSAGE_DEVICE_NAME:
              // save the connected device's name
              mConnectedDeviceName = msg.getData().getString(Constants.DEVICE_NAME);
              if (null != activity) {
                Toast.makeText(activity, "Connected to " + mConnectedDeviceName, Toast.LENGTH_SHORT)
                    .show();
              }
              break;
            case Constants.MESSAGE_TOAST:
              if (null != activity) {
                Toast.makeText(
                        activity, msg.getData().getString(Constants.TOAST), Toast.LENGTH_SHORT)
                    .show();
              }
              break;
          }
        }
Example #29
0
 public View getEffectTypeItem(View view) {
   return view.getRootView().findViewById(R.id.effect_type_item_root);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);
    // change the background color to white
    View LLView = findViewById(R.id.LLMain);
    View root = LLView.getRootView();
    root.setBackgroundColor(Color.argb(0, 238, 244, 228));

    mProgress = (ProgressBar) findViewById(R.id.SplashprogressBar);

    // Play sound

    // SplashSound = MediaPlayer.create(Splash.this, R.raw.arrowwoodimpact);
    // SplashSound.start();

    LocalCache cache = ((LocalCache) getApplicationContext());
    cache.setDataBaseVersion(
        9); // This is now to upgrade the database Just increase by 1 and make sure DBVersion-
            // VersionNumber in database is updated.
    cache.PlaySound(this, R.raw.arrowwoodimpact);

    // Setup Prefs if they are not there. to turn on Sound and ShowAnswer
    OtherPreferences sharedPrefs = new OtherPreferences(this.getBaseContext());

    if (sharedPrefs.getPreference("sound").equalsIgnoreCase("N/A")) {

      sharedPrefs.saveToPref("sound", "on");
      sharedPrefs.saveToPref("ShowAnswer", "on");
    }

    Thread timer =
        new Thread() {
          public void run() {
            while (mProgressStatus < 100) {
              mProgressStatus = copyFileOrDir("videos");
              // Update the progress bar
              mHandler.post(
                  new Runnable() {
                    public void run() {
                      mProgress.setProgress(mProgressStatus);
                    }
                  });
            }
            DataBaseHelper myDbHelper = new DataBaseHelper(getApplicationContext());

            try {

              myDbHelper.createDataBase();
              myDbHelper.close();

            } catch (IOException ioe) {

              throw new Error("Unable to create database");

            }

            /*try {

            	myDbHelper.openDataBase();


            }catch(SQLException sqle){

            	throw sqle;

            }*/
            finally {

              Intent OpenStartPage =
                  new Intent("com.LearnersCloud.iEvaluator1ForAndroid.Chemistry250.TABS");
              startActivity(OpenStartPage);
            }
          }
        };

    timer.start();
  }