Example usage for android.widget ProgressBar setEnabled

List of usage examples for android.widget ProgressBar setEnabled

Introduction

In this page you can find the example usage for android.widget ProgressBar setEnabled.

Prototype

@RemotableViewMethod
public void setEnabled(boolean enabled) 

Source Link

Document

Set the enabled state of this view.

Usage

From source file:com.myapps.upesse.upes_spefest.ui.utils.GlideUtil.java

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static void loadImage(String url, ImageView mPhotoView, final ProgressBar mProgress) {
    Context context = mPhotoView.getContext();
    if (context != null || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)) {
        assert context != null;
        ColorDrawable cd = new ColorDrawable(ContextCompat.getColor(context, R.color.blue_grey_500));

        mProgress.setEnabled(true);
        Glide.with(context).load(url).listener(new RequestListener<String, GlideDrawable>() {
            @Override/*  w  w  w  .  j a va 2  s.  c  o m*/
            public boolean onException(Exception e, String model, Target<GlideDrawable> target,
                    boolean isFirstResource) {
                mProgress.setVisibility(View.GONE);
                return false;
            }

            @Override
            public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target,
                    boolean isFromMemoryCache, boolean isFirstResource) {
                mProgress.setVisibility(View.GONE);
                return false;
            }
        }).placeholder(cd).crossFade().centerCrop().into(mPhotoView);
    }
}

From source file:fr.bmartel.android.flowerpower.FlowerPowerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_flower_power);

    // Use this check to determine whether BLE is supported on the device. Then
    // you can selectively disable BLE-related features.
    if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
        Toast.makeText(this, "Bluetooth Smart is not supported on your device", Toast.LENGTH_SHORT).show();
        finish();//w w w.j  a  v  a 2 s. c  o  m
    }

    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    if (!mBluetoothAdapter.isEnabled()) {
        Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
    }

    final ProgressBar progress_bar = (ProgressBar) findViewById(R.id.scanningProgress);

    if (progress_bar != null)
        progress_bar.setEnabled(false);

    final Button button_stop_scanning = (Button) findViewById(R.id.stop_scanning_button);

    if (button_stop_scanning != null)
        button_stop_scanning.setEnabled(false);

    final TextView scanText = (TextView) findViewById(R.id.scanText);

    if (scanText != null)
        scanText.setText("");

    registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());

    button_stop_scanning.setEnabled(false);

    final Button button_find_accessory = (Button) findViewById(R.id.scanning_button);

    button_stop_scanning.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (currentService.isScanning()) {
                currentService.stopScan();

                if (progress_bar != null) {
                    progress_bar.setEnabled(false);
                    progress_bar.setVisibility(View.GONE);
                }

                if (scanText != null)
                    scanText.setText("");

                if (button_stop_scanning != null)
                    button_stop_scanning.setEnabled(false);
            }
        }
    });

    button_find_accessory.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            triggerNewScan();
        }
    });

    if (mBluetoothAdapter.isEnabled()) {

        Intent intent = new Intent(this, FlowerPowerBtService.class);
        // bind the service to current activity and create it if it didnt exist before
        startService(intent);
        bound = bindService(intent, mServiceConnection, BIND_AUTO_CREATE);
    }
}

From source file:fr.bmartel.android.dotti.DottiActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dotti);

    // Use this check to determine whether BLE is supported on the device. Then
    // you can selectively disable BLE-related features.
    if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
        Toast.makeText(this, "Bluetooth Smart is not supported on your device", Toast.LENGTH_SHORT).show();
        finish();//  ww  w  . j ava  2 s  .  c  o  m
    }

    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    if (!mBluetoothAdapter.isEnabled()) {
        Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
    }

    final ProgressBar progress_bar = (ProgressBar) findViewById(R.id.scanningProgress);

    if (progress_bar != null)
        progress_bar.setEnabled(false);

    final Button button_stop_scanning = (Button) findViewById(R.id.stop_scanning_button);

    if (button_stop_scanning != null)
        button_stop_scanning.setEnabled(false);

    final TextView scanText = (TextView) findViewById(R.id.scanText);

    if (scanText != null)
        scanText.setText("");

    registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());

    button_stop_scanning.setEnabled(false);

    final Button button_find_accessory = (Button) findViewById(R.id.scanning_button);

    button_stop_scanning.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            if (currentService != null && currentService.isScanning()) {

                currentService.stopScan();

                if (progress_bar != null) {
                    progress_bar.setEnabled(false);
                    progress_bar.setVisibility(View.GONE);
                }

                if (scanText != null)
                    scanText.setText("");

                if (button_stop_scanning != null)
                    button_stop_scanning.setEnabled(false);
            }
        }
    });

    button_find_accessory.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            triggerNewScan();
        }
    });

    if (mBluetoothAdapter.isEnabled()) {

        Intent intent = new Intent(this, DottiBtService.class);

        // bind the service to current activity and create it if it didnt exist before
        startService(intent);
        bound = bindService(intent, mServiceConnection, BIND_AUTO_CREATE);
    }
}

From source file:fr.bmartel.android.flowerpower.FlowerPowerActivity.java

/**
 * trigger a BLE scan/*from   w ww  .j av a 2  s  .c  o  m*/
 */
public void triggerNewScan() {

    Button button_stop_scanning = (Button) findViewById(R.id.stop_scanning_button);
    ProgressBar progress_bar = (ProgressBar) findViewById(R.id.scanningProgress);
    TextView scanText = (TextView) findViewById(R.id.scanText);

    if (button_stop_scanning != null && progress_bar != null && scanText != null) {
        if (!currentService.isScanning()) {

            Toast.makeText(FlowerPowerActivity.this, "Looking for new accessories", Toast.LENGTH_SHORT).show();

            if (button_stop_scanning != null)
                button_stop_scanning.setEnabled(true);

            if (progress_bar != null) {
                progress_bar.setEnabled(true);
                progress_bar.setVisibility(View.VISIBLE);
            }

            if (scanText != null)
                scanText.setText("Scanning ...");

            //start scan so clear list view
            currentService.getListViewAdapter().clear();
            currentService.getListViewAdapter().notifyDataSetChanged();

            currentService.clearListAdapter();

            currentService.scanLeDevice(true);
        } else {
            Toast.makeText(FlowerPowerActivity.this, "Scanning already engaged...", Toast.LENGTH_SHORT).show();
        }
    }
}

From source file:fr.bmartel.android.dotti.DottiActivity.java

/**
 * trigger a BLE scan/*from  w w  w  . ja  v  a 2s.co  m*/
 */
public void triggerNewScan() {

    Button button_stop_scanning = (Button) findViewById(R.id.stop_scanning_button);
    ProgressBar progress_bar = (ProgressBar) findViewById(R.id.scanningProgress);
    TextView scanText = (TextView) findViewById(R.id.scanText);

    if (button_stop_scanning != null && progress_bar != null && scanText != null) {
        if (currentService != null && !currentService.isScanning()) {

            Toast.makeText(DottiActivity.this, "Looking for new accessories", Toast.LENGTH_SHORT).show();

            if (button_stop_scanning != null)
                button_stop_scanning.setEnabled(true);

            if (progress_bar != null) {
                progress_bar.setEnabled(true);
                progress_bar.setVisibility(View.VISIBLE);
            }

            if (scanText != null)
                scanText.setText("Scanning ...");

            //start scan so clear list view
            currentService.getListViewAdapter().clear();
            currentService.getListViewAdapter().notifyDataSetChanged();
            currentService.clearListAdapter();

            Log.i(TAG, "START SCAN");

            currentService.disconnectall();

            currentService.scanLeDevice(true);

        } else {
            Toast.makeText(DottiActivity.this, "Scanning already engaged...", Toast.LENGTH_SHORT).show();
        }
    }
}