Skip to content
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
15 changes: 15 additions & 0 deletions Android/SnehaVeerakumar/Advanced/dailyNews/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions Android/SnehaVeerakumar/Advanced/dailyNews/.idea/.gitignore

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

6 changes: 6 additions & 0 deletions Android/SnehaVeerakumar/Advanced/dailyNews/.idea/compiler.xml

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

19 changes: 19 additions & 0 deletions Android/SnehaVeerakumar/Advanced/dailyNews/.idea/gradle.xml

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

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

9 changes: 9 additions & 0 deletions Android/SnehaVeerakumar/Advanced/dailyNews/.idea/misc.xml

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

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

1 change: 1 addition & 0 deletions Android/SnehaVeerakumar/Advanced/dailyNews/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
49 changes: 49 additions & 0 deletions Android/SnehaVeerakumar/Advanced/dailyNews/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
plugins {
id 'com.android.application'
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.assessment"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//noinspection GradleCompatible
implementation 'com.android.support:recyclerview-v7:28.0.0'
//noinspection GradleCompatible
implementation 'com.android.support:cardview-v7:28.0.0'
//noinspection GradleCompatible
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.koushikdutta.ion:ion:2.+'

implementation 'com.squareup.picasso:picasso:2.71828'
}
21 changes: 21 additions & 0 deletions Android/SnehaVeerakumar/Advanced/dailyNews/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.assessment;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.assessment", appContext.getPackageName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.assessment">

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

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="LiveNews"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name=".DetailsActivity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.assessment;

import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.webkit.WebView;

public class DetailsActivity extends AppCompatActivity {

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

WebView editWeb = findViewById(R.id.web);
Intent intent = getIntent();

String url = intent.getStringExtra("url");
editWeb.loadUrl(url);

ActionBar bar = getSupportActionBar();
bar.setTitle("News");
bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("blue")));

bar.setDisplayHomeAsUpEnabled(true);
bar.setDisplayShowHomeEnabled(true);

}

public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId() == android.R.id.home)
{
finish();
}

return super.onOptionsItemSelected(item);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package com.assessment;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.koushikdutta.ion.Ion;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;

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


Context context;

private final ArrayList <ModelItems> items;

public ItemAdapter(Context context, ArrayList<ModelItems> items) {
this.context = context;
this.items = items;

}

@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
LayoutInflater inflater = LayoutInflater.from(this.context);
LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.news, null);

return new ViewHolder(layout);
}

@Override
public void onBindViewHolder(@NonNull ViewHolder holder, final int i) {
final ModelItems item = items.get(i);



String title = item.getTitle();
String author = item.getAuthor();
String date = item.getDate();
String urlToImage = item.getUrlToImage();
final String url = item.getUrl();



if(title!=null)
holder.editTitle.setText(title);
if(author!=null)
holder.editauthor.setText("Author "+author);
if(date!=null)
holder.editdate.setText("published at: "+date);
if(urlToImage!=null)
Picasso.get().load(urlToImage).into(holder.editUrlImage);


holder.mybutton.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {

Intent intent = new Intent(context,DetailsActivity.class);
intent.putExtra("url",url);
context.startActivity(intent);
}
});

}


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

class ViewHolder extends RecyclerView.ViewHolder {

TextView editTitle,editauthor,editdate;
ImageView editUrlImage;
Button mybutton;
ViewHolder(@NonNull View itemView) {
super(itemView);

editTitle = itemView.findViewById(R.id.tittle1);
editUrlImage = itemView.findViewById(R.id.image1);
editauthor = itemView.findViewById(R.id.author);
editdate = itemView.findViewById(R.id.date);
mybutton = itemView.findViewById(R.id.details);


}

}


}
Loading