Skip to content

Commit

Permalink
Merged in experimental (pull request #1)
Browse files Browse the repository at this point in the history
Merge all the changes for parsing and styling please.

Approved-by: Alistair Holmes <[email protected]>
  • Loading branch information
alistairholmes committed Jun 11, 2018
2 parents 56ae858 + 9dd5d6c commit 929d48d
Show file tree
Hide file tree
Showing 15 changed files with 107 additions and 62 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
9 changes: 4 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
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'
implementation 'com.android.support:recyclerview-v7:26.0.2'
implementation 'com.android.support:recyclerview-v7:26.1.0'
// Third Party libs
implementation 'com.squareup.okhttp3:okhttp:3.9.1'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.picasso:picasso:2.5.2'
}
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,25 @@ public class Job {
private String company;

// Date that the job was posted
private String date;
private Date date;

// Website where the job was posted
private String url;

private String logo;

/**
* Constructs a new Job object.
*
* @param jobTitle is the title or role of the job
* @param companyName is the name of the company
* @param postDate is the date that the job was posted
* //applyUrl is the website URL to find more details about the job
* @param companyLogo is a logo of the company
*/

public Job(String jobTitle, String companyName, String postDate, String companyLogo) {
public Job(String jobTitle, String companyName, Date postDate) {
position = jobTitle;
company = companyName;
date = date;
//url = applyUrl;
logo = companyLogo;
date = postDate;

}

// Returns the title of the job
Expand All @@ -48,7 +44,7 @@ public String getCompanyName() {
}

// Returns the date that the job was posted
public String getDatePosted() {
public Date getDatePosted() {
return date;
}

Expand All @@ -57,8 +53,4 @@ public String getUrl() {
return url;
}

// Returns the image use for company logo
public String getLogo() {
return logo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import org.json.JSONException;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -61,12 +58,15 @@ protected void onCreate(Bundle savedInstanceState) {
mainRecyclerView.setLayoutManager(layoutManager);

mainRecyclerView.setHasFixedSize(true);
mainRecyclerView.setAdapter(mAdapter);


try {
run();
} catch (IOException e) {
e.printStackTrace();
}

}

void run() throws IOException {
Expand All @@ -90,16 +90,13 @@ public void onFailure(Call call, IOException e) {
public void onResponse(Call call, Response response) throws IOException {

final String jsonResponse = response.body().string();
Log.d(LOG_TAG, String.valueOf(jsonResponse));

JobActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
mProgressBar.setVisibility(View.INVISIBLE);

String ISO_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ";
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.setDateFormat(ISO_FORMAT);

Gson gson = new GsonBuilder().create();
List<Job> jobs = new ArrayList<Job>();
jobs = Arrays.asList(gson.fromJson(jsonResponse, Job[].class));
Expand All @@ -118,11 +115,9 @@ public void onItemClick(int position) {
});

mainRecyclerView.setAdapter(mAdapter);
Log.d(LOG_TAG, String.valueOf(mAdapter));
}
});


Log.d(LOG_TAG, String.valueOf(mAdapter));
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
package io.github.alistairholmes.digitalnomadjobs;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;

public class JobAdapter extends RecyclerView.Adapter<JobAdapter.ViewHolder> {

private OnItemClickListener mListener;
private List<Job> jobs;

private static final String LOG_TAG = JobAdapter.class.getName();



public interface OnItemClickListener {
void onItemClick(int position);
}
Expand All @@ -33,15 +42,14 @@ public class ViewHolder extends RecyclerView.ViewHolder {
public TextView companyName;
public TextView datePosted;
public View layout;
public ImageView companyLogo;


public ViewHolder(View itemView) {
super(itemView);
layout = itemView;
jobTitle = (TextView) layout.findViewById(R.id.textView_job_title);
companyName = (TextView) layout.findViewById(R.id.textView_company_name);
datePosted = (TextView) layout.findViewById(R.id.textView_date);
companyLogo = (ImageView) layout.findViewById(R.id.imageView);

itemView.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down Expand Up @@ -88,18 +96,25 @@ public void onBindViewHolder(ViewHolder holder, int position) {
String mCompanyName = currentJob.getCompanyName();
holder.companyName.setText(mCompanyName);

String mDatePosted = currentJob.getDatePosted();
holder.datePosted.setText(mDatePosted);
Context context = holder.datePosted.getContext();

Date mDatePosted = currentJob.getDatePosted();
String dateFormat = formatDayMonth(context, mDatePosted);
holder.datePosted.getContext();
holder.datePosted.setText(dateFormat);
}

if (!currentJob.getLogo().isEmpty()) {
Picasso.with(holder.itemView.getContext())
.load(currentJob.getLogo())
.fit()
.into(holder.companyLogo);
@Nullable
public static String formatDayMonth(@NonNull Context context, @Nullable Date date) {
if (date == null) {
return null;
}

SimpleDateFormat sdf = new SimpleDateFormat(
context.getString(R.string.format_date),
Locale.US);
return sdf.format(date);
}

@Override
public int getItemCount() {
return jobs.size();
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/font/alegreya_sans.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="Alegreya Sans"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
</font-family>
7 changes: 7 additions & 0 deletions app/src/main/res/font/alegreya_sans_bold.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="name=Alegreya Sans&amp;weight=700"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
</font-family>
7 changes: 7 additions & 0 deletions app/src/main/res/font/alegreya_sans_light.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="name=Alegreya Sans&amp;weight=300"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
</font-family>
28 changes: 11 additions & 17 deletions app/src/main/res/layout/job_item_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,27 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@mipmap/ic_launcher_round" />

<TextView
android:id="@+id/textView_job_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:text="Front-end Dev"
app:layout_constraintStart_toEndOf="@+id/imageView"
android:layout_marginTop="8dp"
android:fontFamily="@font/alegreya_sans_bold"
tools:text="Front-end Dev"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textView_company_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="SquareSpace"
app:layout_constraintStart_toEndOf="@+id/imageView"
android:fontFamily="@font/alegreya_sans"
tools:text="SquareSpace"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="@+id/textView_job_title"
app:layout_constraintTop_toBottomOf="@+id/textView_job_title" />

<TextView
Expand All @@ -42,7 +35,8 @@
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
android:text="16 June"
android:fontFamily="@font/alegreya_sans_light"
tools:text="16 June"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView_job_title" />
</android.support.constraint.ConstraintLayout>
17 changes: 17 additions & 0 deletions app/src/main/res/values/font_certs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="com_google_android_gms_fonts_certs">
<item>@array/com_google_android_gms_fonts_certs_dev</item>
<item>@array/com_google_android_gms_fonts_certs_prod</item>
</array>
<string-array name="com_google_android_gms_fonts_certs_dev">
<item>
MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEW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/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK
</item>
</string-array>
</resources>
8 changes: 8 additions & 0 deletions app/src/main/res/values/preloaded_fonts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="preloaded_fonts" translatable="false">
<item>@font/alegreya_sans</item>
<item>@font/alegreya_sans_bold</item>
<item>@font/alegreya_sans_light</item>
</array>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<string name="app_name">Digital Nomad Jobs</string>
<!-- Error message when there is no internet connectivity [CHAR LIMIT=NONE] -->
<string name="no_internet_connection">No internet connection.</string>
<string name="format_date">dd MMM</string>
</resources>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-beta1'
classpath 'com.android.tools.build:gradle:3.1.2'


// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Jan 16 21:56:31 CAT 2018
#Sat Jun 09 19:30:51 CAT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip

0 comments on commit 929d48d

Please sign in to comment.