List of usage examples for android.view Window setFlags
public void setFlags(int flags, int mask)
From source file:com.heneryh.aquanotes.ui.livestock.ContentFragment.java
/** Toggle whether the system UI (status bar / system bar) is visible. * This also toggles the action bar visibility. * @param show True to show the system UI, false to hide it. *//* w w w.ja va 2 s. c o m*/ void setSystemUiVisible(boolean show) { mSystemUiVisible = show; Window window = getActivity().getWindow(); WindowManager.LayoutParams winParams = window.getAttributes(); View view = getView(); // ActionBar actionBar = getActivity().getActionBar(); if (show) { // Show status bar (remove fullscreen flag) window.setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN); // Show system bar view.setSystemUiVisibility(View.STATUS_BAR_VISIBLE); // Show action bar // actionBar.show(); } else { // Add fullscreen flag (hide status bar) window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // Hide system bar view.setSystemUiVisibility(View.STATUS_BAR_HIDDEN); // Hide action bar // actionBar.hide(); } window.setAttributes(winParams); }
From source file:com.ericsun.duom.Framework.Activity.BaseActivity.java
private void createRootView(LayoutInflater inflater) { rootView = (ViewGroup) inflater.inflate(R.layout.layout_main, null); actionBarView = (ViewGroup) rootView.findViewById(R.id.layout_titleBar); contentView = (ViewGroup) rootView.findViewById(R.id.layout_content); setRootViewId(R.id.rootView);//from w w w .j av a2s.c o m if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); // Translucent status bar window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarAlpha(1); } rootView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { InputMethodManager imm = (InputMethodManager) ct.getSystemService(INPUT_METHOD_SERVICE); if (null != imm && null != getCurrentFocus()) { return imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); } return false; } }); }
From source file:com.nappking.movietimesup.HomeFragment.java
private void showDialogWithoutNotificationBar(String action, Bundle params) { // Create the dialog dialog = new WebDialog.Builder(getActivity(), Session.getActiveSession(), action, params) .setOnCompleteListener(new WebDialog.OnCompleteListener() { @Override/* www . ja va 2 s .c o m*/ public void onComplete(Bundle values, FacebookException error) { if (error != null && !(error instanceof FacebookOperationCanceledException)) { ((HomeActivity) getActivity()) .showError(getResources().getString(R.string.network_error), false); } dialog = null; dialogAction = null; dialogParams = null; } }).build(); // Hide the notification bar and resize to full screen Window dialog_window = dialog.getWindow(); dialog_window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // Store the dialog information in attributes dialogAction = action; dialogParams = params; // Show the dialog dialog.show(); }
From source file:com.zertinteractive.wallpaper.activities.DetailActivity.java
@SuppressWarnings("ConstantConditions") @Override/* w w w.j a v a 2s. c o m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initActivityTransitions(); setContentView(R.layout.activity_detail); String[] projection = { MediaStore.Images.Media._ID, MediaStore.Images.Media.BUCKET_DISPLAY_NAME, MediaStore.Images.Media.DISPLAY_NAME }; String selection = MediaStore.Images.Media.BUCKET_DISPLAY_NAME + " = ?"; String[] selectionArgs = new String[] { TEMP_WALLPAPER_DIR }; Cursor mImageCursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, selection, selectionArgs, null); mImageCursor.moveToFirst(); if (mImageCursor.getCount() == 1) { imageId = mImageCursor.getInt((mImageCursor.getColumnIndex(MediaStore.Images.Media._ID))); Log.e("CROP", "" + imageId); mImageCursor.close(); } checkDir(); timerTasks = new TimerTasks(context); ViewCompat.setTransitionName(findViewById(R.id.app_bar_layout), EXTRA_IMAGE_SMALL); supportPostponeEnterTransition(); superCategory = getIntent().getExtras().getInt(EXTRA_SUPER_CATEGORY); floatingActionButton = (FloatingActionButton) findViewById(R.id.fab_set_as_wallpaper); floatingActionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setAsWallpaper(imageId); } }); toolbar = ((Toolbar) findViewById(R.id.toolbar)); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); toolbar.setVisibility(View.GONE); String itemTitle = getIntent().getStringExtra(EXTRA_TITLE); progressBar = (ProgressBar) findViewById(R.id.progressBarImage); collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbarLayout.setTitle(itemTitle); collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(android.R.color.transparent)); imageView = (ImageView) findViewById(R.id.image); Picasso.with(this).load(getIntent().getStringExtra(EXTRA_IMAGE_SMALL)).into(imageView, new Callback() { @SuppressWarnings("NewApi") @Override public void onSuccess() { Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); float ImageHieghtTemp = bitmap.getHeight(); float ImageWidthTemp = bitmap.getWidth(); Point size = new Point(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getRealSize(size); float widthMain = size.x; float heightMain = size.y; imageView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); int addWidth = imageView.getMeasuredWidth(); // Display display = getWindowManager().getDefaultDisplay(); // float widthMain = display.getWidth(); // float heightMain = display.getHeight(); Log.e(LOG_TAG, "IMAGE_MAIN : " + ImageWidthTemp + " : " + ImageHieghtTemp); float imageHeight = widthMain * ((float) (bitmap.getHeight()) / (float) (bitmap.getWidth())); float scaleXY = heightMain / imageHeight; if (scaleXY > 1.0007f) { Log.e(LOG_TAG, "SCALE FACTORE : " + scaleXY + " : " + 1.10454545f * scaleXY); scaleXY = 1.8f * scaleXY; } PhotoViewAttacher mAttacherTest = new PhotoViewAttacher(imageView, true, false); mAttacherTest.setZoomScale(scaleXY); mAttacherTest.setScale(scaleXY, (widthMain) / 2, heightMain / 2, true); Log.e(LOG_TAG, "DETAILS : " + widthMain + " : " + heightMain + " : " + scaleXY + " : " + bitmap.getWidth() + " : " + bitmap.getHeight()); Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() { public void onGenerated(Palette palette) { applyPalette(palette); } }); } @Override public void onError() { } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window w = getWindow(); w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } // clearApplicationData(); new ImageLoadTask().execute(""); initDownloadComponents(); mAdView = (AdView) findViewById(R.id.adViewFullImage); mAdView.setVisibility(View.GONE); AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build(); // Start loading the ad in sthe background. mAdView.loadAd(adRequest); mAdView.setAdListener(new AdListener() { @Override public void onAdLoaded() { super.onAdLoaded(); mAdView.setVisibility(View.VISIBLE); } }); }
From source file:org.osm.keypadmapper2.KeypadMapper2Activity.java
@Override public void onAttachedToWindow() { super.onAttachedToWindow(); Window window = getWindow(); window.setFormat(PixelFormat.RGBA_8888); window.setFlags(WindowManager.LayoutParams.FLAG_DITHER, WindowManager.LayoutParams.FLAG_DITHER); Log.d(TAG, "attached to window"); }
From source file:paulscode.android.mupen64plusae.game.GameActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.i("GameActivity", "onCreate"); super.setTheme(android.support.v7.appcompat.R.style.Theme_AppCompat_NoActionBar); //Allow volume keys to control media volume if they are not mapped final SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(this); final boolean volKeyMapped = mPreferences.getBoolean("inputVolumeMappable", false); final AppData appData = new AppData(this); final GlobalPrefs globalPrefs = new GlobalPrefs(this, appData); if (!volKeyMapped && globalPrefs.audioPlugin.enabled) { setVolumeControlStream(AudioManager.STREAM_MUSIC); }//from ww w . j ava 2 s .co m mControllers = new ArrayList<>(); mMogaController = Controller.getInstance(this); // Get the intent data final Bundle extras = this.getIntent().getExtras(); if (extras == null) throw new Error("ROM path and MD5 must be passed via the extras bundle when starting GameActivity"); mRomPath = extras.getString(ActivityHelper.Keys.ROM_PATH); mRomMd5 = extras.getString(ActivityHelper.Keys.ROM_MD5); mRomCrc = extras.getString(ActivityHelper.Keys.ROM_CRC); String romHeaderName = extras.getString(ActivityHelper.Keys.ROM_HEADER_NAME); byte romCountryCode = extras.getByte(ActivityHelper.Keys.ROM_COUNTRY_CODE); String artPath = extras.getString(ActivityHelper.Keys.ROM_ART_PATH); String romGoodName = extras.getString(ActivityHelper.Keys.ROM_GOOD_NAME); String legacySaveName = extras.getString(ActivityHelper.Keys.ROM_LEGACY_SAVE); boolean doRestart = extras.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 GameActivity"); // Initialize MOGA controller API // TODO: Remove hack after MOGA SDK is fixed // mMogaController.init(); MogaHack.init(mMogaController, this); // Get app data and user preferences mGlobalPrefs = new GlobalPrefs(this, appData); mGamePrefs = new GamePrefs(this, mRomMd5, mRomCrc, romHeaderName, romGoodName, RomHeader.countryCodeToSymbol(romCountryCode), appData, mGlobalPrefs, legacySaveName); String cheatArgs = mGamePrefs.getCheatArgs(); mAutoSaveManager = new GameAutoSaveManager(mGamePrefs, mGlobalPrefs.maxAutoSaves); mGlobalPrefs.enforceLocale(this); final Window window = this.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); // Set the screen orientation this.setRequestedOrientation(mGlobalPrefs.displayOrientation); // If the orientation changes, the screensize info changes, so we must refresh dependencies mGlobalPrefs = new GlobalPrefs(this, appData); mGamePrefs = new GamePrefs(this, mRomMd5, mRomCrc, romHeaderName, romGoodName, RomHeader.countryCodeToSymbol(romCountryCode), appData, mGlobalPrefs, legacySaveName); mFirstStart = true; //TODO: Figure out why we call this in the middle super.onCreate(savedInstanceState); // Lay out content and get the views this.setContentView(R.layout.game_activity); mSurface = (GameSurface) this.findViewById(R.id.gameSurface); mOverlay = (GameOverlay) this.findViewById(R.id.gameOverlay); mDrawerLayout = (GameDrawerLayout) this.findViewById(R.id.drawerLayout); mGameSidebar = (GameSidebar) this.findViewById(R.id.gameSidebar); // Don't darken the game screen when the drawer is open mDrawerLayout.setScrimColor(0x0); // Make the background solid black mSurface.getRootView().setBackgroundColor(0xFF000000); mSurface.SetGameSurfaceCreatedListener(this); if (!TextUtils.isEmpty(artPath) && new File(artPath).exists()) mGameSidebar.setImage(new BitmapDrawable(this.getResources(), artPath)); mGameSidebar.setTitle(romGoodName); // Initialize the objects and data files interfacing to the emulator core CoreInterface.initialize(this, mSurface, mGamePrefs, mRomPath, mRomMd5, cheatArgs, doRestart); // Handle events from the side bar mGameSidebar.setActionHandler(this, R.menu.game_drawer); //Reload menus ReloadAllMenus(); // Listen to game surface events (created, changed, destroyed) mSurface.getHolder().addCallback(this); // Update the GameSurface size mSurface.getHolder().setFixedSize(mGamePrefs.videoRenderWidth, mGamePrefs.videoRenderHeight); final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mSurface.getLayoutParams(); params.width = Math.round(mGamePrefs.videoSurfaceWidth * (mGamePrefs.videoSurfaceZoom / 100.f)); params.height = Math.round(mGamePrefs.videoSurfaceHeight * (mGamePrefs.videoSurfaceZoom / 100.f)); if ((mGlobalPrefs.displayOrientation & 1) == 1) params.gravity = mGlobalPrefs.displayPosition | Gravity.CENTER_HORIZONTAL; else params.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; mSurface.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, mGamePrefs.isTouchscreenAnimated, mGlobalPrefs.isFpsEnabled, mGlobalPrefs.touchscreenScale, mGlobalPrefs.touchscreenTransparency); mOverlay.initialize(mTouchscreenMap, !mGamePrefs.isTouchscreenHidden, mGlobalPrefs.isFpsEnabled, mGamePrefs.isAnalogHiddenWhenSensor, mGamePrefs.isTouchscreenAnimated); } // Initialize user interface devices initControllers(mOverlay); // Override the peripheral controllers' key provider, to add some extra // functionality mOverlay.setOnKeyListener(this); 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); } mDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() { @Override public void onDrawerClosed(View arg0) { NativeExports.emuResume(); } @Override public void onDrawerOpened(View arg0) { NativeExports.emuPause(); ReloadAllMenus(); } @Override public void onDrawerSlide(View arg0, float arg1) { } @Override public void onDrawerStateChanged(int newState) { } }); }
From source file:com.devnoobs.bmr.MainActivity.java
@Override public void zmienReklamy(boolean stan) { //Toast toast = Toast.makeText(getApplicationContext(), "test",5 ); //toast.show(); if (stan == true) { adView.setVisibility(View.VISIBLE); adView.loadAd(new AdRequest()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window w = getWindow(); // in Activity's onCreate() for instance w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); // w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); //w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); }//from w ww. jav a2s . co m } else { adView.setVisibility(View.GONE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { super.setTheme(android.R.style.Theme_Holo_Light_NoActionBar_TranslucentDecor); Window w = getWindow(); w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); } } }
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(); }// w w w. j a v a2 s . c o m 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); }
From source file:com.wewow.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setMenuselectedPosition(0);//from w w w . ja va 2 s.com setContentView(R.layout.activity_main); String channel = channels[Integer.parseInt(BuildConfig.AUTO_TYPE)]; context = this; if (android.os.Build.VERSION.SDK_INT > 18) { Window window = getWindow(); window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } progressBar = (LinearLayout) findViewById(R.id.progressBar); progressBar.setVisibility(View.VISIBLE); mTabLayout = (TabLayout) findViewById(R.id.tabs); imageViewLine = (ImageView) findViewById(R.id.imageViewLine); layoutCoverTab = (RelativeLayout) findViewById(R.id.layoutCoverTab); viewPager = (ViewPager) findViewById(R.id.viewPager); float density = Utils.getSceenDensity(this); collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbar.setTitle(getResources().getString(R.string.home_page)); collapsingToolbar.setExpandedTitleColor(getResources().getColor(R.color.transparent)); collapsingToolbar.setCollapsedTitleTextColor(getResources().getColor(R.color.font_color)); initAppBar(); SettingUtils.set(this, CommonUtilities.NETWORK_STATE, false); //if banner data cached if (FileCacheUtil.isCacheDataExist(CommonUtilities.CACHE_FILE_BANNER, this)) { String fileContent = FileCacheUtil.getCache(this, CommonUtilities.CACHE_FILE_BANNER); List<Banner> banners = new ArrayList<Banner>(); try { banners = parseBannersFromString(fileContent); } catch (JSONException e) { e.printStackTrace(); } setUpViewPagerBanner(banners); } //if tab title cached if (FileCacheUtil.isCacheDataExist(CommonUtilities.CACHE_FILE_TAB_TITLE, this)) { String fileContent = FileCacheUtil.getCache(this, CommonUtilities.CACHE_FILE_TAB_TITLE); List<collectionCategory> categories = new ArrayList<collectionCategory>(); try { categories = parseCategoriesFromString(fileContent); } catch (JSONException e) { e.printStackTrace(); } if (Utils.isNetworkAvailable(this)) { setUpNavigationTabTitle(categories); } else { setUpNavigationTab(categories); } } if (Utils.isNetworkAvailable(this)) { //if banner data never cached or outdated if (channel.equals("baidu")) { AIUpdateSDK.updateCheck(MainActivity.this, new CheckUpdateCallback() { @Override public void onCheckUpdateCallback(UpdateInfo info) { if (info != null) { String[] strings = { info.getVersion() + ", " + Utils.byteToMb(info.getSize()), info.getChangeLog() }; if (info.isForceUpdate()) { MessageBoxUtils.messageBoxWithButtons(MainActivity.this, strings, new String[] { getString(R.string.auto_update) }, new Object[] { 0 }, new MessageBoxUtils.MsgboxButtonListener[] { new MessageBoxUtils.MsgboxButtonListener() { @Override public boolean shouldCloseMessageBox(Object tag) { return true; } @Override public void onClick(Object tag) { AIUpdateSDK.updateDownload(MainActivity.this); } } }); } else { MessageBoxUtils.messageBoxWithButtons(MainActivity.this, strings, new String[] { MainActivity.this.getString(R.string.auto_update), MainActivity.this.getString(R.string.do_no_udpate) }, new Object[] { 0, 1 }, new MessageBoxUtils.MsgboxButtonListener[] { new MessageBoxUtils.MsgboxButtonListener() { @Override public boolean shouldCloseMessageBox(Object tag) { return true; } @Override public void onClick(Object tag) { AIUpdateSDK.updateDownload(MainActivity.this); //UserInfoActivity.this.updateUserInfo(); } }, new MessageBoxUtils.MsgboxButtonListener() { @Override public boolean shouldCloseMessageBox(Object tag) { return true; } @Override public void onClick(Object tag) { } }, }); } } } }); } checkcacheUpdatedOrNot(); } else { Toast.makeText(this, getResources().getString(R.string.networkError), Toast.LENGTH_SHORT).show(); } // } setUpToolBar(); // setUpScrollView(); }
From source file:com.zertinteractive.wallpaper.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.e(LOG_TAG, "onCreate()"); setContentView(R.layout.activity_main); context = this; checkPermission();/*from w w w . j av a2s . c o m*/ DetailActivity.setContext(this); initDownloadComponents(); downloadTestImage(); initSearchGridView(); progressBar = (ProgressBar) findViewById(R.id.progressBarImageSearch); progressBar.setVisibility(View.GONE); searchQueryButton = (ImageView) findViewById(R.id.search_query_ok); searchQueryButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); in.hideSoftInputFromWindow(searchKey.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); searchActionMethod(); } }); searchKey = (EditText) findViewById(R.id.search_key); searchKey.setOnEditorActionListener(new TextView.OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // if (event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) { // InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // in.hideSoftInputFromWindow(searchKey.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); // Log.e("SEARCH", searchKey.getText().toString()); // } searchActionMethod(); return false; } }); searchQueryClear = (ImageView) findViewById(R.id.search_query_clear); searchQueryClear.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { searchKey.setText(""); } }); // Gets the ad view defined in layout/ad_fragment.xml with ad unit ID set in // values/strings.xml. mAdView = (AdView) findViewById(R.id.adView); mAdView.setVisibility(View.GONE); // mAdView.setScaleX(1.3f); AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build(); // Start loading the ad in sthe background. mAdView.loadAd(adRequest); mAdView.setAdListener(new AdListener() { @Override public void onAdLoaded() { super.onAdLoaded(); mAdView.setVisibility(View.VISIBLE); } }); // AdView mAdView = (AdView) findViewById(R.id.adView); // AdRequest adRequest = new AdRequest.Builder().build(); // mAdView.loadAd(adRequest); initWallpaperLists(); initRecyclerView(GRIDVIEW_COLUMN); initSearchView(); initFab(); initToolbar(); setupDrawerLayout(); setCategorySutter(false); categorySutterChange(1200); // setNotification(); setupWindowAnimations(); reminderCount = 0; timerTasks = new TimerTasks(context); timerTasks.startTimerTask(); currentWallpaperCategory = WallpaperCategory.ALL; DetailActivity.checkDir(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { setRecyclerAdapter(recyclerView, 0); currentWallpaperCategory = WallpaperCategory.ALL; } LinearLayout categoryHappyWallpaper = (LinearLayout) findViewById(R.id.category_happy); LinearLayout categorySadWallpaper = (LinearLayout) findViewById(R.id.category_sad); LinearLayout categorySurpriseWallpaper = (LinearLayout) findViewById(R.id.category_surprise); LinearLayout categoryAngryWallpaper = (LinearLayout) findViewById(R.id.category_angry); LinearLayout categoryFunnyWallpaper = (LinearLayout) findViewById(R.id.category_funny); LinearLayout categoryAmazedWallpaper = (LinearLayout) findViewById(R.id.category_amazed); categoryHappyWallpaper.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRecyclerAdapter(recyclerView, 1); currentWallpaperCategory = WallpaperCategory.HAPPY; } }); categorySadWallpaper.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRecyclerAdapter(recyclerView, 2); currentWallpaperCategory = WallpaperCategory.SAD; } }); categorySurpriseWallpaper.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRecyclerAdapter(recyclerView, 3); currentWallpaperCategory = WallpaperCategory.SURPRISE; } }); categoryAngryWallpaper.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRecyclerAdapter(recyclerView, 4); currentWallpaperCategory = WallpaperCategory.ANGRY; } }); categoryFunnyWallpaper.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRecyclerAdapter(recyclerView, 5); currentWallpaperCategory = WallpaperCategory.FUNNY; } }); categoryAmazedWallpaper.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRecyclerAdapter(recyclerView, 6); currentWallpaperCategory = WallpaperCategory.AMAZED; } }); ImageView category_daily = (ImageView) findViewById(R.id.category_daily); ImageView category_featured = (ImageView) findViewById(R.id.category_featured); ImageView category_favourite = (ImageView) findViewById(R.id.category_favourite); category_daily.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRecyclerAdapter(recyclerView, 7); currentWallpaperCategory = WallpaperCategory.DAILY; } }); category_featured.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRecyclerAdapter(recyclerView, 8); currentWallpaperCategory = WallpaperCategory.FEATURED; } }); category_favourite.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRecyclerAdapter(recyclerView, 9); currentWallpaperCategory = WallpaperCategory.FAVOURITE; } }); LinearLayout categoryWallpaper = (LinearLayout) findViewById(R.id.categoryButtonArrow); LinearLayout categoryAllWallpaper = (LinearLayout) findViewById(R.id.categoryWallpaper); LinearLayout kidsyWallpaperAction = (LinearLayout) findViewById(R.id.kidsyWallpaperAction); LinearLayout keepCalmWallpaperAction = (LinearLayout) findViewById(R.id.keepCalmWallpaperAction); LinearLayout romanticWallpaperAction = (LinearLayout) findViewById(R.id.romanticWallpaperAction); LinearLayout materialWallpaperAction = (LinearLayout) findViewById(R.id.materialWallpaperAction); categoryAllWallpaper.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setRecyclerAdapter(recyclerView, 0); currentWallpaperCategory = WallpaperCategory.ALL; } }); categoryWallpaper.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { categorySutterChange(600); // YoYo.with(Techniques.RotateAntiClockWise) // .duration(300) // .interpolate(new AccelerateDecelerateInterpolator()) // .withListener(new Animator.AnimatorListener() { // @Override // public void onAnimationStart(Animator animation) { // // } // // @Override // public void onAnimationEnd(Animator animation) { // // } // // @Override // public void onAnimationCancel(Animator animation) { // Toast.makeText(MainActivity.this, "canceled", Toast.LENGTH_SHORT).show(); // } // // @Override // public void onAnimationRepeat(Animator animation) { // // } // }) // .playOn(findViewById(R.id.categoryButtonArrow)); } }); kidsyWallpaperAction.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { openUri(PLAY_STORE_URL); } }); keepCalmWallpaperAction.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { openUri(PLAY_STORE_URL); } }); romanticWallpaperAction.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { openUri(PLAY_STORE_URL); } }); materialWallpaperAction.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { openUri(PLAY_STORE_URL); } }); // Button button = (Button) findViewById(R.id.testButton); // button.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Roboto-LightItalic.ttf"); // SnackbarManager.show( // SnackBar.with(MainActivity.this) // .text("Something has been done") // .actionLabel("Undo") // .margin(15, 15) // .backgroundDrawable(R.drawable.custom_shape) // .actionLabelTypeface(tf) // .actionListener(new ActionClickListener() { // @Override // public void onActionClicked(SnackBar snackBar) { // Toast.makeText(MainActivity.this, // "Action undone", // Toast.LENGTH_SHORT).show(); // } // })); // } // }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window w = getWindow(); w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } else { // do something for lower version } recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); if (dy > 0 && isSearchOn && !isSearchAnimationRunning) { isSearchOn = false; isSearchAnimationRunning = true; YoYo.with(Techniques.ZoomOutPosition).duration(500) .interpolate(new AccelerateDecelerateInterpolator()) .withListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { fabSearchWallpaper.setVisibility(View.GONE); isSearchAnimationRunning = false; } @Override public void onAnimationCancel(Animator animation) { Toast.makeText(MainActivity.this, "canceled", Toast.LENGTH_SHORT).show(); } @Override public void onAnimationRepeat(Animator animation) { } }).playOn(findViewById(R.id.fab_search_wallpaper)); } else if (dy < 0 && !isSearchOn && !isSearchAnimationRunning) { isSearchOn = true; isSearchAnimationRunning = true; fabSearchWallpaper.setVisibility(View.VISIBLE); YoYo.with(Techniques.ZoomInPosition).duration(500) .interpolate(new AccelerateDecelerateInterpolator()) .withListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { isSearchAnimationRunning = false; } @Override public void onAnimationCancel(Animator animation) { Toast.makeText(MainActivity.this, "canceled", Toast.LENGTH_SHORT).show(); } @Override public void onAnimationRepeat(Animator animation) { } }).playOn(findViewById(R.id.fab_search_wallpaper)); } } }); }