List of usage examples for android.content Intent ACTION_MAIN
String ACTION_MAIN
To view the source code for android.content Intent ACTION_MAIN.
Click Source Link
From source file:com.samsung.multiwindow.MultiWindow.java
/** * Executes the request and returns PluginResult. * /* w w w. j av a 2 s . c o m*/ * @param action * The action to be executed. * @param args * JSONArray of arguments for the plugin. * @param callbackContext * The callback id used when calling back into JavaScript. * @return A PluginResult object with a status and message. */ public boolean execute(String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException { int ret = -1; try { // window type argument index is same in all cases of // createmultiwindow windowType = args.getString(mainFsOptions.WINDOW_TYPE.ordinal()); // Do not allow apis if metadata is missing if (!pluginMetadata) { callbackContext.error("METADATA_MISSING"); Log.e("MultiWindow", "Metadata is missing"); return false; } // Verify the multiwindow capability of the device ret = intializeMultiwindow(); if (ret != INIT_SUCCESS) { switch (ret) { case SsdkUnsupportedException.VENDOR_NOT_SUPPORTED: callbackContext.error("VENDOR_NOT_SUPPORTED"); break; case SsdkUnsupportedException.DEVICE_NOT_SUPPORTED: callbackContext.error("DEVICE_NOT_SUPPORTED"); break; default: callbackContext.error("MUTLI_WINDOW_INITIALIZATION_FAILED"); break; } return false; } if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) { Log.d(TAG, "Multiwindow initialization is successful" + ret); } // Check window support windowSupport = isMultiWindowSupported(windowType); if (windowType.equalsIgnoreCase("freestyle")) { if (!windowSupport) { callbackContext.error("FREE_STYLE_NOT_SUPPORTED"); } } else if (windowType.equalsIgnoreCase("splitstyle")) { if (!windowSupport) { callbackContext.error("SPLIT_STYLE_NOT_SUPPORTED"); } } else { callbackContext.error("INVALID_WINDOW_TYPE"); } if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) { Log.d(TAG, "MultiWindow window type Supported:" + windowSupport); } // Get zone info in case of split style if (windowSupport && (action.equals("action_main") || action.equals("action_view"))) { if (windowType.equalsIgnoreCase("splitstyle")) { switch (args.optInt(mainSsOptions.ZONE_INFO.ordinal())) { case ZONE_A: Log.d(TAG, "Zone A selected"); zoneInfo = SMultiWindowActivity.ZONE_A; break; case ZONE_B: Log.d(TAG, "Zone B selected"); zoneInfo = SMultiWindowActivity.ZONE_B; break; case ZONE_FULL: Log.d(TAG, "Zone Full selected"); zoneInfo = SMultiWindowActivity.ZONE_FULL; break; default: Log.d(TAG, "Zone is not selected"); callbackContext.error("INVALID_ZONEINFO"); return false; } } } } catch (Exception e) { callbackContext.error(e.getMessage()); } if (action.equals("action_main")) { if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) { Log.d(TAG, "Action is action_main"); } if (!windowSupport) { return false; } cordova.getThreadPool().execute(new Runnable() { public void run() { Intent intent = new Intent(Intent.ACTION_MAIN); int packageNameIndex = 0; int activityNameIndex = 0; float scaleInfo = 0; int zoneInfo = getZoneInfo(); String windowType = getWindowType(); if (windowType.equalsIgnoreCase("splitstyle")) { packageNameIndex = mainSsOptions.PACKAGE_NAME.ordinal(); activityNameIndex = mainSsOptions.ACTIVITY_NAME.ordinal(); } else { packageNameIndex = mainFsOptions.PACKAGE_NAME.ordinal(); activityNameIndex = mainFsOptions.ACTIVITY_NAME.ordinal(); } try { intent.setComponent(new ComponentName(args.getString(packageNameIndex), args.getString(activityNameIndex))); if (windowType.equalsIgnoreCase("splitstyle")) { SMultiWindowActivity.makeMultiWindowIntent(intent, zoneInfo); } else { scaleInfo = ((float) args.getDouble(mainFsOptions.SCALE_INFO.ordinal())) / 100; if (scaleInfo < 0.6 || scaleInfo > 1.0) { callbackContext.error("INVALID_SCALEINFO"); return; } SMultiWindowActivity.makeMultiWindowIntent(intent, scaleInfo); } } catch (Exception e) { // May be JSONException callbackContext.error(e.getMessage()); } try { cordova.getActivity().startActivity(intent); } catch (ActivityNotFoundException activityNotFound) { callbackContext.error("ACTIVITY_NOT_FOUND"); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0)); } }); return true; } else if (action.equals("action_view")) { if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) { Log.d(TAG, "Action is action_view"); } if (!windowSupport) { return false; } cordova.getThreadPool().execute(new Runnable() { public void run() { int dataUriIndex = 0; float scaleInfo = 0; Intent dataUrl = null; String windowType = getWindowType(); int zoneInfo = getZoneInfo(); if (windowType.equalsIgnoreCase("splitstyle")) { dataUriIndex = viewSsOptions.DATA_URI.ordinal(); } else { dataUriIndex = viewFsOptions.DATA_URI.ordinal(); } String dataUri = null; try { dataUri = args.getString(dataUriIndex); } catch (JSONException e) { e.printStackTrace(); } if (dataUri == null || dataUri.equals("") || dataUri.equals("null")) { callbackContext.error("INVALID_DATA_URI"); return; } else { boolean isUriProper = false; for (String schema : URI_SCHEMA_SUPPORTED) { if (dataUri.startsWith(schema)) { isUriProper = true; break; } } if (!isUriProper) { callbackContext.error("INVALID_DATA_URI"); return; } } try { dataUrl = new Intent(Intent.ACTION_VIEW, Uri.parse(dataUri)); if (windowType.equalsIgnoreCase("splitstyle")) { SMultiWindowActivity.makeMultiWindowIntent(dataUrl, zoneInfo); } else { scaleInfo = ((float) args.getDouble(viewFsOptions.SCALE_INFO.ordinal())) / 100; if (scaleInfo < 0.6 || scaleInfo > 1.0) { callbackContext.error("INVALID_SCALEINFO"); return; } SMultiWindowActivity.makeMultiWindowIntent(dataUrl, scaleInfo); } } catch (Exception e) { // May be JSONException callbackContext.error(e.getMessage()); } try { if (dataUrl != null) { cordova.getActivity().startActivity(dataUrl); } } catch (ActivityNotFoundException activityNotFound) { callbackContext.error("ACTIVITY_NOT_FOUND"); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0)); } }); return true; } else if (action.equals("action_check")) { if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) { Log.d(TAG, "Action is action_check"); } if (windowSupport) { callbackContext.success(); } return true; } else if (action.equals("action_getapps")) { if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) { Log.d(TAG, "Action is action_getapps"); } if (!windowSupport) { return false; } getMultiWindowApps(windowType, callbackContext); return true; } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, 0)); return false; }
From source file:com.anjalimacwan.MainActivity.java
private void checkForAndroidWear() { // Notepad Plugin for Android Wear sends intent with "plugin_install_complete" extra, // in order to verify that the main Notepad app is installed correctly if (getIntent().hasExtra("plugin_install_complete")) { if (getSupportFragmentManager().findFragmentByTag("WearPluginDialogFragmentAlt") == null) { DialogFragment wearDialog = new WearPluginDialogFragmentAlt(); wearDialog.show(getSupportFragmentManager(), "WearPluginDialogFragmentAlt"); }/*from ww w. ja va2s.co m*/ SharedPreferences pref = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE); SharedPreferences.Editor editor = pref.edit(); editor.putBoolean("show_wear_dialog", false); editor.apply(); } else { boolean hasAndroidWear = false; @SuppressWarnings("unused") PackageInfo pInfo; try { pInfo = getPackageManager().getPackageInfo("com.google.android.wearable.app", 0); hasAndroidWear = true; } catch (PackageManager.NameNotFoundException e) { /* Gracefully fail */ } if (hasAndroidWear) { try { pInfo = getPackageManager().getPackageInfo("com.anjalimacwan.wear", 0); Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(ComponentName .unflattenFromString("com.anjalimacwan.wear/com.anjalimacwan.wear.MobileMainActivity")); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } catch (PackageManager.NameNotFoundException e) { SharedPreferences pref = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE); if (pref.getBoolean("show_wear_dialog", true) && getSupportFragmentManager().findFragmentByTag("WearPluginDialogFragment") == null) { DialogFragment wearDialog = new WearPluginDialogFragment(); wearDialog.show(getSupportFragmentManager(), "WearPluginDialogFragment"); } } catch (ActivityNotFoundException e) { /* Gracefully fail */ } } } }
From source file:com.murati.oszk.audiobook.ui.MusicPlayerActivity.java
protected void initializeFromParams(Bundle savedInstanceState, Intent intent) { String mediaId = null;/*from w w w. j av a 2 s . com*/ String action = intent.getAction(); Bundle extras = intent.getExtras(); if (action != null) { switch (action) { case Intent.ACTION_SEARCH: case MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH: LogHelper.d(TAG, "Starting Search Handler"); mSearchParams = intent.getExtras(); mediaId = MediaIDHelper.createMediaID(mSearchParams.getString(SearchManager.QUERY), MediaIDHelper.MEDIA_ID_BY_SEARCH); LogHelper.d(TAG, "Search query=", mediaId); break; case Intent.ACTION_VIEW: if (extras != null) mediaId = extras.getString(MediaIDHelper.EXTRA_MEDIA_ID_KEY); LogHelper.d(TAG, "MediaId fetched=", mediaId); break; case Intent.ACTION_MAIN: default: break; } } else { if (savedInstanceState != null) { // If there is a saved media ID, use it mediaId = savedInstanceState.getString(MediaIDHelper.EXTRA_MEDIA_ID_KEY); } } navigateToBrowser(mediaId); }
From source file:com.miz.service.MovieLibraryUpdate.java
private void setup() { LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(mMessageReceiver, new IntentFilter(STOP_MOVIE_LIBRARY_UPDATE)); // Set up cancel dialog intent Intent notificationIntent = new Intent(this, CancelLibraryUpdate.class); notificationIntent.putExtra("isMovie", true); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent contentIntent = PendingIntent.getActivity(this, NOTIFICATION_ID, notificationIntent, 0); // Setup up notification mBuilder = new NotificationCompat.Builder(getApplicationContext()); mBuilder.setColor(getResources().getColor(R.color.color_primary)); mBuilder.setPriority(NotificationCompat.PRIORITY_MAX); mBuilder.setSmallIcon(R.drawable.ic_sync_white_24dp); mBuilder.setTicker(getString(R.string.updatingMovies)); mBuilder.setContentTitle(getString(R.string.updatingMovies)); mBuilder.setContentText(getString(R.string.gettingReady)); mBuilder.setContentIntent(contentIntent); mBuilder.setOngoing(true);/*from w w w.jav a 2 s.c o m*/ mBuilder.setOnlyAlertOnce(true); mBuilder.addAction(R.drawable.ic_close_white_24dp, getString(android.R.string.cancel), contentIntent); // Build notification Notification updateNotification = mBuilder.build(); // Show the notification mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(NOTIFICATION_ID, updateNotification); // Tell the system that this is an ongoing notification, so it shouldn't be killed startForeground(NOTIFICATION_ID, updateNotification); mSettings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); mClearLibrary = mSettings.getBoolean(CLEAR_LIBRARY_MOVIES, false); mClearUnavailable = mSettings.getBoolean(REMOVE_UNAVAILABLE_FILES_MOVIES, false); mSyncLibraries = mSettings.getBoolean(SYNC_WITH_TRAKT, true); }
From source file:leoisasmendi.android.com.suricatepodcast.MainActivity.java
@Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { Log.d(TAG, "onNavigationItemSelected: "); int id = item.getItemId(); Intent intent;/*w ww.j av a 2 s. c o m*/ switch (id) { case R.id.menu_main: intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); case R.id.menu_search: showSearchFragment(); return true; case R.id.menu_about: showAbout(); return true; case R.id.menu_item_share: Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); String shareBodyText = getString(R.string.share_body_text); // TODO: INSERT THE CORRECT URL // sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "www.audiosear.ch/audio.mp3"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBodyText); startActivity(Intent.createChooser(sharingIntent, "Shearing Option")); return true; case R.id.menu_exit: intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); default: return false; } }
From source file:com.adguard.android.commons.BrowserUtils.java
private static ComponentName getSamsungBrowser(Context context) { Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> installedPackages = context.getPackageManager().queryIntentActivities(mainIntent, 0); ArrayList<ActivityInfo> samsungActivities = new ArrayList<>(); for (ResolveInfo installedPackage : installedPackages) { if (installedPackage.activityInfo.packageName.startsWith(SAMSUNG_BROWSER_PACKAGE)) { samsungActivities.add(installedPackage.activityInfo); }/* w w w.j a va 2s . co m*/ } if (CollectionUtils.isNotEmpty(samsungActivities)) { Collections.sort(samsungActivities, new Comparator<ActivityInfo>() { @Override public int compare(ActivityInfo lhs, ActivityInfo rhs) { return lhs.packageName.compareTo(rhs.packageName); } }); ActivityInfo activityInfo = samsungActivities.get(0); return new ComponentName(activityInfo.packageName, activityInfo.name); } return null; }
From source file:at.jclehner.rxdroid.NotificationReceiver.java
private PendingIntent createOperation(Bundle extras) { Intent intent = new Intent(mContext, NotificationReceiver.class); intent.setAction(Intent.ACTION_MAIN); if (extras != null) intent.putExtras(extras);//w w w .j av a 2 s .c om return PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); }
From source file:com.amaze.filemanager.activities.Preferences.java
@Override public void onBackPressed() { if (select == 1 && changed == 1) restartPC(this); else if (select == 1 || select == 2) { selectItem(0);//from ww w. jav a 2 s . com } else { Intent in = new Intent(Preferences.this, MainActivity.class); in.setAction(Intent.ACTION_MAIN); final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; Activity activity = this; activity.overridePendingTransition(enter_anim, exit_anim); activity.finish(); activity.overridePendingTransition(enter_anim, exit_anim); activity.startActivity(in); } }
From source file:com.teocci.utubinbg.BackgroundAudioService.java
/** * Builds notification panel with buttons and info on it * * @param action Action to be applied/*from w w w .j av a 2 s . c o m*/ */ private void buildNotification(NotificationCompat.Action action) { final NotificationCompat.MediaStyle style = new NotificationCompat.MediaStyle(); Intent intent = new Intent(getApplicationContext(), BackgroundAudioService.class); intent.setAction(ACTION_STOP); PendingIntent stopPendingIntent = PendingIntent.getService(getApplicationContext(), 1, intent, 0); Intent clickIntent = new Intent(this, MainActivity.class); clickIntent.setAction(Intent.ACTION_MAIN); clickIntent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent clickPendingIntent = PendingIntent.getActivity(this, 0, clickIntent, 0); builder = new NotificationCompat.Builder(this); builder.setSmallIcon(R.mipmap.utubinbg_icon); builder.setContentTitle(videoItem.getTitle()); builder.setContentInfo(videoItem.getDuration()); builder.setShowWhen(false); builder.setContentIntent(clickPendingIntent); builder.setDeleteIntent(stopPendingIntent); builder.setOngoing(false); builder.setSubText(videoItem.getViewCount()); builder.setStyle(style); //load bitmap for largeScreen if (videoItem.getThumbnailURL() != null && !videoItem.getThumbnailURL().isEmpty()) { Picasso.with(this).load(videoItem.getThumbnailURL()).into(target); } builder.addAction(generateAction(android.R.drawable.ic_media_previous, "Previous", ACTION_PREVIOUS)); builder.addAction(action); builder.addAction(generateAction(android.R.drawable.ic_media_next, "Next", ACTION_NEXT)); style.setShowActionsInCompactView(0, 1, 2); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(1, builder.build()); }
From source file:info.papdt.blacklight.ui.main.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { mLang = Utility.getCurrentLanguage(this); if (mLang > -1) { Utility.changeLanguage(this, mLang); }// w w w . j a v a 2 s . co m Utility.initDarkMode(this); mLayout = R.layout.main; super.onCreate(savedInstanceState); // Initialize views mDrawer = Utility.findViewById(this, R.id.drawer); mDrawerWrapper = Utility.findViewById(this, R.id.drawer_wrapper); mName = Utility.findViewById(this, R.id.account_name); mAvatar = Utility.findViewById(this, R.id.my_avatar); mCover = Utility.findViewById(this, R.id.my_cover); mPager = Utility.findViewById(this, R.id.main_pager); mTabs = Utility.findViewById(this, R.id.main_tabs); mTabsWrapper = Utility.findViewById(this, R.id.main_tab_wrapper); mToolbarTabs = Utility.findViewById(this, R.id.top_tab); mToolbarWrapper = Utility.findViewById(this, R.id.toolbar_wrapper); mTopWrapper = Utility.findViewById(this, R.id.top_wrapper); mShadow = Utility.findViewById(this, R.id.action_shadow); mSetting = Utility.findViewById(this, R.id.drawer_settings); mMultiUser = Utility.findViewById(this, R.id.drawer_multiuser); mAccountSwitch = Utility.findViewById(this, R.id.account_switch); mAccountSwitchIcon = Utility.findViewById(this, R.id.account_switch_icon); mSearchBox = Utility.findViewById(this, R.id.main_search); final String[] pages = getResources().getStringArray(R.array.main_tabs); mPager.setAdapter(new FragmentStatePagerAdapter(getFragmentManager()) { @Override public int getCount() { return pages.length; } @Override public Fragment getItem(int position) { return mFragments[position]; } @Override public CharSequence getPageTitle(int position) { return pages[position]; } }); mPager.setOffscreenPageLimit(pages.length); mTabs.setViewPager(mPager); // Search Box mSearchHistory = new SearchHistoryCache(this); mSearchBox.setLogoText(getString(R.string.search)); mSearchBox.setSearchListener(new SearchBox.SearchListener() { @Override public void onSearchOpened() { } @Override public void onSearchCleared() { } @Override public void onSearchClosed() { mSearchBox.hideCircularly(MainActivity.this); } @Override public void onSearchTermChanged() { } @Override public void onSearch(String result) { mSearchHistory.addHistory(result); Intent i = new Intent(Intent.ACTION_MAIN); i.setClass(MainActivity.this, SearchActivity.class); i.putExtra("keyword", result); startActivity(i); } }); // Initialize toolbar custom view mTopWrapper.setAlpha(0f); final Drawable[] pageIcons = new Drawable[] { getResources().getDrawable(R.drawable.ic_drawer_home), getResources().getDrawable(R.drawable.ic_drawer_comment), getResources().getDrawable(R.drawable.ic_drawer_at), getResources().getDrawable(R.drawable.ic_drawer_at), getResources().getDrawable(R.drawable.ic_drawer_pm), getResources().getDrawable(R.drawable.ic_drawer_fav) }; mToolbarTabs.setIconAdapter(new SlidingTabLayout.TabIconAdapter() { @Override public Drawable getIcon(int position) { return pageIcons[position]; } }); mToolbarTabs.setViewPager(mPager, mTabs); // Prepare listener to be set later final ViewPager.OnPageChangeListener pageListener = new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { if (position + 1 >= mFragments.length) return; Fragment cur = mFragments[position]; Fragment next = mFragments[position + 1]; float factorCur = 0, factorNext = 0; if (cur instanceof HeaderProvider) { factorCur = ((HeaderProvider) cur).getHeaderFactor(); } if (next instanceof HeaderProvider) { factorNext = ((HeaderProvider) next).getHeaderFactor(); } float factor = factorCur + positionOffset * (factorNext - factorCur); updateHeaderTranslation(factor); } @Override public void onPageSelected(int pos) { } @Override public void onPageScrollStateChanged(int state) { } }; final int color = getResources().getColor(R.color.white); SlidingTabStrip.SimpleTabColorizer colorizer = new SlidingTabStrip.SimpleTabColorizer() { @Override public int getIndicatorColor(int position) { return color; } @Override public int getSelectedTitleColor(int position) { return color; } }; mTabs.setCustomTabColorizer(colorizer); mTabs.notifyIndicatorColorChanged(); mToolbarTabs.setCustomTabColorizer(colorizer); mToolbarTabs.notifyIndicatorColorChanged(); mToolbarTabs.setOnClickCurrentTabListener(new SlidingTabLayout.OnClickCurrentTabListener() { @Override public void onClick(int pos) { Fragment f = mFragments[pos]; if (f instanceof Refresher) { ((Refresher) f).goToTop(); } } }); if (Build.VERSION.SDK_INT >= 21) { mToolbar.setElevation(0); //findViewById(R.id.main_tab_wrapper).setElevation(getToolbarElevation()); } else { mShadow.setAlpha(0); } // Detect if the user chose to use right-handed mode boolean rightHanded = Settings.getInstance(this).getBoolean(Settings.RIGHT_HANDED, false); mDrawerGravity = rightHanded ? Gravity.RIGHT : Gravity.LEFT; //set GroupFragmentCallBack GroupFragment.setGfCallBack(new GroupFragment.GFCallBack() { @Override public void onItemClick() { openOrCloseDrawer(); } }); // Set gravity View nav = findViewById(R.id.nav); DrawerLayout.LayoutParams p = (DrawerLayout.LayoutParams) nav.getLayoutParams(); p.gravity = mDrawerGravity; nav.setLayoutParams(p); // Semi-transparent statusbar over drawer if (Build.VERSION.SDK_INT >= 21) { mDrawer.setStatusBarBackgroundColor(Utility.getColorPrimaryDark(this)); } // Initialize naviagtion drawer //mDrawer = (DrawerLayout) findViewById(R.id.drawer); mToggle = new ActionBarDrawerToggle(this, mDrawer, mToolbar, 0, 0) { @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); invalidateOptionsMenu(); hideFAB(); } @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); invalidateOptionsMenu(); } }; mToggle.setDrawerIndicatorEnabled(true); mDrawer.setDrawerListener(mToggle); // Use system shadow for Lollipop but fall back for pre-L if (Build.VERSION.SDK_INT >= 21) { nav.setElevation(10.0f); } else if (mDrawerGravity == Gravity.LEFT) { mDrawer.setDrawerShadow(R.drawable.drawer_shadow, Gravity.LEFT); } // My account initUserAccount(); //new GroupsTask().execute(); // Initialize FAB mFAB = new FloatingActionButton.Builder(this).withGravity(Gravity.BOTTOM | Gravity.RIGHT) .withPaddings(0, 0, 16, 16).withDrawable(Utility.getFABNewIcon(this)) .withButtonColor(Utility.getFABBackground(this)).withButtonSize(56 + 16).create(); mFAB.setOnClickListener(this); mFAB.setOnLongClickListener(this); // Bind Utility.bindOnClick(this, mSetting, "settings"); Utility.bindOnClick(this, mAccountSwitch, "drawerSwitch"); Utility.bindOnClick(this, mMultiUser, "muser"); Utility.bindOnClick(this, mCover, "showMe"); // Initialize ActionBar Style getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setDisplayUseLogoEnabled(false); getSupportActionBar().setDisplayShowTitleEnabled(true); // Drawer Groups getFragmentManager().beginTransaction().add(R.id.drawer_group, mGroupFragment) .add(R.id.drawer_group, mMultiUserFragment).show(mGroupFragment).hide(mMultiUserFragment).commit(); updateSplashes(); // Ignore first spinner event mIgnore = true; mToolbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { updateSplashes(); } }); // Adjust drawer layout params mDrawerWrapper.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { mHeaderHeight = mTabs.getHeight() + 10; mWrapperHeight = mTabsWrapper.getHeight(); if (DEBUG) { Log.d(TAG, "Global layout. Wrapper height: " + mWrapperHeight); } mToolbarTabs.setOnPageChangeListener(pageListener); mToolbarTabs.setTabIconSize(mToolbar.getHeight()); if (mWrapperHeight > 0) mDrawerWrapper.getViewTreeObserver().removeGlobalOnLayoutListener(this); } }); MultiUserFragment.setMuCallBack(new MultiUserFragment.MuCallBack() { @Override public void syncAccount() { initUserAccount(); ((HomeTimeLineFragment) mFragments[0]).doRefresh(); drawerSwitch(); mMultiUserFragment.reload(); } @Override public void closeDrawer() { openOrCloseDrawer(); } }); }