Skip to content

Commit

Permalink
add a gif
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyWallace committed Mar 20, 2016
1 parent a566d20 commit 43fb0a4
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
20 changes: 18 additions & 2 deletions app/src/main/java/etong/bottomnavigation/demo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.support.design.widget.NavigationView;
Expand Down Expand Up @@ -53,7 +54,7 @@ public void onClick(View view) {
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);

getSupportFragmentManager().beginTransaction().add(R.id.container, MoviesFragment.newInstance()).commitAllowingStateLoss();
getSupportFragmentManager().beginTransaction().replace(R.id.container, MoviesFragment.newInstance()).commitAllowingStateLoss();

setUpBottomNavigationBar();
}
Expand All @@ -68,7 +69,22 @@ public void setUpBottomNavigationBar() {
bottomLayout.setOnTabListener(new BottomNavigationBar.TabListener() {
@Override
public void onSelected(int position) {

Fragment fragment = null;
switch (position){
case 0:
fragment = MoviesFragment.newInstance();
break;
case 1:
fragment = MusicFragment.newInstance();
break;
case 2:
fragment = BooksFragment.newInstance();
break;
case 3:
fragment = NewsstandFragment.newInstance();
break;
}
getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment).commitAllowingStateLoss();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public static MusicFragment newInstance() {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_movies, container, false);
return inflater.inflate(R.layout.fragment_music, container, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class NewsstandFragment extends Fragment {

private RecyclerView recycleView;


public NewsstandFragment() {
// Required empty public constructor
}
Expand All @@ -27,14 +26,12 @@ public static NewsstandFragment newInstance() {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View contentView = inflater.inflate(R.layout.fragment_books, container, false);
recycleView = (RecyclerView) contentView.findViewById(R.id.recycleView);
recycleView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
recycleView.setAdapter(new BookAdapter());
View contentView = inflater.inflate(R.layout.fragment_newsstand, container, false);

return contentView;
}

private class BookAdapter extends RecyclerView.Adapter<ViewHolder>{
private class BookAdapter extends RecyclerView.Adapter<ViewHolder> {

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Expand All @@ -52,7 +49,7 @@ public int getItemCount() {
}
}

private class ViewHolder extends RecyclerView.ViewHolder{
private class ViewHolder extends RecyclerView.ViewHolder {

public ViewHolder(View itemView) {
super(itemView);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/app_bar_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#33000000"
app:layout_scrollFlags="enterAlways"
app:layout_scrollFlags="scroll"
app:popupTheme="@style/AppTheme.PopupOverlay"/>

</android.support.design.widget.AppBarLayout>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<!--<item name="android:windowDrawsSystemBarBackgrounds">true</item>-->
<!--<item name="android:statusBarColor">@android:color/transparent</item>-->
</style>
</resources>
Binary file added gif/demo1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 43fb0a4

Please sign in to comment.