Example usage for android.widget TextView bringToFront

List of usage examples for android.widget TextView bringToFront

Introduction

In this page you can find the example usage for android.widget TextView bringToFront.

Prototype

public void bringToFront() 

Source Link

Document

Change the view's z order in the tree, so it's on top of other sibling views.

Usage

From source file:com.elitise.appv2.Peripheral.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent I = getIntent();/*from  ww  w . j av a2 s  .co  m*/
    name = I.getStringExtra("mBname");
    batteryIdx = I.getIntExtra("idx", -1);
    if (!sNExist()) {
        String mSN = I.getStringExtra("mSN");
        saveSN(mSN);
    }
    isTablet = isTabletDevice();

    //    FirebaseStorage storage = FirebaseStorage.getInstance();
    //    StorageReference storageRef = storage.getReference();
    //    FirebaseOptions opts = FirebaseApp.getInstance().getOptions();
    //    Log.e(TAG, "Bucket = " + opts.getStorageBucket()+"\n URL"+opts.getApplicationId());
    //mDetetor = new GestureDetectorCompat(this, new MyGestureListener());

    setContentView(R.layout.activity_peripherals);
    TextView demoText = (TextView) findViewById(R.id.demoText);
    if (mUser.getBatteriesList().get(batteryIdx).isDemo) {
        demoText.setVisibility(View.VISIBLE);
        demoText.bringToFront();
    } else {
        demoText.setVisibility(View.INVISIBLE);
    }
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    mBluetoothDevices = new HashSet<>();
    mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
    mBluetoothAdapter = mBluetoothManager.getAdapter();
    sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    statusBar = (TextView) findViewById(R.id.statusBar);
    //    boolean enableDiag = sharedPrefs.getBoolean(getString(R.string.pref_mode_key), false);
    //

    //    if (!enableDiag)
    //      mCurrentServiceFragment = new BatteryServiceFragment();
    //    else
    //      mCurrentServiceFragment = new BatteryServiceDiagFragment();
    if (savedInstanceState != null) {
        phoneFragment = (PhoneLayoutFragement) getSupportFragmentManager().findFragmentByTag("PHONE");
        normalFragment = (BatteryServiceFragment) getSupportFragmentManager().findFragmentByTag("NORMAL");
        diagFragment = (BatteryServiceDiagFragment) getSupportFragmentManager().findFragmentByTag("DIAG");
        if (isTablet) {
            mCurrentServiceFragment = normalFragment;
        } else {
            mCurrentServiceFragment = phoneFragment;
        }

    } else {
        diagFragment = new BatteryServiceDiagFragment();
        normalFragment = new BatteryServiceFragment();
        phoneFragment = new PhoneLayoutFragement();
        //mCurrentServiceFragment = normalFragment;

        Bundle bd = new Bundle();
        bd.putString("mBname", name);
        bd.putInt("bIndex", batteryIdx);
        diagFragment.setArguments(bd);
        normalFragment.setArguments(bd);
        phoneFragment.setArguments(bd);
        if (isTablet) {
            mCurrentServiceFragment = normalFragment;
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.normal_fragment_container, normalFragment, "NORMAL")
                    .add(R.id.diag_fragment_container, diagFragment, "DIAG").hide(diagFragment)
                    .show(normalFragment).commit();
        } else {
            mCurrentServiceFragment = phoneFragment;
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.phone_fragment_container, phoneFragment, "PHONE")
                    .add(R.id.normal_fragment_container, normalFragment, "NORMAL")
                    .add(R.id.diag_fragment_container, diagFragment, "DIAG").hide(diagFragment)
                    .hide(normalFragment).show(phoneFragment).commit();
        }
        mCurrentServiceFragment.setArguments(bd);
    }

    if (!mUser.getBatteriesList().get(batteryIdx).isBonded) {
        mBluetoothGattService = mCurrentServiceFragment.getBluetoothGattService();
    } else {
        mBluetoothGattService = mCurrentServiceFragment.getBluetoothGattServiceCustom();
    }

    mAdvSettings = new AdvertiseSettings.Builder().setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED)
            .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH).setConnectable(true).setTimeout(0)
            .build();

    mAdvData = new AdvertiseData.Builder().setIncludeDeviceName(false).setIncludeTxPowerLevel(false)
            .addServiceUuid(
                    mCurrentServiceFragment.getServiceUUID(mUser.getBatteriesList().get(batteryIdx).isBonded))
            .build();

    mScanResponse = new AdvertiseData.Builder().setIncludeDeviceName(true).setIncludeTxPowerLevel(true).build();

    //
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar2);
    setSupportActionBar(toolbar);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);

    getSupportActionBar().setDisplayShowTitleEnabled(false);

    logoView = (Logo_pathsView) findViewById(R.id.logoBar);

    Context context = getApplicationContext(); // or activity.getApplicationContext()
    PackageManager packageManager = context.getPackageManager();
    String packageName = context.getPackageName();

    String myVersionName = "1.0.0"; // initialize String

    try {
        myVersionName = packageManager.getPackageInfo(packageName, 0).versionName;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    logoView.setVersion(myVersionName);

    if (!mBluetoothAdapter.isMultipleAdvertisementSupported()) {
        new MaterialDialog.Builder(this).title("BLE ERROR")
                .content("Sorry, this device not support BLE peripheral mode").positiveText("CONFIRM")
                .onPositive(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        finish();
                    }
                });
    }

}