public void updateFragmentData() { mListValue.clear(); mListValue.addAll( HSVColor.populateValueList( HSVColor.getHueLeft(), HSVColor.getHueRight(), HSVColor.getSaturation())); mAdapter.notifyDataSetChanged(); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_saturation_value, container, false); final ListView listView = (ListView) rootView.findViewById(R.id.list); if (mListValue == null) { mListValue = HSVColor.populateValueList( HSVColor.getHueLeft(), HSVColor.getHueRight(), HSVColor.getSaturation()); } if (mAdapter == null) { mAdapter = new HSVColorAdapter(getActivity().getApplicationContext(), mListValue); } if (listView != null) { listView.setAdapter(mAdapter); listView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick( AdapterView<?> parent, final View view, final int position, long id) { HSVColor.setValue(1f - position * 0.1f); view.animate() .setDuration(300) .alpha(0) .withEndAction( new Runnable() { @Override public void run() { getFragmentManager() .beginTransaction() .replace( R.id.container, new ListFragmentName(), MainActivity.FRAGMENT_NAME) .addToBackStack(null) .commit(); } }); } }); } return rootView; }