Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #51

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
134 changes: 109 additions & 25 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Build Status](https://travis-ci.com/sridharjajoo/NewsApp.svg?branch=master)](https://travis-ci.com/sridharjajoo/NewsApp)
[![Gitter](https://img.shields.io/badge/chat-on%20gitter-ff006f.svg)](https://gitter.im/news_app_kwoc)

# NewsApp
# NEWSAPP
An app that fetches latest news and headlines. It also allows the users to favourite their news. The user also has the option to choose the source of news. They can also search for any particular trending keyword. The following libraries were used in this project.

- [RxJava 2](https://github.com/ReactiveX/RxJava)
Expand Down Expand Up @@ -39,6 +39,7 @@ Finally, the view role in this pattern is to observe a ViewModel observable to g
![](https://raw.githubusercontent.com/rob729/NewsApp/master/Screenshots/img_1.png)
![](https://raw.githubusercontent.com/rob729/NewsApp/master/Screenshots/img2.png)
![](https://raw.githubusercontent.com/rob729/NewsApp/master/Screenshots/img3.png)
<img src="Screenshots/img4.jpg" width="250" title="hover text">

## License

Expand Down
Binary file added Screenshots/img4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies {

// Dagger
implementation "com.google.dagger:dagger:2.14.1"
implementation "com.google.dagger:dagger-android:2.14.1"
implementation "com.google.dagger:dagger-android:2.15"
implementation "com.google.dagger:dagger-android-support:2.14.1"
annotationProcessor "com.google.dagger:dagger-compiler:2.14.1"
annotationProcessor "com.google.dagger:dagger-android-processor:2.14.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class NewsMainActivity extends AppCompatActivity implements HasSupportFra

private ActionBar actionBar;
private ActivityNewsMainBinding binding;
private int TOTALCATEGORY = 3;
private int TOTALCATEGORY = 7;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -188,6 +188,14 @@ public CharSequence getPageTitle(int position) {
return "Sports";
case 2:
return "Entertainment";
case 3:
return "Technology";
case 4:
return "Business";
case 5:
return "General";
case 6:
return "Health";
}
return " ";

Expand All @@ -206,6 +214,14 @@ public Fragment getItem(int position) {
return categoryFragment;
case 2:
return categoryFragment;
case 3:
return categoryFragment;
case 4:
return categoryFragment;
case 5:
return categoryFragment;
case 6:
return categoryFragment;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class CategoryFragment extends Fragment implements Injectable {
private SearchAdapter searchAdapter;
private AppDatabase db;
private String category;
private int selectedCategory=0;
private int selectedCategory = 0;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Expand Down Expand Up @@ -90,12 +90,16 @@ private String findCategory(int selectedCategory){
case 0 : return "science";
case 1 : return "sports";
case 2 : return "entertainment";
case 3 : return "technology";
case 4 : return "business";
case 5 : return "general";
case 6 : return "health";
default: return "science";
}
}

private void showResult(List<Articles> articles) {
if (articles == null || (articles.size()==0)) {
if (articles == null || (articles.size() == 0)) {
searchAdapter.clearRecyclerView();
binding.noSearch.setVisibility(View.VISIBLE);
} else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,10 @@ public class FavouriteFragment extends Fragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_favourite, container, false);
getSavedNews();
return binding.getRoot();
}

@Override
public void onStart() {
super.onStart();
db = AppDatabase.getAppDatabase(getActivity());
List<Favourite> favouriteList = db.favoriteDao().getFavourites();
for (int i = 0; i < favouriteList.size(); i++) {
listArticles.add(favouriteList.get(i).articles);
}
setRecyclerView(listArticles);
}

private void setRecyclerView(List<Articles> articlesList) {
binding.favouriteRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
Expand All @@ -67,4 +58,14 @@ private void setRecyclerView(List<Articles> articlesList) {
private void loadArticles(List<Articles> articlesList) {
searchAdapter.setArticlesList(articlesList);
}

private void getSavedNews(){
db = AppDatabase.getAppDatabase(getActivity());
List<Favourite> favouriteList = db.favoriteDao().getFavourites();
for (int i = 0; i < favouriteList.size(); i++) {
listArticles.add(favouriteList.get(i).articles);
}
setRecyclerView(listArticles);
}

}
4 changes: 3 additions & 1 deletion app/src/main/res/layout/activity_news_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@

<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:tabSelectedTextColor="#FFFFFF"
app:tabTextColor="#ffffff"
android:layout_gravity="center_horizontal"
app:tabMode="scrollable"
android:visibility="gone"/>

<android.support.v4.view.ViewPager
Expand Down