Example usage for android.widget RelativeLayout setVisibility

List of usage examples for android.widget RelativeLayout setVisibility

Introduction

In this page you can find the example usage for android.widget RelativeLayout setVisibility.

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:com.near.chimerarevo.fragments.PostFragment.java

private void addYoutubeVideo(String url) {
    final String yturl;
    if (url.contains("embed")) {
        String temp = url.split("embed/")[1];
        if (url.contains("feature")) {
            temp = temp.split("feature=")[0];
            yturl = temp.substring(0, temp.length() - 1);
        } else//from w w  w . j ava  2  s.c o  m
            yturl = temp;
    } else if (url.contains("youtu.be")) {
        yturl = url.split("youtu.be/")[1];
    } else
        return;

    final RelativeLayout rl = new RelativeLayout(getActivity());
    YouTubeThumbnailView yt = new YouTubeThumbnailView(getActivity());
    ImageView icon = new ImageView(getActivity());

    try {
        yt.setTag(yturl);
        yt.initialize(Constants.YOUTUBE_API_TOKEN, new OnInitializedListener() {
            @Override
            public void onInitializationFailure(YouTubeThumbnailView thumbView,
                    YouTubeInitializationResult error) {
                rl.setVisibility(View.GONE);
            }

            @Override
            public void onInitializationSuccess(YouTubeThumbnailView thumbView,
                    YouTubeThumbnailLoader thumbLoader) {
                thumbLoader.setVideo(yturl);
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }

    RelativeLayout.LayoutParams obj_params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    obj_params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    obj_params.addRule(RelativeLayout.CENTER_VERTICAL);
    yt.setLayoutParams(obj_params);

    icon.setImageResource(R.drawable.yt_play_button);
    icon.setLayoutParams(obj_params);

    RelativeLayout.LayoutParams rl_params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    rl_params.setMargins(0, 10, 0, 0);
    rl.setLayoutParams(rl_params);
    rl.setGravity(Gravity.CENTER_HORIZONTAL);
    rl.setClickable(true);

    rl.addView(yt);
    rl.addView(icon);

    rl.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(getActivity(), YoutubeActivity.class);
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            i.putExtra(Constants.KEY_VIDEO_URL, yturl);
            startActivity(i);
        }
    });

    lay.addView(rl);
}

From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_client.ui.activity.MessagesActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != RESULT_OK) {
        resetValues();/* w  ww .  j a  v a 2  s.c om*/
        System.gc();
        fromGallery = false;

        return;
    }

    if (requestCode == AppUtils.GROUP_ADMIN) {
        if (data.getExtras().getBoolean(ConstantKeys.DELETED, false)) {
            finish();
        }
        return;
    }

    if (requestCode == AppUtils.ACTION_RESPONSE) {
        if (!data.getExtras().getBoolean(ConstantKeys.BACKBUTTON, false)) {
            doRefresh(true);
        }
        return;
    }

    if (requestCode == AppUtils.ACTION_GALLERY) {
        mFileCaptureUri = data.getData();
        fromGallery = true;
    }

    if (mFileCaptureUri == null) {
        Toast.makeText(getApplicationContext(), getApplicationContext().getText(R.string.error_capturing_media),
                Toast.LENGTH_SHORT).show();
        resetValues();
        System.gc();
        fromGallery = false;
        return;
    }

    RelativeLayout rl = (RelativeLayout) messagesActivity.findViewById(R.id.atach_layer);
    rl.setVisibility(View.VISIBLE);
}

From source file:com.mobicage.rogerthat.GroupDetailActivity.java

private void updateGroupForEdit() {
    T.UI();//w ww .ja v a 2 s.  c o  m
    final Button saveBtn = (Button) findViewById(R.id.save_group);
    final ImageView editBtn = (ImageView) findViewById(R.id.edit_group);
    final RelativeLayout updateGroupName = ((RelativeLayout) findViewById(R.id.update_group_name));
    final LinearLayout updateGroupAvatar = ((LinearLayout) findViewById(R.id.update_group_avatar));
    final ImageView newGroupAvatar = ((ImageView) findViewById(R.id.update_group_avatar_img));
    final Button updateAvatarBtn = (Button) findViewById(R.id.update_avatar);
    final Button cancelBtn = (Button) findViewById(R.id.cancel);

    final ImageView friendAvatar = (ImageView) findViewById(R.id.friend_avatar);
    final TextView friendName = (TextView) findViewById(R.id.friend_name);

    if (mEditing) {
        updateGroupName.setVisibility(View.VISIBLE);
        updateGroupAvatar.setVisibility(View.VISIBLE);
        updateGroupName.setBackgroundResource(android.R.drawable.edit_text);
        cancelBtn.setVisibility(View.VISIBLE);
        saveBtn.setVisibility(View.VISIBLE);
        editBtn.setVisibility(View.GONE);

        friendAvatar.setVisibility(View.GONE);
        friendName.setVisibility(View.GONE);

        updateGroupName.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mUpdateGroupName.requestFocus()) {
                    int pos = mUpdateGroupName.getText().length();
                    mUpdateGroupName.setSelection(pos);
                    UIUtils.showKeyboard(getApplicationContext());
                }
            }
        });

        OnClickListener newAvatarListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getNewAvatar(true);
                UIUtils.hideKeyboard(getApplicationContext(), mUpdateGroupName);
            }
        };

        updateAvatarBtn.setOnClickListener(newAvatarListener);
        newGroupAvatar.setOnClickListener(newAvatarListener);

    } else {
        updateGroupName.setVisibility(View.GONE);
        updateGroupAvatar.setVisibility(View.GONE);
        updateGroupName.setBackgroundResource(0);
        cancelBtn.setVisibility(View.GONE);
        saveBtn.setVisibility(View.GONE);
        editBtn.setVisibility(View.VISIBLE);

        friendAvatar.setVisibility(View.VISIBLE);
        friendName.setVisibility(View.VISIBLE);

        final byte[] byteArray;
        if (mPhotoSelected) {
            Bitmap bm = BitmapFactory.decodeFile(mUriSavedImage.getPath(), null);
            bm = ImageHelper.rotateBitmap(bm, mPhoneExifRotation);

            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            bm.compress(Bitmap.CompressFormat.PNG, 100, stream);
            byteArray = stream.toByteArray();
            File image;
            try {
                image = getTmpUploadPhotoLocation();
            } catch (IOException e) {
                L.d(e.getMessage());
                UIUtils.showLongToast(getApplicationContext(), e.getMessage());
                return;
            }
            image.delete();
            mPhotoSelected = false;
            mGroup.avatar = byteArray;
        }
        mGroup.name = mUpdateGroupName.getText().toString();
        mFriendsPlugin.getStore().updateGroup(mGroup.guid, mGroup.name, mGroup.avatar, null);
        mFriendsPlugin.putGroup(mGroup);

        mBackupMembers = new ArrayList<String>(mGroup.members);

        Intent intent = new Intent(mIsNewGroup ? FriendsPlugin.GROUP_ADDED : FriendsPlugin.GROUP_MODIFIED);
        intent.putExtra("guid", mGroup.guid);
        mService.sendBroadcast(intent);
    }
}

From source file:com.maxleap.mall.fragments.MainFragment.java

private void fetchBannerData(final RelativeLayout bannerLayout) {
    FFLog.d("start fetchBannerData");
    MLQuery query = new MLQuery("Banner");
    MLQueryManager.findAllInBackground(query, new FindCallback<MLObject>() {
        @Override/*from  www .j  av a 2 s .  co m*/
        public void done(List<MLObject> list, MLException e) {
            FFLog.d("fetchBannerData list: " + list);
            FFLog.d("fetchBannerData e: " + e);
            if (e == null) {
                ArrayList<Banner> banners = new ArrayList<Banner>();
                for (MLObject object : list) {
                    Banner banner = new Banner(object);
                    if (banner.getStatus() == 1) {
                        banners.add(banner);
                    }
                }
                FFLog.d("fetchBannerData banners: " + banners);
                if (banners.size() > 0) {
                    mBanners.clear();
                    mBanners.addAll(banners);
                    mBannerAdapter.notifyDataSetChanged();
                    bannerLayout.setVisibility(View.VISIBLE);
                    final Indicator indicatorLayout = (Indicator) bannerLayout
                            .findViewById(R.id.head_indicator_layout);
                    indicatorLayout.setCount(mBanners.size());
                    indicatorLayout.select(0);
                }
            }
        }

    });
}

From source file:com.breadwallet.presenter.fragments.FragmentSettings.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // The last two arguments ensure LayoutParams are inflated
    // properly.// w  ww. j  av  a 2 s .c o m

    View rootView = inflater.inflate(R.layout.fragment_settings, container, false);

    app = MainActivity.app;
    fragmentSettings = this;
    initList();
    RelativeLayout about = (RelativeLayout) rootView.findViewById(R.id.about);
    TextView currencyName = (TextView) rootView.findViewById(R.id.three_letters_currency);
    RelativeLayout changePassword = (RelativeLayout) rootView.findViewById(R.id.change_password);
    final String tmp = SharedPreferencesManager.getIso(getActivity());
    currencyName.setText(tmp);
    RelativeLayout localCurrency = (RelativeLayout) rootView.findViewById(R.id.local_currency);
    RelativeLayout recoveryPhrase = (RelativeLayout) rootView.findViewById(R.id.recovery_phrase);
    RelativeLayout startRecoveryWallet = (RelativeLayout) rootView.findViewById(R.id.start_recovery_wallet);
    RelativeLayout fingerprintLimit = (RelativeLayout) rootView.findViewById(R.id.fingerprint_limit);
    RelativeLayout earlyAccess = (RelativeLayout) rootView.findViewById(R.id.early_access);
    RelativeLayout line5 = (RelativeLayout) rootView.findViewById(R.id.settings_line_5);
    TextView theLimit = (TextView) rootView.findViewById(R.id.fingerprint_limit_text);
    RelativeLayout rescan = (RelativeLayout) rootView.findViewById(R.id.rescan_blockchain);

    theLimit.setText(BRStringFormatter.getFormattedCurrencyString("BTC",
            PassCodeManager.getInstance().getLimit(getActivity())));
    FingerprintManager mFingerprintManager;
    mFingerprintManager = (FingerprintManager) getActivity().getSystemService(Context.FINGERPRINT_SERVICE);
    boolean useFingerPrint;
    useFingerPrint = ActivityCompat.checkSelfPermission(getActivity(),
            Manifest.permission.USE_FINGERPRINT) == PackageManager.PERMISSION_GRANTED
            && mFingerprintManager.isHardwareDetected() && mFingerprintManager.hasEnrolledFingerprints();

    if (!useFingerPrint) {
        fingerprintLimit.setVisibility(View.GONE);
        line5.setVisibility(View.GONE);
    }

    fingerprintLimit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (BRAnimator.checkTheMultipressingAvailability()) {
                ((BreadWalletApp) getActivity().getApplicationContext()).promptForAuthentication(getActivity(),
                        BRConstants.AUTH_FOR_LIMIT, null, null, null, null, false);
            }
        }
    });

    startRecoveryWallet.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (BRAnimator.checkTheMultipressingAvailability()) {
                BRAnimator.pressWipeWallet(app, new FragmentWipeWallet());
                app.activityButtonsEnable(false);
            }
        }
    });
    recoveryPhrase.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            BRWalletManager.getInstance(getActivity()).animateSavePhraseFlow();
        }
    });
    about.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (BRAnimator.checkTheMultipressingAvailability()) {
                BRAnimator.animateSlideToLeft(app, new FragmentAbout(), fragmentSettings);
            }
        }
    });
    localCurrency.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (BRAnimator.checkTheMultipressingAvailability()) {
                BRAnimator.animateSlideToLeft(app, new FragmentCurrency(), fragmentSettings);
            }
        }
    });
    changePassword.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (BRAnimator.checkTheMultipressingAvailability()) {
                final android.app.FragmentManager fm = getActivity().getFragmentManager();
                new PasswordDialogFragment().show(fm, PasswordDialogFragment.class.getName());
            }
        }
    }

    );

    rescan.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (BRAnimator.checkTheMultipressingAvailability()) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        BRAnimator.goToMainActivity(fragmentSettings);
                        BRPeerManager.getInstance(getActivity()).rescan();
                        SharedPreferencesManager.putStartHeight(getActivity(), 0);
                    }
                }).start();
            }

        }
    }

    );
    //keep it hidden until finished
    if (!PLATFORM_ON) {
        earlyAccess.setVisibility(View.GONE);
        rootView.findViewById(R.id.early_access_separator).setVisibility(View.GONE);
        rootView.findViewById(R.id.early_access_separator2).setVisibility(View.GONE);

    } else {
        earlyAccess.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (BRAnimator.checkTheMultipressingAvailability()) {

                    BRAnimator.animateSlideToLeft(app, new FragmentWebView(), fragmentSettings);
                }
            }
        });
    }
    return rootView;
}

From source file:de.uni_weimar.m18.anatomiederstadt.element.SliderFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_slider, container, false);
    SeekBar sb = (SeekBar) view.findViewById(R.id.seekBar);
    // scale mMin and mMax
    mMin = (int) (mMin / mGranularity);
    mMax = (int) (mMax / mGranularity);
    sb.setMax(mMax - mMin);/*w  w  w.  jav  a  2  s. co  m*/
    sb.setProgress((mMax - mMin) / 2);
    final RelativeLayout balloon = (RelativeLayout) view.findViewById(R.id.indicatorBalloon);
    final Space space = (Space) view.findViewById(R.id.balloonSpace);

    final Context context = getActivity();
    final TextView balloonText = (TextView) view.findViewById(R.id.indicatorTextView);
    final float[] value = { 0.0f };
    sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

            RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(
                    RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            p.addRule(RelativeLayout.ABOVE, seekBar.getId());
            Rect thumbRect = seekBar.getThumb().getBounds();
            value[0] = mMin + progress * mGranularity;
            String valueString = new DecimalFormat("#.##").format(value[0]);
            balloonText.setText(String.valueOf(valueString) + " " + mSuffix);
            int balloonWidth = balloonText.getWidth();
            p.setMargins(thumbRect.centerX() - balloonWidth / 2, 0, 0, 0);
            balloon.setLayoutParams(p);
            balloon.setVisibility(View.VISIBLE);

            final Animation animFadeOut = AnimationUtils.loadAnimation(context, R.anim.fade_out);
            balloon.startAnimation(animFadeOut);
            animFadeOut.setStartOffset(1000);
            animFadeOut.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {

                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    balloon.setVisibility(View.INVISIBLE);
                }

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            LevelStateManager stateManager = ((AnatomieDerStadtApplication) getActivity()
                    .getApplicationContext()).getStateManager(getActivity());
            stateManager.saveFloat(mVar, value[0]);
        }
    });
    return view;
}

From source file:org.wso2.iot.agent.activities.AuthenticationActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else {/* w  w  w.ja v a 2s.c o  m*/
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }

    setContentView(R.layout.activity_authentication);
    RelativeLayout relativeLayout = (RelativeLayout) this.findViewById(R.id.relavtiveLayoutAuthentication);

    if (Constants.DEFAULT_OWNERSHIP.equals(Constants.OWNERSHIP_COSU)) {
        relativeLayout.setVisibility(RelativeLayout.GONE);
    }
    deviceInfo = new DeviceInfo(context);
    etDomain = (EditText) findViewById(R.id.etDomain);
    etUsername = (EditText) findViewById(R.id.etUsername);
    etPassword = (EditText) findViewById(R.id.etPassword);
    etDomain.setFocusable(true);
    etDomain.requestFocus();
    btnSignIn = (Button) findViewById(R.id.btnSignIn);
    btnSignIn.setOnClickListener(onClickAuthenticate);
    btnSignIn.setEnabled(false);

    // change button color background till user enters a valid input
    btnSignIn.setBackgroundResource(R.drawable.btn_grey);
    btnSignIn.setTextColor(ContextCompat.getColor(this, R.color.black));
    TextView textViewSignIn = (TextView) findViewById(R.id.textViewSignIn);
    LinearLayout loginLayout = (LinearLayout) findViewById(R.id.loginLayout);

    if (Preference.hasPreferenceKey(context, Constants.TOKEN_EXPIRED)) {
        etDomain.setEnabled(false);
        etDomain.setTextColor(ContextCompat.getColor(this, R.color.black));
        etUsername.setEnabled(false);
        etUsername.setTextColor(ContextCompat.getColor(this, R.color.black));
        btnSignIn.setText(R.string.btn_sign_in);
        etPassword.setFocusable(true);
        etPassword.requestFocus();
        String tenantedUserName = Preference.getString(context, Constants.USERNAME);
        int tenantSeparator = tenantedUserName.lastIndexOf('@');
        etUsername.setText(tenantedUserName.substring(0, tenantSeparator));
        etDomain.setText(tenantedUserName.substring(tenantSeparator + 1, tenantedUserName.length()));
        isReLogin = true;
        textViewSignIn.setText(R.string.msg_need_to_sign_in);
    } else if (Constants.CLOUD_MANAGER != null) {
        isCloudLogin = true;
        etDomain.setVisibility(View.GONE);
        textViewSignIn.setText(R.string.txt_sign_in_cloud);
    }

    if (Preference.getBoolean(context, Constants.PreferenceFlag.DEVICE_ACTIVE) && !isReLogin) {
        Intent intent = new Intent(AuthenticationActivity.this, AlreadyRegisteredActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        finish();
        return;
    }

    TextView textViewSignUp = (TextView) findViewById(R.id.textViewSignUp);
    if (!isReLogin && Constants.SIGN_UP_URL != null) {
        Linkify.TransformFilter transformFilter = new Linkify.TransformFilter() {
            @Override
            public String transformUrl(Matcher match, String url) {
                return Constants.SIGN_UP_URL;
            }
        };
        Pattern pattern = Pattern.compile(getResources().getString(R.string.txt_sign_up_linkify));
        Linkify.addLinks(textViewSignUp, pattern, null, null, transformFilter);
    } else {
        textViewSignUp.setVisibility(View.GONE);
    }

    if (Constants.HIDE_LOGIN_UI) {
        loginLayout.setVisibility(View.GONE);
    }

    if (Constants.OWNERSHIP_COSU.equals(Constants.DEFAULT_OWNERSHIP)) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            startLockTask();
        }
    }

    TextView textViewWipeData = (TextView) this.findViewById(R.id.textViewWipeData);
    if (Constants.OWNERSHIP_COSU.equals(Constants.DEFAULT_OWNERSHIP) && Constants.DISPLAY_WIPE_DEVICE_BUTTON) {
        textViewWipeData.setVisibility(View.VISIBLE);
        textViewWipeData.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                new AlertDialog.Builder(AuthenticationActivity.this).setTitle(getString(R.string.app_name))
                        .setMessage(R.string.wipe_confirmation)
                        .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                DevicePolicyManager devicePolicyManager = (DevicePolicyManager) getApplicationContext()
                                        .getSystemService(Context.DEVICE_POLICY_SERVICE);
                                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
                                    devicePolicyManager.wipeData(DevicePolicyManager.WIPE_EXTERNAL_STORAGE
                                            | DevicePolicyManager.WIPE_RESET_PROTECTION_DATA);
                                } else {
                                    devicePolicyManager.wipeData(DevicePolicyManager.WIPE_EXTERNAL_STORAGE);
                                }
                            }
                        }).setNegativeButton(android.R.string.no, null).show();
            }
        });
    }

    ImageView logo = (ImageView) findViewById(R.id.imageViewLogo);
    if (Constants.COSU_SECRET_EXIT) {
        logo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                kioskExit++;
                if (kioskExit == 6) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        stopLockTask();
                    }
                    finish();
                }
            }
        });
    }

    etUsername.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            enableSubmitIfReady();
        }

        @Override
        public void afterTextChanged(Editable s) {
            enableSubmitIfReady();
        }
    });

    etPassword.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            enableSubmitIfReady();
        }

        @Override
        public void afterTextChanged(Editable s) {
            enableSubmitIfReady();
        }
    });

    if (org.wso2.iot.agent.proxy.utils.Constants.Authenticator.AUTHENTICATOR_IN_USE
            .equals(org.wso2.iot.agent.proxy.utils.Constants.Authenticator.MUTUAL_SSL_AUTHENTICATOR)) {

        AuthenticatorFactory authenticatorFactory = new AuthenticatorFactory();
        ClientAuthenticator authenticator = authenticatorFactory.getClient(
                org.wso2.iot.agent.proxy.utils.Constants.Authenticator.AUTHENTICATOR_IN_USE,
                AuthenticationActivity.this, Constants.AUTHENTICATION_REQUEST_CODE);
        authenticator.doAuthenticate();
    }

    //This is an override to ownership type.
    if (Constants.DEFAULT_OWNERSHIP != null) {
        deviceType = Constants.DEFAULT_OWNERSHIP;
        Preference.putString(context, Constants.DEVICE_TYPE, deviceType);
    } else {
        deviceType = Constants.OWNERSHIP_BYOD;
    }

    if (Constants.OWNERSHIP_COSU.equals(Constants.DEFAULT_OWNERSHIP)) {
        Intent intent = getIntent();
        if (intent.hasExtra("android.app.extra.token")) {
            adminAccessToken = intent.getStringExtra("android.app.extra.token");
            proceedToAuthentication();
        }
    }

    // This is added so that in case due to an agent customisation, if the authentication
    // activity is called the AUTO_ENROLLMENT_BACKGROUND_SERVICE_ENABLED is set, the activity
    // must be finished.
    if (Constants.AUTO_ENROLLMENT_BACKGROUND_SERVICE_ENABLED) {
        finish();
    }
}

From source file:com.sbhstimetable.sbhs_timetable_android.CountdownFragment.java

public void updateTimer() {
    final View f = this.getView();
    if (f == null) {
        return;//from   w  w  w.j a  va 2 s .  com
    }

    if (timeLeft != null) {
        cancelling = true;
        timeLeft.cancel();
        cancelling = false;
    }

    RelativeLayout extraData = (RelativeLayout) f.findViewById(R.id.countdown_extraData);
    TextView teacher = (TextView) extraData.findViewById(R.id.countdown_extraData_teacher);
    teacher.setText("");
    TextView room = (TextView) extraData.findViewById(R.id.countdown_extraData_room);
    room.setText("");
    TextView subject = (TextView) extraData.findViewById(R.id.countdown_extraData_subject);
    subject.setText("");
    String label = "Something";
    String connector = "happens in";
    TodayJson.Period p = null;
    if (DateTimeHelper.bells != null) {
        BelltimesJson.Bell next = DateTimeHelper.bells.getNextBell();
        if (next != null) {
            BelltimesJson.Bell now = DateTimeHelper.bells.getIndex(next.getIndex() - 1);
            if (now.isPeriod() && now.getPeriodNumber() < 5) { // in a period, it's not last period.
                connector = "ends in";
                if (ApiAccessor.isLoggedIn() && TodayJson.getInstance() != null) {
                    p = TodayJson.getInstance().getPeriod(now.getPeriodNumber());
                    label = p.name();
                    teacher.setText(p.teacher());
                    room.setText(p.room());
                    subject.setText(p.name());
                    extraData.setVisibility(View.VISIBLE);
                } else {
                    label = now.getLabel();
                    extraData.setVisibility(View.INVISIBLE);
                }
            } else if (now.isPeriod() && now.getPeriodNumber() == 5) { // last period
                connector = "in";
                label = "School ends";
                extraData.setVisibility(View.INVISIBLE);
            } else if (now.getIndex() + 1 < DateTimeHelper.bells.getMaxIndex()
                    && DateTimeHelper.bells.getIndex(now.getIndex() + 1).isPeriod()) { // in a break followed by a period - Lunch 2, Recess, Transition.
                connector = "starts in";
                if (ApiAccessor.isLoggedIn() && TodayJson.getInstance() != null) {
                    p = TodayJson.getInstance()
                            .getPeriod(DateTimeHelper.bells.getIndex(now.getIndex() + 1).getPeriodNumber());
                    label = p.name();
                    teacher.setText(p.teacher());
                    room.setText(p.room());
                    subject.setText(p.name());
                    extraData.setVisibility(View.VISIBLE);
                } else {
                    label = DateTimeHelper.bells.getIndex(now.getIndex() + 1).getLabel();
                    extraData.setVisibility(View.VISIBLE);
                }
            } else { // There's consecutive non-periods - i.e lunch 1 -> lunch 2
                label = now.getLabel();
                connector = "starts in";
            }
        } else {
            // end of day
            label = "School starts";
            connector = "in";
            if (TodayJson.getInstance() != null && TodayJson.getInstance().getPeriod(1) != null) {
                extraData.setVisibility(View.VISIBLE);
                p = TodayJson.getInstance().getPeriod(1);
                teacher.setText(p.teacher());
                room.setText(p.room());
                subject.setText(p.name());
            } else {
                extraData.setVisibility(View.INVISIBLE);
            }
        }
    }

    if (p != null) {
        if (p.teacherChanged()) {
            teacher.setTextColor(getActivity().getResources().getColor(R.color.standout));
        } else {
            //teacher.setTextColor(getActivity().getResources().getColor(R.color.secondary_text_dark));
        }
        if (p.roomChanged()) {
            room.setTextColor(getActivity().getResources().getColor(R.color.standout));
        } else {
            //room.setTextColor(getActivity().getResources().getColor(android.R.color.secondary_text_dark));
        }
    }

    final String innerLabel = label;
    ((TextView) f.findViewById(R.id.countdown_name)).setText(label);
    ((TextView) f.findViewById(R.id.countdown_in)).setText(connector);
    final TextView t = (TextView) f.findViewById(R.id.countdown_countdown);
    final CountdownFragment frag = this;
    CountDownTimer timer = new CountDownTimer(DateTimeHelper.milliSecondsUntilNextEvent(), 1000) {
        long lastTime = 10000;
        boolean isLast = innerLabel.equals("School ends");

        @Override
        public void onTick(long l) {
            lastTime = l;
            t.setText(DateTimeHelper.formatToCountdown(l));
        }

        @Override
        public void onFinish() {
            if (this.lastTime <= 1000 && !cancelling) {
                if (this.isLast) {
                    ApiAccessor.getToday(frag.getActivity());
                    ApiAccessor.getBelltimes(frag.getActivity());
                }
                final Handler h = new Handler();
                h.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        updateTimer();
                    }
                }, 1000);
            }
        }
    };
    timer.start();
    timeLeft = timer;
}

From source file:com.wewow.MainActivity.java

private void removeCover(boolean isHideSoftInput) {
    if (isAppBarFolded) {
        imageViewLine.setBackgroundColor(getResources().getColor(R.color.line_color));
        toolbar.setBackgroundColor(getResources().getColor(R.color.white));
        layoutCoverTab.setVisibility(View.GONE);
        mTabLayout.setBackgroundColor(getResources().getColor(R.color.transparent));
    } else {/*from w w  w. jav a  2 s  . c  o m*/
        toolbar.setBackgroundColor(getResources().getColor(R.color.transparent));
    }

    RelativeLayout layoutCover = (RelativeLayout) findViewById(R.id.layoutCover);
    layoutCover.setVisibility(View.GONE);

    if (isHideSoftInput) {
        new Handler().postDelayed(new Runnable() {

            public void run() {
                //execute the task
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

                imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0);
            }
        }, 100);
    }
}

From source file:org.woltage.irssiconnectbot.ConsoleActivity.java

@Override
@TargetApi(11)/*from ww  w.j av a2 s.co m*/
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    if (!InstallMosh.isInstallStarted()) {
        new InstallMosh(this);
    }

    configureStrictMode();
    hardKeyboard = getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY;

    hardKeyboard = hardKeyboard && !Build.MODEL.contains("Transformer");

    this.setContentView(R.layout.act_console);
    BugSenseHandler.setup(this, "d27a12dc");

    clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    // hide action bar if requested by user
    try {
        ActionBar actionBar = getActionBar();
        if (!prefs.getBoolean(PreferenceConstants.ACTIONBAR, true)) {
            actionBar.hide();
        }
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
    } catch (NoSuchMethodError error) {
        Log.w(TAG, "Android sdk version pre 11. Not touching ActionBar.");
    }

    // hide status bar if requested by user
    if (prefs.getBoolean(PreferenceConstants.FULLSCREEN, false)) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    // TODO find proper way to disable volume key beep if it exists.
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    // handle requested console from incoming intent
    requested = getIntent().getData();

    inflater = LayoutInflater.from(this);

    flip = (ViewFlipper) findViewById(R.id.console_flip);
    empty = (TextView) findViewById(android.R.id.empty);

    stringPromptGroup = (RelativeLayout) findViewById(R.id.console_password_group);
    stringPromptInstructions = (TextView) findViewById(R.id.console_password_instructions);
    stringPrompt = (EditText) findViewById(R.id.console_password);
    stringPrompt.setOnKeyListener(new OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_UP)
                return false;
            if (keyCode != KeyEvent.KEYCODE_ENTER)
                return false;

            // pass collected password down to current terminal
            String value = stringPrompt.getText().toString();

            PromptHelper helper = getCurrentPromptHelper();
            if (helper == null)
                return false;
            helper.setResponse(value);

            // finally clear password for next user
            stringPrompt.setText("");
            updatePromptVisible();

            return true;
        }
    });

    booleanPromptGroup = (RelativeLayout) findViewById(R.id.console_boolean_group);
    booleanPrompt = (TextView) findViewById(R.id.console_prompt);

    booleanYes = (Button) findViewById(R.id.console_prompt_yes);
    booleanYes.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            PromptHelper helper = getCurrentPromptHelper();
            if (helper == null)
                return;
            helper.setResponse(Boolean.TRUE);
            updatePromptVisible();
        }
    });

    booleanNo = (Button) findViewById(R.id.console_prompt_no);
    booleanNo.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            PromptHelper helper = getCurrentPromptHelper();
            if (helper == null)
                return;
            helper.setResponse(Boolean.FALSE);
            updatePromptVisible();
        }
    });

    // preload animations for terminal switching
    slide_left_in = AnimationUtils.loadAnimation(this, R.anim.slide_left_in);
    slide_left_out = AnimationUtils.loadAnimation(this, R.anim.slide_left_out);
    slide_right_in = AnimationUtils.loadAnimation(this, R.anim.slide_right_in);
    slide_right_out = AnimationUtils.loadAnimation(this, R.anim.slide_right_out);

    fade_out_delayed = AnimationUtils.loadAnimation(this, R.anim.fade_out_delayed);
    fade_stay_hidden = AnimationUtils.loadAnimation(this, R.anim.fade_stay_hidden);

    // Preload animation for keyboard button
    keyboard_fade_in = AnimationUtils.loadAnimation(this, R.anim.keyboard_fade_in);
    keyboard_fade_out = AnimationUtils.loadAnimation(this, R.anim.keyboard_fade_out);

    inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    final RelativeLayout keyboardGroup = (RelativeLayout) findViewById(R.id.keyboard_group);

    if (Build.MODEL.contains("Transformer")
            && getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY
            && prefs.getBoolean(PreferenceConstants.ACTIONBAR, true)) {
        keyboardGroup.setEnabled(false);
        keyboardGroup.setVisibility(View.INVISIBLE);
    }

    mKeyboardButton = (ImageView) findViewById(R.id.button_keyboard);
    mKeyboardButton.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            View flip = findCurrentView(R.id.console_flip);
            if (flip == null)
                return;

            inputManager.showSoftInput(flip, InputMethodManager.SHOW_FORCED);
            keyboardGroup.setVisibility(View.GONE);
        }
    });

    final ImageView symButton = (ImageView) findViewById(R.id.button_sym);
    symButton.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            View flip = findCurrentView(R.id.console_flip);
            if (flip == null)
                return;

            TerminalView terminal = (TerminalView) flip;

            TerminalKeyListener handler = terminal.bridge.getKeyHandler();
            handler.showCharPickerDialog(terminal);
            keyboardGroup.setVisibility(View.GONE);
        }
    });

    mInputButton = (ImageView) findViewById(R.id.button_input);
    mInputButton.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            View flip = findCurrentView(R.id.console_flip);
            if (flip == null)
                return;

            final TerminalView terminal = (TerminalView) flip;
            Thread promptThread = new Thread(new Runnable() {
                public void run() {
                    String inj = getCurrentPromptHelper().requestStringPrompt(null, "");
                    terminal.bridge.injectString(inj);
                }
            });
            promptThread.setName("Prompt");
            promptThread.setDaemon(true);
            promptThread.start();

            keyboardGroup.setVisibility(View.GONE);
        }
    });

    final ImageView ctrlButton = (ImageView) findViewById(R.id.button_ctrl);
    ctrlButton.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            View flip = findCurrentView(R.id.console_flip);
            if (flip == null)
                return;
            TerminalView terminal = (TerminalView) flip;

            TerminalKeyListener handler = terminal.bridge.getKeyHandler();
            handler.metaPress(TerminalKeyListener.META_CTRL_ON);
            terminal.bridge.tryKeyVibrate();

            keyboardGroup.setVisibility(View.GONE);
        }
    });

    final ImageView escButton = (ImageView) findViewById(R.id.button_esc);
    escButton.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            View flip = findCurrentView(R.id.console_flip);
            if (flip == null)
                return;
            TerminalView terminal = (TerminalView) flip;

            TerminalKeyListener handler = terminal.bridge.getKeyHandler();
            handler.sendEscape();
            terminal.bridge.tryKeyVibrate();
            keyboardGroup.setVisibility(View.GONE);
        }
    });

    // detect fling gestures to switch between terminals
    final GestureDetector detect = new GestureDetector(new ICBSimpleOnGestureListener(this));

    flip.setLongClickable(true);
    flip.setOnTouchListener(new ICBOnTouchListener(this, keyboardGroup, detect));

}