--- /dev/null
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:aapt="http://schemas.android.com/aapt"
+ android:width="108dp"
+ android:height="108dp"
+ android:viewportHeight="108"
+ android:viewportWidth="108">
+ <path
+ android:fillType="evenOdd"
+ android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
+ android:strokeColor="#00000000"
+ android:strokeWidth="1">
+ <aapt:attr name="android:fillColor">
+ <gradient
+ android:endX="78.5885"
+ android:endY="90.9159"
+ android:startX="48.7653"
+ android:startY="61.0927"
+ android:type="linear">
+ <item
+ android:color="#44000000"
+ android:offset="0.0" />
+ <item
+ android:color="#00000000"
+ android:offset="1.0" />
+ </gradient>
+ </aapt:attr>
+ </path>
+ <path
+ android:fillColor="#FFFFFF"
+ android:fillType="nonZero"
+ android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
+ android:strokeColor="#00000000"
+ android:strokeWidth="1" />
+</vector>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<vector
+ android:height="108dp"
+ android:width="108dp"
+ android:viewportHeight="108"
+ android:viewportWidth="108"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#26A69A"
+ android:pathData="M0,0h108v108h-108z"/>
+ <path android:fillColor="#00000000" android:pathData="M9,0L9,108"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M19,0L19,108"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M29,0L29,108"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M39,0L39,108"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M49,0L49,108"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M59,0L59,108"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M69,0L69,108"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M79,0L79,108"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M89,0L89,108"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M99,0L99,108"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M0,9L108,9"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M0,19L108,19"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M0,29L108,29"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M0,39L108,39"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M0,49L108,49"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M0,59L108,59"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M0,69L108,69"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M0,79L108,79"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M0,89L108,89"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M0,99L108,99"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M19,29L89,29"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M19,39L89,39"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M19,49L89,49"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M19,59L89,59"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M19,69L89,69"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M19,79L89,79"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M29,19L29,89"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M39,19L39,89"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M49,19L49,89"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M59,19L59,89"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M69,19L69,89"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+ <path android:fillColor="#00000000" android:pathData="M79,19L79,89"
+ android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
+</vector>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/mainRoot"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".AndroidReaderActivity">
+
+ <EditText
+ android:id="@+id/editText"
+ android:layout_width="177dp"
+ android:layout_height="38dp"
+ android:layout_marginStart="8dp"
+ android:layout_marginTop="8dp"
+ android:ems="10"
+ android:inputType="textPersonName"
+ android:text="@string/enter_text"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <Button
+ android:id="@+id/button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="8dp"
+ android:layout_marginStart="8dp"
+ android:onClick="onClick"
+ android:text="Download if needed"
+ app:layout_constraintBottom_toBottomOf="@+id/editText"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_bias="1.0"
+ app:layout_constraintStart_toEndOf="@+id/editText" />
+
+ <Button
+ android:id="@+id/button2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="8dp"
+ android:layout_marginStart="8dp"
+ android:layout_marginTop="28dp"
+ android:onClick="buttonClick"
+ android:text="Add all sources"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_bias="0.472"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/editText" />
+
+ <LinearLayout
+ android:id="@+id/dropZone"
+ android:layout_width="363dp"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="8dp"
+ android:layout_marginStart="8dp"
+ android:layout_marginTop="88dp"
+ android:orientation="vertical"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/editText"></LinearLayout>
+
+</android.support.constraint.ConstraintLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="be.nikiroo.testy.be.nikiroo.fanfix.reader.android.SayIt">
+
+ <TextView
+ android:id="@+id/textView"
+ android:layout_width="285dp"
+ android:layout_height="250dp"
+ android:text="TextView"
+ tools:layout_editor_absoluteX="38dp"
+ tools:layout_editor_absoluteY="130dp" />
+</android.support.constraint.ConstraintLayout>
--- /dev/null
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/coverWidget"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:clickable="true"
+ android:focusable="true"
+ android:onClick="onFrag">
+
+ <!-- TODO: Update blank fragment layout -->
+
+ <android.support.constraint.ConstraintLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="8dp"
+ android:layout_marginStart="8dp"
+ android:layout_marginTop="8dp"
+ android:text="TITLE"
+ app:layout_constraintEnd_toStartOf="@+id/cover"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="@+id/cover" />
+
+ <ImageView
+ android:id="@+id/cover"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="8dp"
+ android:layout_marginEnd="8dp"
+ android:layout_marginTop="8dp"
+ android:src="@mipmap/ic_launcher"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+ </android.support.constraint.ConstraintLayout>
+</FrameLayout>
--- /dev/null
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="be.nikiroo.fanfix.reader.android.AndroidReaderGroup">
+
+ <!-- TODO: Update blank fragment layout -->
+
+ <LinearLayout
+ android:id="@+id/AndroidReaderGroup_root"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"></LinearLayout>
+
+</FrameLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+ <background android:drawable="@drawable/ic_launcher_background"/>
+ <foreground android:drawable="@drawable/ic_launcher_foreground"/>
+</adaptive-icon>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+ <background android:drawable="@drawable/ic_launcher_background"/>
+ <foreground android:drawable="@drawable/ic_launcher_foreground"/>
+</adaptive-icon>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="colorPrimary">#3F51B5</color>
+ <color name="colorPrimaryDark">#303F9F</color>
+ <color name="colorAccent">#FF4081</color>
+</resources>
--- /dev/null
+<resources>
+ <string name="app_name">Fanfix</string>
+ <string name="enter_text">testy</string>
+ <string name="clickit">Click here</string>
+
+ <!-- TODO: Remove or change this placeholder text -->
+ <string name="hello_blank_fragment">Hello blank fragment</string>
+</resources>
--- /dev/null
+<resources>
+
+ <!-- Base application theme. -->
+ <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- Customize your theme here. -->
+ </style>
+
+</resources>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="be.nikiroo.fanfix.reader.android">
+
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.INTERNET" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@mipmap/ic_launcher"
+ android:label="@string/app_name"
+ android:roundIcon="@mipmap/ic_launcher_round"
+ android:supportsRtl="true"
+ android:theme="@style/AppTheme">
+ <activity android:name="be.nikiroo.fanfix.reader.android.AndroidReaderActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity android:name="be.nikiroo.fanfix.reader.android.SayIt" />
+ </application>
+</manifest>
\ No newline at end of file
--- /dev/null
+package be.nikiroo.fanfix.reader.android;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+
+import java.io.File;
+import java.io.IOException;
+
+import be.nikiroo.fanfix.reader.BasicReader;
+
+public class AndroidReader extends BasicReader {
+ private Activity app;
+
+ /**
+ * Do not use.
+ */
+ private AndroidReader() {
+ // Required for reflection
+ }
+
+ public AndroidReader(Activity app) {
+ this.app = app;
+ }
+
+ @Override
+ public void read() throws IOException {
+ }
+
+ @Override
+ public void browse(String source) {
+ }
+
+ @Override
+ protected void start(File target, String program) throws IOException {
+ if (program == null) {
+ try {
+ Intent[] intents = new Intent[] { //
+ new Intent(Intent.ACTION_VIEW), //
+ new Intent(Intent.ACTION_OPEN_DOCUMENT) //
+ };
+
+ for (Intent intent : intents) {
+ intent.setDataAndType(Uri.parse(target.toURI().toString()),
+ "application/x-cbz");
+ }
+
+ Intent chooserIntent = Intent.createChooser(intents[0],
+ "Open CBZ in...");
+
+ // chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
+ // intents);
+
+ app.startActivity(chooserIntent);
+ } catch (UnsupportedOperationException e) {
+ super.start(target, program);
+ }
+ } else {
+ super.start(target, program);
+ }
+ }
+}
--- /dev/null
+package be.nikiroo.fanfix.reader.android;
+
+import android.app.Activity;
+import android.app.FragmentTransaction;
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.os.Environment;
+import android.view.View;
+import android.widget.EditText;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import be.nikiroo.fanfix.Instance;
+import be.nikiroo.fanfix.data.MetaData;
+import be.nikiroo.fanfix.reader.BasicReader;
+import be.nikiroo.fanfix.reader.Reader;
+import be.nikiroo.utils.TraceHandler;
+
+public class AndroidReaderActivity extends Activity implements
+ AndroidReaderBook.OnFragmentInteractionListener {
+ private static Reader reader = null;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ config();
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ int i = 1;
+
+ public void buttonClick(View view) {
+ AndroidReaderGroup group = null;
+ if (group == null) {
+ group = new AndroidReaderGroup();
+ }
+
+ FragmentTransaction trans = getFragmentManager().beginTransaction();
+ trans.replace(R.id.dropZone, group);
+ trans.commit();
+ getFragmentManager().executePendingTransactions();
+
+ group.fill(reader, null);
+ }
+
+ public void onClick(View view) {
+ new AsyncTask<Void, Void, String>() {
+ @Override
+ protected void onPreExecute() {
+ EditText editText = findViewById(R.id.editText);
+ editText.setText("Downloading...");
+ }
+
+ @Override
+ protected String doInBackground(Void... voids) {
+ try {
+ URL[] urls = new URL[] {
+ new URL("https://e621.net/pool/show/13124"),
+ new URL("https://e621.net/pool/show/13121"), };
+
+ for (int i = 0; i < urls.length; i++) {
+ if (reader.getLibrary().getList().size() <= i) {
+ reader.getLibrary().imprt(urls[i], null);
+ }
+ }
+
+ String message = "";
+ for (MetaData meta : reader.getLibrary().getList()) {
+ message += meta.getTitle() + "\n";
+ }
+
+ return message;
+ } catch (Exception e) {
+ return e.getClass() + ": " + e.getMessage();
+ }
+ }
+
+ @Override
+ protected void onPostExecute(String message) {
+ EditText editText = findViewById(R.id.editText);
+ editText.setText("testy");
+
+ Intent intent = new Intent(AndroidReaderActivity.this,
+ SayIt.class);
+ intent.putExtra(SayIt.MESSAGE, message);
+ startActivity(intent);
+ }
+ }.execute();
+ }
+
+ @Override
+ public void onFragmentInteraction(MetaData meta) {
+ AndroidReader reader = new AndroidReader(this);
+ try {
+ reader.openExternal(Instance.getLibrary(), meta.getLuid());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void config() {
+ if (reader != null) {
+ return;
+ }
+
+ String internal = getExternalFilesDir(null).toString();
+ File user = Environment
+ .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS);
+
+ try {
+ File parent = user.getParentFile();
+ if (parent.exists() || parent.mkdirs()) {
+ File test = new File(parent, "test");
+ if (test.exists() || (test.createNewFile() && test.delete())) {
+ user = parent;
+ }
+ }
+ } catch (Exception e) {
+ // Fall back to Documents/Books
+ }
+
+ System.setProperty("DEBUG", "1");
+ System.setProperty("fanfix.home", internal);
+ System.setProperty("fanfix.libdir", new File(user, "Books").toString());
+
+ Instance.resetConfig(false);
+ Instance.setTraceHandler(new TraceHandler(true, true, 2));
+
+ BasicReader.setDefaultReaderType(Reader.ReaderType.ANDROID);
+ reader = BasicReader.getReader();
+ }
+}
\ No newline at end of file
--- /dev/null
+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.Instance;
+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 Reader reader;
+ private OnFragmentInteractionListener listener;
+ private MetaData meta;
+
+ /**
+ * 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.
+ * <p>
+ * See the Android Training lesson <a href=
+ * "http://developer.android.com/training/basics/fragments/communicating.html"
+ * >Communicating with Other Fragments</a> 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 Reader reader, final String luid) {
+ View view = getView();
+ if (view == null) {
+ return;
+ }
+
+ final ImageView cover = view.findViewById(R.id.cover);
+ final TextView title = view.findViewById(R.id.title);
+ final FrameLayout frame = view.findViewById(R.id.coverWidget);
+
+ new AsyncTask<Void, Void, MetaData>() {
+ @Override
+ protected MetaData doInBackground(Void[] objects) {
+ return Instance.getLibrary().getInfo(luid);
+ }
+
+ @Override
+ protected void onPostExecute(MetaData meta) {
+ AndroidReaderBook.this.meta = meta;
+
+ if (meta != null) {
+ title.setText(meta.getTitle());
+ try {
+ Image coverImage = reader.getLibrary().getCover(
+ meta.getLuid());
+ if (coverImage != null) {
+ Bitmap coverBitmap = ImageUtilsAndroid
+ .fromImage(coverImage);
+ coverBitmap = Bitmap.createScaledBitmap(
+ coverBitmap, 128, 128, true);
+ cover.setImageBitmap(coverBitmap);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ frame.setClickable(true);
+ frame.setFocusable(true);
+ frame.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ OnFragmentInteractionListener llistener = listener;
+ if (llistener != null) {
+ llistener
+ .onFragmentInteraction(AndroidReaderBook.this.meta);
+ }
+ }
+ });
+ }
+ }.execute();
+ }
+}
--- /dev/null
+package be.nikiroo.fanfix.reader.android;
+
+import android.app.Fragment;
+import android.app.FragmentTransaction;
+import android.content.Context;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import java.util.List;
+
+import be.nikiroo.fanfix.data.MetaData;
+import be.nikiroo.fanfix.reader.Reader;
+
+/**
+ * A simple {@link Fragment} subclass. Activities that contain this fragment
+ * must implement the {@link AndroidReaderGroup.OnFragmentInteractionListener}
+ * interface to handle interaction events.
+ */
+public class AndroidReaderGroup extends Fragment {
+ private OnFragmentInteractionListener listener;
+
+ public interface OnFragmentInteractionListener {
+ void onFragmentInteraction(MetaData meta);
+ }
+
+ public AndroidReaderGroup() {
+ // Required empty public constructor
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ return inflater.inflate(R.layout.fragment_android_reader_group,
+ container, false);
+ }
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ if (context instanceof OnFragmentInteractionListener) {
+ listener = (OnFragmentInteractionListener) context;
+ }
+ }
+
+ @Override
+ public void onDetach() {
+ super.onDetach();
+ listener = null;
+ }
+
+ public void fill(final Reader reader, final String source) {
+ new AsyncTask<Void, Void, List<MetaData>>() {
+ @Override
+ protected List<MetaData> doInBackground(Void... voids) {
+ return reader.getLibrary().getListBySource(source);
+ }
+
+ @Override
+ protected void onPostExecute(List<MetaData> metas) {
+ for (MetaData meta : metas) {
+ String tag = "Book_" + meta.getLuid();
+ tag = null; // TODO: how does it work?
+ AndroidReaderBook book = null;// (AndroidReaderBook)
+ // getFragmentManager().findFragmentByTag(tag);
+ if (book == null) {
+ book = new AndroidReaderBook();
+ FragmentTransaction trans = getFragmentManager()
+ .beginTransaction();
+ trans.add(R.id.AndroidReaderGroup_root, book, tag);
+ trans.commit();
+ getFragmentManager().executePendingTransactions();
+ }
+ book.fill(reader, meta.getLuid());
+ }
+ }
+ }.execute();
+ }
+}
--- /dev/null
+package be.nikiroo.fanfix.reader.android;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.TextView;
+
+
+public class SayIt extends Activity {
+ public static final String MESSAGE = "be.nikiroo.testy.message";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_say_it);
+
+ // Get the Intent that started this activity and extract the string
+ Intent intent = getIntent();
+ String message = intent.getStringExtra(SayIt.MESSAGE);
+
+ // Capture the layout's TextView and set the string as its text
+ TextView textView = findViewById(R.id.textView);
+ textView.setText(message);
+ }
+}