Skip to content

Commit

Permalink
new code uploaded
Browse files Browse the repository at this point in the history
  • Loading branch information
HasnathJami committed Feb 10, 2022
1 parent 96fc768 commit bd0aaca
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 2 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

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

1 change: 1 addition & 0 deletions .idea/misc.xml

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

3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ dependencies {
implementation 'com.android.volley:volley:1.2.1'
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.bumptech.glide:glide:4.13.0'

}
7 changes: 6 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.recyclerviewimplementation">
<uses-permission android:name="android.permission.INTERNET"/>

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.RecyclerViewImplementation">
<activity
android:name=".DetailActivity"
android:exported="false" />
<activity
android:name=".MainActivityForVolley"
android:exported="true">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package com.example.recyclerviewimplementation.Adapter;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView;

import com.example.recyclerviewimplementation.DetailActivity;
import com.example.recyclerviewimplementation.Model.Model;
import com.example.recyclerviewimplementation.R;

Expand Down Expand Up @@ -47,6 +51,24 @@ public void onBindViewHolder(@NonNull viewHolder holder, int position) {
holder.tv4.setText(model.getBody());

//Glide.with(context).load(model.getPoster()).into(holder.imageViewId);
//Picasso.get().load(model.getImage()).into(holder.bookImage);
holder.constraintLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent =new Intent(context, DetailActivity.class);
Bundle bundle=new Bundle();

bundle.putString("uId",model.getUserId());
bundle.putString("jId",model.getId());
bundle.putString("jTitle",model.getTitle());
bundle.putString("jBody",model.getBody());
intent.putExtras(bundle);

context.startActivity(intent);

}
});


}

Expand All @@ -59,13 +81,16 @@ public int getItemCount() {
public class viewHolder extends RecyclerView.ViewHolder{

TextView tv1,tv2,tv3,tv4;
ConstraintLayout constraintLayout;
public viewHolder(@NonNull View itemView) {
super(itemView);

tv1=itemView.findViewById(R.id.textView1Id);
tv2=itemView.findViewById(R.id.textView2Id);
tv3=itemView.findViewById(R.id.textView3Id);
tv4=itemView.findViewById(R.id.textView4Id);
constraintLayout=itemView.findViewById(R.id.samplaLayoutId);

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.example.recyclerviewimplementation;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.example.recyclerviewimplementation.databinding.ActivityDetailBinding;

import java.lang.String;

public class DetailActivity extends AppCompatActivity {

ActivityDetailBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding=ActivityDetailBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
//setContentView(R.layout.activity_detail);

Bundle bundle=getIntent().getExtras();

String uId=bundle.getString("uId");
String Id=bundle.getString("jId");
String Title=bundle.getString("jTitle");
String Body= bundle.getString("jBody");

binding.id1.setText(uId);
binding.id2.setText(Id);
binding.id3.setText(Title);
binding.id4.setText(Body);


}
}
50 changes: 50 additions & 0 deletions app/src/main/res/layout/activity_detail.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DetailActivity">

<TextView
android:id="@+id/id1"
android:layout_width="66dp"
android:layout_height="14dp"
android:layout_marginTop="176dp"
android:text="TextView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/id2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="64dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="@+id/id1"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/id1"
app:layout_constraintTop_toBottomOf="@+id/id1" />

<TextView
android:id="@+id/id3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="64dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="@+id/id2"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/id2"
app:layout_constraintTop_toBottomOf="@+id/id2" />

<TextView
android:id="@+id/id4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="56dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="@+id/id3"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/id3"
app:layout_constraintTop_toBottomOf="@+id/id3" />
</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 3 additions & 1 deletion app/src/main/res/layout/sample_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
android:paddingBottom="4dp"
android:paddingRight="4dp"
android:paddingLeft="4dp"
android:layout_gravity="center_horizontal">
android:layout_gravity="center_horizontal"
android:id="@+id/samplaLayoutId"
>


<androidx.cardview.widget.CardView
Expand Down

0 comments on commit bd0aaca

Please sign in to comment.