Skip to content

Commit

Permalink
f2
Browse files Browse the repository at this point in the history
  • Loading branch information
ridhambhat committed Jul 7, 2020
1 parent 0337a98 commit df42227
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
package com.example.storieslibrary;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;

import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.RecyclerView;

import com.mikhaellopez.circularimageview.CircularImageView;
import com.squareup.picasso.Picasso;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

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

private List<String> from;
private List<Integer> readState;
private List<String> showlink;
private LayoutInflater mInflater;
private Context ctx;

// data is passed into the constructor
public RoundStoryAdapter(Context context, List<String> data, List<Integer> readState) {
public RoundStoryAdapter(Context context, List<String> data, List<Integer> readState, ArrayList<String> showlink) {
this.mInflater = LayoutInflater.from(context);
this.from = data;
this.readState=readState;
this.showlink = showlink;
ctx=context;
}

Expand Down Expand Up @@ -62,15 +61,20 @@ public void onBindViewHolder(ViewHolder holder, int position) {
else
from=from2;
holder.storyFrom.setText(from);
AssetManager assetManager = ctx.getAssets();
try (
InputStream inputStream = assetManager.open("club_logos/"+from2+".png");
) {
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
holder.roundFrame.setImageBitmap(bitmap);
} catch (IOException ex) {
//Toast.makeText(ctx,"path - "+" club_logo/"+"from2"+".png",Toast.LENGTH_SHORT).show();
}
Picasso.with(ctx)
.load(showlink.get(position))
.placeholder(R.drawable.loading)
.into(holder.roundFrame);

// AssetManager assetManager = ctx.getAssets();
// try (
// InputStream inputStream = assetManager.open("club_logos/"+from2+".png");
// ) {
// Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
// holder.roundFrame.setImageBitmap(bitmap);
// } catch (IOException ex) {
// //Toast.makeText(ctx,"path - "+" club_logo/"+"from2"+".png",Toast.LENGTH_SHORT).show();
// }

int state=this.readState.get(position);
if(state != 0){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ private void setRecyclerView()
{
// Log.d("SRV", "setRecyclerView: ");
rv.setLayoutManager(new LinearLayoutManager(ctx,LinearLayoutManager.HORIZONTAL, false));
rv.setAdapter(new RoundStoryAdapter(ctx,storyFrom, storyState));
ArrayList<String> showlink = new ArrayList<>();
for(int i = 0; i<storyFrom.size(); i++)
showlink.add(storyLink.get(i).get(0));
rv.setAdapter(new RoundStoryAdapter(ctx,storyFrom, storyState, showlink));
rv.addOnItemTouchListener(
new RecyclerItemClickListener(ctx, rv, new RecyclerItemClickListener.OnItemClickListener() {
@Override
Expand Down
Binary file removed storieslibrary/src/main/res/drawable/loggo.jpeg
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
app:civ_border_color="#716C6C"
app:civ_border_width="3dp"
android:background="#ffffff"
android:src="@drawable/loggo"
android:src="@drawable/loading"
android:id="@+id/roundedimgframe"
/>

Expand Down

0 comments on commit df42227

Please sign in to comment.