package be.nikiroo.fanfix.reader.android; import android.app.Activity; import android.app.Fragment; import android.graphics.Bitmap; import android.os.AsyncTask; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; import java.io.IOException; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.reader.Reader; import be.nikiroo.utils.Image; import be.nikiroo.utils.android.ImageUtilsAndroid; public class AndroidReaderBook extends Fragment { private OnFragmentInteractionListener listener; /** * This interface must be implemented by activities that contain this * fragment to allow an interaction in this fragment to be communicated to * the activity and potentially other fragments contained in that activity. *
* See the Android Training lesson Communicating with Other Fragments for more information.
*/
public interface OnFragmentInteractionListener {
void onFragmentInteraction(MetaData meta);
}
public AndroidReaderBook() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_android_reader_book,
container, false);
}
@Override
public void onAttach(Activity context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
listener = (OnFragmentInteractionListener) context;
}
}
@Override
public void onDetach() {
super.onDetach();
listener = null;
}
public void fill(final MetaData meta, final Reader reader) {
ViewHolder viewHolder = new ViewHolder(getView());
viewHolder.title.setText(meta.getTitle());
viewHolder.author.setText(meta.getAuthor());
viewHolder.frame.setClickable(true);
viewHolder.frame.setFocusable(true);
viewHolder.frame.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
OnFragmentInteractionListener llistener = listener;
if (llistener != null) {
llistener.onFragmentInteraction(meta);
}
}
});
new AsyncTask