mirror of
https://github.com/MinimalBible/MinimalBible-Legacy
synced 2024-11-13 19:48:38 -05:00
Browsing documents, now with 100% more butter!
This commit is contained in:
parent
1ac2c6539e
commit
5c9e0ecba4
@ -21,8 +21,8 @@ dependencies {
|
|||||||
// apt "org.androidannotations:androidannotations:3.0+"
|
// apt "org.androidannotations:androidannotations:3.0+"
|
||||||
// compile "org.androidannotations:androidannotations-api:3.0+"
|
// compile "org.androidannotations:androidannotations-api:3.0+"
|
||||||
|
|
||||||
apt 'com.squareup.dagger:dagger-compiler:1.1.0'
|
apt 'com.squareup.dagger:dagger-compiler:1.2.1+'
|
||||||
compile 'com.squareup.dagger:dagger:1.1.0'
|
compile 'com.squareup.dagger:dagger:1.2.1+'
|
||||||
|
|
||||||
apt 'com.jakewharton:butterknife:5.0.1'
|
apt 'com.jakewharton:butterknife:5.0.1'
|
||||||
compile 'com.jakewharton:butterknife:5.0.1'
|
compile 'com.jakewharton:butterknife:5.0.1'
|
||||||
@ -34,13 +34,6 @@ dependencies {
|
|||||||
// compile 'com.google.android:support-v4:r7'
|
// compile 'com.google.android:support-v4:r7'
|
||||||
}
|
}
|
||||||
|
|
||||||
apt {
|
|
||||||
arguments {
|
|
||||||
androidManifestFile variant.processResources.manifestFile
|
|
||||||
resourcePackageName "org.bspeice.minimalbible"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 19
|
compileSdkVersion 19
|
||||||
buildToolsVersion "19.0.3"
|
buildToolsVersion "19.0.3"
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/img_download_icon"
|
android:id="@+id/img_download_icon"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_marginLeft="0dp"
|
android:layout_marginLeft="0dp"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
@ -19,7 +18,6 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/txt_download_item_name"
|
android:id="@+id/txt_download_item_name"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_toRightOf="@+id/img_download_icon"
|
android:layout_toRightOf="@+id/img_download_icon"
|
||||||
android:layout_toLeftOf="@+id/img_download_index_downloaded" />
|
android:layout_toLeftOf="@+id/img_download_index_downloaded" />
|
||||||
|
|
||||||
@ -29,7 +27,6 @@
|
|||||||
android:id="@+id/img_download_index_downloaded"
|
android:id="@+id/img_download_index_downloaded"
|
||||||
android:src="@drawable/ic_action_search"
|
android:src="@drawable/ic_action_search"
|
||||||
style="@style/AppBaseTheme.Borderless"
|
style="@style/AppBaseTheme.Borderless"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_toLeftOf="@+id/img_download_item_downloaded" />
|
android:layout_toLeftOf="@+id/img_download_item_downloaded" />
|
||||||
|
|
||||||
@ -37,7 +34,6 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/img_download_item_downloaded"
|
android:id="@+id/img_download_item_downloaded"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
style="@style/AppBaseTheme.Borderless" />
|
style="@style/AppBaseTheme.Borderless" />
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
package org.bspeice.minimalbible.activities.downloader;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import org.androidannotations.annotations.EViewGroup;
|
|
||||||
import org.androidannotations.annotations.ViewById;
|
|
||||||
import org.bspeice.minimalbible.R;
|
|
||||||
import org.crosswire.jsword.book.Book;
|
|
||||||
|
|
||||||
@EViewGroup(R.layout.list_download_items)
|
|
||||||
public class BookItemView extends RelativeLayout {
|
|
||||||
|
|
||||||
@ViewById (R.id.img_download_icon) ImageView downloadIcon;
|
|
||||||
@ViewById(R.id.txt_download_item_name) TextView itemName;
|
|
||||||
@ViewById(R.id.img_download_index_downloaded) ImageView isIndexedDownloaded;
|
|
||||||
@ViewById(R.id.img_download_item_downloaded) ImageView isDownloaded;
|
|
||||||
|
|
||||||
public BookItemView (Context ctx) {
|
|
||||||
super(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void bind(Book b) {
|
|
||||||
itemName.setText(b.getName());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +1,22 @@
|
|||||||
package org.bspeice.minimalbible.activities.downloader;
|
package org.bspeice.minimalbible.activities.downloader;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.bspeice.minimalbible.R;
|
||||||
import org.crosswire.jsword.book.Book;
|
import org.crosswire.jsword.book.Book;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.InjectView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter to inflate list_download_items.xml
|
* Adapter to inflate list_download_items.xml
|
||||||
*/
|
*/
|
||||||
@ -41,8 +49,7 @@ public class BookListAdapter extends BaseAdapter {
|
|||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
BookItemView itemView;
|
BookItemView itemView;
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
itemView = BookItemView_.build(this.ctx);
|
itemView = new BookItemView(this.ctx);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
itemView = (BookItemView) convertView;
|
itemView = (BookItemView) convertView;
|
||||||
}
|
}
|
||||||
@ -50,4 +57,22 @@ public class BookListAdapter extends BaseAdapter {
|
|||||||
itemView.bind(getItem(position));
|
itemView.bind(getItem(position));
|
||||||
return itemView;
|
return itemView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class BookItemView extends RelativeLayout {
|
||||||
|
|
||||||
|
@InjectView(R.id.img_download_icon) ImageView downloadIcon;
|
||||||
|
@InjectView(R.id.txt_download_item_name) TextView itemName;
|
||||||
|
@InjectView(R.id.img_download_index_downloaded) ImageView isIndexedDownloaded;
|
||||||
|
@InjectView(R.id.img_download_item_downloaded) ImageView isDownloaded;
|
||||||
|
|
||||||
|
public BookItemView (Context ctx) {
|
||||||
|
super(ctx);
|
||||||
|
View v = LayoutInflater.from(ctx).inflate(R.layout.list_download_items, this);
|
||||||
|
ButterKnife.inject(this, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void bind(Book b) {
|
||||||
|
itemName.setText(b.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,19 +7,17 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.readystatesoftware.systembartint.SystemBarTintManager;
|
import com.readystatesoftware.systembartint.SystemBarTintManager;
|
||||||
|
|
||||||
import org.androidannotations.annotations.AfterViews;
|
|
||||||
import org.androidannotations.annotations.EFragment;
|
|
||||||
import org.androidannotations.annotations.FragmentArg;
|
|
||||||
import org.androidannotations.annotations.Trace;
|
|
||||||
import org.androidannotations.annotations.ViewById;
|
|
||||||
import org.bspeice.minimalbible.MinimalBibleConstants;
|
import org.bspeice.minimalbible.MinimalBibleConstants;
|
||||||
import org.bspeice.minimalbible.R;
|
import org.bspeice.minimalbible.R;
|
||||||
import org.crosswire.jsword.book.Book;
|
import org.crosswire.jsword.book.Book;
|
||||||
@ -29,33 +27,58 @@ import org.crosswire.jsword.book.FilterUtil;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.InjectView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A placeholder fragment containing a simple view.
|
* A placeholder fragment containing a simple view.
|
||||||
*/
|
*/
|
||||||
@EFragment(R.layout.fragment_download)
|
|
||||||
public class BookListFragment extends Fragment {
|
public class BookListFragment extends Fragment {
|
||||||
/**
|
/**
|
||||||
* The fragment argument representing the section number for this fragment.
|
* The fragment argument representing the section number for this fragment.
|
||||||
*/
|
*/
|
||||||
|
private static final String ARG_BOOK_CATEGORY = "book_category";
|
||||||
|
|
||||||
private final String TAG = "BookListFragment";
|
private final String TAG = "BookListFragment";
|
||||||
|
|
||||||
@FragmentArg
|
@InjectView(R.id.lst_download_available)
|
||||||
BookCategory bookCategory;
|
ListView downloadsAvailable;
|
||||||
|
|
||||||
@ViewById(R.id.lst_download_available)
|
|
||||||
protected ListView downloadsAvailable;
|
|
||||||
|
|
||||||
private ProgressDialog refreshDialog;
|
private ProgressDialog refreshDialog;
|
||||||
|
|
||||||
@Trace
|
/**
|
||||||
@AfterViews
|
* Returns a new instance of this fragment for the given section number.
|
||||||
public void updateName() {
|
* TODO: This will need to be switched to an @Provides class
|
||||||
((DownloadActivity) getActivity()).onSectionAttached(bookCategory.toString());
|
*/
|
||||||
displayModules();
|
public static BookListFragment newInstance(BookCategory c) {
|
||||||
|
BookListFragment fragment = new BookListFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putString(ARG_BOOK_CATEGORY, c.toString());
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayModules() {
|
public BookListFragment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View rootView = inflater.inflate(R.layout.fragment_download, container,
|
||||||
|
false);
|
||||||
|
ButterKnife.inject(this, rootView);
|
||||||
|
displayModules();
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Activity activity) {
|
||||||
|
super.onAttach(activity);
|
||||||
|
((DownloadActivity) activity).onSectionAttached(getArguments()
|
||||||
|
.getString(ARG_BOOK_CATEGORY));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void displayModules() {
|
||||||
SharedPreferences prefs = getActivity()
|
SharedPreferences prefs = getActivity()
|
||||||
.getSharedPreferences(
|
.getSharedPreferences(
|
||||||
MinimalBibleConstants.DOWNLOAD_PREFS_FILE,
|
MinimalBibleConstants.DOWNLOAD_PREFS_FILE,
|
||||||
@ -110,7 +133,9 @@ public class BookListFragment extends Fragment {
|
|||||||
|
|
||||||
public void displayBooks(List<Book> bookList) {
|
public void displayBooks(List<Book> bookList) {
|
||||||
try {
|
try {
|
||||||
BookFilter f = FilterUtil.filterFromCategory(bookCategory);
|
// TODO: Should the filter be applied earlier in the process?
|
||||||
|
BookCategory c = BookCategory.fromString(getArguments().getString(ARG_BOOK_CATEGORY));
|
||||||
|
BookFilter f = FilterUtil.filterFromCategory(c);
|
||||||
List<Book> filteredBooks = FilterUtil.applyFilter(bookList, f);
|
List<Book> filteredBooks = FilterUtil.applyFilter(bookList, f);
|
||||||
downloadsAvailable.setAdapter(new BookListAdapter(this.getActivity(), filteredBooks));
|
downloadsAvailable.setAdapter(new BookListAdapter(this.getActivity(), filteredBooks));
|
||||||
setInsets(getActivity(), downloadsAvailable);
|
setInsets(getActivity(), downloadsAvailable);
|
||||||
|
@ -47,7 +47,7 @@ public class DownloadActivity extends BaseActivity implements
|
|||||||
fragmentManager
|
fragmentManager
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
.replace(R.id.container,
|
.replace(R.id.container,
|
||||||
BookListFragment_.builder().bookCategory(DownloadManager.VALID_CATEGORIES[position]).build()).commit();
|
BookListFragment.newInstance(DownloadManager.VALID_CATEGORIES[position])).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSectionAttached(String category) {
|
public void onSectionAttached(String category) {
|
||||||
|
Loading…
Reference in New Issue
Block a user