Skip to content
This repository has been archived by the owner on Oct 16, 2019. It is now read-only.

Commit

Permalink
Merge pull request #48 from derekcsm/dev
Browse files Browse the repository at this point in the history
Dev 1.5.1 [quick fix]
  • Loading branch information
derekcsm authored Dec 28, 2016
2 parents 9f731ed + d5cb221 commit babf77d
Show file tree
Hide file tree
Showing 86 changed files with 4,257 additions and 4,029 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
public ApplicationTest() {
super(Application.class);
}
}
14 changes: 7 additions & 7 deletions app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.derek_s.hubble_gallery"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.derek_s.hubble_gallery">

<application
android:name=".base.HubbleApplicationDebug"
tools:replace="name">
<application
android:name=".base.HubbleApplicationDebug"
tools:replace="name">

</application>
</application>

</manifest>
25 changes: 14 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.derek_s.hubble_gallery"
xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.derek_s.hubble_gallery">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Expand All @@ -13,7 +13,7 @@
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".act_main.ActMain"
android:name=".home.ActHome"
android:label="@string/hubble">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand All @@ -22,28 +22,31 @@
</intent-filter>
</activity>
<activity
android:name=".ui.activities.ActDetails"
android:name=".detailspage.DetailsActivity"
android:label="@string/title_activity_act_details"
android:parentActivityName=".act_main.ActMain">
android:parentActivityName=".home.ActHome">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".act_main.ActMain"/>
android:value=".home.ActHome"/>
</activity>

<activity
android:name=".ui.activities.ActWelcome"
android:label="@string/title_activity_act_onboarding">
</activity>
android:label="@string/title_activity_act_onboarding"/>
<activity
android:name=".ui.activities.ActImageViewer"
android:name=".imageviewer.ImageViewerActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/title_activity_act_image_viewer"
android:parentActivityName=".ui.activities.ActDetails"
android:parentActivityName=".detailspage.DetailsActivity"
android:theme="@style/FullscreenTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.activities.ActDetails"/>
android:value=".detailspage.DetailsActivity"/>
</activity>

<meta-data
android:name="io.fabric.ApiKey"
android:value="4380b3109a9ab4f6f9e83235aa8fce93a9335556"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.derek_s.hubble_gallery.api;

/**
* Created by dereksmith on 15-02-26.
*/

public class ApiClient {
}
141 changes: 69 additions & 72 deletions app/src/main/java/com/derek_s/hubble_gallery/api/GetAlbum.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,87 +13,84 @@
import java.io.IOException;
import java.util.ArrayList;

/**
* Created by dereksmith on 15-03-01.
*/
public class GetAlbum extends AsyncTask<Void, Void, ArrayList<TileObject>> {

private OnTaskComplete onTaskComplete;
int limit;
int page;
String query;
boolean hiRes = false;

public GetAlbum(int limit, int page, String query, boolean hiRes) {
this.limit = limit;
this.page = page;
this.query = query;
this.hiRes = hiRes;
FragMain.currentPage = page;
}
int limit;
int page;
String query;
boolean hiRes = false;
private OnTaskComplete onTaskComplete;

public GetAlbum(int limit, int page, String query, boolean hiRes) {
this.limit = limit;
this.page = page;
this.query = query;
this.hiRes = hiRes;
FragMain.currentPage = page;
}

public void setGetAlbumCompleteListener(OnTaskComplete onTaskComplete) {
this.onTaskComplete = onTaskComplete;
}

@Override
protected void onPreExecute() {
super.onPreExecute();
}

@Override
protected ArrayList<TileObject> doInBackground(Void... arg0) {
ArrayList<TileObject> mArray = new ArrayList<>();
try {
Document doc = null;

if (hiRes) {
doc = Jsoup.connect("http://hubble.stsci.edu/gallery/album/" + query + "/npp/" + limit + "/hires/true/" + "+" + page).get();
} else {
doc = Jsoup.connect("http://hubble.stsci.edu/gallery/album/" + query + "/npp/" + limit + "/" + "+" + page).get();
}
Elements links = doc.select("div#ListBlock");
for (int i = 0; i < limit; i++) {
try {
Element link = links.select("a").get(i);
Element img = link.select("img").first();

public interface OnTaskComplete {
void setTaskComplete(ArrayList<TileObject> result);
}
//Log.i("apod", "src: " + img.attr("src"));

public void setGetAlbumCompleteListener(OnTaskComplete onTaskComplete) {
this.onTaskComplete = onTaskComplete;
}
TileObject t = new TileObject();
t.setId(link.id());
t.setTitle(link.attr("title"));
t.setHref(link.attr("href"));

@Override
protected void onPreExecute() {
super.onPreExecute();
}
// uses higher res image for thumbnails
String src = img.attr("src");
if (src.contains(".gif"))
src = src.replace(".gif", ".jpg");
src = src.replace("-thumb", "-web");

@Override
protected ArrayList<TileObject> doInBackground(Void... arg0) {
ArrayList<TileObject> mArray = new ArrayList<>();
try {
Document doc = null;

if (hiRes) {
doc = Jsoup.connect("http://hubblesite.org/gallery/album/" + query + "/npp/" + limit + "/hires/true/" + "+" + page).get();
} else {
doc = Jsoup.connect("http://hubblesite.org/gallery/album/" + query + "/npp/" + limit + "/" + "+" + page).get();
}
Elements links = doc.select("div#ListBlock");
for (int i = 0; i < limit; i++) {
try {
Element link = links.select("a").get(i);
Element img = link.select("img").first();

//Log.i("apod", "src: " + img.attr("src"));

TileObject t = new TileObject();
t.setId(link.id());
t.setTitle(link.attr("title"));
t.setHref(link.attr("href"));

// uses higher res image for thumbnails
String src = img.attr("src");
if (src.contains(".gif"))
src = src.replace(".gif", ".jpg");
src = src.replace("-thumb", "-web");

t.setSrc(src);

mArray.add(t);
} catch (IndexOutOfBoundsException e) {
// stop the iteration
i = limit;
}
}

} catch (IOException e) {
e.printStackTrace();
t.setSrc(src);

mArray.add(t);
} catch (IndexOutOfBoundsException e) {
// stop the iteration
i = limit;
}
return mArray;
}
}

@Override
protected void onPostExecute(ArrayList<TileObject> result) {
onTaskComplete.setTaskComplete(result);
} catch (IOException e) {
e.printStackTrace();
}
return mArray;
}

@Override
protected void onPostExecute(ArrayList<TileObject> result) {
onTaskComplete.setTaskComplete(result);
}

public interface OnTaskComplete {
void setTaskComplete(ArrayList<TileObject> result);
}


}
14 changes: 6 additions & 8 deletions app/src/main/java/com/derek_s/hubble_gallery/api/GetDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,15 @@
public class GetDetails extends AsyncTask<Void, Void, DetailsObject> {

private static String TAG = "GetDetails";
private OnTaskComplete onTaskComplete;
String newsUrl;
String href;
private OnTaskComplete onTaskComplete;

public GetDetails(String href) {
this.href = href;
Log.i(TAG, "href: " + href);
}

public interface OnTaskComplete {
void setTaskComplete(DetailsObject result, String newsUrl);
}

public void setGetDetailsCompleteListener(OnTaskComplete onTaskComplete) {
this.onTaskComplete = onTaskComplete;
}
Expand All @@ -46,7 +42,7 @@ protected DetailsObject doInBackground(Void... arg0) {

if (!href.contains("newscenter")) {
// get the newscenter url
doc = Jsoup.connect("http://hubblesite.org" + href).timeout(8 * 1000).get();
doc = Jsoup.connect("http://hubble.stsci.edu" + href).timeout(8 * 1000).get();
infoHolder = doc.getElementsByClass("info-holder").first();
}

Expand All @@ -59,12 +55,11 @@ protected DetailsObject doInBackground(Void... arg0) {
Log.i(TAG, "newsUrl " + newsUrl);

// with the new url then get the info
doc = Jsoup.connect("http://hubblesite.org" + newsUrl).get();
doc = Jsoup.connect("http://hubble.stsci.edu" + newsUrl).get();

Elements p = doc.getElementsByTag("p");
detailsObject.setDescription(p.toString());


} catch (IOException e) {
e.printStackTrace();
}
Expand All @@ -76,5 +71,8 @@ protected void onPostExecute(DetailsObject result) {
onTaskComplete.setTaskComplete(result, newsUrl);
}

public interface OnTaskComplete {
void setTaskComplete(DetailsObject result, String newsUrl);
}

}
24 changes: 10 additions & 14 deletions app/src/main/java/com/derek_s/hubble_gallery/base/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@

import android.os.Environment;

/**
* Created by dereksmith on 15-03-15.
*/
public class Constants {

public static final String MODE_KEY = "current_mode";
public static final String PARAM_TILE_KEY = "tile_param";
public static final String PARAM_DETAILS_KEY = "details_param";
public static final String ONBOARDING_SHOWN ="onboarding_shown";
public static final String MODE_KEY = "current_mode";
public static final String PARAM_TILE_KEY = "tile_param";
public static final String PARAM_DETAILS_KEY = "details_param";
public static final String ONBOARDING_SHOWN = "onboarding_shown";
public static final int LOADED_MODE = 0;
public static final int FAVORITES_MODE = 1;
public static final int SEARCH_MODE = 2;

public static String imageDirectory() {
return Environment.getExternalStorageDirectory() + "/Pictures/Hubble";
}

public static final int LOADED_MODE = 0;
public static final int FAVORITES_MODE = 1;
public static final int SEARCH_MODE = 2;
public static String imageDirectory() {
return Environment.getExternalStorageDirectory() + "/Pictures/Hubble";
}

}
32 changes: 16 additions & 16 deletions app/src/main/java/com/derek_s/hubble_gallery/base/FragBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@

public class FragBase extends Fragment {

@Override
public void onCreate(Bundle savedState) {
super.onCreate(savedState);
DaggerActivityComponent.builder()
.appComponent(((HubbleApplication) getActivity().getApplication()).getAppComponent())
.build()
.inject(this);
}
@Inject
public Resources resources;
@Inject
public NetworkUtil networkUtil;
@Inject
public TinyDB db;
@Inject
public FavoriteUtils favoriteUtils;

@Inject
public Resources resources;
@Inject
public NetworkUtil networkUtil;
@Inject
public TinyDB db;
@Inject
public FavoriteUtils favoriteUtils;
@Override
public void onCreate(Bundle savedState) {
super.onCreate(savedState);
DaggerActivityComponent.builder()
.appComponent(((HubbleApplication) getActivity().getApplication()).getAppComponent())
.build()
.inject(this);
}
}
Loading

0 comments on commit babf77d

Please # to comment.