List of usage examples for android.view Gravity CENTER_HORIZONTAL
int CENTER_HORIZONTAL
To view the source code for android.view Gravity CENTER_HORIZONTAL.
Click Source Link
From source file:org.openmrs.mobile.activities.formdisplay.FormDisplayPageFragment.java
@Override public LinearLayout createSectionLayout(String sectionLabel) { LinearLayout sectionLinearLayout = new LinearLayout(getActivity()); LinearLayout.LayoutParams layoutParams = getAndAdjustLinearLayoutParams(sectionLinearLayout); TextView tv = new TextView(getActivity()); tv.setText(sectionLabel);/*ww w. j av a 2s . co m*/ tv.setGravity(Gravity.CENTER_HORIZONTAL); tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); tv.setTextColor(ContextCompat.getColor(getActivity(), R.color.primary)); sectionLinearLayout.addView(tv, layoutParams); return sectionLinearLayout; }
From source file:com.adarshahd.indianrailinfo.donate.TrainEnquiry.java
private void startDetailsActivity() { //For testing!!! /*File file = new File("/sdcard/train_details_trn_number.html"); String result = "";/*w w w . j a v a 2 s.c o m*/ try { FileInputStream stream = new FileInputStream(file); InputStreamReader readerStream = new InputStreamReader(stream); BufferedReader reader = new BufferedReader(readerStream); String str; while((str = reader.readLine()) != null) { result += str; } } catch (IOException e) { e.printStackTrace(); }*/ if (mPage.contains("unavailable")) { TextView tv = new TextView(mActivity); tv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL)); tv.setTextColor(Color.RED); tv.setTextSize(20); tv.setText( "Response from server: \n\n\"The requested service is currently unavailable. Please try again later\""); mFrameLayout.removeAllViews(); mFrameLayout.addView(tv); return; } if (mPage.contains("invalid")) { TextView tv = new TextView(mActivity); tv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL)); tv.setTextColor(Color.RED); tv.setTextSize(20); tv.setText("Invalid Station code! Please select the station code from drop down list."); mFrameLayout.removeAllViews(); mFrameLayout.addView(tv); return; } if (mPage.contains("No Matching Trains")) { TextView tv = new TextView(mActivity); tv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL)); tv.setTextColor(Color.RED); tv.setTextSize(20); tv.setText("No Matching train found! Please check the train number/name"); mFrameLayout.removeAllViews(); mFrameLayout.addView(tv); return; } //put the required intent data and start TrainEnquiryDetails activity. Intent intent = new Intent(this, TrainEnquiryDetails.class); intent.putExtra(TRAIN, mTrainNumber); intent.putExtra(SEARCH, searchUsingTrnNumber); intent.putExtra(PAGE, mPage); intent.putExtra(SRC, mACTFrom.getText().toString()); intent.putExtra(DST, mACTTo.getText().toString()); intent.putExtra(DAY_TRAVEL, mCal.get(Calendar.DAY_OF_MONTH)); intent.putExtra(MONTH_TRAVEL, mCal.get(Calendar.MONTH)); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); //Try to parse the mTrainNumber; try { Integer.parseInt(mTrainNumber); isInteger = true; } catch (Exception e) { isInteger = false; } intent.putExtra(ISINT, isInteger); startActivity(intent); }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * DOUBLE TEXT ROW/* w w w . j a va 2 s. co m*/ * @param att * @param linear * @return */ public LinearLayout getDoubleTextRow(Map<String, String> att, LinearLayout linear) { LinearLayout container_layout = new LinearLayout(context); container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo)); container_layout.setMinimumHeight(46); container_layout.setVerticalGravity(Gravity.CENTER); LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.3f); TextView tx = new TextView(context); tx.setText(att.get("title")); tx.setTextSize(11); tx.setTypeface(null, Typeface.BOLD); tx.setGravity(Gravity.LEFT); tx.setPadding(2, 0, 0, 2); tx.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(tx, value_params); LinearLayout.LayoutParams value_one_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.35f); TextView t1 = new TextView(context); t1.setText(att.get("value1").equals("") ? " - " : att.get("value1")); t1.setTextSize(11); t1.setGravity(Gravity.CENTER_HORIZONTAL); t1.setPadding(2, 0, 0, 2); t1.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(t1, value_one_params); LinearLayout.LayoutParams value_two_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.35f); TextView t2 = new TextView(context); t2.setTextSize(11); t2.setText(att.get("value2").equals("") ? " - " : att.get("value2")); t2.setGravity(Gravity.CENTER_HORIZONTAL); t2.setPadding(2, 0, 0, 2); t2.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(t2, value_two_params); linear.addView(container_layout); return linear; }
From source file:android.support.designox.widget.CollapsingTextHelper.java
private void calculateBaseOffsets() { final float currentTextSize = mCurrentTextSize; // We then calculate the collapsed text size, using the same logic calculateUsingTextSize(mCollapsedTextSize); float width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0; final int collapsedAbsGravity = GravityCompat.getAbsoluteGravity(mCollapsedTextGravity, mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR); switch (collapsedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.BOTTOM: mCollapsedDrawY = mCollapsedBounds.bottom; break;//from ww w .j a va 2 s. co m case Gravity.TOP: mCollapsedDrawY = mCollapsedBounds.top - mTextPaint.ascent(); break; case Gravity.CENTER_VERTICAL: default: float textHeight = mTextPaint.descent() - mTextPaint.ascent(); float textOffset = (textHeight / 2) - mTextPaint.descent(); mCollapsedDrawY = mCollapsedBounds.centerY() + textOffset; break; } switch (collapsedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: mCollapsedDrawX = mCollapsedBounds.centerX() - (width / 2); break; case Gravity.RIGHT: mCollapsedDrawX = mCollapsedBounds.right - width; break; case Gravity.LEFT: default: mCollapsedDrawX = mCollapsedBounds.left; break; } calculateUsingTextSize(mExpandedTextSize); width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0; final int expandedAbsGravity = GravityCompat.getAbsoluteGravity(mExpandedTextGravity, mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR); switch (expandedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.BOTTOM: mExpandedDrawY = mExpandedBounds.bottom; break; case Gravity.TOP: mExpandedDrawY = mExpandedBounds.top - mTextPaint.ascent(); break; case Gravity.CENTER_VERTICAL: default: float textHeight = mTextPaint.descent() - mTextPaint.ascent(); float textOffset = (textHeight / 2) - mTextPaint.descent(); mExpandedDrawY = mExpandedBounds.centerY() + textOffset; break; } switch (expandedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: mExpandedDrawX = mExpandedBounds.centerX() - (width / 2); break; case Gravity.RIGHT: mExpandedDrawX = mExpandedBounds.right - width; break; case Gravity.LEFT: default: mExpandedDrawX = mExpandedBounds.left; break; } // The bounds have changed so we need to clear the texture clearTexture(); // Now reset the text size back to the original setInterpolatedTextSize(currentTextSize); }
From source file:lewa.support.v7.internal.view.menu.ActionMenuItemView.java
@Override public boolean onLongClick(View v) { if (hasText()) { // Don't show the cheat sheet for items that already show text. return false; }//from w w w. j a v a 2s . com final int[] screenPos = new int[2]; final Rect displayFrame = new Rect(); getLocationOnScreen(screenPos); getWindowVisibleDisplayFrame(displayFrame); final Context context = getContext(); final int width = getWidth(); ///LEWA MODIFY BEGIN final int height = Injector.getHeight(this); final int midy = Injector.measureMidy(this, screenPos[1], height); //final int height = getHeight(); //final int midy = screenPos[1] + height / 2; ///LEWA MODIFY END int referenceX = screenPos[0] + width / 2; if (ViewCompat.getLayoutDirection(v) == ViewCompat.LAYOUT_DIRECTION_LTR) { final int screenWidth = context.getResources().getDisplayMetrics().widthPixels; referenceX = screenWidth - referenceX; // mirror } Toast cheatSheet = Toast.makeText(context, mItemData.getTitle(), Toast.LENGTH_SHORT); if (midy < displayFrame.height()) { // Show along the top; follow action buttons cheatSheet.setGravity(Gravity.TOP | GravityCompat.END, referenceX, height); } else { // Show along the bottom center cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height); } cheatSheet.show(); return true; }
From source file:com.amitupadhyay.aboutexample.util.CollapsingTextHelper.java
private void calculateBaseOffsets() { // We then calculate the collapsed text size, using the same logic mTextPaint.setTextSize(mCollapsedTextSize); float width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0; final int collapsedAbsGravity = GravityCompat.getAbsoluteGravity(mCollapsedTextGravity, mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR); switch (collapsedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.BOTTOM: mCollapsedDrawY = mCollapsedBounds.bottom; break;/* w ww . j a v a2s. co m*/ case Gravity.TOP: mCollapsedDrawY = mCollapsedBounds.top - mTextPaint.ascent(); break; case Gravity.CENTER_VERTICAL: default: float textHeight = mTextPaint.descent() - mTextPaint.ascent(); float textOffset = (textHeight / 2) - mTextPaint.descent(); mCollapsedDrawY = mCollapsedBounds.centerY() + textOffset; break; } switch (collapsedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: mCollapsedDrawX = mCollapsedBounds.centerX() - (width / 2); break; case Gravity.RIGHT: mCollapsedDrawX = mCollapsedBounds.right - width; break; case Gravity.LEFT: default: mCollapsedDrawX = mCollapsedBounds.left; break; } mTextPaint.setTextSize(mExpandedTextSize); width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0; final int expandedAbsGravity = GravityCompat.getAbsoluteGravity(mExpandedTextGravity, mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR); switch (expandedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.BOTTOM: mExpandedDrawY = mExpandedBounds.bottom; break; case Gravity.TOP: mExpandedDrawY = mExpandedBounds.top - mTextPaint.ascent(); break; case Gravity.CENTER_VERTICAL: default: float textHeight = mTextPaint.descent() - mTextPaint.ascent(); float textOffset = (textHeight / 2) - mTextPaint.descent(); mExpandedDrawY = mExpandedBounds.centerY() + textOffset; break; } switch (expandedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: mExpandedDrawX = mExpandedBounds.centerX() - (width / 2); break; case Gravity.RIGHT: mExpandedDrawX = mExpandedBounds.right - width; break; case Gravity.LEFT: default: mExpandedDrawX = mExpandedBounds.left; break; } // The bounds have changed so we need to clear the texture clearTexture(); }
From source file:com.h6ah4i.android.tablayouthelper.TabLayoutHelper.java
protected void adjustTabModeInternal(@NonNull TabLayout tabLayout, int prevScrollX) { int prevTabMode = tabLayout.getTabMode(); tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER); int newTabMode = determineTabMode(tabLayout); cancelPendingUpdateScrollPosition(); if (newTabMode == TabLayout.MODE_FIXED) { tabLayout.setTabGravity(TabLayout.GRAVITY_FILL); tabLayout.setTabMode(TabLayout.MODE_FIXED); } else {// w ww . j a v a 2 s . c o m LinearLayout slidingTabStrip = (LinearLayout) tabLayout.getChildAt(0); slidingTabStrip.setGravity(Gravity.CENTER_HORIZONTAL); if (prevTabMode == TabLayout.MODE_SCROLLABLE) { // restore scroll position tabLayout.scrollTo(prevScrollX, 0); } else { // scroll to current selected tab mUpdateScrollPositionRunnable = new Runnable() { @Override public void run() { mUpdateScrollPositionRunnable = null; updateScrollPosition(); } }; mTabLayout.post(mUpdateScrollPositionRunnable); } } }
From source file:ru.shmakinv.android.material.widget.CollapsingTextHelper.java
@SuppressLint("RtlHardcoded") private void calculateBaseOffsets() { final float currentTextSize = mCurrentTextSize; // We then calculate the collapsed text size, using the same logic calculateUsingTextSize(mCollapsedTextSize); float width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0; final int collapsedAbsGravity = GravityCompat.getAbsoluteGravity(mCollapsedTextGravity, mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR); switch (collapsedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.BOTTOM: mCollapsedDrawY = mCollapsedBounds.bottom; break;//from www. j a v a2s . co m case Gravity.TOP: mCollapsedDrawY = mCollapsedBounds.top - mTextPaint.ascent(); break; case Gravity.CENTER_VERTICAL: default: float textHeight = mTextPaint.descent() - mTextPaint.ascent(); float textOffset = (textHeight / 2) - mTextPaint.descent(); mCollapsedDrawY = mCollapsedBounds.centerY() + textOffset; break; } switch (collapsedAbsGravity & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: mCollapsedDrawX = mCollapsedBounds.centerX() - (width / 2); break; case Gravity.RIGHT: mCollapsedDrawX = mCollapsedBounds.right - width; break; case Gravity.LEFT: default: mCollapsedDrawX = mCollapsedBounds.left; break; } calculateUsingTextSize(mExpandedTextSize); width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0; final int expandedAbsGravity = GravityCompat.getAbsoluteGravity(mExpandedTextGravity, mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR); switch (expandedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.BOTTOM: mExpandedDrawY = mExpandedBounds.bottom; break; case Gravity.TOP: mExpandedDrawY = mExpandedBounds.top - mTextPaint.ascent(); break; case Gravity.CENTER_VERTICAL: default: float textHeight = mTextPaint.descent() - mTextPaint.ascent(); float textOffset = (textHeight / 2) - mTextPaint.descent(); mExpandedDrawY = mExpandedBounds.centerY() + textOffset; break; } switch (expandedAbsGravity & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: mExpandedDrawX = mExpandedBounds.centerX() - (width / 2); break; case Gravity.RIGHT: mExpandedDrawX = mExpandedBounds.right - width; break; case Gravity.LEFT: default: mExpandedDrawX = mExpandedBounds.left; break; } // The bounds have changed so we need to clear the texture clearTexture(); // Now reset the text size back to the original setInterpolatedTextSize(currentTextSize); }
From source file:com.bridgeconn.autographago.ui.customviews.TabLayoutHelper.java
protected void adjustTabModeInternal(@NonNull TabLayout tabLayout, int prevScrollX) { if (tabLayout == null) { return;/*from w ww. java2 s .c o m*/ } int prevTabMode = tabLayout.getTabMode(); tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER); int newTabMode = determineTabMode(tabLayout); cancelPendingUpdateScrollPosition(); if (newTabMode == TabLayout.MODE_FIXED) { tabLayout.setTabGravity(TabLayout.GRAVITY_FILL); tabLayout.setTabMode(TabLayout.MODE_FIXED); } else { LinearLayout slidingTabStrip = (LinearLayout) tabLayout.getChildAt(0); slidingTabStrip.setGravity(Gravity.CENTER_HORIZONTAL); if (prevTabMode == TabLayout.MODE_SCROLLABLE) { // restore scroll position tabLayout.scrollTo(prevScrollX, 0); } else { // scroll to current selected tab mUpdateScrollPositionRunnable = new Runnable() { @Override public void run() { mUpdateScrollPositionRunnable = null; updateScrollPosition(); } }; mTabLayout.post(mUpdateScrollPositionRunnable); } } }
From source file:paulscode.android.mupen64plusae.game.GameFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mAppData = new AppData(getActivity()); mMogaController = Controller.getInstance(getActivity()); // Initialize the objects and data files interfacing to the emulator core final FragmentManager fm = getActivity().getSupportFragmentManager(); mCoreFragment = (CoreFragment) fm.findFragmentByTag(STATE_CORE_FRAGMENT); if (mCoreFragment == null) { mCoreFragment = new CoreFragment(); fm.beginTransaction().add(mCoreFragment, STATE_CORE_FRAGMENT).commit(); }/*from ww w . ja va 2 s . com*/ mCoreFragment.setCoreEventListener(this); // Get the args data mRomPath = getArguments().getString(ActivityHelper.Keys.ROM_PATH); mRomMd5 = getArguments().getString(ActivityHelper.Keys.ROM_MD5); mRomCrc = getArguments().getString(ActivityHelper.Keys.ROM_CRC); mRomHeaderName = getArguments().getString(ActivityHelper.Keys.ROM_HEADER_NAME); mRomCountryCode = getArguments().getByte(ActivityHelper.Keys.ROM_COUNTRY_CODE); mRomArtPath = getArguments().getString(ActivityHelper.Keys.ROM_ART_PATH); mRomGoodName = getArguments().getString(ActivityHelper.Keys.ROM_GOOD_NAME); mRomLegacySave = getArguments().getString(ActivityHelper.Keys.ROM_LEGACY_SAVE); mDoRestart = getArguments().getBoolean(ActivityHelper.Keys.DO_RESTART, false); if (TextUtils.isEmpty(mRomPath) || TextUtils.isEmpty(mRomMd5)) throw new Error("ROM path and MD5 must be passed via the extras bundle when starting GameFragment"); // Initialize MOGA controller API // TODO: Remove hack after MOGA SDK is fixed // mMogaController.init(); MogaHack.init(mMogaController, getActivity()); // Get app data and user preferences mGlobalPrefs = new GlobalPrefs(getActivity(), mAppData); //Allow volume keys to control media volume if they are not mapped if (!mGlobalPrefs.volKeysMappable && mGlobalPrefs.audioPlugin.enabled) { getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC); } mGamePrefs = new GamePrefs(getActivity(), mRomMd5, mRomCrc, mRomHeaderName, mRomGoodName, CountryCode.getCountryCode(mRomCountryCode).toString(), mAppData, mGlobalPrefs, mRomLegacySave); mGameDataManager = new GameDataManager(mGlobalPrefs, mGamePrefs, mGlobalPrefs.maxAutoSaves); mGameDataManager.makeDirs(); mGameDataManager.moveFromLegacy(); final Window window = getActivity().getWindow(); // Enable full-screen mode window.setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN); window.setFlags(LayoutParams.FLAG_LAYOUT_IN_SCREEN, LayoutParams.FLAG_LAYOUT_IN_SCREEN); // Keep screen from going to sleep window.setFlags(LayoutParams.FLAG_KEEP_SCREEN_ON, LayoutParams.FLAG_KEEP_SCREEN_ON); mFirstStart = true; // Lay out content and get the views SurfaceView surfaceView = (SurfaceView) getView().findViewById(R.id.gameSurface); mOverlay = (GameOverlay) getView().findViewById(R.id.gameOverlay); mDrawerLayout = (GameDrawerLayout) getView().findViewById(R.id.drawerLayout); mGameSidebar = (GameSidebar) getView().findViewById(R.id.gameSidebar); // Don't darken the game screen when the drawer is open mDrawerLayout.setScrimColor(0x0); mDrawerLayout.setSwipGestureEnabled(mGlobalPrefs.inGameMenuIsSwipGesture); mDrawerLayout.setBackgroundColor(0xFF000000); if (!TextUtils.isEmpty(mRomArtPath) && new File(mRomArtPath).exists()) mGameSidebar.setImage(new BitmapDrawable(this.getResources(), mRomArtPath)); mGameSidebar.setTitle(mRomGoodName); // Handle events from the side bar mGameSidebar.setActionHandler(this, R.menu.game_drawer); // Listen to game surface events (created, changed, destroyed) surfaceView.getHolder().addCallback(this); // Update the SurfaceView size surfaceView.getHolder().setFixedSize(mGamePrefs.videoRenderWidth, mGamePrefs.videoRenderHeight); final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) surfaceView.getLayoutParams(); params.width = Math.round(mGamePrefs.videoSurfaceWidth * (mGamePrefs.videoSurfaceZoom / 100.f)); params.height = Math.round(mGamePrefs.videoSurfaceHeight * (mGamePrefs.videoSurfaceZoom / 100.f)); params.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; surfaceView.setLayoutParams(params); // Initialize the screen elements if (mGamePrefs.isTouchscreenEnabled || mGlobalPrefs.isFpsEnabled) { // The touch map and overlay are needed to display frame rate and/or controls mTouchscreenMap = new VisibleTouchMap(this.getResources()); mTouchscreenMap.load(mGamePrefs.touchscreenSkin, mGamePrefs.touchscreenProfile, mGlobalPrefs.isTouchscreenAnimated, mGlobalPrefs.isFpsEnabled, mGlobalPrefs.fpsXPosition, mGlobalPrefs.fpsYPosition, mGlobalPrefs.touchscreenScale, mGlobalPrefs.touchscreenTransparency); mOverlay.initialize(mCoreFragment, mTouchscreenMap, !mGamePrefs.isTouchscreenHidden, mGlobalPrefs.isFpsEnabled, mGamePrefs.isAnalogHiddenWhenSensor, mGlobalPrefs.isTouchscreenAnimated); } // Initialize user interface devices initControllers(mOverlay); // Override the peripheral controllers' key provider, to add some extra // functionality mOverlay.setOnKeyListener(this); mOverlay.requestFocus(); if (savedInstanceState == null) { // Show the drawer at the start and have it hide itself // automatically mDrawerLayout.openDrawer(GravityCompat.START); mDrawerLayout.postDelayed(new Runnable() { @Override public void run() { mDrawerLayout.closeDrawer(GravityCompat.START); } }, 1000); } if (mDrawerOpenState) { Log.e("CoreFragment", "Opening drawer"); mDrawerLayout.postDelayed(new Runnable() { @Override public void run() { mCoreFragment.pauseEmulator(); mDrawerLayout.openDrawer(GravityCompat.START); } }, 1000); } mDrawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() { @Override public void onDrawerClosed(View arg0) { if (!mShuttingDown) { mCoreFragment.resumeEmulator(); mDrawerOpenState = false; } } @Override public void onDrawerOpened(View arg0) { mCoreFragment.pauseEmulator(); ReloadAllMenus(); } @Override public void onDrawerSlide(View arg0, float arg1) { } @Override public void onDrawerStateChanged(int newState) { } }); // Check periodically for touch input to determine if we should // hide the controls mHandler = new Handler(); Calendar calendar = Calendar.getInstance(); mLastTouchTime = calendar.get(Calendar.SECOND); if (mGlobalPrefs.touchscreenAutoHideEnabled) mHandler.postDelayed(mLastTouchChecker, 500); //Callback for onWindowFocusChanged final ViewTreeObserver viewTreeObserver = getView().getViewTreeObserver(); viewTreeObserver.addOnWindowFocusChangeListener(this); //Callback for onGenericMotion getView().setOnGenericMotionListener(this); }