aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/miz_hi/smileessence/dialog/SeekBarDialog.java
blob: aab761ce8b01b859ae3a8837085f32fe89de9481 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package net.miz_hi.smileessence.dialog;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface.OnClickListener;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import net.miz_hi.smileessence.R;

public class SeekBarDialog
{

    private Activity activity;
    private String title, text;
    private OnClickListener listener;
    private int seekBarMax;
    private int seekBarStart = 1;
    private View dialogView;
    private TextView textView, levelView;
    private SeekBar seekbar;
    private int levelCorrect = 0;

    public SeekBarDialog(Activity activity, String title)
    {
        this.activity = activity;
        this.title = title;
        LayoutInflater layoutInflater = LayoutInflater.from(activity);
        dialogView = layoutInflater.inflate(R.layout.dialog_seekbar_layout, null);
        textView = (TextView) dialogView.findViewById(R.id.textView_seekDialog);
        levelView = (TextView) dialogView.findViewById(R.id.textView_seekLevel);
        seekbar = (SeekBar) dialogView.findViewById(R.id.seekBar_seekDialog);
    }

    public void setText(String text)
    {
        this.text = text;
    }

    public void setOnClickListener(OnClickListener listener)
    {
        this.listener = listener;
    }

    public void setSeekBarMax(int i)
    {
        this.seekBarMax = i;
    }

    public void setSeekBarStart(int i)
    {
        this.seekBarStart = i;
    }

    public void setLevelCorrect(int addition)
    {
        this.levelCorrect = addition;
    }

    public int getProgress()
    {
        return this.seekbar.getProgress();
    }

    public AlertDialog createSeekBarDialog()
    {
        ContentDialog dialog = new ContentDialog(activity, title);
        textView.setText(text);
        seekbar.setMax(seekBarMax);
        seekbar.setProgress(seekBarStart);
        levelView.setText(Integer.toString(seekBarStart + levelCorrect));
        seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
        {
            @Override
            public void onStopTrackingTouch(SeekBar seekbar)
            {
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekbar)
            {
            }

            @Override
            public void onProgressChanged(SeekBar seekbar, int i, boolean flag)
            {
                levelView.setText(String.valueOf(i + levelCorrect));
            }
        });

        dialog.setContentView(dialogView);
        dialog.setOnClickListener(listener);
        return dialog.create();
    }

}