List of usage examples for android.app ActivityOptions makeCustomAnimation
public static ActivityOptions makeCustomAnimation(Context context, int enterResId, int exitResId)
From source file:com.aware.Aware_Preferences.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mSensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE); //Start the Aware Intent startAware = new Intent(getApplicationContext(), Aware.class); startService(startAware);//w w w . jav a 2 s . c om addPreferencesFromResource(R.xml.aware_preferences); setContentView(R.layout.aware_ui); navigationDrawer = (DrawerLayout) findViewById(R.id.aware_ui_main); navigationList = (ListView) findViewById(R.id.aware_navigation); navigationToggle = new ActionBarDrawerToggle(this, navigationDrawer, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); if (Build.VERSION.SDK_INT > 11) { getActionBar().setTitle(getTitle()); invalidateOptionsMenu(); } } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); if (Build.VERSION.SDK_INT > 11) { getActionBar().setTitle(getTitle()); invalidateOptionsMenu(); } } }; navigationDrawer.setDrawerListener(navigationToggle); String[] options = { "Stream", "Sensors", "Plugins", "Studies" }; NavigationAdapter nav_adapter = new NavigationAdapter(getApplicationContext(), options); navigationList.setAdapter(nav_adapter); navigationList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { LinearLayout item_container = (LinearLayout) view.findViewById(R.id.nav_container); item_container.setBackgroundColor(Color.DKGRAY); for (int i = 0; i < navigationList.getChildCount(); i++) { if (i != position) { LinearLayout other = (LinearLayout) navigationList.getChildAt(i); LinearLayout other_item = (LinearLayout) other.findViewById(R.id.nav_container); other_item.setBackgroundColor(Color.TRANSPARENT); } } Bundle animations = ActivityOptions.makeCustomAnimation(Aware_Preferences.this, R.anim.anim_slide_in_left, R.anim.anim_slide_out_left).toBundle(); switch (position) { case 0: //Stream Intent stream_ui = new Intent(Aware_Preferences.this, Stream_UI.class); startActivity(stream_ui, animations); break; case 1: //Sensors Intent sensors_ui = new Intent(Aware_Preferences.this, Aware_Preferences.class); startActivity(sensors_ui, animations); break; case 2: //Plugins Intent plugin_manager = new Intent(Aware_Preferences.this, Plugins_Manager.class); startActivity(plugin_manager, animations); break; case 3: //Studies if (Aware.getSetting(getApplicationContext(), "study_id").length() > 0) { new Async_StudyData().execute( Aware.getSetting(getApplicationContext(), Aware_Preferences.WEBSERVICE_SERVER)); } else { Intent join_study = new Intent(Aware_Preferences.this, CameraStudy.class); startActivityForResult(join_study, REQUEST_JOIN_STUDY, animations); } break; } navigationDrawer.closeDrawer(navigationList); } }); if (getActionBar() != null) { getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); } SharedPreferences prefs = getSharedPreferences(getPackageName(), Context.MODE_PRIVATE); if (prefs.getAll().isEmpty() && Aware.getSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID).length() == 0) { is_first_time = true; PreferenceManager.setDefaultValues(getApplicationContext(), getPackageName(), Context.MODE_PRIVATE, R.xml.aware_preferences, true); prefs.edit().commit(); //commit changes } else { PreferenceManager.setDefaultValues(getApplicationContext(), getPackageName(), Context.MODE_PRIVATE, R.xml.aware_preferences, false); } Map<String, ?> defaults = prefs.getAll(); for (Map.Entry<String, ?> entry : defaults.entrySet()) { if (Aware.getSetting(getApplicationContext(), entry.getKey()).length() == 0) { Aware.setSetting(getApplicationContext(), entry.getKey(), entry.getValue()); } } if (Aware.getSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID).length() == 0) { UUID uuid = UUID.randomUUID(); Aware.setSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID, uuid.toString()); } }
From source file:ca.zadrox.dota2esportticker.ui.MatchDetailActivity.java
private void updateContentFromSAPI(DotaGameData[] data) { String tOn = teamLeftName;/*from w w w. j a va 2 s . co m*/ String tTn = teamRightName; long matchId = 0; if (data != null && data.length != 0) { for (DotaGameData gameData : data) { if (gameData.getType() != DotaGameData.LIVE_DATA) { continue; } gameData = (Game) gameData; if (((Game) gameData).dire_team != null && ((Game) gameData).radiant_team != null) { String sRn = ((Game) gameData).radiant_team.team_name; String sDn = ((Game) gameData).dire_team.team_name; if (StringUtils.areTeamsPlaying(tOn, tTn, sRn, sDn)) { matchId = ((Game) gameData).match_id; break; } } } } if (matchId == 0) { return; } final MessageCardView mSteamCard = (MessageCardView) mDetailsContainer.findViewById(R.id.card_live_stats); mSteamCard.show(); final Intent viewLiveGameDetails = new Intent(this, LiveGameStatsActivity.class); viewLiveGameDetails.putExtra(LiveGameStatsActivity.ARGS_GAME_TLL, teamLeftFlagUrl); viewLiveGameDetails.putExtra(LiveGameStatsActivity.ARGS_GAME_TLR, teamRightFlagUrl); viewLiveGameDetails.putExtra(LiveGameStatsActivity.ARGS_GAME_BO, bestOf); viewLiveGameDetails.putExtra(LiveGameStatsActivity.ARGS_GAME_TNL, teamLeftName); viewLiveGameDetails.putExtra(LiveGameStatsActivity.ARGS_GAME_TNR, teamRightName); viewLiveGameDetails.putExtra(LiveGameStatsActivity.ARGS_GAME_TN, tournamentName); viewLiveGameDetails.putExtra(LiveGameStatsActivity.ARGS_GAME_MID, matchId); mSteamCard.setListener(new MessageCardView.OnMessageCardButtonClicked() { @Override public void onMessageCardButtonClicked(String tag) { if ("VIEW_NOW".equals(tag)) { startActivity(viewLiveGameDetails, ActivityOptions .makeCustomAnimation(mContext, R.anim.anim_slide_in, R.anim.anim_scale_out).toBundle()); } else { mSteamCard.dismiss(true); } } }); }
From source file:com.android.leanlauncher.LauncherTransitionable.java
boolean startActivity(View v, Intent intent, Object tag) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try {/*from ww w .j av a2s .c om*/ // Only launch using the new animation if the shortcut has not opted out (this is a // private contract between launcher and may be ignored in the future). boolean useLaunchAnimation = (v != null) && !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION); LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(this); UserManagerCompat userManager = UserManagerCompat.getInstance(this); UserHandleCompat user = null; if (intent.hasExtra(AppInfo.EXTRA_PROFILE)) { long serialNumber = intent.getLongExtra(AppInfo.EXTRA_PROFILE, -1); user = userManager.getUserForSerialNumber(serialNumber); } Bundle optsBundle = null; if (useLaunchAnimation) { ActivityOptions opts = Utilities.isLmpOrAbove() ? ActivityOptions.makeCustomAnimation(this, R.anim.task_open_enter, R.anim.no_anim) : ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getMeasuredWidth(), v.getMeasuredHeight()); optsBundle = opts.toBundle(); } if (user == null || user.equals(UserHandleCompat.myUserHandle())) { // Could be launching some bookkeeping activity startActivity(intent, optsBundle); } else { // TODO Component can be null when shortcuts are supported for secondary user launcherApps.startActivityForProfile(intent.getComponent(), user, intent.getSourceBounds(), optsBundle); } return true; } catch (SecurityException e) { Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); Log.e(TAG, "Launcher does not have the permission to launch " + intent + ". Make sure to create a MAIN intent-filter for the corresponding activity " + "or use the exported attribute for this activity. " + "tag=" + tag + " intent=" + intent, e); } return false; }
From source file:com.klinker.android.launcher.launcher3.Launcher.java
private boolean startActivity(View v, Intent intent, Object tag) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try {//w w w .j ava 2 s. c o m // Only launch using the new animation if the shortcut has not opted out (this is a // private contract between launcher and may be ignored in the future). boolean useLaunchAnimation = (v != null) && !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION); LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(this); UserManagerCompat userManager = UserManagerCompat.getInstance(this); UserHandleCompat user = null; if (intent.hasExtra(AppInfo.EXTRA_PROFILE)) { long serialNumber = intent.getLongExtra(AppInfo.EXTRA_PROFILE, -1); user = userManager.getUserForSerialNumber(serialNumber); } Bundle optsBundle = null; if (useLaunchAnimation) { ActivityOptions opts = null; if (sClipRevealMethod != null) { // TODO: call method directly when Launcher3 can depend on M APIs int left = 0, top = 0; int width = v.getMeasuredWidth(), height = v.getMeasuredHeight(); if (v instanceof TextView) { // Launch from center of icon, not entire view Drawable icon = Workspace.getTextViewIcon((TextView) v); if (icon != null) { Rect bounds = icon.getBounds(); left = (width - bounds.width()) / 2; top = v.getPaddingTop(); width = bounds.width(); height = bounds.height(); } } try { opts = (ActivityOptions) sClipRevealMethod.invoke(null, v, left, top, width, height); } catch (IllegalAccessException e) { Log.d(TAG, "Could not call makeClipRevealAnimation: " + e); sClipRevealMethod = null; } catch (InvocationTargetException e) { Log.d(TAG, "Could not call makeClipRevealAnimation: " + e); sClipRevealMethod = null; } } if (opts == null && !Utilities.isLmpOrAbove()) { // Below L, we use a scale up animation opts = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getMeasuredWidth(), v.getMeasuredHeight()); } else if (opts == null && Utilities.isLmpMR1()) { // On L devices, we use the device default slide-up transition. // On L MR1 devices, we a custom version of the slide-up transition which // doesn't have the delay present in the device default. opts = ActivityOptions.makeCustomAnimation(this, R.anim.task_open_enter, R.anim.no_anim); } optsBundle = opts != null ? opts.toBundle() : null; } if (user == null || user.equals(UserHandleCompat.myUserHandle())) { // Could be launching some bookkeeping activity startActivity(intent, optsBundle); } else { // TODO Component can be null when shortcuts are supported for secondary user launcherApps.startActivityForProfile(intent.getComponent(), user, intent.getSourceBounds(), optsBundle); } return true; } catch (SecurityException e) { Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); Log.e(TAG, "Launcher does not have the permission to launch " + intent + ". Make sure to create a MAIN intent-filter for the corresponding activity " + "or use the exported attribute for this activity. " + "tag=" + tag + " intent=" + intent, e); } return false; }
From source file:xyz.klinker.blur.launcher3.Launcher.java
private boolean startActivity(View v, Intent intent, Object tag) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try {//from w w w . j a v a 2 s. c om // Only launch using the new animation if the shortcut has not opted out (this is a // private contract between launcher and may be ignored in the future). boolean useLaunchAnimation = (v != null) && !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION); LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(this); UserManagerCompat userManager = UserManagerCompat.getInstance(this); UserHandleCompat user = null; if (intent.hasExtra(AppInfo.EXTRA_PROFILE)) { long serialNumber = intent.getLongExtra(AppInfo.EXTRA_PROFILE, -1); user = userManager.getUserForSerialNumber(serialNumber); } Bundle optsBundle = null; if (useLaunchAnimation) { ActivityOptions opts = null; if (Utilities.ATLEAST_MARSHMALLOW) { int left = 0, top = 0; int width = v.getMeasuredWidth(), height = v.getMeasuredHeight(); if (v instanceof TextView) { // Launch from center of icon, not entire view Drawable icon = Workspace.getTextViewIcon((TextView) v); if (icon != null) { Rect bounds = icon.getBounds(); left = (width - bounds.width()) / 2; top = v.getPaddingTop(); width = bounds.width(); height = bounds.height(); } } opts = ActivityOptions.makeClipRevealAnimation(v, left, top, width, height); } else if (!Utilities.ATLEAST_LOLLIPOP) { // Below L, we use a scale up animation opts = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getMeasuredWidth(), v.getMeasuredHeight()); } else if (Utilities.ATLEAST_LOLLIPOP_MR1) { // On L devices, we use the device default slide-up transition. // On L MR1 devices, we a custom version of the slide-up transition which // doesn't have the delay present in the device default. opts = ActivityOptions.makeCustomAnimation(this, R.anim.task_open_enter, R.anim.no_anim); } optsBundle = opts != null ? opts.toBundle() : null; } if (user == null || user.equals(UserHandleCompat.myUserHandle())) { StrictMode.VmPolicy oldPolicy = StrictMode.getVmPolicy(); try { // Temporarily disable deathPenalty on all default checks. For eg, shortcuts // containing file Uris would cause a crash as penaltyDeathOnFileUriExposure // is enabled by default on NYC. StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build()); // Could be launching some bookkeeping activity startActivity(intent, optsBundle); } finally { StrictMode.setVmPolicy(oldPolicy); } } else { // TODO Component can be null when shortcuts are supported for secondary user launcherApps.startActivityForProfile(intent.getComponent(), user, intent.getSourceBounds(), optsBundle); } return true; } catch (SecurityException e) { if (Utilities.ATLEAST_MARSHMALLOW && tag instanceof ItemInfo) { // Due to legacy reasons, direct call shortcuts require Launchers to have the // corresponding permission. Show the appropriate permission prompt if that // is the case. if (intent.getComponent() == null && Intent.ACTION_CALL.equals(intent.getAction()) && checkSelfPermission( Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { // TODO: Rename sPendingAddItem to a generic name. sPendingAddItem = preparePendingAddArgs(REQUEST_PERMISSION_CALL_PHONE, intent, 0, (ItemInfo) tag); requestPermissions(new String[] { Manifest.permission.CALL_PHONE }, REQUEST_PERMISSION_CALL_PHONE); return false; } } Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); Log.e(TAG, "Launcher does not have the permission to launch " + intent + ". Make sure to create a MAIN intent-filter for the corresponding activity " + "or use the exported attribute for this activity. " + "tag=" + tag + " intent=" + intent, e); } return false; }
From source file:com.android.launcher3.Launcher.java
private Bundle getActivityLaunchOptions(View v) { if (Utilities.ATLEAST_MARSHMALLOW) { int left = 0, top = 0; int width = v.getMeasuredWidth(), height = v.getMeasuredHeight(); if (v instanceof TextView) { // Launch from center of icon, not entire view Drawable icon = Workspace.getTextViewIcon((TextView) v); if (icon != null) { Rect bounds = icon.getBounds(); left = (width - bounds.width()) / 2; top = v.getPaddingTop(); width = bounds.width();//from w w w . j a v a 2s . c o m height = bounds.height(); } } return ActivityOptions.makeClipRevealAnimation(v, left, top, width, height).toBundle(); } else if (Utilities.ATLEAST_LOLLIPOP_MR1) { // On L devices, we use the device default slide-up transition. // On L MR1 devices, we use a custom version of the slide-up transition which // doesn't have the delay present in the device default. return ActivityOptions.makeCustomAnimation(this, R.anim.task_open_enter, R.anim.no_anim).toBundle(); } return null; }