<file_sep>package com.example.mostpopularapi;

import android.database.Cursor;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

public class FavoriteArticle extends AppCompatActivity {

    private TextView articleText;
    private TextView conten;
    private TextView link;
    private long id;
    private DBHelper db;
    private Cursor cursor;
    private FloatingActionButton fab;
    private ImageView imageView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_article);

        fab = findViewById(R.id.btn_favorites);
        fab.hide();

        db = new DBHelper(this, 1);

        id = Import.id;
        articleText = findViewById(R.id.articleText);
        conten = findViewById(R.id.contentTextArticle);
        link = findViewById(R.id.link);
        imageView = findViewById(R.id.iv);

        cursor = db.viewArticleId(id);

        cursor.moveToFirst();

        articleText.setText(cursor.getString(cursor.getColumnIndex("title")));
        String content;
        content = "" +
                "keywords: " + cursor.getString(cursor.getColumnIndex("keywords")) +
                "\ncount type: " + cursor.getString(cursor.getColumnIndex("count_type")) +
                "\ncolumn: "  + cursor.getString(cursor.getColumnIndex("colum")) +
                "\nsection: " + cursor.getString(cursor.getColumnIndex("section")) +
                "\nbyline: " + cursor.getString(cursor.getColumnIndex("byline")) +
                "\nabstract: " + cursor.getString(cursor.getColumnIndex("abstract")) +
                "\npublished date: " + cursor.getString(cursor.getColumnIndex("published_date")) +
                "\nupdated: " + cursor.getString(cursor.getColumnIndex("updated"));
        conten.setText(content);

        Picasso.get().load(cursor.getString(cursor.getColumnIndex("url_image"))).into(imageView);

        link.setText("Link: " + cursor.getString(cursor.getColumnIndex("url")));

        Toolbar toolbar = findViewById(R.id.toolbarArticle);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == android.R.id.home) {
            finish();
        }
        return super.onOptionsItemSelected(item);
    }

}
<file_sep>package com.example.mostpopularapi;

import android.database.Cursor;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.MenuItem;
import android.support.v7.widget.Toolbar;

public class FavoritesActivity extends AppCompatActivity {

    private RecyclerView favoritesArticle;
    private FavoritesAdapter favoritesAdapter;
    private Cursor cursor;
    private DBHelper db;
    private int countItems;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.favorites_activity);

        db = new DBHelper(this, 1);

        cursor = db.viewArticle();
        countItems = db.viewKol();

        favoritesArticle = findViewById(R.id.rv_fav);

        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        favoritesArticle.setLayoutManager(layoutManager);

        favoritesAdapter = new FavoritesAdapter( countItems,this, cursor);
        favoritesArticle.setAdapter(favoritesAdapter);

        Toolbar toolbar = findViewById(R.id.toolbarFav);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == android.R.id.home) {
            finish();
        }
        return super.onOptionsItemSelected(item);
    }
}
<file_sep>package com.example.mostpopularapi;

import java.util.List;

 class Import {
     static Result ob;
     static Long id;
}
<file_sep>package com.example.mostpopularapi;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

public class ViewPagerAdapter extends FragmentPagerAdapter {

    final int NumbOfTabs = 3;
    private String Titles[] = new String[] { "Emailed", "Shared", "Viewed" };
    private Context context;

    public ViewPagerAdapter(FragmentManager fm, Context context) {
        super(fm);

        this.context = context;
    }

    @Override
    public Fragment getItem(int position) {

        if (position == 0) {
            EmailedFragment tab = new EmailedFragment();
            return tab;
        }
        if (position == 1) {
            SharedFragment tab = new SharedFragment();
            return tab;
        }
        else {
            ViewedFragment tab = new ViewedFragment();
            return tab;
        }
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return Titles[position];
    }

    @Override
    public int getCount() {
        return NumbOfTabs;
    }
}<file_sep>package com.example.mostpopularapi;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import java.util.List;

import static android.support.constraint.Constraints.TAG;


public class ArticlesAdapter extends RecyclerView.Adapter<ArticlesAdapter.ArticlesViewHolder>{

    private Context parent;
    private List<Result> mArticles;
    private Result articles;

    public ArticlesAdapter(Context parent, List<Result> dataList){
        this.parent = parent;
        mArticles = dataList;
    }

    @NonNull
    @Override
    public ArticlesViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        Context context = viewGroup.getContext();

        LayoutInflater inflater = LayoutInflater.from(context);
        View v = inflater.inflate(R.layout.item, viewGroup, false);
        ArticlesViewHolder viewHolder = new ArticlesViewHolder(v);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ArticlesViewHolder articlesViewHolder, int position) {
        articles = mArticles.get(position);
        articlesViewHolder.listItemView.setText(articles.getTitle());
    }

    @Override
    public int getItemCount() {
        return mArticles.size();
    }

    class ArticlesViewHolder extends RecyclerView.ViewHolder {

        TextView listItemView;

        public ArticlesViewHolder(@NonNull View itemView) {
            super(itemView);
            listItemView = itemView.findViewById(R.id.text_title);

            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    int positionIndex = getAdapterPosition();
                    Result impID = mArticles.get(positionIndex);
                    Intent intent = new Intent(parent, ArticlesActivity.class);
                    Import.ob = impID;
                    parent.startActivity(intent);
                }
            });
        }
    }
}
<file_sep>package com.example.mostpopularapi;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.example.mostpopularapi.retrofit.API;
import com.example.mostpopularapi.retrofit.RetroArticle;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class SharedFragment extends Fragment {

    private RecyclerView sharedArticle;
    private ArticlesAdapter sharedAdapter;
    private List<Result> sharedList;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        final View v = inflater.inflate(R.layout.fragment_articles, container, false);

        if(InternetConnection.checkConnection(v.getContext())){

          API api = RetroArticle.getRetrofitIntance().create(API.class);

            Call<Example> call = api.getSharedJSON();

            call.enqueue(new Callback<Example>() {
                @Override
                public void onResponse(Call<Example> call, Response<Example> response) {

                    sharedList = response.body().getResults();

                    sharedArticle = v.findViewById(R.id.rv_articles);
                    LinearLayoutManager layoutManager = new LinearLayoutManager(v.getContext());
                    sharedArticle.setLayoutManager(layoutManager);

                    sharedAdapter = new ArticlesAdapter(v.getContext(), sharedList);
                    sharedArticle.setAdapter(sharedAdapter);
                }

                @Override
                public void onFailure(Call<Example> call, Throwable t) {
                    Toast.makeText(v.getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
                }
            });
        }
        else{
            Toast.makeText(v.getContext(),"No Internet Connection", Toast.LENGTH_SHORT).show();
        }
        return v;
    }
}
