[Android] Simplify LayoutInflater retrieval for KeyBindPreference.java and SeekbarPreference.java.
Simplify application info retrieval in OverlayActivity.java.
This commit is contained in:
parent
16127e046c
commit
e71bce0cbd
|
@ -7,7 +7,7 @@ import android.os.Bundle;
|
|||
public final class OverlayActivity extends DirectoryActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
File overlayDir = new File(getBaseContext().getApplicationInfo().dataDir, "overlays");
|
||||
File overlayDir = new File(getApplicationInfo().dataDir, "overlays");
|
||||
if (overlayDir.exists())
|
||||
super.setStartDirectory(overlayDir.getAbsolutePath());
|
||||
|
||||
|
|
|
@ -42,15 +42,16 @@ final class KeyBindEditText extends EditText
|
|||
final class KeyBindPreference extends DialogPreference implements View.OnKeyListener, AdapterView.OnItemClickListener, LayoutInflater.Factory {
|
||||
private int key_bind_code;
|
||||
private boolean grabKeyCode = false;
|
||||
KeyBindEditText keyText;
|
||||
private KeyBindEditText keyText;
|
||||
private String[] key_labels;
|
||||
private final int DEFAULT_KEYCODE = 0;
|
||||
private final Context context;
|
||||
|
||||
public KeyBindPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
this.context = context;
|
||||
key_labels = getContext().getResources().getStringArray(R.array.key_bind_values);
|
||||
this.key_labels = getContext().getResources().getStringArray(R.array.key_bind_values);
|
||||
}
|
||||
|
||||
private void setKey(int keyCode, boolean force)
|
||||
|
@ -63,15 +64,10 @@ final class KeyBindPreference extends DialogPreference implements View.OnKeyList
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindDialogView(View view) {
|
||||
super.onBindDialogView(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected View onCreateDialogView()
|
||||
{
|
||||
LayoutInflater inflater = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).cloneInContext(getContext());
|
||||
LayoutInflater inflater = LayoutInflater.from(context).cloneInContext(getContext());
|
||||
inflater.setFactory(this);
|
||||
View view = inflater.inflate(R.layout.key_bind_dialog, null);
|
||||
keyText = (KeyBindEditText) view.findViewById(R.id.key_bind_value);
|
||||
|
|
|
@ -11,26 +11,34 @@ import android.widget.SeekBar;
|
|||
import android.widget.TextView;
|
||||
|
||||
public final class SeekbarPreference extends DialogPreference implements SeekBar.OnSeekBarChangeListener {
|
||||
float seek_value;
|
||||
SeekBar bar;
|
||||
TextView text;
|
||||
|
||||
private float seek_value;
|
||||
private SeekBar bar;
|
||||
private TextView text;
|
||||
private final Context context;
|
||||
|
||||
public SeekbarPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected View onCreateDialogView()
|
||||
{
|
||||
LayoutInflater inflater = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE));
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
View view = inflater.inflate(R.layout.seek_dialog, null);
|
||||
bar = (SeekBar) view.findViewById(R.id.seekbar_bar);
|
||||
text = (TextView) view.findViewById(R.id.seekbar_text);
|
||||
seek_value = getPersistedFloat(1.0f);
|
||||
this.bar = (SeekBar) view.findViewById(R.id.seekbar_bar);
|
||||
this.text = (TextView) view.findViewById(R.id.seekbar_text);
|
||||
this.seek_value = getPersistedFloat(1.0f);
|
||||
|
||||
// Set initial progress for seek bar and set the listener.
|
||||
int prog = (int) (seek_value * 100);
|
||||
bar.setProgress(prog);
|
||||
text.setText(prog + "%");
|
||||
bar.setOnSeekBarChangeListener(this);
|
||||
this.bar.setProgress(prog);
|
||||
this.text.setText(prog + "%");
|
||||
this.bar.setOnSeekBarChangeListener(this);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue