Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syncronizedimages with their info, removed the progress bar, sped #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion .idea/gradle.xml

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

18 changes: 17 additions & 1 deletion .idea/misc.xml

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

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/java/com/example/samplegallery/APIKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
* keys publically!
*/
public class APIKeys {
public static final String FLICKR_API_KEY = "64ffdc1fd4b18211f4f98513848d2335";
public static final String FLICKR_API_KEY = "b189cbcb6aeea9a8ae5d0a10ec002496";
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
package com.example.samplegallery;

import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageRequest;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.NetworkImageView;
import com.example.samplegallery.Utilities.VolleyErrorListener;
import com.example.samplegallery.Utilities.VolleyRequestQueue;

Expand Down Expand Up @@ -43,11 +47,11 @@ public void onCreate(Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
RelativeLayout rootView = (RelativeLayout) inflater.
inflate(R.layout.photo_blowup_fragment, container, false);
final NetworkImageView img = (NetworkImageView) rootView.findViewById(R.id.photo_blowup);
final ImageView img = (ImageView) rootView.findViewById(R.id.photo_blowup);
final TextView photoTitleView = (TextView) rootView.findViewById(R.id.photo_title);
final TextView photoDescriptionView =
(TextView) rootView.findViewById(R.id.photo_description);
// create a request for photo title
final TextView photoDescriptionView = (TextView) rootView.findViewById(R.id.photo_description);
final ProgressBar progressBar = (ProgressBar) rootView.findViewById(R.id.blowup_progress_bar);
// / create a request for photo title
JsonObjectRequest photoInfoRequest = new JsonObjectRequest(
Request.Method.GET,
getPhotosInfoUrl(),
Expand Down Expand Up @@ -86,16 +90,29 @@ public void onResponse(JSONObject response) {
try {
sizes = response.getJSONObject("sizes").getJSONArray("size");
photoUrl = sizes
.getJSONObject(sizes.length() - 1)
.getJSONObject(sizes.length() - 3) //finding a smaller size will speed up load times
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug:

what if the length of sizes is less than 3?

.getString("source");
} catch (JSONException e) {
e.printStackTrace();
}

// finally set the url for the image
img.setImageUrl(
photoUrl,
VolleyRequestQueue.getInstance(getContext()).getImgLoader());
Response.Listener<Bitmap> imgListener = new Response.Listener<Bitmap>() {
@Override
public void onResponse(Bitmap response) {
img.setImageBitmap(response);
photoDescriptionView.setVisibility(View.VISIBLE);
photoTitleView.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
}
};
Response.ErrorListener errorListener = new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//things2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh?

}
};
//solution is deprecated: better, worse or equivalent to hacky?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean here?

ImageRequest getImgReq = new ImageRequest(photoUrl, imgListener, 0,0,null,errorListener);
VolleyRequestQueue.getInstance(getContext()).addToRequestQueue(getImgReq);
}
},
new VolleyErrorListener(getContext())
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/photo_blowup_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/blowup_progress_bar"
style="@android:style/Widget.ProgressBar.Large"
android:layout_centerInParent="true"/>

<com.android.volley.toolbox.NetworkImageView
<ImageView
android:id="@+id/photo_blowup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down