Add library class

This commit is contained in:
inorichi 2015-09-25 12:44:11 +02:00
parent 9e5622c92e
commit 393caaa549
9 changed files with 217 additions and 105 deletions

View file

@ -1,5 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 23

View file

@ -15,3 +15,4 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-dontwarn java.lang.invoke.*

View file

@ -1,42 +1,37 @@
package eu.kanade.mangafeed.ui.activity;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ProgressBar;
import android.widget.FrameLayout;
import com.mikepenz.materialdrawer.Drawer;
import com.mikepenz.materialdrawer.DrawerBuilder;
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
import javax.inject.Inject;
import eu.kanade.mangafeed.R;
import butterknife.Bind;
import butterknife.ButterKnife;
import eu.kanade.mangafeed.R;
import eu.kanade.mangafeed.data.helpers.DatabaseHelper;
import eu.kanade.mangafeed.ui.fragment.LibraryFragment;
import rx.subscriptions.CompositeSubscription;
import timber.log.Timber;
import uk.co.ribot.easyadapter.EasyRecyclerAdapter;
public class MainActivity extends BaseActivity {
@Bind(R.id.recycler_characters)
RecyclerView mCharactersRecycler;
@Bind(R.id.toolbar)
Toolbar mToolbar;
Toolbar toolbar;
@Bind(R.id.progress_indicator)
ProgressBar mProgressBar;
@Bind(R.id.swipe_container)
SwipeRefreshLayout mSwipeRefresh;
@Bind(R.id.drawer_container)
FrameLayout container;
@Inject DatabaseHelper mDb;
private Drawer drawer;
private CompositeSubscription mSubscriptions;
private EasyRecyclerAdapter<Character> mEasyRecycleAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -45,9 +40,49 @@ public class MainActivity extends BaseActivity {
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
mSubscriptions = new CompositeSubscription();
//mDataManager = App.get(this).getComponent().dataManager();
setupToolbar();
setupRecyclerView();
drawer = new DrawerBuilder()
.withActivity(this)
.withRootView(container)
.withToolbar(toolbar)
.withActionBarDrawerToggleAnimated(true)
.addDrawerItems(
new PrimaryDrawerItem()
.withName(R.string.library_title)
.withIdentifier(R.id.nav_drawer_library),
new PrimaryDrawerItem()
.withName(R.string.recent_updates_title)
.withIdentifier(R.id.nav_drawer_recent_updates),
new PrimaryDrawerItem()
.withName(R.string.catalogues_title)
.withIdentifier(R.id.nav_drawer_catalogues),
new PrimaryDrawerItem()
.withName(R.string.settings_title)
.withIdentifier(R.id.nav_drawer_settings)
)
.withSavedInstance(savedInstanceState)
.withOnDrawerItemClickListener(
(view, position, drawerItem) -> {
if (drawerItem != null) {
int identifier = drawerItem.getIdentifier();
switch (identifier) {
case R.id.nav_drawer_library:
setFragment(LibraryFragment.newInstance());
break;
case R.id.nav_drawer_catalogues:
case R.id.nav_drawer_recent_updates:
case R.id.nav_drawer_settings:
break;
}
}
return false;
}
)
.build();
drawer.setSelection(R.id.nav_drawer_library);
}
@Override
@ -73,13 +108,21 @@ public class MainActivity extends BaseActivity {
}
private void setupToolbar() {
setSupportActionBar(mToolbar);
setSupportActionBar(toolbar);
}
private void setupRecyclerView() {
mCharactersRecycler.setLayoutManager(new LinearLayoutManager(this));
mCharactersRecycler.setAdapter(mEasyRecycleAdapter);
mSwipeRefresh.setColorSchemeResources(R.color.primary);
private void setFragment(Fragment fragment) {
try {
if (fragment != null && getSupportFragmentManager() != null) {
FragmentTransaction ft = getFragmentManager().beginTransaction();
if (ft != null) {
ft.replace(R.id.content_layout, fragment);
ft.commit();
}
}
} catch (Exception e) {
}
}
}

View file

@ -0,0 +1,55 @@
package eu.kanade.mangafeed.ui.fragment;
import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import java.util.ArrayList;
import eu.kanade.mangafeed.R;
import eu.kanade.mangafeed.ui.activity.BaseActivity;
public class LibraryFragment extends Fragment {
public static LibraryFragment newInstance() {
LibraryFragment fragment = new LibraryFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
public LibraryFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((BaseActivity) getActivity()).getSupportActionBar().setTitle(R.string.library_title);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_library, container, false);
return view;
}
public class LocalManga {
public String name;
public String url;
public LocalManga(String name, String url) {
this.name = name;
this.url = url;
}
}
}

View file

@ -1,55 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg_light_grey">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_characters"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:clipToPadding="false"/>
</android.support.v4.widget.SwipeRefreshLayout>
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:id="@+id/progress_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
android:background="@color/primary"
android:theme="@style/AppTheme.ActionBar"/>
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:elevation="4dp" />
</android.support.design.widget.AppBarLayout>
<!-- the layout which will contain (host) the drawerLayout -->
<FrameLayout
android:layout_below="@id/toolbar"
android:id="@+id/drawer_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.design.widget.CoordinatorLayout>
<!-- the layout which will be the content of the activity (which will be hosted inside the drawer (NOT the list of the drawer)) -->
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</FrameLayout>
</RelativeLayout>

View file

@ -0,0 +1,20 @@
<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="eu.kanade.mangafeed.ui.fragment.LibraryFragment">
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="4dp"
android:clipToPadding="false"
android:verticalSpacing="4dp"
android:horizontalSpacing="4dp"
android:columnWidth="96dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:drawSelectorOnTop="true"
android:fastScrollEnabled="true"
android:id="@+id/gridView" />
</FrameLayout>

View file

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="144dp"
android:id="@+id/thumbnailImageView"/>
</FrameLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="48dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:id="@+id/footerLinearLayout">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="middle"
android:maxLines="2"
android:textColor="@color/white"
android:textStyle="bold"
android:id="@+id/nameTextView" />
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="nav_drawer_library" type="id">nav_drawer_library</item>
<item name="nav_drawer_recent_updates" type="id">nav_drawer_recent_updates</item>
<item name="nav_drawer_catalogues" type="id">nav_drawer_catalogues</item>
<item name="nav_drawer_settings" type="id">nav_drawer_settings</item>
</resources>

View file

@ -1,35 +1,12 @@
<resources>
<string name="app_name">AndroidBoilerPlate</string>
<string name="app_name">Mangafeed</string>
<!-- Activity labels -->
<string name="label_main">Boilerplate</string>
<string name="label_main">Mangafeed</string>
<!-- Main Activity -->
<string name="action_github">View on GitHub</string>
<string name="text_view">View</string>
<string name="text_collections">Collections</string>
<string name="text_no_description">No description available</string>
<string name="text_films_description">%d films</string>
<!-- Character Activity -->
<string name="text_lorem_ipsum">
Don\'t underestimate the Force. The Force is strong with this one. I have you now. He is here. \n \n
I suggest you try it again, Luke. This time, let go your conscious self and act on instinct. The more you tighten your grip, Tarkin, the more star systems will slip through your fingers. I\'m trying not to, kid. Red Five standing by.\n \n
I care. So, what do you think of her, Han? Obi-Wan is here. The Force is with him. I\'m surprised you had the courage to take the responsibility yourself. Red Five standing by. I need your help, Luke. She needs your help. I\'m getting too old for this sort of thing.\n \n
What!? All right. Well, take care of yourself, Han. I guess that\'s what you\'re best at, ain\'t it? I don\'t know what you\'re talking about. I am a member of the Imperial Senate on a diplomatic mission to Alderaan, Red Five standing by.\n \n
I suggest you try it again, Luke. This time, let go your conscious self and act on instinct. I want to come with you to Alderaan. There\'s nothing for me here now. I want to learn the ways of the Force and be a Jedi, like my father before me. She must have hidden the plans in the escape pod. Send a detachment down to retrieve them, and see to it personally, Commander. There\'ll be no one to stop us this time! Obi-Wan is here. The Force is with him.\n \n
Hey, Luke! May the Force be with you. Alderaan? I\'m not going to Alderaan. I\'ve got to go home. It\'s late, I\'m in for it as it is. Obi-Wan is here. The Force is with him. Don\'t be too proud of this technological terror you\'ve constructed. The ability to destroy a planet is insignificant next to the power of the Force. She must have hidden the plans in the escape pod. Send a detachment down to retrieve them, and see to it personally, Commander. There\'ll be no one to stop us this time!\n \n
</string>
<!-- Detail Fragment -->
<string-array name="detail_fragment_titles">
<item>Films</item>
<item>Vehicles</item>
<item>Species</item>
<item>Starships</item>
</string-array>
<string name="text_no_data">No data to display</string>
@ -45,13 +22,9 @@
<!-- Arrays -->
<integer-array name="characters">
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
</integer-array>
<string name="library_title">My library</string>
<string name="recent_updates_title">Recent updates</string>
<string name="catalogues_title">Catalogues</string>
<string name="settings_title">Settings</string>
</resources>