Changed IdFragment to BaseFeatureFragment
I also cleaned up some redundant code by moving most if the base requirements of features into BaseFeatureFragment Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -0,0 +1,102 @@
|
|||||||
|
/**
|
||||||
|
* FeatureFragment.java
|
||||||
|
* @date May 26, 2012
|
||||||
|
* @author ricky barrette
|
||||||
|
* @author Twenty Codes, LLC
|
||||||
|
*/
|
||||||
|
package com.TwentyCodes.android.LocationRinger.ui.fragments;
|
||||||
|
|
||||||
|
import com.TwentyCodes.android.LocationRinger.FeatureRemovedListener;
|
||||||
|
import com.TwentyCodes.android.LocationRinger.R;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a simple extention of a fragment that will allow for storage of an id
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
public class BaseFeatureFragment extends Fragment implements OnClickListener{
|
||||||
|
|
||||||
|
private final int mId;
|
||||||
|
private final FeatureRemovedListener mRemovedListener;
|
||||||
|
private final int mIconRes;
|
||||||
|
private final int mLayout;
|
||||||
|
private ImageView mIcon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Feature Fragment
|
||||||
|
* @param id
|
||||||
|
* @param layout
|
||||||
|
* @param listener
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
public BaseFeatureFragment(int id, int layout, FeatureRemovedListener listener){
|
||||||
|
this(id, layout, -1, listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new FeatureFragment
|
||||||
|
* @param id
|
||||||
|
* @param layout
|
||||||
|
* @param icon
|
||||||
|
* @param listener
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
public BaseFeatureFragment(int id, int layout, int icon, FeatureRemovedListener listener){
|
||||||
|
super();
|
||||||
|
if ( listener == null )
|
||||||
|
throw new NullPointerException();
|
||||||
|
mRemovedListener = listener;
|
||||||
|
mId = id;
|
||||||
|
mIconRes = icon;
|
||||||
|
mLayout = layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the id of this fragment
|
||||||
|
*/
|
||||||
|
public int getFragmentId() {
|
||||||
|
return mId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the user clicks the remove button
|
||||||
|
* @param v
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if(v.getId() == R.id.close)
|
||||||
|
if(this.mRemovedListener != null)
|
||||||
|
this.mRemovedListener.onFeatureRemoved(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
final View view = inflater.inflate(mLayout, container, false);
|
||||||
|
mIcon = (ImageView) view.findViewById(R.id.icon);
|
||||||
|
view.findViewById(R.id.close).setOnClickListener(this);
|
||||||
|
if(this.mIconRes != -1)
|
||||||
|
setIcon(this.mIconRes);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the icon of this feature fragment
|
||||||
|
* @param icon
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
public void setIcon(int icon){
|
||||||
|
mIcon.setImageDrawable(this.getActivity().getResources().getDrawable(icon));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -245,8 +245,8 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC
|
|||||||
public void onFeatureRemoved(Fragment f) {
|
public void onFeatureRemoved(Fragment f) {
|
||||||
this.remove(f);
|
this.remove(f);
|
||||||
|
|
||||||
if(f instanceof IdFragment){
|
if(f instanceof BaseFeatureFragment){
|
||||||
final int id = ((IdFragment) f).getFragmentId();
|
final int id = ((BaseFeatureFragment) f).getFragmentId();
|
||||||
mAdded.remove(new Integer(id));
|
mAdded.remove(new Integer(id));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
/**
|
|
||||||
* IdFragment.java
|
|
||||||
* @date May 26, 2012
|
|
||||||
* @author ricky barrette
|
|
||||||
* @author Twenty Codes, LLC
|
|
||||||
*/
|
|
||||||
package com.TwentyCodes.android.LocationRinger.ui.fragments;
|
|
||||||
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a simple extention of a fragment that will allow for storage of an id
|
|
||||||
* @author ricky barrette
|
|
||||||
*/
|
|
||||||
public class IdFragment extends Fragment {
|
|
||||||
|
|
||||||
private final int mId;
|
|
||||||
|
|
||||||
public IdFragment(int id){
|
|
||||||
super();
|
|
||||||
mId = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the id of this fragment
|
|
||||||
*/
|
|
||||||
public int getFragmentId() {
|
|
||||||
return mId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -23,7 +23,6 @@ import android.view.View;
|
|||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -38,7 +37,7 @@ import com.TwentyCodes.android.LocationRinger.debug.Debug;
|
|||||||
* This fragment will be for ringtone settings
|
* This fragment will be for ringtone settings
|
||||||
* @author ricky
|
* @author ricky
|
||||||
*/
|
*/
|
||||||
public class RingtoneFragment extends IdFragment implements OnClickListener, OnSeekBarChangeListener {
|
public class RingtoneFragment extends BaseFeatureFragment implements OnClickListener, OnSeekBarChangeListener {
|
||||||
|
|
||||||
private static final String TAG = "RingtoneFragment";
|
private static final String TAG = "RingtoneFragment";
|
||||||
private final int mStream;
|
private final int mStream;
|
||||||
@@ -48,27 +47,22 @@ public class RingtoneFragment extends IdFragment implements OnClickListener, OnS
|
|||||||
private final String mKeyUri;
|
private final String mKeyUri;
|
||||||
private final String mKeyVolume;
|
private final String mKeyVolume;
|
||||||
private final ContentValues mInfo;
|
private final ContentValues mInfo;
|
||||||
private final FeatureRemovedListener mRemovedListener;
|
|
||||||
private final int mLabel;
|
private final int mLabel;
|
||||||
private EditText mRingtone;
|
private EditText mRingtone;
|
||||||
private Uri mRingtoneURI;
|
private Uri mRingtoneURI;
|
||||||
private SeekBar mVolume;
|
private SeekBar mVolume;
|
||||||
private ImageView mIcon;
|
|
||||||
|
|
||||||
public RingtoneFragment(ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream, int id){
|
public RingtoneFragment(ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream, int id){
|
||||||
super(id);
|
super(id, R.layout.ringtone_fragment, removedListener);
|
||||||
|
|
||||||
if ( info == null )
|
if ( info == null )
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
if ( changedListener == null )
|
if ( changedListener == null )
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
if ( removedListener == null )
|
|
||||||
throw new NullPointerException();
|
|
||||||
|
|
||||||
this.mChangedListener = changedListener;
|
this.mChangedListener = changedListener;
|
||||||
this.mStream = stream;
|
this.mStream = stream;
|
||||||
this.mInfo = info;
|
this.mInfo = info;
|
||||||
this.mRemovedListener = removedListener;
|
|
||||||
|
|
||||||
switch(stream){
|
switch(stream){
|
||||||
case AudioManager.STREAM_NOTIFICATION:
|
case AudioManager.STREAM_NOTIFICATION:
|
||||||
@@ -126,7 +120,7 @@ public class RingtoneFragment extends IdFragment implements OnClickListener, OnS
|
|||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
private void notifyVolumeChanged(int progress) {
|
private void notifyVolumeChanged(int progress) {
|
||||||
mIcon.setImageDrawable(this.getActivity().getResources().getDrawable(progress == 0 ? android.R.drawable.ic_lock_silent_mode : android.R.drawable.ic_lock_silent_mode_off));
|
setIcon(progress == 0 ? android.R.drawable.ic_lock_silent_mode : android.R.drawable.ic_lock_silent_mode_off);
|
||||||
if(this.mChangedListener != null){
|
if(this.mChangedListener != null){
|
||||||
final ContentValues info = new ContentValues();
|
final ContentValues info = new ContentValues();
|
||||||
info.put(this.mKeyVolume, progress);
|
info.put(this.mKeyVolume, progress);
|
||||||
@@ -167,17 +161,15 @@ public class RingtoneFragment extends IdFragment implements OnClickListener, OnS
|
|||||||
case R.id.ringtone:
|
case R.id.ringtone:
|
||||||
getRingtoneURI(this.mType, mRingtoneURI);
|
getRingtoneURI(this.mType, mRingtoneURI);
|
||||||
break;
|
break;
|
||||||
case R.id.close:
|
default:
|
||||||
if(this.mRemovedListener != null)
|
super.onClick(v);
|
||||||
this.mRemovedListener.onFeatureRemoved(this);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
final View view = inflater.inflate(R.layout.ringtone_fragment, container, false);
|
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
final AudioManager audioManager = (AudioManager) this.getActivity().getSystemService(Context.AUDIO_SERVICE);
|
final AudioManager audioManager = (AudioManager) this.getActivity().getSystemService(Context.AUDIO_SERVICE);
|
||||||
|
|
||||||
if(Debug.DEBUG)
|
if(Debug.DEBUG)
|
||||||
@@ -190,8 +182,7 @@ public class RingtoneFragment extends IdFragment implements OnClickListener, OnS
|
|||||||
final TextView label = (TextView) view.findViewById(R.id.title);
|
final TextView label = (TextView) view.findViewById(R.id.title);
|
||||||
label.setText(mLabel);
|
label.setText(mLabel);
|
||||||
|
|
||||||
mIcon = (ImageView) view.findViewById(R.id.icon);
|
setIcon(android.R.drawable.ic_lock_silent_mode_off);
|
||||||
mIcon.setImageDrawable(this.getActivity().getResources().getDrawable(android.R.drawable.ic_lock_silent_mode_off));
|
|
||||||
|
|
||||||
this.mRingtone = (EditText) view.findViewById(R.id.ringtone);
|
this.mRingtone = (EditText) view.findViewById(R.id.ringtone);
|
||||||
mVolume = (SeekBar) view.findViewById(R.id.ringtone_volume);
|
mVolume = (SeekBar) view.findViewById(R.id.ringtone_volume);
|
||||||
@@ -234,7 +225,7 @@ public class RingtoneFragment extends IdFragment implements OnClickListener, OnS
|
|||||||
mVolume.setProgress(0);
|
mVolume.setProgress(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
mIcon.setImageDrawable(this.getActivity().getResources().getDrawable(mVolume.getProgress() == 0 ? android.R.drawable.ic_lock_silent_mode : android.R.drawable.ic_lock_silent_mode_off));
|
setIcon(mVolume.getProgress() == 0 ? android.R.drawable.ic_lock_silent_mode : android.R.drawable.ic_lock_silent_mode_off);
|
||||||
|
|
||||||
mVolume.setOnSeekBarChangeListener(this);
|
mVolume.setOnSeekBarChangeListener(this);
|
||||||
return view;
|
return view;
|
||||||
|
|||||||
@@ -10,11 +10,9 @@ import android.content.ContentValues;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.ToggleButton;
|
import android.widget.ToggleButton;
|
||||||
|
|
||||||
@@ -27,21 +25,19 @@ import com.TwentyCodes.android.LocationRinger.db.RingerDatabase;
|
|||||||
* A simple fragment that displays a toggle button and a title label
|
* A simple fragment that displays a toggle button and a title label
|
||||||
* @author ricky
|
* @author ricky
|
||||||
*/
|
*/
|
||||||
public class ToggleButtonFragment extends IdFragment implements OnCheckedChangeListener, OnClickListener {
|
public class ToggleButtonFragment extends BaseFeatureFragment implements OnCheckedChangeListener {
|
||||||
|
|
||||||
private final String mTitle;
|
private final String mTitle;
|
||||||
private final String mKey;
|
private final String mKey;
|
||||||
private final ContentValues mInfo;
|
private final ContentValues mInfo;
|
||||||
private final OnContentChangedListener mChangedListener;
|
private final OnContentChangedListener mChangedListener;
|
||||||
private final int mIcon;
|
|
||||||
private final FeatureRemovedListener mRemovedListener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ToggleButtonFtagment
|
* Creates a new ToggleButtonFtagment
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public ToggleButtonFragment(int icon, String title, String key, ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int id) {
|
public ToggleButtonFragment(int icon, String title, String key, ContentValues info, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int id) {
|
||||||
super(id);
|
super(id, R.layout.toggle_button_fragment, icon, removedListener);
|
||||||
|
|
||||||
if ( info == null )
|
if ( info == null )
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
@@ -51,15 +47,11 @@ public class ToggleButtonFragment extends IdFragment implements OnCheckedChangeL
|
|||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
if ( changedListener == null )
|
if ( changedListener == null )
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
if ( removedListener == null )
|
|
||||||
throw new NullPointerException();
|
|
||||||
|
|
||||||
this.mTitle = title;
|
this.mTitle = title;
|
||||||
this.mKey = key;
|
this.mKey = key;
|
||||||
this.mInfo = info;
|
this.mInfo = info;
|
||||||
this.mChangedListener = changedListener;
|
this.mChangedListener = changedListener;
|
||||||
this.mIcon = icon;
|
|
||||||
this.mRemovedListener = removedListener;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,16 +60,11 @@ public class ToggleButtonFragment extends IdFragment implements OnCheckedChangeL
|
|||||||
* @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
|
* @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle icicle) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
final View view = inflater.inflate(R.layout.toggle_button_fragment, container, false);
|
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
final TextView t = (TextView) view.findViewById(R.id.title);
|
final TextView t = (TextView) view.findViewById(R.id.title);
|
||||||
t.setText(this.mTitle);
|
t.setText(this.mTitle);
|
||||||
|
|
||||||
final ImageView icon = (ImageView) view.findViewById(R.id.icon);
|
|
||||||
icon.setImageDrawable(this.getActivity().getResources().getDrawable(mIcon));
|
|
||||||
|
|
||||||
view.findViewById(R.id.close).setOnClickListener(this);
|
|
||||||
|
|
||||||
final ToggleButton b = (ToggleButton) view.findViewById(R.id.toggle);
|
final ToggleButton b = (ToggleButton) view.findViewById(R.id.toggle);
|
||||||
if(this.mInfo.containsKey(this.mKey))
|
if(this.mInfo.containsKey(this.mKey))
|
||||||
b.setChecked(RingerDatabase.parseBoolean(this.mInfo.getAsString(this.mKey)));
|
b.setChecked(RingerDatabase.parseBoolean(this.mInfo.getAsString(this.mKey)));
|
||||||
@@ -98,15 +85,4 @@ public class ToggleButtonFragment extends IdFragment implements OnCheckedChangeL
|
|||||||
this.mChangedListener.onInfoContentChanged(info);
|
this.mChangedListener.onInfoContentChanged(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the user clicks the remove button
|
|
||||||
* @param v
|
|
||||||
* @author ricky barrette
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if(this.mRemovedListener != null)
|
|
||||||
this.mRemovedListener.onFeatureRemoved(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -15,9 +15,7 @@ import android.os.Bundle;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -32,7 +30,7 @@ import com.TwentyCodes.android.LocationRinger.debug.Debug;
|
|||||||
* This fragment will represent the volume fragments
|
* This fragment will represent the volume fragments
|
||||||
* @author ricky
|
* @author ricky
|
||||||
*/
|
*/
|
||||||
public class VolumeFragment extends IdFragment implements OnSeekBarChangeListener, OnClickListener {
|
public class VolumeFragment extends BaseFeatureFragment implements OnSeekBarChangeListener {
|
||||||
|
|
||||||
private static final String TAG = "VolumeFragment";
|
private static final String TAG = "VolumeFragment";
|
||||||
private final AudioManager mAudioManager;
|
private final AudioManager mAudioManager;
|
||||||
@@ -41,8 +39,6 @@ public class VolumeFragment extends IdFragment implements OnSeekBarChangeListene
|
|||||||
private final String mKey;
|
private final String mKey;
|
||||||
private final ContentValues mInfo;
|
private final ContentValues mInfo;
|
||||||
private final int mLabel;
|
private final int mLabel;
|
||||||
private final FeatureRemovedListener mRemovedListener;
|
|
||||||
private ImageView mIcon;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Volume Fragment
|
* Creates a new Volume Fragment
|
||||||
@@ -53,7 +49,7 @@ public class VolumeFragment extends IdFragment implements OnSeekBarChangeListene
|
|||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public VolumeFragment(ContentValues info, Context context, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream, int id){
|
public VolumeFragment(ContentValues info, Context context, OnContentChangedListener changedListener, FeatureRemovedListener removedListener, int stream, int id){
|
||||||
super(id);
|
super(id, R.layout.volume_fragment, removedListener);
|
||||||
|
|
||||||
if ( info == null )
|
if ( info == null )
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
@@ -61,14 +57,11 @@ public class VolumeFragment extends IdFragment implements OnSeekBarChangeListene
|
|||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
if ( changedListener == null )
|
if ( changedListener == null )
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
if ( removedListener == null )
|
|
||||||
throw new NullPointerException();
|
|
||||||
|
|
||||||
this.mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
this.mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||||
this.mStream = stream;
|
this.mStream = stream;
|
||||||
this.mChangedListener = changedListener;
|
this.mChangedListener = changedListener;
|
||||||
this.mInfo = info;
|
this.mInfo = info;
|
||||||
this.mRemovedListener = removedListener;
|
|
||||||
|
|
||||||
switch(this.mStream){
|
switch(this.mStream){
|
||||||
case AudioManager.STREAM_ALARM:
|
case AudioManager.STREAM_ALARM:
|
||||||
@@ -118,7 +111,7 @@ public class VolumeFragment extends IdFragment implements OnSeekBarChangeListene
|
|||||||
for(Entry<String,Object> item : this.mInfo.valueSet())
|
for(Entry<String,Object> item : this.mInfo.valueSet())
|
||||||
Log.d(TAG, item.getKey() +" = "+ item.getValue());
|
Log.d(TAG, item.getKey() +" = "+ item.getValue());
|
||||||
|
|
||||||
final View view = inflater.inflate(R.layout.volume_fragment, container, false);
|
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
final TextView label = (TextView) view.findViewById(R.id.title);
|
final TextView label = (TextView) view.findViewById(R.id.title);
|
||||||
final SeekBar volume = (SeekBar) view.findViewById(R.id.volume);
|
final SeekBar volume = (SeekBar) view.findViewById(R.id.volume);
|
||||||
volume.setMax(this.mAudioManager.getStreamMaxVolume(mStream));
|
volume.setMax(this.mAudioManager.getStreamMaxVolume(mStream));
|
||||||
@@ -127,16 +120,12 @@ public class VolumeFragment extends IdFragment implements OnSeekBarChangeListene
|
|||||||
|
|
||||||
label.setText(mLabel);
|
label.setText(mLabel);
|
||||||
|
|
||||||
mIcon = (ImageView) view.findViewById(R.id.icon);
|
|
||||||
|
|
||||||
view.findViewById(R.id.close).setOnClickListener(this);
|
|
||||||
|
|
||||||
if(this.mInfo.containsKey(this.mKey))
|
if(this.mInfo.containsKey(this.mKey))
|
||||||
volume.setProgress(Integer.parseInt(this.mInfo.getAsString(this.mKey)));
|
volume.setProgress(Integer.parseInt(this.mInfo.getAsString(this.mKey)));
|
||||||
else
|
else
|
||||||
notifyListener(this.mAudioManager.getStreamVolume(mStream));
|
notifyListener(this.mAudioManager.getStreamVolume(mStream));
|
||||||
|
|
||||||
mIcon.setImageDrawable(this.getActivity().getResources().getDrawable(volume.getProgress() == 0 ? android.R.drawable.ic_lock_silent_mode : android.R.drawable.ic_lock_silent_mode_off));
|
setIcon(volume.getProgress() == 0 ? android.R.drawable.ic_lock_silent_mode : android.R.drawable.ic_lock_silent_mode_off);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +133,7 @@ public class VolumeFragment extends IdFragment implements OnSeekBarChangeListene
|
|||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
if(fromUser){
|
if(fromUser){
|
||||||
notifyListener(progress);
|
notifyListener(progress);
|
||||||
mIcon.setImageDrawable(this.getActivity().getResources().getDrawable(progress == 0 ? android.R.drawable.ic_lock_silent_mode : android.R.drawable.ic_lock_silent_mode_off));
|
setIcon(progress == 0 ? android.R.drawable.ic_lock_silent_mode : android.R.drawable.ic_lock_silent_mode_off);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,15 +157,4 @@ public class VolumeFragment extends IdFragment implements OnSeekBarChangeListene
|
|||||||
@Override
|
@Override
|
||||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the user clicks on the remove button
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see android.view.View.OnClickListener#onClick(android.view.View)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if(this.mRemovedListener != null)
|
|
||||||
this.mRemovedListener.onFeatureRemoved(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user