Skip to content

Commit

Permalink
[CHORE] Project Setup
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDancerCodes committed Feb 16, 2018
1 parent f9b7510 commit 95850ec
Show file tree
Hide file tree
Showing 20 changed files with 775 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ freeline.py
freeline/
freeline_project_description.json

/secrets.properties
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

// TODO 1: Required dependencies
}
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.thedancercodes.retrofiti">

<!--TODO 2: Set Internet Permission-->

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down
100 changes: 100 additions & 0 deletions app/src/main/java/com/thedancercodes/retrofiti/DetailActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package com.thedancercodes.retrofiti;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;



public class DetailActivity extends AppCompatActivity {

TextView nameOfMovie, plotSynopsis, userRating, releaseDate;
ImageView mImageView;

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

// Display the Back Button.
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

// This method handles the swivel/drop of the Collapsing Toolbar.
// This shows/hides the toolbar title on scroll.
initCollapsingToolbar();

// TIP: You can use butterknife here to simply field binding for views.
mImageView = (ImageView) findViewById(R.id.thumbnail_image_header);
nameOfMovie = (TextView) findViewById(R.id.title);
plotSynopsis = (TextView) findViewById(R.id.plotsynopsis);
userRating = (TextView) findViewById(R.id.userrating);
releaseDate = (TextView) findViewById(R.id.releasedate);

// Check whether the Intent received from MainActivity has the required data.
Intent intentThatStartedThisActivity = getIntent();
if (intentThatStartedThisActivity.hasExtra("original_title")) {

String thumbnail = getIntent().getExtras().getString("poster_path");
String movieName = getIntent().getExtras().getString("original_title");
String synopsis = getIntent().getExtras().getString("overview");
String rating = getIntent().getExtras().getString("vote_average");
String dateOfRelease = getIntent().getExtras().getString("release_date");

// Set up data [Strings] to appropriate views.
Glide.with(this)
.load(thumbnail)
.apply(new RequestOptions()
.placeholder(R.drawable.load))
.into(mImageView);

nameOfMovie.setText(movieName);
plotSynopsis.setText(synopsis);
userRating.setText(rating);
releaseDate.setText(dateOfRelease);
} else {
// User Feeback when there's no data in the Intent
Toast.makeText(this, "No API Data", Toast.LENGTH_SHORT).show();
}
}

private void initCollapsingToolbar() {
final CollapsingToolbarLayout collapsingToolbarLayout =
(CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
collapsingToolbarLayout.setTitle(" ");

AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appbar);
appBarLayout.setExpanded(true);

appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
boolean isShow = false;
int scrollRange = -1;

@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (scrollRange == -1) {
scrollRange = appBarLayout.getTotalScrollRange();
}
if (scrollRange + verticalOffset == 0) {
collapsingToolbarLayout.setTitle(getString(R.string.movie_details));
isShow = true;
} else if (isShow) {
collapsingToolbarLayout.setTitle(" ");
isShow = false;
}
}
});
}
}
59 changes: 57 additions & 2 deletions app/src/main/java/com/thedancercodes/retrofiti/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,68 @@
package com.thedancercodes.retrofiti;

import android.support.v7.app.AppCompatActivity;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.ContextWrapper;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.widget.Toast;

import com.thedancercodes.retrofiti.adapter.MoviesAdapter;
import com.thedancercodes.retrofiti.model.Movie;

import java.util.List;

public class MainActivity extends AppCompatActivity {

// Create the field variables
private RecyclerView mRecyclerView;
private MoviesAdapter adapter;
private List<Movie> mMovieList;
ProgressDialog pd;
private SwipeRefreshLayout swipeContainer;
public static final String LOG_TAG = MoviesAdapter.class.getName();

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

initViews();

swipeContainer = (SwipeRefreshLayout) findViewById(R.id.main_content);
swipeContainer.setColorSchemeResources(android.R.color.holo_orange_dark);
swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
initViews();
Toast.makeText(MainActivity.this, "Movies Refreshed", Toast.LENGTH_SHORT).show();
}
});
}
}

public Activity getActivity() {
Context context = this;
while (context instanceof ContextWrapper) {
if (context instanceof Activity) {
return (Activity) context;
}
context = ((ContextWrapper) context).getBaseContext();
}
return null;
}
// TODO 6a: initViews() Method
// This method is responsible for initializing the views.
private void initViews() {

}

// TODO 6b: loadJSON() Method
// This method is responsible for loading JSON data.
private void loadJSON() {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.thedancercodes.retrofiti.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.thedancercodes.retrofiti.DetailActivity;
import com.thedancercodes.retrofiti.R;
import com.thedancercodes.retrofiti.model.Movie;

import java.util.List;

/**
* Created by TheDancerCodes on 14/02/2018.
*/

public class MoviesAdapter extends RecyclerView.Adapter<MoviesAdapter.MyViewHolder> {

private Context mContext;
private List<Movie> mMovieList;

public MoviesAdapter(Context context, List<Movie> movieList) {
mContext = context;
mMovieList = movieList;
}

/*
Binding Data to our Views
*/

@Override
public MoviesAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.movie_card, parent, false);
return new MyViewHolder(view);
}

// TODO 5b: Implement onBindViewHolder
@Override
public void onBindViewHolder(final MoviesAdapter.MyViewHolder holder, int position) {

}

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

// TODO 5a: Implement MyViewHolder
public class MyViewHolder extends RecyclerView.ViewHolder {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.thedancercodes.retrofiti.api;

public class Client {

//TODO 4a: Define API Client

//"http://api.themoviedb.org/3/";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.thedancercodes.retrofiti.api;

public interface Service {

//TODO 4b: Define API Service

}
Loading

0 comments on commit 95850ec

Please sign in to comment.