forked from TheDancerCodes/Retrofiti
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9b7510
commit 95850ec
Showing
20 changed files
with
775 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,3 +65,4 @@ freeline.py | |
freeline/ | ||
freeline_project_description.json | ||
|
||
/secrets.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
app/src/main/java/com/thedancercodes/retrofiti/DetailActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
59
app/src/main/java/com/thedancercodes/retrofiti/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | ||
|
||
} | ||
|
||
} |
61 changes: 61 additions & 0 deletions
61
app/src/main/java/com/thedancercodes/retrofiti/adapter/MoviesAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
|
||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/thedancercodes/retrofiti/api/Client.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/"; | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/thedancercodes/retrofiti/api/Service.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
} |
Oops, something went wrong.