List of usage examples for android.app Activity startActivity
@Override public void startActivity(Intent intent, @Nullable Bundle options)
From source file:com.android.tv.dvr.ui.DvrUiHelper.java
/** * Shows the details activity for the DVR items. The type of DVR items may be * {@link ScheduledRecording}, {@link RecordedProgram}, or {@link SeriesRecording}. *///from w w w .j a v a2 s . c om public static void startDetailsActivity(Activity activity, Object dvrItem, @Nullable ImageView imageView, boolean hideViewSchedule) { if (dvrItem == null) { return; } Intent intent = new Intent(activity, DvrDetailsActivity.class); long recordingId; int viewType; if (dvrItem instanceof ScheduledRecording) { ScheduledRecording schedule = (ScheduledRecording) dvrItem; recordingId = schedule.getId(); if (schedule.getState() == ScheduledRecording.STATE_RECORDING_NOT_STARTED) { viewType = DvrDetailsActivity.SCHEDULED_RECORDING_VIEW; } else if (schedule.getState() == ScheduledRecording.STATE_RECORDING_IN_PROGRESS) { viewType = DvrDetailsActivity.CURRENT_RECORDING_VIEW; } else { return; } } else if (dvrItem instanceof RecordedProgram) { recordingId = ((RecordedProgram) dvrItem).getId(); viewType = DvrDetailsActivity.RECORDED_PROGRAM_VIEW; } else if (dvrItem instanceof SeriesRecording) { recordingId = ((SeriesRecording) dvrItem).getId(); viewType = DvrDetailsActivity.SERIES_RECORDING_VIEW; } else { return; } intent.putExtra(DvrDetailsActivity.RECORDING_ID, recordingId); intent.putExtra(DvrDetailsActivity.DETAILS_VIEW_TYPE, viewType); intent.putExtra(DvrDetailsActivity.HIDE_VIEW_SCHEDULE, hideViewSchedule); Bundle bundle = null; if (imageView != null) { bundle = ActivityOptionsCompat .makeSceneTransitionAnimation(activity, imageView, DvrDetailsActivity.SHARED_ELEMENT_NAME) .toBundle(); } activity.startActivity(intent, bundle); }
From source file:com.amazon.android.navigator.Navigator.java
/** * Start activity./*w w w. ja v a 2 s . com*/ * * @param currentActivity Current activity reference. * @param screenName Screen name. * @param providedBundle Provided bundle. */ private void startActivity(Activity currentActivity, String screenName, Bundle providedBundle, ActivitySwitchListener activitySwitchListener) { Class newActivityClass = mScreenNameClassMap.get(screenName); if (mCurrentActivity == null) { Log.d(TAG, "mCurrentActivity is null, switching to:" + screenName); Intent intent = new Intent(); intent.setComponent(new ComponentName(mContext, newActivityClass)); if (activitySwitchListener != null) { activitySwitchListener.onPreActivitySwitch(intent); } mContext.startActivity(intent); return; } Intent intent = new Intent(currentActivity, newActivityClass); if (activitySwitchListener != null) { activitySwitchListener.onPreActivitySwitch(intent); } Bundle bundle = providedBundle; IActivityTransition activityTransition = null; if (currentActivity instanceof IActivityTransition) { activityTransition = (IActivityTransition) currentActivity; activityTransition.onBeforeActivityTransition(); } Log.d(TAG, "Activity: " + getActivityName(currentActivity) + " is starting a new " + "activity" + intent); if (bundle != null) { currentActivity.startActivity(intent, bundle); } else { currentActivity.startActivity(intent); } if (activityTransition != null) { activityTransition.onPostStartActivity(); } }
From source file:jahirfiquitiva.iconshowcase.fragments.WallpapersFragment.java
private static void setupLayout(final boolean fromTask, final Activity context, final ImageView noConnection) { if (WallpapersList.getWallpapersList() != null && WallpapersList.getWallpapersList().size() > 0) { context.runOnUiThread(new Runnable() { @Override//from ww w . java 2 s. c o m public void run() { mAdapter = new WallpapersAdapter(context, new WallpapersAdapter.ClickListener() { @Override public void onClick(WallpapersAdapter.WallsHolder view, int position, boolean longClick) { if ((longClick && !ShowcaseActivity.wallsPicker) || ShowcaseActivity.wallsPicker) { final MaterialDialog dialog = new MaterialDialog.Builder(context) .content(R.string.downloading_wallpaper).progress(true, 0).cancelable(false) .show(); WallpaperItem wallItem = WallpapersList.getWallpapersList().get(position); Glide.with(context).load(wallItem.getWallURL()).asBitmap() .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(final Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { if (resource != null) { new ApplyWallpaper(context, dialog, resource, ShowcaseActivity.wallsPicker, layout).execute(); } } }); } else { final Intent intent = new Intent(context, ViewerActivity.class); intent.putExtra("item", WallpapersList.getWallpapersList().get(position)); intent.putExtra("transitionName", ViewCompat.getTransitionName(view.wall)); Bitmap bitmap; if (view.wall.getDrawable() != null) { bitmap = Utils.drawableToBitmap(view.wall.getDrawable()); try { String filename = "temp.png"; FileOutputStream stream = context.openFileOutput(filename, Context.MODE_PRIVATE); bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); stream.close(); intent.putExtra("image", filename); } catch (Exception e) { Utils.showLog(context, "Error getting drawable " + e.getLocalizedMessage()); } ActivityOptionsCompat options = ActivityOptionsCompat .makeSceneTransitionAnimation(context, view.wall, ViewCompat.getTransitionName(view.wall)); context.startActivity(intent, options.toBundle()); } else { context.startActivity(intent); } } } }); mAdapter.setData(WallpapersList.getWallpapersList()); mRecyclerView.setAdapter(mAdapter); fastScroller = (RecyclerFastScroller) layout.findViewById(R.id.rvFastScroller); fastScroller.attachRecyclerView(mRecyclerView); if (fastScroller.getVisibility() != View.VISIBLE) { fastScroller.setVisibility(View.VISIBLE); } if (Utils.hasNetwork(context)) { hideProgressBar(); noConnection.setVisibility(View.GONE); mRecyclerView.setVisibility(View.VISIBLE); fastScroller.setVisibility(View.VISIBLE); mSwipeRefreshLayout.setEnabled(false); mSwipeRefreshLayout.setRefreshing(false); } else { hideStuff(noConnection); } } }); } else { context.runOnUiThread(new Runnable() { @Override public void run() { if (layout != null) { noConnection.setVisibility(View.GONE); showProgressBar(); Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { context.runOnUiThread(new Runnable() { @Override public void run() { hideStuff(noConnection); } }); } }, 7500); } } }); } }