Search in sources :

Example 1 with CircularProgressView

use of com.github.rahatarmanahmed.cpv.CircularProgressView in project HAR-Android by linw7.

the class RemindPhoneActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_remind_phone);
    set_start = (CircularProgressButton) findViewById(R.id.set_start);
    time = (TextView) findViewById(R.id.time);
    activity = (TextView) findViewById(R.id.activity);
    progressView = (CircularProgressView) findViewById(R.id.progress_view);
    energy_step = (TextView) findViewById(R.id.energy_step);
    distance_step = (TextView) findViewById(R.id.distance_step);
    time_start = (TextView) findViewById(R.id.time_start);
    time_end = (TextView) findViewById(R.id.time_end);
    acc_sensor = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    sensor_type = Sensor.TYPE_ACCELEROMETER;
    acc_sensor.registerListener(acc_listener, acc_sensor.getDefaultSensor(sensor_type), SensorManager.SENSOR_DELAY_FASTEST);
    set_start.setIndeterminateProgressMode(true);
    activity.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            for (int i = 0; i < check.length; i++) check[i] = false;
            AlertDialog dialog = new AlertDialog.Builder(RemindPhoneActivity.this).setTitle("请选择监控行为").setIcon(R.drawable.logo_activity).setNegativeButton("取消", null).setPositiveButton("确定", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String str = set_activity();
                    choice_activity = 1;
                }
            }).setMultiChoiceItems(ACTIVITY, null, new DialogInterface.OnMultiChoiceClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                    check[which] = true;
                }
            }).create();
            dialog.show();
        }
    });
    time.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Calendar calendar = Calendar.getInstance();
            TimePickerDialog timePickerDialog = new TimePickerDialog(RemindPhoneActivity.this, new TimePickerDialog.OnTimeSetListener() {

                @Override
                public void onTimeSet(TimePicker view, int h, int m) {
                    hour = h;
                    minute = m;
                    second = 10;
                    // second = h * 3600 + m * 60;
                    String time_length = "" + (h * 60 + minute);
                    choice_time = 1;
                }
            }, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), true);
            timePickerDialog.show();
        }
    });
    set_start.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            tag = 1;
            retag = 1;
            set_start.setProgress(60);
            progressView.startAnimation();
            if ((choice_time == 1) && (choice_activity == 1) && has_set()) {
                for (int i = 0; i < 6; i++) {
                    if (check[i] == true) {
                        set_time[i] = second;
                        Log.i("" + ACTIVITY[i], "" + set_time[i]);
                    }
                }
                alter_ok();
            } else
                alter_no(choice_time, choice_activity);
        }
    });
}
Also used : AlertDialog(android.app.AlertDialog) TimePicker(android.widget.TimePicker) DialogInterface(android.content.DialogInterface) Calendar(java.util.Calendar) TimePickerDialog(android.app.TimePickerDialog) CircularProgressView(com.github.rahatarmanahmed.cpv.CircularProgressView) View(android.view.View) TextView(android.widget.TextView)

Example 2 with CircularProgressView

use of com.github.rahatarmanahmed.cpv.CircularProgressView in project HAR-Android by linw7.

the class StepMainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_step_main);
    total_step = (TextView) findViewById(R.id.total_step);
    current_step = (TextView) findViewById(R.id.current_step);
    energy_step = (TextView) findViewById(R.id.energy_step);
    distance_step = (TextView) findViewById(R.id.distance_step);
    circular_button = (CircularProgressButton) findViewById(R.id.circular_button);
    progress_step = (ProgressBar) findViewById(R.id.progress_step);
    progress_energy = (ProgressBar) findViewById(R.id.progress_energy);
    progress_step_text = (TextView) findViewById(R.id.progress_step_text);
    progress_energy_text = (TextView) findViewById(R.id.progress_energy_text);
    progressView = (CircularProgressView) findViewById(R.id.progress_view);
    target_step = (TextView) findViewById(R.id.target_step);
    target_energy = (TextView) findViewById(R.id.target_energy);
    text_step = (TextView) findViewById(R.id.text_step);
    text_energy = (TextView) findViewById(R.id.text_energy);
    runable = false;
    circular_button.setIndeterminateProgressMode(true);
    // 设置目标
    target_step.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AlertDialog dialog = new AlertDialog.Builder(StepMainActivity.this).setTitle("请设置步数目标").setIcon(R.drawable.logo_activity).setSingleChoiceItems(STEP, -1, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Toast.makeText(StepMainActivity.this, STEP[which], Toast.LENGTH_SHORT).show();
                    if (which == 0)
                        set_step = 2000;
                    else if (which == 1)
                        set_step = 4000;
                    else if (which == 2)
                        set_step = 6000;
                    else if (which == 3)
                        set_step = 8000;
                    else if (which == 4)
                        set_step = 10000;
                    set_step = 100;
                    Log.i("step", "设置步数:" + set_step);
                    dialog.dismiss();
                }
            }).create();
            dialog.show();
        }
    });
    // 设置能量目标
    target_energy.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AlertDialog dialog = new AlertDialog.Builder(StepMainActivity.this).setTitle("请设置卡路里目标").setIcon(R.drawable.logo_activity).setSingleChoiceItems(ENERGY, -1, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Toast.makeText(StepMainActivity.this, ENERGY[which], Toast.LENGTH_SHORT).show();
                    if (which == 0)
                        set_energy = 300;
                    else if (which == 1)
                        set_energy = 600;
                    else if (which == 2)
                        set_energy = 900;
                    else if (which == 3)
                        set_energy = 1200;
                    else if (which == 4)
                        set_energy = 1500;
                    set_energy = 6;
                    dialog.dismiss();
                }
            }).create();
            dialog.show();
        }
    });
    // 传感器
    final SensorEventListener step_listener = new SensorEventListener() {

        @Override
        public void onSensorChanged(SensorEvent sensorEvent) {
            if (sensorEvent.sensor.getType() == Sensor.TYPE_STEP_COUNTER) {
                if (new_start == false) {
                    new_start = true;
                    cur_step = (int) (sensorEvent.values[0]);
                }
                mCount = sensorEvent.values[0];
            }
            if (sensorEvent.sensor.getType() == Sensor.TYPE_STEP_DETECTOR) {
                if (sensorEvent.values[0] == 1.0) {
                    mDetector = mDetector + 1;
                }
            }
        }

        @Override
        public // 传感器精度改变时调用
        void onAccuracyChanged(Sensor sensor, int i) {
        }
    };
    mCount = 0;
    mDetector = 0;
    mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mStepCount = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
    mStepDetector = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR);
    mSensorManager.registerListener(step_listener, mStepCount, SensorManager.SENSOR_DELAY_FASTEST);
    mSensorManager.registerListener(step_listener, mStepDetector, SensorManager.SENSOR_DELAY_FASTEST);
    timer.schedule(display_task, 0, 100);
    circular_button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!runable) {
                run();
            } else {
                reset();
            }
        }
    });
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) SensorEventListener(android.hardware.SensorEventListener) CircularProgressView(com.github.rahatarmanahmed.cpv.CircularProgressView) TextView(android.widget.TextView) View(android.view.View) SensorEvent(android.hardware.SensorEvent) Sensor(android.hardware.Sensor)

Example 3 with CircularProgressView

use of com.github.rahatarmanahmed.cpv.CircularProgressView in project ForPDA by RadiationX.

the class ImagesAdapter method loadImage.

private void loadImage(View imageLayout, int position) {
    assert imageLayout != null;
    CircularProgressView progressBar = (CircularProgressView) imageLayout.findViewById(R.id.progress_bar);
    PhotoView photoView = (PhotoView) imageLayout.findViewById(R.id.photo_view);
    if (crop)
        photoView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    if (clickListener != null)
        photoView.setOnClickListener(v -> clickListener.itemClick(v, position));
    imageLoader.displayImage(urls.get(position), photoView, options, new SimpleImageLoadingListener() {

        @Override
        public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            progressBar.setVisibility(View.GONE);
        }

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            progressBar.setVisibility(View.GONE);
        // delayedHide(1000);
        }

        @Override
        public void onLoadingCancelled(String imageUri, View view) {
            progressBar.setVisibility(View.GONE);
        }

        @Override
        public void onLoadingStarted(String imageUri, View view) {
            progressBar.setVisibility(View.VISIBLE);
            if (progressBar.isIndeterminate()) {
                progressBar.setIndeterminate(false);
                progressBar.stopAnimation();
            }
        }
    }, (s, view, i, i1) -> progressBar.setProgress((int) (100F * i / i1)));
    photoView.setOnPhotoTapListener(tapListener);
}
Also used : PhotoView(com.github.chrisbanes.photoview.PhotoView) CircularProgressView(com.github.rahatarmanahmed.cpv.CircularProgressView) Context(android.content.Context) LayoutInflater(android.view.LayoutInflater) PhotoView(com.github.chrisbanes.photoview.PhotoView) ImageView(android.widget.ImageView) PagerAdapter(android.support.v4.view.PagerAdapter) ImageLoader(com.nostra13.universalimageloader.core.ImageLoader) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) ViewGroup(android.view.ViewGroup) List(java.util.List) Bitmap(android.graphics.Bitmap) OnPhotoTapListener(com.github.chrisbanes.photoview.OnPhotoTapListener) SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) View(android.view.View) App(forpdateam.ru.forpda.App) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) R(forpdateam.ru.forpda.R) Log(android.util.Log) SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) CircularProgressView(com.github.rahatarmanahmed.cpv.CircularProgressView) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) CircularProgressView(com.github.rahatarmanahmed.cpv.CircularProgressView) PhotoView(com.github.chrisbanes.photoview.PhotoView) ImageView(android.widget.ImageView) View(android.view.View)

Aggregations

View (android.view.View)3 CircularProgressView (com.github.rahatarmanahmed.cpv.CircularProgressView)3 AlertDialog (android.app.AlertDialog)2 DialogInterface (android.content.DialogInterface)2 TextView (android.widget.TextView)2 TimePickerDialog (android.app.TimePickerDialog)1 Context (android.content.Context)1 Bitmap (android.graphics.Bitmap)1 Sensor (android.hardware.Sensor)1 SensorEvent (android.hardware.SensorEvent)1 SensorEventListener (android.hardware.SensorEventListener)1 PagerAdapter (android.support.v4.view.PagerAdapter)1 Log (android.util.Log)1 LayoutInflater (android.view.LayoutInflater)1 ViewGroup (android.view.ViewGroup)1 ImageView (android.widget.ImageView)1 TimePicker (android.widget.TimePicker)1 OnPhotoTapListener (com.github.chrisbanes.photoview.OnPhotoTapListener)1 PhotoView (com.github.chrisbanes.photoview.PhotoView)1 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)1