Example usage for android.content Intent FLAG_ACTIVITY_NO_ANIMATION

List of usage examples for android.content Intent FLAG_ACTIVITY_NO_ANIMATION

Introduction

In this page you can find the example usage for android.content Intent FLAG_ACTIVITY_NO_ANIMATION.

Prototype

int FLAG_ACTIVITY_NO_ANIMATION

To view the source code for android.content Intent FLAG_ACTIVITY_NO_ANIMATION.

Click Source Link

Document

If set in an Intent passed to Context#startActivity Context.startActivity() , this flag will prevent the system from applying an activity transition animation to go to the next activity state.

Usage

From source file:com.daiv.android.twitter.listeners.InteractionClickListener.java

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    HoloTextView title = (HoloTextView) view.findViewById(R.id.title);
    String mTitle = title.getText().toString();

    HoloTextView text = (HoloTextView) view.findViewById(R.id.text);
    String mText = text.getText().toString();

    // get the datasource ready to read/write
    InteractionsDataSource data = InteractionsDataSource.getInstance(context);

    if (mTitle.contains(context.getResources().getString(R.string.mentioned_by))) { // this is a mention
        if (MainDrawerArrayAdapter.current < 3) {
            new Handler().postDelayed(new Runnable() {
                @Override/*from   ww  w.j av  a2 s  .  co m*/
                public void run() {
                    try {
                        drawer.closeDrawer(Gravity.END);
                    } catch (Exception e) {
                        // landscape mode
                    }
                }
            }, 300);

            viewPager.setCurrentItem((mentionsPage), true);
        } else {
            final int pos = i;
            try {
                drawer.closeDrawer(Gravity.END);
            } catch (Exception e) {
                // landscape mode
            }
            new Thread(new Runnable() {
                @Override
                public void run() {
                    Intent intent = new Intent(context, MainActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                    intent.putExtra("page_to_open", mentionsPage);
                    intent.putExtra("from_drawer", true);

                    sharedPreferences.edit().putBoolean("should_refresh", false).commit();

                    try {
                        Thread.sleep(400);
                    } catch (Exception e) {

                    }

                    try {
                        context.startActivity(intent);
                        ((Activity) context).overridePendingTransition(0, 0);
                        ((Activity) context).finish();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
            }).start();
        }
    } else if (mTitle.contains(context.getResources().getString(R.string.retweeted))
            || mTitle.contains(context.getResources().getString(R.string.favorited))
            || mTitle.contains(context.getResources().getString(R.string.quoted))
            || mTitle.contains(context.getResources().getString(R.string.new_favorites))
            || mTitle.contains(context.getResources().getString(R.string.new_retweets))
            || mTitle.contains(context.getResources().getString(R.string.new_quotes))) { // it is a retweet or favorite

        try {
            drawer.closeDrawer(Gravity.END);
        } catch (Exception e) {
            // landscape mode
        }

        // open up the dialog with the users that retweeted it

        final String[] fItems = data
                .getUsers(sharedPreferences.getInt("current_account", 1), i,
                        DrawerActivity.oldInteractions.getText().toString()
                                .equals(context.getResources().getString(R.string.old_interactions)))
                .split(" ");

        LayoutInflater factory = LayoutInflater.from(context);
        View content = factory.inflate(R.layout.interaction_dialog, null);

        TextView textView = (TextView) content.findViewById(R.id.text);
        textView.setText(mText);

        ListView lv = (ListView) content.findViewById(R.id.list);
        lv.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_selectable_list_item, fItems));

        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setView(content);

        AlertDialog alert = builder.create();
        alert.show();
    } else if (mTitle.contains(context.getResources().getString(R.string.followed))) { // someone new followed you

        try {
            drawer.closeDrawer(Gravity.END);
        } catch (Exception e) {
            // landscape mode
        }

        // a new follower, open up the followers profile
        String username = mTitle.substring(mTitle.indexOf("@") + 1, mTitle.indexOf(" "));
    } else if (mTitle.contains(context.getResources().getString(R.string.tweeted))) {
        try {
            drawer.closeDrawer(Gravity.END);
        } catch (Exception e) {
            // landscape mode
        }

        // a new follower, open up the followers profile
        String username = mTitle.substring(mTitle.indexOf("@") + 1, mTitle.indexOf(" "));
    }

    // mark it read in the sql database
    data.markRead(sharedPreferences.getInt("current_account", 1), i);

    // tell the system to refresh the notifications when the user opens the drawer again
    sharedPreferences.edit().putBoolean("new_notification", true).commit();
}

From source file:com.btmura.android.reddit.app.GlobalMenuFragment.java

public boolean onQueryTextSubmit(String query) {
    if (listener != null && listener.submitQuery(query)) {
        searchItem.collapseActionView();
    } else {//  w  ww. j  av  a2  s. co  m
        Intent intent = new Intent(getActivity(), SearchActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NO_ANIMATION);
        intent.putExtra(SearchActivity.EXTRA_SUBREDDIT, subredditNameHolder.getSubreddit());
        intent.putExtra(SearchActivity.EXTRA_QUERY, query);
        startActivityForResult(intent, REQUEST_SEARCH);
    }
    return true;
}

From source file:com.example.administrator.myapplication2._2_exercise._2_End._2_EndMain.java

@Override
public void onBackPressed() {
    //Set Class to Top of App and no history
    Intent launchNextActivity;/*  w ww. jav a 2  s .  co m*/
    launchNextActivity = new Intent(this, Main.class);
    launchNextActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    launchNextActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    launchNextActivity.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    startActivity(launchNextActivity);
}

From source file:com.klinker.android.twitter.listeners.InteractionClickListener.java

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    HoloTextView title = (HoloTextView) view.findViewById(R.id.title);
    String mTitle = title.getText().toString();

    HoloTextView text = (HoloTextView) view.findViewById(R.id.text);
    String mText = text.getText().toString();

    // get the datasource ready to read/write
    InteractionsDataSource data = InteractionsDataSource.getInstance(context);

    if (mTitle.contains(context.getResources().getString(R.string.mentioned_by))) { // this is a mention
        if (MainDrawerArrayAdapter.current < 3) {
            new Handler().postDelayed(new Runnable() {
                @Override/*from w  w w. j  a va2  s.c o  m*/
                public void run() {
                    try {
                        drawer.closeDrawer(Gravity.END);
                    } catch (Exception e) {
                        // landscape mode
                    }
                }
            }, 300);

            viewPager.setCurrentItem((1 + extraPages), true);
        } else {
            final int pos = i;
            try {
                drawer.closeDrawer(Gravity.END);
            } catch (Exception e) {
                // landscape mode
            }
            new Thread(new Runnable() {
                @Override
                public void run() {
                    Intent intent = new Intent(context, MainActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                    intent.putExtra("page_to_open", (1 + extraPages));
                    intent.putExtra("from_drawer", true);

                    sharedPreferences.edit().putBoolean("should_refresh", false).commit();

                    try {
                        Thread.sleep(400);
                    } catch (Exception e) {

                    }

                    try {
                        context.startActivity(intent);
                        ((Activity) context).overridePendingTransition(0, 0);
                        ((Activity) context).finish();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
            }).start();
        }
    } else if (mTitle.contains(context.getResources().getString(R.string.retweeted))
            || mTitle.contains(context.getResources().getString(R.string.favorited))
            || mTitle.contains(context.getResources().getString(R.string.new_favorites))
            || mTitle.contains(context.getResources().getString(R.string.new_retweets))) { // it is a retweet or favorite

        try {
            drawer.closeDrawer(Gravity.END);
        } catch (Exception e) {
            // landscape mode
        }

        // open up the dialog with the users that retweeted it

        final String[] fItems = data
                .getUsers(sharedPreferences.getInt("current_account", 1), i,
                        DrawerActivity.oldInteractions.getText().toString()
                                .equals(context.getResources().getString(R.string.old_interactions)))
                .split(" ");

        LayoutInflater factory = LayoutInflater.from(context);
        View content = factory.inflate(R.layout.interaction_dialog, null);

        TextView textView = (TextView) content.findViewById(R.id.text);
        textView.setText(mText);

        ListView lv = (ListView) content.findViewById(R.id.list);
        lv.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_selectable_list_item, fItems));
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
                String touched = fItems[item];

                Intent user = new Intent(context, ProfilePager.class);
                user.putExtra("screenname", touched.replace("@", "").replace(" ", ""));
                user.putExtra("proPic", "");
                context.startActivity(user);
            }
        });

        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setView(content);

        AlertDialog alert = builder.create();
        alert.show();
    } else if (mTitle.contains(context.getResources().getString(R.string.followed))) { // someone new followed you

        try {
            drawer.closeDrawer(Gravity.END);
        } catch (Exception e) {
            // landscape mode
        }

        // a new follower, open up the followers profile
        String username = mTitle.substring(mTitle.indexOf("@") + 1, mTitle.indexOf(" "));

        Intent user = new Intent(context, ProfilePager.class);
        user.putExtra("screenname", username);
        user.putExtra("proPic", "");
        context.startActivity(user);
    } else if (mTitle.contains(context.getResources().getString(R.string.tweeted))) {
        try {
            drawer.closeDrawer(Gravity.END);
        } catch (Exception e) {
            // landscape mode
        }

        // a new follower, open up the followers profile
        String username = mTitle.substring(mTitle.indexOf("@") + 1, mTitle.indexOf(" "));

        Intent user = new Intent(context, ProfilePager.class);
        user.putExtra("screenname", username);
        user.putExtra("proPic", "");
        context.startActivity(user);
    }

    // mark it read in the sql database
    data.markRead(sharedPreferences.getInt("current_account", 1), i);

    // tell the system to refresh the notifications when the user opens the drawer again
    sharedPreferences.edit().putBoolean("new_notification", true).commit();
}

From source file:fi.iki.murgo.irssinotifier.IrssiNotifierActivity.java

public void restart() {
    Intent intent = getIntent();/* w w  w. ja va 2 s .  c  o m*/
    overridePendingTransition(0, 0);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    finish();

    overridePendingTransition(0, 0);
    startActivity(intent);
}

From source file:nz.co.android.cowseye2.activity.RecordLocationActivity.java

@Override
protected void nextActivety() {
    if (hasAllDetails()) {
        // Intent intent = buildLocationDataIntent(RESULT_OK);
        // startActivity(intent);
        if (dialog != null)
            dialog.dismiss();//from   ww w  .  ja va  2  s  .co m
        if (addressCoordinates != null)
            submissionEventBuilder.setGeoCoordinates(addressCoordinates);
        startActivity(new Intent(RecordLocationActivity.this, PreviewActivity.class)
                .addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION));

        // get coordinates from address location
        // dialog = ProgressDialog.show(LocationActivity.this,
        // "Acquiring coordinates from address", "Please wait...");
        // TODO DO NOT
        // new GeoCodeCoordinatesService(LocationActivity.this,
        // gpsManager.getGeoCoder(),
        // addressEditText.getText().toString().trim()).execute();
    } else
        Toast.makeText(RecordLocationActivity.this, getResources().getString(R.string.nocoordinates),
                Toast.LENGTH_SHORT).show();
}

From source file:com.bluros.music.utils.NavigationUtils.java

public static void navigateToSettings(Activity context) {
    final Intent intent = new Intent(context, SettingsActivity.class);
    if (!PreferencesUtility.getInstance(context).getSystemAnimations()) {
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    }/*  w w w .j  a v  a2  s.  c  o  m*/
    intent.setAction(Constants.NAVIGATE_SETTINGS);
    context.startActivity(intent);
}

From source file:com.bluros.music.utils.NavigationUtils.java

public static void navigateToSearch(Activity context) {
    final Intent intent = new Intent(context, SearchActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    intent.setAction(Constants.NAVIGATE_SEARCH);
    context.startActivity(intent);//w w  w  . j  a  v  a  2s  . c  o  m
}

From source file:com.duy.pascal.ui.activities.SplashScreenActivity.java

/**
 * If receive data from other app (it could be file, text from clipboard),
 * You will be handle data and send to {@link EditorActivity}
 *///from  w w  w . ja v a  2 s  .c  o m
private void startMainActivity() {
    Intent data = getIntent();
    String action = data.getAction();
    DLog.d(TAG, "startMainActivity: action = " + action);

    String type = data.getType();
    Intent intentEdit = new Intent(this, EditorActivity.class);
    if (action != null && Intent.ACTION_SEND.equals(action) && type != null) {
        FirebaseAnalytics.getInstance(this).logEvent("open_from_clipboard", new Bundle());
        if (type.equals("text/plain")) {
            handleActionSend(data, intentEdit);
        }
    } else if (action != null && Intent.ACTION_VIEW.equals(action) && type != null) {
        FirebaseAnalytics.getInstance(this).logEvent("open_from_another", new Bundle());
        handleActionView(data, intentEdit);
    } else if (action != null && action.equalsIgnoreCase("run_from_shortcut")) {
        FirebaseAnalytics.getInstance(this).logEvent("run_from_shortcut", new Bundle());
        handleRunProgram(data);
        return;
    }

    intentEdit.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    startActivity(intentEdit);
    overridePendingTransition(0, 0);
    finish();

}

From source file:com.example.administrator.myapplication2._5_Group._5_Group.LeftFragment.java

public void outGroup() {

    AsyncHttpClient client1 = new AsyncHttpClient();
    client1.get("http://14.63.219.140:8080/han5/webresources/han5.grouping/deleteGrouping/" + id,
            new JsonHttpResponseHandler() {
                @Override/*www.j  a  va  2  s  .co  m*/
                public void onStart() {
                    Log.i("boogil1", "outGroup receive json data start! ");
                }

                @Override
                public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                    Log.i("boogil1", "outGroup success! ");
                }

                @Override
                public void onFailure(int statusCode, Header[] headers, String responseString,
                        Throwable throwable) {
                    Log.i("boogil1", "outGroup fail!");
                }
            });

    AsyncHttpClient client2 = new AsyncHttpClient();
    client2.get("http://14.63.219.140:8080/han5/webresources/han5.nowgps/deleteNowgps/" + id,
            new JsonHttpResponseHandler() {
                @Override
                public void onStart() {
                    Log.i("boogil1", "outGroup2 receive json data start! ");
                }

                @Override
                public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                    Log.i("boogil1", "outGroup2 success! ");
                }

                @Override
                public void onFailure(int statusCode, Header[] headers, String responseString,
                        Throwable throwable) {
                    Log.i("boogil1", "outGroup2 fail!");
                }
            });

    //Set Class to Top of App and no history
    Intent launchNextActivity;
    launchNextActivity = new Intent(getActivity(), Main.class);
    launchNextActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    launchNextActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    launchNextActivity.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    startActivity(launchNextActivity);

}