static void activateTab(Activity a, int id) { Intent intent = new Intent(Intent.ACTION_PICK); switch (id) { case R.id.artisttab: intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/artistalbum"); break; case R.id.albumtab: intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/album"); break; case R.id.songtab: intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track"); break; case R.id.playlisttab: intent.setDataAndType(Uri.EMPTY, MediaStore.Audio.Playlists.CONTENT_TYPE); break; case R.id.nowplayingtab: intent = new Intent(a, MediaPlaybackActivity.class); a.startActivity(intent); // fall through and return default: return; } intent.putExtra("withtabs", true); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); a.startActivity(intent); a.finish(); a.overridePendingTransition(0, 0); }
/** * Launch activity using custom animations. Uses ActivityOptions if on JellyBean, otherwise * overrides transition * * @param parent parent activity * @param intent intent to launch * @param animIn In animation * @param animOut Out animation */ public static void launchActivity(Activity parent, Intent intent, int animIn, int animOut) { if (isJellyBean()) parent.startActivity( intent, ActivityOptions.makeCustomAnimation(parent, animIn, animOut).toBundle()); else { parent.startActivity(intent); parent.overridePendingTransition(animIn, animOut); } }
public static void restartPC(final Activity activity) { if (activity == null) return; final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; activity.overridePendingTransition(enter_anim, exit_anim); activity.finish(); activity.overridePendingTransition(enter_anim, exit_anim); activity.startActivity(activity.getIntent()); }
/** * activity切换动画 * * @param m * @param isEnd */ @SuppressLint("NewApi") public static void runActivityAnim(Activity m, boolean isEnd) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.DONUT) { if (isEnd) { m.overridePendingTransition(R.anim.activity_close_enter, R.anim.activity_close_exit); } else { m.overridePendingTransition(R.anim.activity_open_enter, R.anim.activity_open_exit); } } }
@SuppressLint("NewApi") public static final void recreateActivityCompat(final Activity a) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { a.recreate(); } else { final Intent intent = a.getIntent(); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); a.finish(); a.overridePendingTransition(0, 0); a.startActivity(intent); a.overridePendingTransition(0, 0); } }
public static void refreshActivity(Activity activity) { activity.finish(); Intent intent = new Intent(activity, activity.getClass()); intent.putExtra(WAS_REFRESHED, true); activity.startActivity(intent); activity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); }
/** * 显示发帖页面 * * @param context */ public static void showMessagePub(Activity context, int catalog) { Intent intent = new Intent(); intent.setClass(context, MessagePub.class); intent.putExtra("catalog", catalog); context.startActivity(intent); context.overridePendingTransition(R.anim.workbook_in, R.anim.none); }
public static void startActivityForResult( Class<?> toClass, Bundle bundle, Activity fromActivity, int requstCode) { Intent intent = new Intent(fromActivity, toClass); if (bundle != null) intent.putExtras(bundle); fromActivity.startActivityForResult(intent, requstCode); fromActivity.overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out); }
@Override public void onClick(View view) { try { long genreId = genres.get(getAdapterPosition()).getId(); Context context = getActivity(); Intent mIntent = new Intent(context, PlaylistActivity.class); Bundle mBundle = new Bundle(); mBundle.putLong("id", genreId); mBundle.putLong("tagfor", PhoneMediaControl.SongsLoadFor.Genre.ordinal()); mBundle.putString( "albumname", ((TextView) view.findViewById(R.id.title)).getText().toString().trim()); mBundle.putString("title_one", "All my songs"); mBundle.putString( "title_sec", ((TextView) view.findViewById(R.id.details)).getText().toString().trim()); mIntent.putExtras(mBundle); context.startActivity(mIntent); ((Activity) context).overridePendingTransition(0, 0); } catch (Exception e) { Log.i(TAG, Log.getStackTraceString(e)); } }
/** * 跳转到下一页面 * * @param context * @param cls 转入页 * @param enterAnim * @param exitAnim * @param exit 是否关闭当前页 */ public static void mNext( Activity context, Class<?> cls, int enterAnim, int exitAnim, boolean exit) { context.startActivity(new Intent(context, cls)); if (exit) { context.finish(); } context.overridePendingTransition(enterAnim, exitAnim); }
@Override public void onClick(View v) { if (v.getTag() != null && "back".equals(v.getTag())) { activity.finish(); activity.overridePendingTransition( com.android.common.R.anim.next_zoomin, com.android.common.R.anim.back_zoomout); } }
public static void refreshActivity(Activity currentActivity) { Intent intent = new Intent(currentActivity, currentActivity.getClass()); currentActivity.startActivity(intent); currentActivity.finish(); currentActivity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); }
/** * Start a new Activity with a Split animation * * @param currActivity The current Activity * @param intent The Intent needed tot start the new Activity * @param splitYCoord The Y coordinate where we want to split the Activity on the animation. -1 * will split the Activity equally */ public static void startActivity(Activity currActivity, Intent intent, int splitYCoord) { // Preparing the bitmaps that we need to show prepare(currActivity, splitYCoord); currActivity.startActivity(intent); currActivity.overridePendingTransition(0, 0); // 禁止默认的跳转动画 }
public static void backActivity(Activity currentActivity, Class<?> activityClass) { Intent intent = new Intent(currentActivity, activityClass); currentActivity.startActivity(intent); currentActivity.finish(); currentActivity.overridePendingTransition( android.R.anim.slide_in_left, android.R.anim.slide_out_right); }
private static void startCameraActivity(Activity activity, String action) { Intent intent = new Intent(action); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); // Keep the camera instance for a while. // This avoids re-opening the camera and saves time. CameraHolder.instance().keep(); activity.startActivity(intent); activity.overridePendingTransition(NO_ANIMATION, NO_ANIMATION); }
private static void openGif(final boolean gfy, Activity contextActivity, String submission) { if (SettingValues.gif) { Intent myIntent = new Intent(contextActivity, GifView.class); if (gfy) { myIntent.putExtra(GifView.EXTRA_URL, "gfy" + submission); } else { myIntent.putExtra(GifView.EXTRA_URL, "" + submission); } contextActivity.startActivity(myIntent); contextActivity.overridePendingTransition(R.anim.slideright, R.anim.fade_out); } else { Reddit.defaultShare(submission, contextActivity); } }
public static void showReaderPhotoViewer( Activity activity, String imageUrl, boolean isPrivate, View source, int startX, int startY) { if (TextUtils.isEmpty(imageUrl)) { return; } Intent intent = new Intent(activity, ReaderPhotoViewerActivity.class); intent.putExtra(ReaderPhotoViewerActivity.ARG_IMAGE_URL, imageUrl); intent.putExtra(ReaderPhotoViewerActivity.ARG_IS_PRIVATE, isPrivate); // use built-in scale animation on jb+, fall back to our own animation on pre-jb if (source != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { ActivityOptionsCompat options = ActivityOptionsCompat.makeScaleUpAnimation(source, startX, startY, 0, 0); ActivityCompat.startActivity(activity, intent, options.toBundle()); } else { activity.startActivity(intent); activity.overridePendingTransition(R.anim.reader_photo_in, 0); } }
public static boolean handleOnItemSelected(MenuItem item, Context c) { Intent intent = null; switch (item.getItemId()) { case id.home: intent = new Intent(c, MainActivity.class); break; case id.rooms: intent = new Intent(c, RoomGestionActivity.class); break; case id.customers: intent = new Intent(c, CustomerGestionActivity.class); break; case id.bookings: intent = new Intent(c, BookingGestionActivity.class); break; case id.search: intent = new Intent(c, SearchActivity.class); break; default: ((Activity) c).finish(); } if (intent != null) { intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); } c.startActivity(intent); ((Activity) c) .overridePendingTransition( 0, c.getResources().getAnimation(anim.abc_fade_out).getAttributeCount()); return true; }
public static void startSimEditor(SettingsPreferenceFragment fragment, Bundle extras) { Activity activity = fragment.getActivity(); if (activity.getIntent().getBooleanExtra(EXTRA_IS_OOBE, false)) { Intent intent = new Intent(activity, SetupWizardForOobe.class); intent.putExtra(EXTRA_IS_OOBE, true); intent.putExtra(EXTRA_OOBE_SETTINGS, ID_SIM_INFO_EDITOR); intent.putExtra( OOBE_BASIC_STEP_TOTAL, activity.getIntent().getIntExtra(OOBE_BASIC_STEP_TOTAL, 1)); intent.putExtra( OOBE_BASIC_STEP_INDEX, activity.getIntent().getIntExtra(OOBE_BASIC_STEP_INDEX, 0)); intent.putExtras(extras); activity.startActivity(intent); activity.overridePendingTransition(R.anim.slide_right_in, R.anim.slide_left_out); } else { fragment.startFragment( fragment, SimInfoEditor.class.getCanonicalName(), -1, extras, R.string.gemini_sim_info_title); Xlog.i(TAG, "startFragment " + SimInfoEditor.class.getCanonicalName()); } }
protected void onPostExecute(Boolean deleted) { try { pDialog.dismiss(); Toast.makeText(context, "Save Complete", Toast.LENGTH_SHORT).show(); } catch (Exception e) { // not attached } SharedPreferences sharedPrefs = context.getSharedPreferences( "com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); sharedPrefs.edit().putBoolean("version_2_2_7_1", false).commit(); PreferenceManager.getDefaultSharedPreferences(context) .edit() .putBoolean("version_2_2_7_1", false) .commit(); ((Activity) context).finish(); context.startActivity(new Intent(context, MainActivity.class)); ((Activity) context).overridePendingTransition(0, 0); }
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String guid = (String) parent.getItemAtPosition(position); if (StringUtil.isEmpty(guid)) return; guid = guid.trim(); int pid = StringUtil.getUrlParameter(guid, "pid"); int tid = StringUtil.getUrlParameter(guid, "tid"); int authorid = StringUtil.getUrlParameter(guid, "authorid"); Intent intent = new Intent(); intent.putExtra("tab", "1"); intent.putExtra("tid", tid); intent.putExtra("pid", pid); intent.putExtra("authorid", authorid); if (fromreplyactivity) { intent.putExtra("fromreplyactivity", 1); } ListView listview = (ListView) parent; Object a = parent.getAdapter(); TopicListAdapter adapter = null; if (a instanceof TopicListAdapter) { adapter = (TopicListAdapter) a; } else if (a instanceof HeaderViewListAdapter) { HeaderViewListAdapter ha = (HeaderViewListAdapter) a; adapter = (TopicListAdapter) ha.getWrappedAdapter(); position -= ha.getHeadersCount(); } adapter.setSelected(position); listview.setItemChecked(position, true); intent.setClass(activity, PhoneConfiguration.getInstance().articleActivityClass); activity.startActivity(intent); if (PhoneConfiguration.getInstance().showAnimation) activity.overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit); }
static void start(@NonNull Activity activity, boolean shouldRefresh) { Intent intent = new Intent(activity, MainActivity.class); intent.putExtra(EXTRA_SHOULD_REFRESH, shouldRefresh); activity.startActivity(intent); activity.overridePendingTransition(R.anim.activity_fade_enter, R.anim.activity_fade_exit); }
public static void closeActivity(Activity activity) { activity.overridePendingTransition(R.anim.close_enter, R.anim.open_exit); }
public static void openSearchActivity(Activity context) { Intent searchIntent = new Intent(context, SearchActivity.class); context.startActivity(searchIntent); context.overridePendingTransition(R.anim.pull_in_left, R.anim.push_out_right); }
/** 退出动画结束时应该有的动画 */ protected void exitAnimsEnd() { mSceneRoot.setAlpha(0); mBackground.setAlpha(0); mActivity.finish(); mActivity.overridePendingTransition(0, 0); }
public static void GoToFatwa(int fatwaIndex, Activity context) { Intent fatwaIntent = new Intent(context, FatwaActivity.class); fatwaIntent.putExtra("FATWA_INDEX", String.valueOf(fatwaIndex)); context.startActivity(fatwaIntent); context.overridePendingTransition(R.anim.pull_in_left, R.anim.push_out_right); }
/** * 播放Activity切换时的切换动画效果<br> * 使用场景:紧挨着startActivity()或者finish()函数之后调用 */ public void playActivityChangeAnimation(Activity context, int enterAnim, int exitAnim) { context.overridePendingTransition(enterAnim, exitAnim); }
public static void enterFromBottomAnimation(Activity activity) { activity.overridePendingTransition( R.anim.activity_open_translate_from_bottom, R.anim.activity_no_animation); }
public static void exitToBottomAnimation(Activity activity) { activity.overridePendingTransition( R.anim.activity_no_animation, R.anim.activity_close_translate_to_bottom); }
public static void overridePendingTransitions(Activity paramActivity, int paramInt1, int paramInt2) { paramActivity.overridePendingTransition(paramInt1, paramInt2); }