mirror of
https://github.com/MinimalBible/MinimalBible-Legacy
synced 2024-11-14 12:08:51 -05:00
Merge branch 'ButterKnife'
This commit is contained in:
commit
0f109e21b4
@ -18,11 +18,14 @@ dependencies {
|
||||
compile project(path: ':jsword-minimalbible', configuration: 'buildJSword')
|
||||
compile project(':appcompat_v7')
|
||||
|
||||
apt "org.androidannotations:androidannotations:3.0+"
|
||||
compile "org.androidannotations:androidannotations-api:3.0+"
|
||||
// apt "org.androidannotations:androidannotations:3.0+"
|
||||
// compile "org.androidannotations:androidannotations-api:3.0+"
|
||||
|
||||
apt 'com.squareup.dagger:dagger-compiler:1.1.0'
|
||||
compile 'com.squareup.dagger:dagger:1.1.0'
|
||||
apt 'com.squareup.dagger:dagger-compiler:1.2.1+'
|
||||
compile 'com.squareup.dagger:dagger:1.2.1+'
|
||||
|
||||
apt 'com.jakewharton:butterknife:5.0.1'
|
||||
compile 'com.jakewharton:butterknife:5.0.1'
|
||||
|
||||
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
|
||||
compile 'de.greenrobot:eventbus:2.2.0'
|
||||
@ -31,13 +34,6 @@ dependencies {
|
||||
// compile 'com.google.android:support-v4:r7'
|
||||
}
|
||||
|
||||
apt {
|
||||
arguments {
|
||||
androidManifestFile variant.processResources.manifestFile
|
||||
resourcePackageName "org.bspeice.minimalbible"
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion "19.0.3"
|
||||
|
@ -9,7 +9,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/img_download_icon"
|
||||
android:layout_weight="1"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginLeft="0dp"
|
||||
android:layout_alignParentTop="true"
|
||||
@ -19,7 +18,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/txt_download_item_name"
|
||||
android:layout_weight="1"
|
||||
android:layout_toRightOf="@+id/img_download_icon"
|
||||
android:layout_toLeftOf="@+id/img_download_index_downloaded" />
|
||||
|
||||
@ -29,7 +27,6 @@
|
||||
android:id="@+id/img_download_index_downloaded"
|
||||
android:src="@drawable/ic_action_search"
|
||||
style="@style/AppBaseTheme.Borderless"
|
||||
android:layout_weight="1"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toLeftOf="@+id/img_download_item_downloaded" />
|
||||
|
||||
@ -37,7 +34,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/img_download_item_downloaded"
|
||||
android:layout_weight="1"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
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;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
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 java.util.List;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
BookItemView itemView;
|
||||
if (convertView == null) {
|
||||
itemView = BookItemView_.build(this.ctx);
|
||||
|
||||
itemView = new BookItemView(this.ctx);
|
||||
} else {
|
||||
itemView = (BookItemView) convertView;
|
||||
}
|
||||
@ -50,4 +57,22 @@ public class BookListAdapter extends BaseAdapter {
|
||||
itemView.bind(getItem(position));
|
||||
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.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
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.R;
|
||||
import org.crosswire.jsword.book.Book;
|
||||
@ -29,33 +27,58 @@ import org.crosswire.jsword.book.FilterUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
|
||||
/**
|
||||
* A placeholder fragment containing a simple view.
|
||||
*/
|
||||
@EFragment(R.layout.fragment_download)
|
||||
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";
|
||||
|
||||
@FragmentArg
|
||||
BookCategory bookCategory;
|
||||
|
||||
@ViewById(R.id.lst_download_available)
|
||||
protected ListView downloadsAvailable;
|
||||
@InjectView(R.id.lst_download_available)
|
||||
ListView downloadsAvailable;
|
||||
|
||||
private ProgressDialog refreshDialog;
|
||||
|
||||
@Trace
|
||||
@AfterViews
|
||||
public void updateName() {
|
||||
((DownloadActivity) getActivity()).onSectionAttached(bookCategory.toString());
|
||||
displayModules();
|
||||
/**
|
||||
* Returns a new instance of this fragment for the given section number.
|
||||
* TODO: This will need to be switched to an @Provides class
|
||||
*/
|
||||
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()
|
||||
.getSharedPreferences(
|
||||
MinimalBibleConstants.DOWNLOAD_PREFS_FILE,
|
||||
@ -110,7 +133,9 @@ public class BookListFragment extends Fragment {
|
||||
|
||||
public void displayBooks(List<Book> bookList) {
|
||||
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);
|
||||
downloadsAvailable.setAdapter(new BookListAdapter(this.getActivity(), filteredBooks));
|
||||
setInsets(getActivity(), downloadsAvailable);
|
||||
|
@ -47,7 +47,7 @@ public class DownloadActivity extends BaseActivity implements
|
||||
fragmentManager
|
||||
.beginTransaction()
|
||||
.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) {
|
||||
|
Loading…
Reference in New Issue
Block a user