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:dk.ciid.android.infobooth.activities.SubscriptionFinalActivity.java

private void changeActivity(String activityName) {
    Intent openActivity = new Intent(activityName);
    openActivity.putExtra("isInDebugMode", isInDebugMode);
    openActivity.putExtra("selectedService", selectedService);
    openActivity.putExtra("serviceIdItems", serviceIdItems);
    openActivity.putExtra("serviceNameItems", serviceNameItems);
    openActivity.putExtra("serviceDescItems", serviceDescItems);
    openActivity.putExtra("voice1", voice1);
    openActivity.putExtra("voice2", voice2);
    openActivity.putExtra("voice3", voice3);
    openActivity.putExtra("voice4", voice4);
    openActivity.putExtra("voice5", voice5);
    openActivity.putExtra("voice6", voice6);
    openActivity.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    mediaPlayer.stop();//ww w.j  ava2s.  c  o  m
    mediaPlayer.release();
    startActivity(openActivity);
    closeAccessory();
}

From source file:com.goftagram.telegram.messenger.NotificationsController.java

public void processNewMessages(final ArrayList<MessageObject> messageObjects, final boolean isLast) {
    if (messageObjects.isEmpty()) {
        return;// w ww.  ja  v  a2  s.c  o m
    }
    final ArrayList<MessageObject> popupArray = new ArrayList<>(popupMessages);
    notificationsQueue.postRunnable(new Runnable() {
        @Override
        public void run() {
            boolean added = false;

            int oldCount = popupArray.size();
            HashMap<Long, Boolean> settingsCache = new HashMap<>();
            SharedPreferences preferences = ApplicationLoader.applicationContext
                    .getSharedPreferences("Notifications", Context.MODE_PRIVATE);
            int popup = 0;

            for (int a = 0; a < messageObjects.size(); a++) {
                MessageObject messageObject = messageObjects.get(a);
                long mid = messageObject.messageOwner.id;
                if (messageObject.messageOwner.to_id.channel_id != 0) {
                    mid |= ((long) messageObject.messageOwner.to_id.channel_id) << 32;
                }
                if (pushMessagesDict.containsKey(mid)) {
                    continue;
                }
                long dialog_id = messageObject.getDialogId();
                long original_dialog_id = dialog_id;
                if (dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) {
                    playInChatSound();
                    continue;
                }
                if (messageObject.messageOwner.mentioned) {
                    dialog_id = messageObject.messageOwner.from_id;
                }
                if (isPersonalMessage(messageObject)) {
                    personal_count++;
                }
                added = true;

                Boolean value = settingsCache.get(dialog_id);
                boolean isChat = (int) dialog_id < 0;
                popup = (int) dialog_id == 0 ? 0 : preferences.getInt(isChat ? "popupGroup" : "popupAll", 0);
                if (value == null) {
                    int notifyOverride = getNotifyOverride(preferences, dialog_id);
                    value = !(notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true)
                            || isChat && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0);
                    settingsCache.put(dialog_id, value);
                }
                if (value) {
                    if (popup != 0) {
                        popupArray.add(0, messageObject);
                    }
                    delayedPushMessages.add(messageObject);
                    pushMessages.add(0, messageObject);
                    pushMessagesDict.put(mid, messageObject);
                    if (original_dialog_id != dialog_id) {
                        pushDialogsOverrideMention.put(original_dialog_id, 1);
                    }
                }
            }

            if (added) {
                notifyCheck = isLast;
            }

            if (!popupArray.isEmpty() && oldCount != popupArray.size()
                    && !AndroidUtilities.needShowPasscode(false)) {
                final int popupFinal = popup;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        popupMessages = popupArray;
                        if (ApplicationLoader.mainInterfacePaused
                                || !ApplicationLoader.isScreenOn && !UserConfig.isWaitingForPasscodeEnter) {
                            MessageObject messageObject = messageObjects.get(0);
                            if (popupFinal == 3 || popupFinal == 1 && ApplicationLoader.isScreenOn
                                    || popupFinal == 2 && !ApplicationLoader.isScreenOn) {
                                Intent popupIntent = new Intent(ApplicationLoader.applicationContext,
                                        PopupNotificationActivity.class);
                                popupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                                        | Intent.FLAG_ACTIVITY_NO_ANIMATION
                                        | Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_FROM_BACKGROUND);
                                ApplicationLoader.applicationContext.startActivity(popupIntent);
                            }
                        }
                    }
                });
            }
        }
    });
}

From source file:org.cafemember.messenger.NotificationsController.java

public void processNewMessages(final ArrayList<MessageObject> messageObjects, final boolean isLast) {
    if (messageObjects.isEmpty()) {
        return;//from   w w w .j a va 2  s.  c o m
    }
    final ArrayList<MessageObject> popupArray = new ArrayList<>(popupMessages);
    notificationsQueue.postRunnable(new Runnable() {
        @Override
        public void run() {
            boolean added = false;

            int oldCount = popupArray.size();
            HashMap<Long, Boolean> settingsCache = new HashMap<>();
            SharedPreferences preferences = ApplicationLoader.applicationContext
                    .getSharedPreferences("Notifications", Context.MODE_PRIVATE);
            boolean allowPinned = preferences.getBoolean("PinnedMessages", true);
            int popup = 0;

            for (int a = 0; a < messageObjects.size(); a++) {
                MessageObject messageObject = messageObjects.get(a);
                long mid = messageObject.messageOwner.id;
                if (messageObject.messageOwner.to_id.channel_id != 0) {
                    mid |= ((long) messageObject.messageOwner.to_id.channel_id) << 32;
                }
                if (pushMessagesDict.containsKey(mid)) {
                    continue;
                }
                long dialog_id = messageObject.getDialogId();
                long original_dialog_id = dialog_id;
                if (dialog_id == opened_dialog_id && ApplicationLoader.isScreenOn) {
                    playInChatSound();
                    continue;
                }
                if (messageObject.messageOwner.mentioned) {
                    if (!allowPinned
                            && messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) {
                        continue;
                    }
                    dialog_id = messageObject.messageOwner.from_id;
                }
                if (isPersonalMessage(messageObject)) {
                    personal_count++;
                }
                added = true;

                Boolean value = settingsCache.get(dialog_id);
                boolean isChat = (int) dialog_id < 0;
                popup = (int) dialog_id == 0 ? 0 : preferences.getInt(isChat ? "popupGroup" : "popupAll", 0);
                if (value == null) {
                    int notifyOverride = getNotifyOverride(preferences, dialog_id);
                    value = !(notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true)
                            || isChat && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0);
                    settingsCache.put(dialog_id, value);
                }
                if (value) {
                    if (popup != 0) {
                        popupArray.add(0, messageObject);
                    }
                    delayedPushMessages.add(messageObject);
                    pushMessages.add(0, messageObject);
                    pushMessagesDict.put(mid, messageObject);
                    if (original_dialog_id != dialog_id) {
                        pushDialogsOverrideMention.put(original_dialog_id, 1);
                    }
                }
            }

            if (added) {
                notifyCheck = isLast;
            }

            if (!popupArray.isEmpty() && oldCount != popupArray.size()
                    && !AndroidUtilities.needShowPasscode(false)) {
                final int popupFinal = popup;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        popupMessages = popupArray;
                        if (ApplicationLoader.mainInterfacePaused
                                || !ApplicationLoader.isScreenOn && !UserConfig.isWaitingForPasscodeEnter) {
                            MessageObject messageObject = messageObjects.get(0);
                            if (popupFinal == 3 || popupFinal == 1 && ApplicationLoader.isScreenOn
                                    || popupFinal == 2 && !ApplicationLoader.isScreenOn) {
                                Intent popupIntent = new Intent(ApplicationLoader.applicationContext,
                                        PopupNotificationActivity.class);
                                popupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                                        | Intent.FLAG_ACTIVITY_NO_ANIMATION
                                        | Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_FROM_BACKGROUND);
                                ApplicationLoader.applicationContext.startActivity(popupIntent);
                            }
                        }
                    }
                });
            }
        }
    });
}

From source file:eu.funceptionapps.convertitall.ui.ConverterInterface.java

public void restartInterface() {

    Intent intent = getIntent();/*from w w w  .  j a  v  a2 s.c o  m*/
    overridePendingTransition(0, 0);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    finish();

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

From source file:ir.besteveryeverapp.telegram.NotificationsController.java

public void processNewMessages(final ArrayList<MessageObject> messageObjects, final boolean isLast) {
    if (messageObjects.isEmpty()) {
        return;/*w ww  .j a  va2 s.  com*/
    }
    final ArrayList<MessageObject> popupArray = new ArrayList<>(popupMessages);
    notificationsQueue.postRunnable(new Runnable() {
        @Override
        public void run() {
            boolean added = false;

            int oldCount = popupArray.size();
            HashMap<Long, Boolean> settingsCache = new HashMap<>();
            SharedPreferences preferences = ApplicationLoader.applicationContext
                    .getSharedPreferences("Notifications", Context.MODE_PRIVATE);
            boolean allowPinned = preferences.getBoolean("PinnedMessages", true);
            int popup = 0;

            for (int a = 0; a < messageObjects.size(); a++) {
                MessageObject messageObject = messageObjects.get(a);
                long mid = messageObject.messageOwner.id;
                if (messageObject.messageOwner.to_id.channel_id != 0) {
                    mid |= ((long) messageObject.messageOwner.to_id.channel_id) << 32;
                }
                if (pushMessagesDict.containsKey(mid)) {
                    continue;
                }
                long dialog_id = messageObject.getDialogId();
                long original_dialog_id = dialog_id;
                if (dialog_id == opened_dialog_id && ApplicationLoader.isScreenOn) {
                    playInChatSound();
                    continue;
                }
                if (messageObject.messageOwner.mentioned) {
                    if (!allowPinned
                            && messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) {
                        continue;
                    }
                    dialog_id = messageObject.messageOwner.from_id;
                }
                if (isPersonalMessage(messageObject)) {
                    personal_count++;
                }
                added = true;

                Boolean value = settingsCache.get(dialog_id);
                boolean isChat = (int) dialog_id < 0;
                popup = (int) dialog_id == 0 ? 0 : preferences.getInt(isChat ? "popupGroup" : "popupAll", 0);
                if (value == null) {
                    int notifyOverride = getNotifyOverride(preferences, dialog_id);
                    value = !(notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true)
                            || isChat && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0);
                    settingsCache.put(dialog_id, value);
                }
                if (popup != 0 && messageObject.messageOwner.to_id.channel_id != 0
                        && !messageObject.isMegagroup()) {
                    popup = 0;
                }
                if (value) {
                    if (popup != 0) {
                        popupArray.add(0, messageObject);
                    }
                    delayedPushMessages.add(messageObject);
                    pushMessages.add(0, messageObject);
                    pushMessagesDict.put(mid, messageObject);
                    if (original_dialog_id != dialog_id) {
                        pushDialogsOverrideMention.put(original_dialog_id, 1);
                    }
                }
            }

            if (added) {
                notifyCheck = isLast;
            }

            if (!popupArray.isEmpty() && oldCount != popupArray.size()
                    && !AndroidUtilities.needShowPasscode(false)) {
                final int popupFinal = popup;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        popupMessages = popupArray;
                        if (ApplicationLoader.mainInterfacePaused
                                || !ApplicationLoader.isScreenOn && !UserConfig.isWaitingForPasscodeEnter) {
                            MessageObject messageObject = messageObjects.get(0);
                            if (popupFinal == 3 || popupFinal == 1 && ApplicationLoader.isScreenOn
                                    || popupFinal == 2 && !ApplicationLoader.isScreenOn) {
                                Intent popupIntent = new Intent(ApplicationLoader.applicationContext,
                                        PopupNotificationActivity.class);
                                popupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                                        | Intent.FLAG_ACTIVITY_NO_ANIMATION
                                        | Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_FROM_BACKGROUND);
                                ApplicationLoader.applicationContext.startActivity(popupIntent);
                            }
                        }
                    }
                });
            }
        }
    });
}

From source file:ir.irani.telecam.messenger.NotificationsController.java

public void processNewMessages(final ArrayList<MessageObject> messageObjects, final boolean isLast) {
    if (messageObjects.isEmpty()) {
        return;/*from   www . ja v  a 2s .  c o m*/
    }
    final ArrayList<MessageObject> popupArray = new ArrayList<>(popupMessages);
    notificationsQueue.postRunnable(new Runnable() {
        @Override
        public void run() {
            boolean added = false;

            int oldCount = popupArray.size();
            HashMap<Long, Boolean> settingsCache = new HashMap<>();
            SharedPreferences preferences = ApplicationLoader.applicationContext
                    .getSharedPreferences("Notifications", Context.MODE_PRIVATE);
            boolean allowPinned = preferences.getBoolean("PinnedMessages", true);
            int popup = 0;

            for (int a = 0; a < messageObjects.size(); a++) {
                MessageObject messageObject = messageObjects.get(a);
                long mid = messageObject.messageOwner.id;
                if (messageObject.messageOwner.to_id.channel_id != 0) {
                    mid |= ((long) messageObject.messageOwner.to_id.channel_id) << 32;
                }
                if (pushMessagesDict.containsKey(mid)) {
                    continue;
                }
                long dialog_id = messageObject.getDialogId();
                long original_dialog_id = dialog_id;
                if (dialog_id == opened_dialog_id && ApplicationLoader.isScreenOn) {
                    playInChatSound();
                    continue;
                }
                if (messageObject.messageOwner.mentioned) {
                    if (!allowPinned
                            && messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) {
                        continue;
                    }
                    dialog_id = messageObject.messageOwner.from_id;
                }
                if (isPersonalMessage(messageObject)) {
                    personal_count++;
                }
                added = true;

                Boolean value = settingsCache.get(dialog_id);
                boolean isChat = (int) dialog_id < 0;
                //if(HiddenController.IsHidden(dialog_id))continue;
                popup = (int) dialog_id == 0 ? 0 : preferences.getInt(isChat ? "popupGroup" : "popupAll", 0);
                if (value == null) {
                    int notifyOverride = getNotifyOverride(preferences, dialog_id);
                    value = !(notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true)
                            || isChat && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0);
                    settingsCache.put(dialog_id, value);
                }
                if (popup != 0 && messageObject.messageOwner.to_id.channel_id != 0
                        && !messageObject.isMegagroup()) {
                    popup = 0;
                }
                if (value) {
                    if (popup != 0) {
                        popupArray.add(0, messageObject);
                    }
                    delayedPushMessages.add(messageObject);
                    pushMessages.add(0, messageObject);
                    pushMessagesDict.put(mid, messageObject);
                    if (original_dialog_id != dialog_id) {
                        pushDialogsOverrideMention.put(original_dialog_id, 1);
                    }
                }
            }

            if (added) {
                notifyCheck = isLast;
            }

            if (!popupArray.isEmpty() && oldCount != popupArray.size()
                    && !AndroidUtilities.needShowPasscode(false)) {
                final int popupFinal = popup;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        popupMessages = popupArray;
                        if (ApplicationLoader.mainInterfacePaused
                                || !ApplicationLoader.isScreenOn && !UserConfig.isWaitingForPasscodeEnter) {
                            MessageObject messageObject = messageObjects.get(0);
                            if (popupFinal == 3 || popupFinal == 1 && ApplicationLoader.isScreenOn
                                    || popupFinal == 2 && !ApplicationLoader.isScreenOn) {
                                Intent popupIntent = new Intent(ApplicationLoader.applicationContext,
                                        PopupNotificationActivity.class);
                                popupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                                        | Intent.FLAG_ACTIVITY_NO_ANIMATION
                                        | Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_FROM_BACKGROUND);
                                ApplicationLoader.applicationContext.startActivity(popupIntent);
                            }
                        }
                    }
                });
            }
        }
    });
}

From source file:org.nypl.simplified.app.MainSettingsAccountActivity.java

@Override
protected void onCreate(final @Nullable Bundle state) {
    super.onCreate(state);

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
        this.account = new AccountsRegistry(this).getAccount(extras.getInt("selected_account"));
    } else {// w  w w.ja  v  a2s  .  c om
        this.account = Simplified.getCurrentAccount();
    }

    final ActionBar bar = this.getActionBar();
    if (android.os.Build.VERSION.SDK_INT < 21) {
        bar.setDisplayHomeAsUpEnabled(false);
        bar.setHomeButtonEnabled(true);
        bar.setIcon(R.drawable.ic_arrow_back);
    } else {
        bar.setHomeAsUpIndicator(R.drawable.ic_arrow_back);
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setHomeButtonEnabled(false);
    }

    final DocumentStoreType docs = Simplified.getDocumentStore(this.account, getResources());

    final LayoutInflater inflater = NullCheck.notNull(this.getLayoutInflater());

    final FrameLayout content_area = this.getContentFrame();
    final ViewGroup layout = NullCheck
            .notNull((ViewGroup) inflater.inflate(R.layout.settings_account, content_area, false));
    content_area.addView(layout);
    content_area.requestLayout();

    final TextView in_barcode_label = NullCheck.notNull(this.findViewById(R.id.settings_barcode_label));
    final TextView in_barcode_text = NullCheck.notNull(this.findViewById(R.id.settings_barcode_text));
    final TextView in_pin_label = NullCheck.notNull(this.findViewById(R.id.settings_pin_label));
    final ImageView in_barcode_image = NullCheck.notNull(this.findViewById(R.id.settings_barcode_image));
    final TextView in_barcode_image_toggle = NullCheck
            .notNull(this.findViewById(R.id.settings_barcode_toggle_barcode));
    final TextView in_pin_text = NullCheck.notNull(this.findViewById(R.id.settings_pin_text));
    final CheckBox in_pin_reveal = NullCheck.notNull(this.findViewById(R.id.settings_reveal_password));

    if (!this.account.pinRequired()) {
        in_pin_label.setVisibility(View.INVISIBLE);
        in_pin_text.setVisibility(View.INVISIBLE);
        in_pin_reveal.setVisibility(View.INVISIBLE);
    }

    final Button in_login = NullCheck.notNull(this.findViewById(R.id.settings_login));
    final Button in_signup = NullCheck.notNull(this.findViewById(R.id.settings_signup));

    this.sync_switch = findViewById(R.id.sync_switch);
    this.sync_table_row = findViewById(R.id.sync_table_row);
    this.sync_table_row.setVisibility(View.GONE);
    this.advanced_table_row = findViewById(R.id.link_advanced);
    this.advanced_table_row.setVisibility(View.GONE);

    this.advanced_table_row.setOnClickListener(view -> {
        final FragmentManager mgr = getFragmentManager();
        final FragmentTransaction transaction = mgr.beginTransaction();
        final SettingsAccountAdvancedFragment fragment = new SettingsAccountAdvancedFragment();
        transaction.add(R.id.settings_account_container, fragment).addToBackStack("advanced").commit();
    });

    final TableRow in_privacy = findViewById(R.id.link_privacy);
    final TableRow in_license = findViewById(R.id.link_license);

    final TextView account_name = NullCheck.notNull(this.findViewById(android.R.id.text1));
    final TextView account_subtitle = NullCheck.notNull(this.findViewById(android.R.id.text2));

    final ImageView in_account_icon = NullCheck.notNull(this.findViewById(R.id.account_icon));

    in_pin_text.setTransformationMethod(PasswordTransformationMethod.getInstance());
    if (android.os.Build.VERSION.SDK_INT >= 21) {
        this.handle_pin_reveal(in_pin_text, in_pin_reveal);
    } else {
        in_pin_reveal.setVisibility(View.GONE);
    }

    final TableRow in_report_issue = findViewById(R.id.report_issue);

    if (this.account.getSupportEmail() == null) {
        in_report_issue.setVisibility(View.GONE);
    } else {
        in_report_issue.setVisibility(View.VISIBLE);
        in_report_issue.setOnClickListener(view -> {
            final Intent intent = new Intent(this, ReportIssueActivity.class);
            final Bundle b = new Bundle();
            b.putInt("selected_account", this.account.getId());
            intent.putExtras(b);
            startActivity(intent);
        });
    }

    final TableRow in_support_center = findViewById(R.id.support_center);
    if (this.account.supportsHelpCenter()) {
        in_support_center.setVisibility(View.VISIBLE);
        in_support_center.setOnClickListener(view -> {
            final HSHelpStack stack = HSHelpStack.getInstance(this);
            final HSDeskGear gear = new HSDeskGear("https://nypl.desk.com/", "4GBRmMv8ZKG8fGehhA", null);
            stack.setGear(gear);
            stack.showHelp(this);
        });
    } else {
        in_support_center.setVisibility(View.GONE);
    }

    //Get labels from the current authentication document.
    final AuthenticationDocumentType auth_doc = docs.getAuthenticationDocument();
    in_barcode_label.setText(auth_doc.getLabelLoginUserID());
    in_pin_label.setText(auth_doc.getLabelLoginPassword());

    final TableLayout in_table_with_code = NullCheck
            .notNull(this.findViewById(R.id.settings_login_table_with_code));
    in_table_with_code.setVisibility(View.GONE);
    final TableLayout in_table_signup = NullCheck.notNull(this.findViewById(R.id.settings_signup_table));

    //    boolean locationpermission = false;
    //    if (ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
    //      locationpermission = true;
    //    }
    //    else
    //    {
    //      ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
    //    }

    if (this.account.supportsCardCreator() || this.account.getCardCreatorUrl() != null) {
        in_table_signup.setVisibility(View.VISIBLE);
    } else {
        in_table_signup.setVisibility(View.GONE);
    }

    in_login.setOnClickListener(v -> this.onLoginWithBarcode());

    final CheckBox in_age13_checkbox = NullCheck.notNull(this.findViewById(R.id.age13_checkbox));

    if (Simplified.getSharedPrefs().contains("age13")) {
        in_age13_checkbox.setChecked(Simplified.getSharedPrefs().getBoolean("age13"));
    } else if (account.getId() == 2) {
        showAgeGateOptionsDialog(in_age13_checkbox);
    }

    in_age13_checkbox.setOnCheckedChangeListener(this::showAgeChangeConfirmation);

    if (this.account.needsAuth()) {
        in_login.setVisibility(View.VISIBLE);
        in_age13_checkbox.setVisibility(View.GONE);
    } else {
        in_login.setVisibility(View.GONE);
        in_age13_checkbox.setVisibility(View.VISIBLE);
    }

    if (this.account.supportsCardCreator()) {
        in_signup.setOnClickListener(v -> {
            final Intent cardcreator = new Intent(this, CardCreatorActivity.class);
            startActivity(cardcreator);
        });
        in_signup.setText(R.string.need_card_button);

    } else if (this.account.getCardCreatorUrl() != null) {
        in_signup.setOnClickListener(v -> {
            final Intent e_card = new Intent(Intent.ACTION_VIEW);
            e_card.setData(Uri.parse(this.account.getCardCreatorUrl()));
            startActivity(e_card);
        });
        in_signup.setText(R.string.need_card_button);
    }

    final boolean permission = Simplified.getSharedPrefs().getBoolean("syncPermissionGranted",
            this.account.getId());
    this.sync_switch.setChecked(permission);

    /*
    If switching on, disable user interaction until server has responded.
    If switching off, disable applicable network requests by updating shared prefs flags.
     */
    this.sync_switch.setOnCheckedChangeListener((buttonView, isChecked) -> {
        if (isChecked) {
            buttonView.setEnabled(false);
            annotationsManager.updateServerSyncPermissionStatus(true, (success) -> {
                if (success) {
                    Simplified.getSharedPrefs().putBoolean("syncPermissionGranted", this.account.getId(), true);
                    this.sync_switch.setChecked(true);
                } else {
                    Simplified.getSharedPrefs().putBoolean("syncPermissionGranted", this.account.getId(),
                            false);
                    this.sync_switch.setChecked(false);
                }
                this.sync_switch.setEnabled(true);
                return kotlin.Unit.INSTANCE;
            });
        } else {
            Simplified.getSharedPrefs().putBoolean("syncPermissionGranted", this.account.getId(), false);
            this.sync_switch.setChecked(false);
        }
    });

    if (this.account.getPrivacyPolicy() != null) {
        in_privacy.setVisibility(View.VISIBLE);
    } else {
        in_privacy.setVisibility(View.GONE);
    }
    if (this.account.getContentLicense() != null) {
        in_license.setVisibility(View.VISIBLE);
    } else {
        in_license.setVisibility(View.GONE);
    }

    in_license.setOnClickListener(view -> {
        final Intent intent = new Intent(this, WebViewActivity.class);
        final Bundle b = new Bundle();
        WebViewActivity.setActivityArguments(b, this.account.getContentLicense(), "Content Licenses",
                SimplifiedPart.PART_SETTINGS);
        intent.putExtras(b);
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivity(intent);
    });

    in_privacy.setOnClickListener(view -> {
        final Intent intent = new Intent(this, WebViewActivity.class);
        final Bundle b = new Bundle();
        WebViewActivity.setActivityArguments(b, this.account.getPrivacyPolicy(), "Privacy Policy",
                SimplifiedPart.PART_SETTINGS);
        intent.putExtras(b);
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivity(intent);
    });

    this.navigationDrawerSetActionBarTitle();

    this.account_name_text = account_name;
    this.account_subtitle_text = account_subtitle;
    this.account_icon = in_account_icon;
    this.barcode_text = in_barcode_text;
    this.pin_text = in_pin_text;
    this.barcode_image_toggle = in_barcode_image_toggle;
    this.barcode_image = in_barcode_image;
    this.login = in_login;
    this.table_with_code = in_table_with_code;
    this.table_signup = in_table_signup;

    final CheckBox in_eula_checkbox = NullCheck.notNull(this.findViewById(R.id.eula_checkbox));

    final OptionType<EULAType> eula_opt = docs.getEULA();

    if (eula_opt.isSome()) {
        final Some<EULAType> some_eula = (Some<EULAType>) eula_opt;
        final EULAType eula = some_eula.get();

        in_eula_checkbox.setChecked(eula.eulaHasAgreed());
        in_eula_checkbox.setEnabled(true);
        in_eula_checkbox.setOnCheckedChangeListener((button, checked) -> eula.eulaSetHasAgreed(checked));

        if (eula.eulaHasAgreed()) {
            LOG.debug("EULA: agreed");
        } else {
            LOG.debug("EULA: not agreed");
        }
    } else {
        LOG.debug("EULA: unavailable");
    }

    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}

From source file:com.shafiq.mytwittle.App.java

public void restartApp(Activity currentActivity) {
    Intent intent = getBaseContext().getPackageManager()
            .getLaunchIntentForPackage(getBaseContext().getPackageName());
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_ANIMATION
            | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    currentActivity.overridePendingTransition(0, 0);
    currentActivity.startActivity(intent);
}

From source file:com.nononsenseapps.notepad.ActivityMain.java

private void restartAndRefresh() {
    shouldRestart = false;//from  w  w  w .  j a v  a2  s. c o m
    Intent intent = getIntent();
    overridePendingTransition(0, 0);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    finish();
    overridePendingTransition(0, 0);
    startActivity(intent);
}

From source file:com.tealeaf.TeaLeaf.java

protected void reset() {
    group.removeView(glView);/*www  . j a  v a2 s  . co  m*/
    glViewPaused = false;
    glView.destroy();
    NativeShim.reset();
    Intent intent = getIntent();
    overridePendingTransition(0, 0);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    finish();
    overridePendingTransition(0, 0);
    startActivity(intent);
}