@Override public void onAttach(Activity activity) { super.onAttach(activity); Intent intent = this.getActivity().getIntent(); id = intent.getIntExtra("id", -1); page = PageEnum.valueOf(intent.getStringExtra("page")); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (isInRetainLifecycle()) { if (savedMovieJson != null) { onPostExecute(savedMovieJson); } else { this.refresh(); this.setStatus(Status.WORKING); } } }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); posterImageView = (LoadingPosterView) view.findViewById(R.id.posterLoadingPosterView); titleTextView = (TextView) view.findViewById(R.id.titleTextView); yearTextView = (TextView) view.findViewById(R.id.yearTextView); plotTextView = (TextView) view.findViewById(R.id.plotTextView); editWorkingTextView = (WorkingTextView) view.findViewById(R.id.editWorkingTextView); editWorkingTextView.setVisibility(View.VISIBLE); refreshWorkingTextView = (WorkingTextView) view.findViewById(R.id.refreshWorkingTextView); refreshWorkingTextView.setVisibility(View.VISIBLE); deleteWorkingTextView = (WorkingTextView) view.findViewById(R.id.deleteWorkingTextView); deleteWorkingTextView.setVisibility(View.VISIBLE); // releases should never be null but it wont be shown to the user if its downloaded releasesWorkingTextView = (WorkingTextView) view.findViewById(R.id.releasesWorkingTextView); if (page == PageEnum.WANTED || page == PageEnum.ALL) { releasesWorkingTextView.setVisibility(View.VISIBLE); releasesWorkingTextView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getSherlockActivity(), ReleasesActivity.class); intent.putExtra("id", id); startActivity(intent); } }); } editWorkingTextView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { final EditDialog diag = new EditDialog(titles, origTitle, profileId); diag.setOnOkClick( new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { diag.dismiss(); editWorkingTextView.setIsWorking(true); Preferences pref = Preferences.getSingleton(EditMovieFragment.this.getSherlockActivity()); MovieEditTask task = new MovieEditTask( pref, EditMovieFragment.this.id, diag.getSelectedProfileId(), diag.getSelectedTitle()) { @Override protected void onPostExecute(Void result) { super.onPostExecute(result); // there is no way to tell if this failed from couchpotato only if i got // an exception from io or something like that if (error == null) { editWorkingTextView.setIsWorking(false); editWorkingTextView.setIsSuccessful(true); EditMovieFragment.this.refresh(); } else { editWorkingTextView.setIsWorking(false); editWorkingTextView.setIsSuccessful(false); } } }; task.execute(); } }); diag.show(getFragmentManager(), "edit"); } }); refreshWorkingTextView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { refreshWorkingTextView.setIsWorking(true); Preferences pref = Preferences.getSingleton(v.getContext()); RefreshTask task = new RefreshTask(pref, id) { @Override protected void onPostExecute(Void result) { super.onPostExecute(result); if (error == null) { refreshWorkingTextView.setIsWorking(false); refreshWorkingTextView.setIsSuccessful(true); } else { refreshWorkingTextView.setIsWorking(false); refreshWorkingTextView.setIsSuccessful(false); } } }; task.execute(); } }); deleteWorkingTextView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { deleteWorkingTextView.setIsWorking(true); List<Integer> ids = new ArrayList<Integer>(); ids.add(id); // TODO add a DeleteTask constructor that doesnt need lists Preferences pref = Preferences.getSingleton(v.getContext()); MovieDeleteTask task = new MovieDeleteTask(pref, ids, page) { @Override protected void onPostExecute(Void result) { super.onPostExecute(result); if (error == null) { deleteWorkingTextView.setIsWorking(false); deleteWorkingTextView.setIsSuccessful(true); if (EditMovieFragment.this != null && EditMovieFragment.this.getActivity() != null) { EditMovieFragment.this.getActivity().finish(); } } else { deleteWorkingTextView.setIsWorking(false); deleteWorkingTextView.setIsSuccessful(false); } } }; task.execute(); } }); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setRetainInstance(true); }
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.edit_movie_menu, menu); }