40 Comments

  1. Hello sir , i wrote the same code but i got an error in gson part
    "com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $"
    Sir please help me to resolve this error

  2. Hai, I implementing your project. I am facing the below error. can you please guide me. Your Videos are very helpful. I am trying to do all your projects.

    Process: com.example.cointracker, PID: 10871

    java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

    at android.os.Handler.<init>(Handler.java:200)

    at android.os.Handler.<init>(Handler.java:114)

    at android.widget.Toast$TN.<init>(Toast.java:342)

    at android.widget.Toast.<init>(Toast.java:99)

    at android.widget.Toast.makeText(Toast.java:248)

    at com.example.cointracker.MainActivity$5.onFailure(MainActivity.java:130)

  3. Source Code link not working.
    Showing only ads.
    There is no link to download source code or skip ads.

    Can you please provide another working link??

    I'm from India and the link in not opening properly from there i also tried vpn but didn't worked

  4. Hey EDMT,, Requesting a tutorial on using Version 2 of this API. Link to V2: https://coinmarketcap.com/api/

    says they will take down version 1 by November 2018.

    CoinMarketCap Public API Documentation

    Version 2

    The Public API will be migrating to the new, more powerful Professional API on December 4th, 2018. Please update your application to use the free tier of the Professional API before then.

    Summary of Endpoints

  5. Chào Anh, e muốn làm cái app về check domain và đăng ký domain thì mình làm tương tự như video của a được ko a? cảm ơn a

  6. final List<CoinModel> newItems=gson.fromJson(body,new TypeToken<List<CoinModel>>(){}.getType());
    please any one resolve my error in this line.
    error type:
    FATAL EXCEPTION: OkHttp Dispatcher
    Process: com.example.fakhar.coinmarketcap, PID: 11962
    com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $

  7. its giving crash on Google play console oppo A37 and android 5.1

    Aug 4, 12:56 AM on app version 1
    Oppo A37f (A37f), Android 5.1
    Report 1

    java.lang.NullPointerException:
    at abduldev.cryptocoins.Adapter.CoinAdapter.onBindViewHolder (CoinAdapter.java:79)
    at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder (RecyclerView.java:6673)
    at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder (RecyclerView.java:6714)
    at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline (RecyclerView.java:5647)
    my code is absolutely write as i write according to your tutorial

    public class CoinAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{

    ILoadMore iLoadMore;
    boolean isLoading;
    Activity activity;
    List<CoinModel> items;

    int visibleThreshold = 5, lastVisibleItem,totalItemCount;

    public CoinAdapter(RecyclerView recyclerView, Activity activity, final List<CoinModel> items) {
    this.activity = activity;
    this.items = items;
    final LinearLayoutManager linearLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
    @Override
    public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);
    totalItemCount = linearLayoutManager.getItemCount();
    lastVisibleItem = linearLayoutManager.findLastVisibleItemPosition();
    if (!isLoading && totalItemCount <= (lastVisibleItem+visibleThreshold))
    {
    if (iLoadMore != null)
    iLoadMore.onLoadMore();
    isLoading = true;
    }
    }
    });
    }

    public void setiLoadMore(ILoadMore iLoadMore) {
    this.iLoadMore = iLoadMore;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    View view = LayoutInflater.from(activity)
    .inflate(R.layout.coin_layout,parent,false);

    return new CoinViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
    CoinModel item = items.get(position);
    CoinViewHolder holderItem = (CoinViewHolder)holder;
    holderItem.coin_name.setText(item.getName());
    holderItem.coin_price.setText(item.getPrice_usd());
    holderItem.coin_symbol.setText(item.getSymbol());
    holderItem.one_hour_change.setText(item.getPercent_change_1h()+"%");
    holderItem.twenty_hours_change.setText(item.getPercent_change_24h()+"%");
    holderItem.seven_days_change.setText(item.getPercent_change_7d()+"%");

    // Now Load Image
    Picasso.with(activity)
    .load(new StringBuilder("https://res.cloudinary.com/dxi90ksom/image/upload/&quot😉
    .append(item.getSymbol().toLowerCase()).append(".png").toString())
    .into(holderItem.coin_icon);

    holderItem.one_hour_change.setTextColor(item.getPercent_change_1h().contains("-")?
    Color.parseColor("#FF0000"):Color.parseColor("#32CD32"));
    holderItem.twenty_hours_change.setTextColor(item.getPercent_change_1h().contains("-")?
    Color.parseColor("#FF0000"):Color.parseColor("#32CD32"));
    holderItem.seven_days_change.setTextColor(item.getPercent_change_1h().contains("-")?
    Color.parseColor("#FF0000"):Color.parseColor("#32CD32"));

    }

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

    public void setLoaded(){isLoading = false ;}
    public void updateData(List<CoinModel> coinModels){
    this.items = coinModels;
    notifyDataSetChanged();
    }
    }

  8. -19 02:00:37.731 29160-29178/cryotocoins.abduldev.cryptocoinrates E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
    Process: cryotocoins.abduldev.cryptocoinrates, PID: 29160
    java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
    at android.os.Handler.<init>(Handler.java:200)
    at android.os.Handler.<init>(Handler.java:114)
    at android.widget.Toast$TN.<init>(Toast.java:372)
    at android.widget.Toast.<init>(Toast.java:105)
    at android.widget.Toast.makeText(Toast.java:264)
    at cryotocoins.abduldev.cryptocoinrates.MainActivity$5.onFailure(MainActivity.java:135)

    java file:

    on MainActivity.java its crashes when internet connection is off?

    private void loadFirst10Coin(int index) {

    client = new OkHttpClient();
    request = new Request.Builder().url(String.format("https://api.coinmarketcap.com/v1/ticker/?start=%d&limit=10&quot;, index))
    .build();
    swipeRefreshLayout.setRefreshing(true);
    client.newCall(request)
    .enqueue(new Callback() {
    @Override
    public void onFailure(Call call, IOException e) {
    Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onResponse(Call call, Response response) throws IOException {

    String body = response.body().string();
    Gson gson = new Gson();
    final List<CoinModel> newItems = gson.fromJson(body, new TypeToken<List<CoinModel>>() {
    }.getType());
    runOnUiThread(new Runnable() {
    @Override
    public void run() {

    adapter.updateData(newItems);

    }
    });
    }
    });
    if (swipeRefreshLayout.isRefreshing())
    swipeRefreshLayout.setRefreshing(false);
    }

    what to do man?

  9. how much request it can handle i developed your news app its good but its crashes due to bad worst api and showing fatal error of loading images or request at picasso line so i decided to not publish it to store can you tell its api better than newsapi.org??? or not

  10. Really nice tutorial. Just to point out, in 12:15 is not constraintTop, but constraintBottom… same for the next TextViews. That's why percentages don't align with the bottom of the icon's coin when you test it at the end of the video.

  11. Thank you so much! I have a problem with this line 🙁
    private void loadFirst10Coin(int index) {
    ……………………………
    final List<CoinModel> newItems = gson.fromJson(body, new TypeToken<List<CoinModel>>(){}.getType());
    }
    I would appreciate your help 🙂

Leave a Reply

Your email address will not be published.


*


47 − = 41