diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/.gitignore b/Android/Amit Shekhar/Advanced/NavNewsApp/.gitignore new file mode 100644 index 00000000..aa724b77 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/.gitignore @@ -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 diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/.gitignore b/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/compiler.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/compiler.xml new file mode 100644 index 00000000..fb7f4a8a --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/gradle.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/gradle.xml new file mode 100644 index 00000000..5cd135a0 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/jarRepositories.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/jarRepositories.xml new file mode 100644 index 00000000..0380d8d3 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/jarRepositories.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/misc.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/misc.xml new file mode 100644 index 00000000..6199cc2a --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/runConfigurations.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/runConfigurations.xml new file mode 100644 index 00000000..797acea5 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/.gitignore b/Android/Amit Shekhar/Advanced/NavNewsApp/app/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/build.gradle b/Android/Amit Shekhar/Advanced/NavNewsApp/app/build.gradle new file mode 100644 index 00000000..28bfad8d --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/build.gradle @@ -0,0 +1,57 @@ +plugins { + id 'com.android.application' +} + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "com.example.navnewsapp" + minSdkVersion 21 + 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 + } + buildFeatures { + viewBinding true + } +} + +dependencies { + + //Retrofit + implementation 'com.squareup.retrofit2:retrofit:2.4.0' + implementation 'com.squareup.retrofit2:converter-gson:2.2.0' + + //Date/Time + implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final' + + //Picaso for image url + implementation 'com.squareup.picasso:picasso:2.5.0' + + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'com.google.android.material:material:1.3.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1' + implementation 'androidx.navigation:navigation-fragment:2.3.0' + implementation 'androidx.navigation:navigation-ui:2.3.0' + implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' + testImplementation 'junit:junit:4.+' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/proguard-rules.pro b/Android/Amit Shekhar/Advanced/NavNewsApp/app/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/androidTest/java/com/example/navnewsapp/ExampleInstrumentedTest.java b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/androidTest/java/com/example/navnewsapp/ExampleInstrumentedTest.java new file mode 100644 index 00000000..affca9d6 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/androidTest/java/com/example/navnewsapp/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.navnewsapp; + +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 Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.example.navnewsapp", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/AndroidManifest.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..3242e3c5 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/Adapter.java b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/Adapter.java new file mode 100644 index 00000000..9816a0f5 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/Adapter.java @@ -0,0 +1,119 @@ +package com.example.navnewsapp; + +import android.content.Context; +import android.content.Intent; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.cardview.widget.CardView; +import androidx.recyclerview.widget.RecyclerView; + +import com.example.navnewsapp.Model.Articles; +import com.example.navnewsapp.Model.Source; +import com.squareup.picasso.Picasso; + +import org.ocpsoft.prettytime.PrettyTime; +import org.ocpsoft.prettytime.format.SimpleTimeFormat; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +public class Adapter extends RecyclerView.Adapter { + + Context context; + List articles; + + + public Adapter(Context context, List articles) { + this.context = context; + this.articles = articles; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.items,parent,false); + return new ViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull final ViewHolder holder, int position) { + + + final Articles a = articles.get(position); + + String imageUrl = a.getUrlToImage(); + String url = a.getUrl(); + + Picasso.with(context).load(imageUrl).into(holder.imageView); + + holder.tvTitle.setText(a.getTitle()); + holder.tvSource.setText(a.getSource().getName()); + holder.tvDate.setText("\u2022"+dateTime(a.getPublishedAt())); + + holder.cardView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(context, com.example.navnewsapp.Detailed.class); + intent.putExtra("title",a.getTitle()); + intent.putExtra("source",a.getSource().getName()); + intent.putExtra("time",dateTime(a.getPublishedAt())); + intent.putExtra("desc",a.getDescription()); + intent.putExtra("imageUrl",a.getUrlToImage()); + intent.putExtra("url",a.getUrl()); + context.startActivity(intent); + } + }); + + } + + @Override + public int getItemCount() { + return articles.size(); + } + + public class ViewHolder extends RecyclerView.ViewHolder { + TextView tvTitle,tvSource,tvDate; + ImageView imageView; + CardView cardView; + + public ViewHolder(@NonNull View itemView) { + super(itemView); + + tvTitle = itemView.findViewById(R.id.tvTitle); + tvSource = itemView.findViewById(R.id.tvSource); + tvDate = itemView.findViewById(R.id.tvDate); + imageView = itemView.findViewById(R.id.image); + cardView = itemView.findViewById(R.id.cardView); + + } + } + + + public String dateTime(String t){ + PrettyTime prettyTime = new PrettyTime(new Locale(getCountry())); + String time = null; + try { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:",Locale.ENGLISH); + Date date = simpleDateFormat.parse(t); + time = prettyTime.format(date); + }catch (ParseException e) { + e.printStackTrace(); + } + return time; + + } + + public String getCountry(){ + Locale locale = Locale.getDefault(); + String country = locale.getCountry(); + return country.toLowerCase(); + } +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ApiClient.java b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ApiClient.java new file mode 100644 index 00000000..d03e43b6 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ApiClient.java @@ -0,0 +1,26 @@ +package com.example.navnewsapp; + +import retrofit2.Retrofit; +import retrofit2.converter.gson.GsonConverterFactory; + +public class ApiClient { + private static final String BASE_URL = "https://newsapi.org/v2/"; + private static ApiClient apiClient; + private static Retrofit retrofit; + + private ApiClient(){ + retrofit = new Retrofit.Builder().baseUrl(BASE_URL).addConverterFactory(GsonConverterFactory.create()).build(); + } + + public static synchronized ApiClient getInstance(){ + if (apiClient == null){ + apiClient = new ApiClient(); + } + return apiClient; + } + + + public ApiInterface getApi(){ + return retrofit.create(ApiInterface.class); + } +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ApiInterface.java b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ApiInterface.java new file mode 100644 index 00000000..236a01bb --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ApiInterface.java @@ -0,0 +1,26 @@ +package com.example.navnewsapp; + +import com.example.navnewsapp.Model.Headlines; + +import retrofit2.Call; +import retrofit2.http.GET; +import retrofit2.http.Query; + +public interface ApiInterface { + + + @GET("top-headlines") + Call getHeadlines( + @Query("country") String country, + @Query("apiKey") String apiKey + ); + + @GET("everything") + Call getSpecificData( + @Query("q") String query, + @Query("apiKey") String apiKey + ); + + + +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/Detailed.java b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/Detailed.java new file mode 100644 index 00000000..1efab5d5 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/Detailed.java @@ -0,0 +1,67 @@ +package com.example.navnewsapp; + + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.webkit.WebView; +import android.webkit.WebViewClient; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.TextView; + +import com.squareup.picasso.Picasso; + +public class Detailed extends AppCompatActivity { + + TextView tvTitle,tvSource,tvTime,tvDesc; + ImageView imageView; + WebView webView; + ProgressBar loader; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_detailed); + + tvTitle = findViewById(R.id.tvTitle); + tvSource = findViewById(R.id.tvSource); + tvTime = findViewById(R.id.tvDate); + tvDesc = findViewById(R.id.tvDesc); + + imageView = findViewById(R.id.imageView); + + webView = findViewById(R.id.webView); + + loader = findViewById(R.id.webViewLoader); + loader.setVisibility(View.VISIBLE); + + Intent intent = getIntent(); + String title = intent.getStringExtra("title"); + String source = intent.getStringExtra("source"); + String time = intent.getStringExtra("time"); + String desc = intent.getStringExtra("desc"); + String imageUrl = intent.getStringExtra("imageUrl"); + String url = intent.getStringExtra("url"); + + + tvTitle.setText(title); + tvSource.setText(source); + tvTime.setText(time); + tvDesc.setText(desc); + + Picasso.with(Detailed.this).load(imageUrl).into(imageView); + + webView.getSettings().setDomStorageEnabled(true); + webView.getSettings().setJavaScriptEnabled(true); + webView.getSettings().setLoadsImagesAutomatically(true); + webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); + webView.setWebViewClient(new WebViewClient()); + webView.loadUrl(url); + if (webView.isShown()){ + loader.setVisibility(View.INVISIBLE); + } + } +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/HomeActivity.java b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/HomeActivity.java new file mode 100644 index 00000000..455189ce --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/HomeActivity.java @@ -0,0 +1,148 @@ +package com.example.navnewsapp; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import android.app.Dialog; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +import com.example.navnewsapp.Model.Articles; +import com.example.navnewsapp.Model.Headlines; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; + +public class HomeActivity extends AppCompatActivity { + + RecyclerView recyclerView; + SwipeRefreshLayout swipeRefreshLayout; + EditText etQuery; + Button btnSearch,btnAboutUs; + Dialog dialog; + final String API_KEY = "98a295c4c04749a1aa784bf6c4256ed4"; + Adapter adapter; + List articles = new ArrayList<>(); + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + swipeRefreshLayout = findViewById(R.id.swipeRefresh); + recyclerView = findViewById(R.id.recyclerView); + + etQuery = findViewById(R.id.etQuery); + btnSearch = findViewById(R.id.btnSearch); + btnAboutUs = findViewById(R.id.aboutUs); + dialog = new Dialog(HomeActivity.this); + + recyclerView.setLayoutManager(new LinearLayoutManager(this)); + final String country = getCountry(); + + + swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + retrieveJson("",country,API_KEY); + } + }); + retrieveJson("",country,API_KEY); + + btnSearch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (!etQuery.getText().toString().equals("")){ + swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + retrieveJson(etQuery.getText().toString(),country,API_KEY); + } + }); + retrieveJson(etQuery.getText().toString(),country,API_KEY); + }else{ + swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + retrieveJson("",country,API_KEY); + } + }); + retrieveJson("",country,API_KEY); + } + } + }); + + btnAboutUs.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showDialog(); + } + }); + + + + + + + } + + public void retrieveJson(String query ,String country, String apiKey){ + + + swipeRefreshLayout.setRefreshing(true); + Call call; + if (!etQuery.getText().toString().equals("")){ + call= ApiClient.getInstance().getApi().getSpecificData(query,apiKey); + }else{ + call= ApiClient.getInstance().getApi().getHeadlines(country,apiKey); + } + + call.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + if (response.isSuccessful() && response.body().getArticles() != null){ + swipeRefreshLayout.setRefreshing(false); + articles.clear(); + articles = response.body().getArticles(); + adapter = new Adapter(HomeActivity.this,articles); + recyclerView.setAdapter(adapter); + } + } + + @Override + public void onFailure(Call call, Throwable t) { + swipeRefreshLayout.setRefreshing(false); + Toast.makeText(HomeActivity.this, t.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); + } + }); + } + + public String getCountry(){ + Locale locale = Locale.getDefault(); + String country = locale.getCountry(); + return country.toLowerCase(); + } + + public void showDialog(){ + Button btnClose; + dialog.setContentView(R.layout.about_us_pop_up); + dialog.show(); + btnClose = dialog.findViewById(R.id.close); + + btnClose.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialog.dismiss(); + } + }); + } +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/MainActivity.java b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/MainActivity.java new file mode 100644 index 00000000..e642d2cc --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/MainActivity.java @@ -0,0 +1,62 @@ +package com.example.navnewsapp; + +import android.os.Bundle; +import android.view.View; +import android.view.Menu; +import com.google.android.material.snackbar.Snackbar; +import com.google.android.material.navigation.NavigationView; +import androidx.navigation.NavController; +import androidx.navigation.Navigation; +import androidx.navigation.ui.AppBarConfiguration; +import androidx.navigation.ui.NavigationUI; +import androidx.drawerlayout.widget.DrawerLayout; +import androidx.appcompat.app.AppCompatActivity; +import com.example.navnewsapp.databinding.ActivityMainBinding; + +public class MainActivity extends AppCompatActivity { + + private AppBarConfiguration mAppBarConfiguration; +private ActivityMainBinding binding; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + binding = ActivityMainBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + + setSupportActionBar(binding.appBarMain.toolbar); + binding.appBarMain.fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + DrawerLayout drawer = binding.drawerLayout; + NavigationView navigationView = binding.navView; + // Passing each menu ID as a set of Ids because each + // menu should be considered as top level destinations. + mAppBarConfiguration = new AppBarConfiguration.Builder( + R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow) + .setDrawerLayout(drawer) + .build(); + NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main); + NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration); + NavigationUI.setupWithNavController(navigationView, navController); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.main, menu); + return true; + } + + @Override + public boolean onSupportNavigateUp() { + NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main); + return NavigationUI.navigateUp(navController, mAppBarConfiguration) + || super.onSupportNavigateUp(); + } +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/Model/Articles.java b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/Model/Articles.java new file mode 100644 index 00000000..5b8c08be --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/Model/Articles.java @@ -0,0 +1,94 @@ +package com.example.navnewsapp.Model; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Articles { + + + @SerializedName("source") + @Expose + private Source source; + + @SerializedName("author") + @Expose + private String author; + + @SerializedName("title") + @Expose + private String title; + + @SerializedName("description") + @Expose + private String description; + + @SerializedName("url") + @Expose + private String url; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + @SerializedName("urlToImage") + @Expose + private String urlToImage; + + @SerializedName("publishedAt") + @Expose + private String publishedAt; + + + + public Source getSource() { + return source; + } + + public void setSource(Source source) { + this.source = source; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getUrlToImage() { + return urlToImage; + } + + public void setUrlToImage(String urlToImage) { + this.urlToImage = urlToImage; + } + + public String getPublishedAt() { + return publishedAt; + } + + public void setPublishedAt(String publishedAt) { + this.publishedAt = publishedAt; + } +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/Model/Headlines.java b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/Model/Headlines.java new file mode 100644 index 00000000..5733923a --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/Model/Headlines.java @@ -0,0 +1,45 @@ +package com.example.navnewsapp.Model; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +public class Headlines { + + @SerializedName("status") + @Expose + private String status; + + @SerializedName("totalResults") + @Expose + private String totalResults; + + @SerializedName("articles") + @Expose + private List articles; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getTotalResults() { + return totalResults; + } + + public void setTotalResults(String totalResults) { + this.totalResults = totalResults; + } + + public List getArticles() { + return articles; + } + + public void setArticles(List articles) { + this.articles = articles; + } +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/Model/Source.java b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/Model/Source.java new file mode 100644 index 00000000..05ed2b1d --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/Model/Source.java @@ -0,0 +1,31 @@ +package com.example.navnewsapp.Model; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Source { + + @SerializedName("id") + @Expose + private String id; + + @SerializedName("name") + @Expose + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/gallery/GalleryFragment.java b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/gallery/GalleryFragment.java new file mode 100644 index 00000000..be11859e --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/gallery/GalleryFragment.java @@ -0,0 +1,181 @@ +package com.example.navnewsapp.ui.gallery; + +import android.app.Dialog; +import android.content.Intent; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.lifecycle.Observer; +import androidx.lifecycle.ViewModelProvider; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.example.navnewsapp.Adapter; +import com.example.navnewsapp.ApiClient; +import com.example.navnewsapp.HomeActivity; +import com.example.navnewsapp.Model.Articles; +import com.example.navnewsapp.Model.Headlines; +import com.example.navnewsapp.R; +import com.example.navnewsapp.databinding.FragmentHomeBinding; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; + +public class GalleryFragment extends Fragment { + + RecyclerView recyclerView; + SwipeRefreshLayout swipeRefreshLayout; + EditText etQuery; + Button btnSearch,btnAboutUs; + Dialog dialog; + final String API_KEY = "98a295c4c04749a1aa784bf6c4256ed4"; + Adapter adapter; + List articles = new ArrayList<>(); + private GalleryViewModel homeViewModel; + private FragmentHomeBinding binding; + + public View onCreateView(@NonNull LayoutInflater inflater, + ViewGroup container, Bundle savedInstanceState) { + homeViewModel = + new ViewModelProvider(this).get(GalleryViewModel.class); +// +// binding = FragmentHomeBinding.inflate(inflater, container, false); +// View root = binding.getRoot(); + View root = inflater.inflate(R.layout.fragment_home,container,false); + + + swipeRefreshLayout = root.findViewById(R.id.swipeRefresh); + recyclerView = root.findViewById(R.id.recyclerView); + + etQuery = root.findViewById(R.id.etQuery); + btnSearch = root.findViewById(R.id.btnSearch); + btnAboutUs = root.findViewById(R.id.aboutUs); + dialog = new Dialog(getContext()); + + recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + final String country = getCountry(); + + swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + retrieveJson("",country,API_KEY); + } + }); + retrieveJson("",country,API_KEY); + + btnSearch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (!etQuery.getText().toString().equals("")){ + swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + retrieveJson(etQuery.getText().toString(),country,API_KEY); + } + }); + retrieveJson(etQuery.getText().toString(),country,API_KEY); + }else{ + swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + retrieveJson("",country,API_KEY); + } + }); + retrieveJson("",country,API_KEY); + } + } + }); + + btnAboutUs.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showDialog(); + } + }); + +// +// final TextView textView = binding.textHome; +// homeViewModel.getText().observe(getViewLifecycleOwner(), new Observer() { +// @Override +// public void onChanged(@Nullable String s) { +// textView.setText(s); +// } +// }); +// Intent in = new Intent(getActivity(), HomeActivity.class); +// startActivity(in); + return root; + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + binding = null; + } + + public void retrieveJson(String query ,String country, String apiKey){ + + + swipeRefreshLayout.setRefreshing(true); + Call call; + if (!etQuery.getText().toString().equals("")){ + call= ApiClient.getInstance().getApi().getSpecificData(query,apiKey); + }else{ + call= ApiClient.getInstance().getApi().getSpecificData("business",apiKey); + } + + call.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + if (response.isSuccessful() && response.body().getArticles() != null){ + swipeRefreshLayout.setRefreshing(false); + articles.clear(); + articles = response.body().getArticles(); + adapter = new Adapter(getContext(),articles); + recyclerView.setAdapter(adapter); + } + } + + @Override + public void onFailure(Call call, Throwable t) { + swipeRefreshLayout.setRefreshing(false); + Toast.makeText(getContext(), t.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); + } + }); + } + + public String getCountry(){ + Locale locale = Locale.getDefault(); + String country = locale.getCountry(); + return country.toLowerCase(); + } + + public void showDialog(){ + Button btnClose; + dialog.setContentView(R.layout.about_us_pop_up); + dialog.show(); + btnClose = dialog.findViewById(R.id.close); + + btnClose.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialog.dismiss(); + } + }); + } + +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/gallery/GalleryViewModel.java b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/gallery/GalleryViewModel.java new file mode 100644 index 00000000..8aef264b --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/gallery/GalleryViewModel.java @@ -0,0 +1,19 @@ +package com.example.navnewsapp.ui.gallery; + +import androidx.lifecycle.LiveData; +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; + +public class GalleryViewModel extends ViewModel { + + private MutableLiveData mText; + + public GalleryViewModel() { + mText = new MutableLiveData<>(); + mText.setValue("This is gallery fragment"); + } + + public LiveData getText() { + return mText; + } +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/home/HomeFragment.java b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/home/HomeFragment.java new file mode 100644 index 00000000..49e99145 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/home/HomeFragment.java @@ -0,0 +1,181 @@ +package com.example.navnewsapp.ui.home; + +import android.app.Dialog; +import android.content.Intent; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.lifecycle.Observer; +import androidx.lifecycle.ViewModelProvider; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.example.navnewsapp.Adapter; +import com.example.navnewsapp.ApiClient; +import com.example.navnewsapp.HomeActivity; +import com.example.navnewsapp.Model.Articles; +import com.example.navnewsapp.Model.Headlines; +import com.example.navnewsapp.R; +import com.example.navnewsapp.databinding.FragmentHomeBinding; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; + +public class HomeFragment extends Fragment { + + RecyclerView recyclerView; + SwipeRefreshLayout swipeRefreshLayout; + EditText etQuery; + Button btnSearch,btnAboutUs; + Dialog dialog; + final String API_KEY = "98a295c4c04749a1aa784bf6c4256ed4"; + Adapter adapter; + List articles = new ArrayList<>(); + private HomeViewModel homeViewModel; + private FragmentHomeBinding binding; + + public View onCreateView(@NonNull LayoutInflater inflater, + ViewGroup container, Bundle savedInstanceState) { + homeViewModel = + new ViewModelProvider(this).get(HomeViewModel.class); +// +// binding = FragmentHomeBinding.inflate(inflater, container, false); +// View root = binding.getRoot(); + View root = inflater.inflate(R.layout.fragment_home,container,false); + + + swipeRefreshLayout = root.findViewById(R.id.swipeRefresh); + recyclerView = root.findViewById(R.id.recyclerView); + + etQuery = root.findViewById(R.id.etQuery); + btnSearch = root.findViewById(R.id.btnSearch); + btnAboutUs = root.findViewById(R.id.aboutUs); + dialog = new Dialog(getContext()); + + recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + final String country = getCountry(); + + swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + retrieveJson("",country,API_KEY); + } + }); + retrieveJson("",country,API_KEY); + + btnSearch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (!etQuery.getText().toString().equals("")){ + swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + retrieveJson(etQuery.getText().toString(),country,API_KEY); + } + }); + retrieveJson(etQuery.getText().toString(),country,API_KEY); + }else{ + swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + retrieveJson("",country,API_KEY); + } + }); + retrieveJson("",country,API_KEY); + } + } + }); + + btnAboutUs.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showDialog(); + } + }); + +// +// final TextView textView = binding.textHome; +// homeViewModel.getText().observe(getViewLifecycleOwner(), new Observer() { +// @Override +// public void onChanged(@Nullable String s) { +// textView.setText(s); +// } +// }); +// Intent in = new Intent(getActivity(), HomeActivity.class); +// startActivity(in); + return root; + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + binding = null; + } + + public void retrieveJson(String query ,String country, String apiKey){ + + + swipeRefreshLayout.setRefreshing(true); + Call call; + if (!etQuery.getText().toString().equals("")){ + call= ApiClient.getInstance().getApi().getSpecificData(query,apiKey); + }else{ + call= ApiClient.getInstance().getApi().getHeadlines(country,apiKey); + } + + call.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + if (response.isSuccessful() && response.body().getArticles() != null){ + swipeRefreshLayout.setRefreshing(false); + articles.clear(); + articles = response.body().getArticles(); + adapter = new Adapter(getContext(),articles); + recyclerView.setAdapter(adapter); + } + } + + @Override + public void onFailure(Call call, Throwable t) { + swipeRefreshLayout.setRefreshing(false); + Toast.makeText(getContext(), t.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); + } + }); + } + + public String getCountry(){ + Locale locale = Locale.getDefault(); + String country = locale.getCountry(); + return country.toLowerCase(); + } + + public void showDialog(){ + Button btnClose; + dialog.setContentView(R.layout.about_us_pop_up); + dialog.show(); + btnClose = dialog.findViewById(R.id.close); + + btnClose.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialog.dismiss(); + } + }); + } + +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/home/HomeViewModel.java b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/home/HomeViewModel.java new file mode 100644 index 00000000..f8176bda --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/home/HomeViewModel.java @@ -0,0 +1,19 @@ +package com.example.navnewsapp.ui.home; + +import androidx.lifecycle.LiveData; +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; + +public class HomeViewModel extends ViewModel { + + private MutableLiveData mText; + + public HomeViewModel() { + mText = new MutableLiveData<>(); + mText.setValue("This is home fragment"); + } + + public LiveData getText() { + return mText; + } +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/slideshow/SlideshowFragment.java b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/slideshow/SlideshowFragment.java new file mode 100644 index 00000000..76a47daa --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/slideshow/SlideshowFragment.java @@ -0,0 +1,181 @@ +package com.example.navnewsapp.ui.slideshow; + +import android.app.Dialog; +import android.content.Intent; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.lifecycle.Observer; +import androidx.lifecycle.ViewModelProvider; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.example.navnewsapp.Adapter; +import com.example.navnewsapp.ApiClient; +import com.example.navnewsapp.HomeActivity; +import com.example.navnewsapp.Model.Articles; +import com.example.navnewsapp.Model.Headlines; +import com.example.navnewsapp.R; +import com.example.navnewsapp.databinding.FragmentHomeBinding; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; + +public class SlideshowFragment extends Fragment { + + RecyclerView recyclerView; + SwipeRefreshLayout swipeRefreshLayout; + EditText etQuery; + Button btnSearch,btnAboutUs; + Dialog dialog; + final String API_KEY = "98a295c4c04749a1aa784bf6c4256ed4"; + Adapter adapter; + List articles = new ArrayList<>(); + private SlideshowViewModel homeViewModel; + private FragmentHomeBinding binding; + + public View onCreateView(@NonNull LayoutInflater inflater, + ViewGroup container, Bundle savedInstanceState) { + homeViewModel = + new ViewModelProvider(this).get(SlideshowViewModel.class); +// +// binding = FragmentHomeBinding.inflate(inflater, container, false); +// View root = binding.getRoot(); + View root = inflater.inflate(R.layout.fragment_home,container,false); + + + swipeRefreshLayout = root.findViewById(R.id.swipeRefresh); + recyclerView = root.findViewById(R.id.recyclerView); + + etQuery = root.findViewById(R.id.etQuery); + btnSearch = root.findViewById(R.id.btnSearch); + btnAboutUs = root.findViewById(R.id.aboutUs); + dialog = new Dialog(getContext()); + + recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + final String country = getCountry(); + + swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + retrieveJson("",country,API_KEY); + } + }); + retrieveJson("",country,API_KEY); + + btnSearch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (!etQuery.getText().toString().equals("")){ + swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + retrieveJson(etQuery.getText().toString(),country,API_KEY); + } + }); + retrieveJson(etQuery.getText().toString(),country,API_KEY); + }else{ + swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + retrieveJson("",country,API_KEY); + } + }); + retrieveJson("",country,API_KEY); + } + } + }); + + btnAboutUs.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showDialog(); + } + }); + +// +// final TextView textView = binding.textHome; +// homeViewModel.getText().observe(getViewLifecycleOwner(), new Observer() { +// @Override +// public void onChanged(@Nullable String s) { +// textView.setText(s); +// } +// }); +// Intent in = new Intent(getActivity(), HomeActivity.class); +// startActivity(in); + return root; + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + binding = null; + } + + public void retrieveJson(String query ,String country, String apiKey){ + + + swipeRefreshLayout.setRefreshing(true); + Call call; + if (!etQuery.getText().toString().equals("")){ + call= ApiClient.getInstance().getApi().getSpecificData(query,apiKey); + }else{ + call= ApiClient.getInstance().getApi().getSpecificData("sports",apiKey); + } + + call.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + if (response.isSuccessful() && response.body().getArticles() != null){ + swipeRefreshLayout.setRefreshing(false); + articles.clear(); + articles = response.body().getArticles(); + adapter = new Adapter(getContext(),articles); + recyclerView.setAdapter(adapter); + } + } + + @Override + public void onFailure(Call call, Throwable t) { + swipeRefreshLayout.setRefreshing(false); + Toast.makeText(getContext(), t.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); + } + }); + } + + public String getCountry(){ + Locale locale = Locale.getDefault(); + String country = locale.getCountry(); + return country.toLowerCase(); + } + + public void showDialog(){ + Button btnClose; + dialog.setContentView(R.layout.about_us_pop_up); + dialog.show(); + btnClose = dialog.findViewById(R.id.close); + + btnClose.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialog.dismiss(); + } + }); + } + +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/slideshow/SlideshowViewModel.java b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/slideshow/SlideshowViewModel.java new file mode 100644 index 00000000..478f53af --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/java/com/example/navnewsapp/ui/slideshow/SlideshowViewModel.java @@ -0,0 +1,19 @@ +package com.example.navnewsapp.ui.slideshow; + +import androidx.lifecycle.LiveData; +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; + +public class SlideshowViewModel extends ViewModel { + + private MutableLiveData mText; + + public SlideshowViewModel() { + mText = new MutableLiveData<>(); + mText.setValue("This is slideshow fragment"); + } + + public LiveData getText() { + return mText; + } +} \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 00000000..2b068d11 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/black_background.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/black_background.xml new file mode 100644 index 00000000..fa1fffd7 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/black_background.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/gradient.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/gradient.xml new file mode 100644 index 00000000..d0292748 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/gradient.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_close_black_24dp.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_close_black_24dp.xml new file mode 100644 index 00000000..f1fe6ec2 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_close_black_24dp.xml @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_dot_24dp.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_dot_24dp.xml new file mode 100644 index 00000000..78df78a4 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_dot_24dp.xml @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_launcher_background.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..07d5da9c --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_menu_camera.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_menu_camera.xml new file mode 100644 index 00000000..634fe922 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_menu_camera.xml @@ -0,0 +1,12 @@ + + + + diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_menu_gallery.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_menu_gallery.xml new file mode 100644 index 00000000..03c77099 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_menu_gallery.xml @@ -0,0 +1,9 @@ + + + diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_menu_slideshow.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_menu_slideshow.xml new file mode 100644 index 00000000..5e9e163a --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_menu_slideshow.xml @@ -0,0 +1,9 @@ + + + diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_search_black_24dp.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_search_black_24dp.xml new file mode 100644 index 00000000..f1fe6ec2 --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/ic_search_black_24dp.xml @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/side_nav_bar.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/side_nav_bar.xml new file mode 100644 index 00000000..6d81870b --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/drawable/side_nav_bar.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/font/g_bold.otf b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/font/g_bold.otf new file mode 100644 index 00000000..7413e3d4 Binary files /dev/null and b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/font/g_bold.otf differ diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/font/g_light.otf b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/font/g_light.otf new file mode 100644 index 00000000..dbc05129 Binary files /dev/null and b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/font/g_light.otf differ diff --git a/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/layout/about_us_pop_up.xml b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/layout/about_us_pop_up.xml new file mode 100644 index 00000000..49cb50db --- /dev/null +++ b/Android/Amit Shekhar/Advanced/NavNewsApp/app/src/main/res/layout/about_us_pop_up.xml @@ -0,0 +1,59 @@ + + + + + + +