mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Add library class
This commit is contained in:
parent
9e5622c92e
commit
393caaa549
9 changed files with 217 additions and 105 deletions
|
@ -1,5 +1,6 @@
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'com.neenbedankt.android-apt'
|
apply plugin: 'com.neenbedankt.android-apt'
|
||||||
|
apply plugin: 'me.tatarka.retrolambda'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 23
|
compileSdkVersion 23
|
||||||
|
|
1
app/proguard-rules.pro
vendored
1
app/proguard-rules.pro
vendored
|
@ -15,3 +15,4 @@
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
# public *;
|
# public *;
|
||||||
#}
|
#}
|
||||||
|
-dontwarn java.lang.invoke.*
|
|
@ -1,42 +1,37 @@
|
||||||
package eu.kanade.mangafeed.ui.activity;
|
package eu.kanade.mangafeed.ui.activity;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.app.Fragment;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.app.FragmentTransaction;
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
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 javax.inject.Inject;
|
||||||
|
|
||||||
import eu.kanade.mangafeed.R;
|
|
||||||
|
|
||||||
import butterknife.Bind;
|
import butterknife.Bind;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
import eu.kanade.mangafeed.R;
|
||||||
import eu.kanade.mangafeed.data.helpers.DatabaseHelper;
|
import eu.kanade.mangafeed.data.helpers.DatabaseHelper;
|
||||||
|
import eu.kanade.mangafeed.ui.fragment.LibraryFragment;
|
||||||
import rx.subscriptions.CompositeSubscription;
|
import rx.subscriptions.CompositeSubscription;
|
||||||
import timber.log.Timber;
|
|
||||||
import uk.co.ribot.easyadapter.EasyRecyclerAdapter;
|
|
||||||
|
|
||||||
public class MainActivity extends BaseActivity {
|
public class MainActivity extends BaseActivity {
|
||||||
|
|
||||||
@Bind(R.id.recycler_characters)
|
|
||||||
RecyclerView mCharactersRecycler;
|
|
||||||
|
|
||||||
@Bind(R.id.toolbar)
|
@Bind(R.id.toolbar)
|
||||||
Toolbar mToolbar;
|
Toolbar toolbar;
|
||||||
|
|
||||||
@Bind(R.id.progress_indicator)
|
@Bind(R.id.drawer_container)
|
||||||
ProgressBar mProgressBar;
|
FrameLayout container;
|
||||||
|
|
||||||
@Bind(R.id.swipe_container)
|
|
||||||
SwipeRefreshLayout mSwipeRefresh;
|
|
||||||
|
|
||||||
@Inject DatabaseHelper mDb;
|
@Inject DatabaseHelper mDb;
|
||||||
|
private Drawer drawer;
|
||||||
private CompositeSubscription mSubscriptions;
|
private CompositeSubscription mSubscriptions;
|
||||||
private EasyRecyclerAdapter<Character> mEasyRecycleAdapter;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -45,9 +40,49 @@ public class MainActivity extends BaseActivity {
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
mSubscriptions = new CompositeSubscription();
|
mSubscriptions = new CompositeSubscription();
|
||||||
//mDataManager = App.get(this).getComponent().dataManager();
|
|
||||||
setupToolbar();
|
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
|
@Override
|
||||||
|
@ -73,13 +108,21 @@ public class MainActivity extends BaseActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupToolbar() {
|
private void setupToolbar() {
|
||||||
setSupportActionBar(mToolbar);
|
setSupportActionBar(toolbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupRecyclerView() {
|
private void setFragment(Fragment fragment) {
|
||||||
mCharactersRecycler.setLayoutManager(new LinearLayoutManager(this));
|
try {
|
||||||
mCharactersRecycler.setAdapter(mEasyRecycleAdapter);
|
if (fragment != null && getSupportFragmentManager() != null) {
|
||||||
|
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||||
|
if (ft != null) {
|
||||||
|
ft.replace(R.id.content_layout, fragment);
|
||||||
|
ft.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
mSwipeRefresh.setColorSchemeResources(R.color.primary);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,55 +1,31 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
<android.support.design.widget.CoordinatorLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:gravity="center"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:background="@color/bg_light_grey">
|
|
||||||
|
|
||||||
<RelativeLayout
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="?attr/actionBarSize"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
android:background="?attr/colorPrimary"
|
||||||
|
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||||
|
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||||
|
android:elevation="4dp" />
|
||||||
|
|
||||||
<android.support.v4.widget.SwipeRefreshLayout
|
<!-- the layout which will contain (host) the drawerLayout -->
|
||||||
android:id="@+id/swipe_container"
|
<FrameLayout
|
||||||
|
android:layout_below="@id/toolbar"
|
||||||
|
android:id="@+id/drawer_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<!-- 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_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
</FrameLayout>
|
||||||
android:id="@+id/recycler_characters"
|
</FrameLayout>
|
||||||
android:layout_width="match_parent"
|
</RelativeLayout>
|
||||||
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.support.design.widget.AppBarLayout>
|
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
|
20
app/src/main/res/layout/fragment_library.xml
Normal file
20
app/src/main/res/layout/fragment_library.xml
Normal 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>
|
36
app/src/main/res/layout/item_library.xml
Normal file
36
app/src/main/res/layout/item_library.xml
Normal 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>
|
7
app/src/main/res/values/ids.xml
Normal file
7
app/src/main/res/values/ids.xml
Normal 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>
|
|
@ -1,35 +1,12 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">AndroidBoilerPlate</string>
|
<string name="app_name">Mangafeed</string>
|
||||||
|
|
||||||
<!-- Activity labels -->
|
<!-- Activity labels -->
|
||||||
<string name="label_main">Boilerplate</string>
|
<string name="label_main">Mangafeed</string>
|
||||||
|
|
||||||
<!-- Main Activity -->
|
<!-- Main Activity -->
|
||||||
|
|
||||||
<string name="action_github">View on GitHub</string>
|
<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>
|
<string name="text_no_data">No data to display</string>
|
||||||
|
|
||||||
|
@ -45,13 +22,9 @@
|
||||||
|
|
||||||
<!-- Arrays -->
|
<!-- Arrays -->
|
||||||
|
|
||||||
<integer-array name="characters">
|
<string name="library_title">My library</string>
|
||||||
<item>1</item>
|
<string name="recent_updates_title">Recent updates</string>
|
||||||
<item>2</item>
|
<string name="catalogues_title">Catalogues</string>
|
||||||
<item>3</item>
|
<string name="settings_title">Settings</string>
|
||||||
<item>4</item>
|
|
||||||
<item>5</item>
|
|
||||||
<item>6</item>
|
|
||||||
</integer-array>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue