Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudino2001 committed May 19, 2023
0 parents commit 90bb793
Show file tree
Hide file tree
Showing 58 changed files with 1,635 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Gabriel Claudino

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
15 changes: 15 additions & 0 deletions MoviesTMDB/.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 MoviesTMDB/.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 MoviesTMDB/.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 MoviesTMDB/.idea/gradle.xml

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

10 changes: 10 additions & 0 deletions MoviesTMDB/.idea/misc.xml

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

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

android {
namespace 'br.com.application.moviestmdb'
compileSdk 33

defaultConfig {
applicationId "br.com.application.moviestmdb"
minSdk 24
targetSdk 33
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.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

//My implementations:
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
implementation 'com.github.bumptech.glide:glide:4.10.0'
}
21 changes: 21 additions & 0 deletions MoviesTMDB/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 br.com.application.moviestmdb;

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("br.com.application.moviestmdb", appContext.getPackageName());
}
}
37 changes: 37 additions & 0 deletions MoviesTMDB/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

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

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.MoviesTMDB"
tools:targetApi="31">
<activity
android:name=".DetalhesMovieActivity"
android:parentActivityName=".MainActivity"
android:exported="false"
android:screenOrientation="portrait"/>
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
</application>

</manifest>
Binary file added MoviesTMDB/app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package br.com.application.moviestmdb;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class Adapter_item_filme extends ArrayAdapter<Filme> {
private final Context context;
private final List<Filme> filmes;

private final List<Genero> generos;

public Adapter_item_filme(Context context, List<Filme> filmes, List<Genero> generos){
super(context, R.layout.item_filme_dois, filmes);
this.context = context;
this.filmes = filmes;
this.generos = generos;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.item_filme_dois, parent, false);

ImageView cartaz = (ImageView) rowView.findViewById(R.id.cartaz);
TextView titulo = (TextView) rowView.findViewById(R.id.title);
TextView overview = (TextView) rowView.findViewById(R.id.overview);
TextView release_date = (TextView) rowView.findViewById(R.id.release_date);
TextView vote_average = (TextView) rowView.findViewById(R.id.vote_average);
TextView genero = (TextView) rowView.findViewById(R.id.genero);

String url_p1 = "https://image.tmdb.org/t/p/w500";
String url_p2 = filmes.get(position).getPoster_path();
String url_p3 = "?api_key=da0e4838c057baf77b75e5338ced2bb3";
URL url;
try {
url = new URL(url_p1 + url_p2 + url_p3);
} catch (MalformedURLException e) {
Toast.makeText(context, "erro: img" + position, Toast.LENGTH_SHORT).show();
throw new RuntimeException(e);
}
//GITHUB
Glide.with(context).load(url).into(cartaz);

titulo.setText(filmes.get(position).getTitle());
overview.setText(filmes.get(position).getOverview());
release_date.setText(filmes.get(position).getRelease_date());
vote_average.setText("Avaliação: " + filmes.get(position).getVote_average().toString());

String str_generos_do_filme = "";
for(int i = 0; i<filmes.get(position).getGenre_ids().size(); i++){
Integer id_genero_filme = filmes.get(position).getGenre_ids().get(i);
for(int j = 0; j<generos.size(); j++){
if(Objects.equals(generos.get(j).getId(), id_genero_filme)){
str_generos_do_filme = str_generos_do_filme + " " + generos.get(j).getName();
}
}
}
genero.setText(str_generos_do_filme);
return rowView;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package br.com.application.moviestmdb;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.Objects;

public class DetalhesMovieActivity extends AppCompatActivity {

private TextView titulo, original_title, release_date, overview, genre_ids, vote_average;
private ImageView banner;
Filme filme;
List<Genero> generos;

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

titulo = (TextView) findViewById(R.id.titulo);
vote_average = (TextView) findViewById(R.id.vote_average);
banner = (ImageView) findViewById(R.id.banner);
original_title = (TextView) findViewById(R.id.original_title);
release_date = (TextView) findViewById(R.id.release_date);
overview = (TextView) findViewById(R.id.overview);
genre_ids = (TextView) findViewById(R.id.genre_ids);

Intent intent = getIntent();
if (intent.hasExtra("filme_obj")) {
// Recupere o objeto do Intent usando getSerializableExtra() ou getParcelableExtra()
filme = (Filme) intent.getSerializableExtra("filme_obj");
generos = (List<Genero>) intent.getSerializableExtra("generos_obj");
}

titulo.setText(filme.getTitle());
original_title.setText(filme.getOriginal_title());
release_date.setText("Data de lançamento:\n" + filme.getRelease_date());
overview.setText("Descrição:\n" + filme.getOverview());
vote_average.setText("Avaliação:\n" + filme.getVote_average());


String str_generos_do_filme = "";
for(int i = 0; i<filme.getGenre_ids().size(); i++){
Integer id_genero_filme = filme.getGenre_ids().get(i);
for(int j = 0; j<generos.size(); j++){
if(Objects.equals(generos.get(j).getId(), id_genero_filme)){
str_generos_do_filme = str_generos_do_filme + "\n" + generos.get(j).getName();
}
}
}
genre_ids.setText("Genero(s):\n" + str_generos_do_filme);


String url_p1 = "https://image.tmdb.org/t/p/w500";
String url_p2 = filme.getBackdrop_path();
String url_p3 = "?api_key=da0e4838c057baf77b75e5338ced2bb3";
URL url = null;
try {
url = new URL(url_p1 + url_p2 + url_p3);
} catch (MalformedURLException e) {
Toast.makeText(this, "Erro", Toast.LENGTH_SHORT).show();
}
//GITHUB
Glide.with(this).load(url).into(banner);
}
}
Loading

0 comments on commit 90bb793

Please sign in to comment.