├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── ic_location-web.png
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── search.png
│ │ │ │ ├── ic_filter_list_black_24dp.xml
│ │ │ │ ├── ic_map_icon.xml
│ │ │ │ ├── ic_network_off.xml
│ │ │ │ └── custom_seekbar.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main_activity.xml
│ │ │ └── layout
│ │ │ │ ├── loader_layout.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── seekbar_layout.xml
│ │ │ │ └── card_layout_main.xml
│ │ ├── java
│ │ │ └── lingaraj
│ │ │ │ └── hourglass
│ │ │ │ └── in
│ │ │ │ └── getmyparkingchallenge
│ │ │ │ ├── Constants.java
│ │ │ │ ├── cloud
│ │ │ │ └── service
│ │ │ │ │ ├── KickStarter.java
│ │ │ │ │ └── Response
│ │ │ │ │ └── KickStarterResponse.java
│ │ │ │ ├── Helpers.java
│ │ │ │ ├── KickStarterApp.java
│ │ │ │ ├── adapters
│ │ │ │ └── KickStarterAdapter.java
│ │ │ │ └── activities
│ │ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── lingaraj
│ │ │ └── hourglass
│ │ │ └── in
│ │ │ └── getmyparkingchallenge
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── lingaraj
│ │ └── hourglass
│ │ └── in
│ │ └── getmyparkingchallenge
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/src/main/ic_location-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/GetMyParkingChallenge/master/app/src/main/ic_location-web.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/GetMyParkingChallenge/master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/GetMyParkingChallenge/master/app/src/main/res/drawable/search.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/GetMyParkingChallenge/master/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/GetMyParkingChallenge/master/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/GetMyParkingChallenge/master/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/GetMyParkingChallenge/master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lingarajsankaravelu/GetMyParkingChallenge/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun May 07 08:22:43 IST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | KickStarter
3 | Loading
4 | Network Unavailable
5 | Home
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/java/lingaraj/hourglass/in/getmyparkingchallenge/Constants.java:
--------------------------------------------------------------------------------
1 | package lingaraj.hourglass.in.getmyparkingchallenge;
2 |
3 | /**
4 | * Created by lingaraj on 5/7/17.
5 | */
6 |
7 | public class Constants {
8 |
9 | public static String rest_server_url = "http://starlord.hackerearth.com/";
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_filter_list_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_map_icon.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/test/java/lingaraj/hourglass/in/getmyparkingchallenge/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package lingaraj.hourglass.in.getmyparkingchallenge;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/java/lingaraj/hourglass/in/getmyparkingchallenge/cloud/service/KickStarter.java:
--------------------------------------------------------------------------------
1 | package lingaraj.hourglass.in.getmyparkingchallenge.cloud.service;
2 |
3 | import java.util.List;
4 |
5 | import lingaraj.hourglass.in.getmyparkingchallenge.cloud.service.Response.KickStarterResponse;
6 | import retrofit.Callback;
7 | import retrofit.http.GET;
8 |
9 | /**
10 | * Created by lingaraj on 5/7/17.
11 | */
12 |
13 | public interface KickStarter {
14 |
15 | @GET("/kickstarter")
16 | void getKickstarterDemo(Callback> response);
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_network_off.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 96dp
4 | 96dp
5 | 16dp
6 | 16dp
7 | 8dp
8 | 240dp
9 | 20sp
10 | 16sp
11 | 16dp
12 | 48dp
13 | 8dp
14 | 240dp
15 | 16sp
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/lingaraj/hourglass/in/getmyparkingchallenge/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package lingaraj.hourglass.in.getmyparkingchallenge;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("lingaraj.hourglass.in.getmyparkingchallenge", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/lingaraj/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/custom_seekbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
12 |
13 |
14 | -
15 |
16 |
17 |
18 |
19 |
23 |
24 |
25 |
26 | -
27 |
28 |
29 |
30 |
31 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/loader_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
10 |
17 |
18 |
24 |
25 |
30 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | buildscript {
4 | repositories {
5 | mavenCentral()
6 | }
7 |
8 | }
9 |
10 | android {
11 | dataBinding.enabled = true;
12 | compileSdkVersion 25
13 | buildToolsVersion "25.0.0"
14 | defaultConfig {
15 | vectorDrawables.useSupportLibrary = true
16 | applicationId "lingaraj.hourglass.in.getmyparkingchallenge"
17 | minSdkVersion 16
18 | targetSdkVersion 25
19 | versionCode 1
20 | versionName "1.0"
21 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
22 | }
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 | compileOptions {
30 | sourceCompatibility JavaVersion.VERSION_1_7
31 | targetCompatibility JavaVersion.VERSION_1_7
32 | }
33 |
34 | }
35 |
36 | dependencies {
37 | compile fileTree(include: ['*.jar'], dir: 'libs')
38 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
39 | exclude group: 'com.android.support', module: 'support-annotations'
40 | })
41 | compile 'com.android.support:appcompat-v7:25.3.1'
42 | compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
43 | testCompile 'junit:junit:4.12'
44 | compile 'com.pnikosis:materialish-progress:1.7'
45 | compile 'com.squareup.retrofit:retrofit:1.9.0'
46 | compile 'com.squareup.okhttp:okhttp:2.4.0'
47 | compile 'com.squareup.picasso:picasso:2.5.2'
48 | compile 'com.android.support:design:26.0.0-alpha1'
49 | compile 'com.android.support:cardview-v7:26.0.0-alpha1'
50 | compile 'com.thefinestartist:finestwebview:1.2.7'
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
4 |
9 |
10 |
11 |
15 |
19 |
20 |
26 |
27 |
28 |
29 |
30 |
34 |
35 |
36 |
37 |
40 |
41 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/java/lingaraj/hourglass/in/getmyparkingchallenge/Helpers.java:
--------------------------------------------------------------------------------
1 | package lingaraj.hourglass.in.getmyparkingchallenge;
2 |
3 | import android.content.Context;
4 | import android.support.v4.content.ContextCompat;
5 |
6 | /**
7 | * Created by lingaraj on 5/7/17.
8 | */
9 |
10 | public class Helpers {
11 |
12 |
13 | public static int getClassColor(Context context,int i) {
14 | switch (i) {
15 | case 1:
16 | return ContextCompat.getColor(context,R.color.Color1);
17 | case 2:
18 | return ContextCompat.getColor(context,R.color.Color2);
19 | case 3:
20 | return ContextCompat.getColor(context,R.color.Color3);
21 | case 4:
22 | return ContextCompat.getColor(context,R.color.Color4);
23 | case 5:
24 | return ContextCompat.getColor(context,R.color.Color5);
25 | case 6:
26 | return ContextCompat.getColor(context,R.color.Color6);
27 | case 7:
28 | return ContextCompat.getColor(context,R.color.Color7);
29 | case 8:
30 | return ContextCompat.getColor(context,R.color.Color8);
31 | case 9:
32 | return ContextCompat.getColor(context,R.color.Color9);
33 | case 10:
34 | return ContextCompat.getColor(context,R.color.Color10);
35 | case 11:
36 | return ContextCompat.getColor(context,R.color.Color11);
37 | case 12:
38 | return ContextCompat.getColor(context,R.color.Color12);
39 | case 13:
40 | return ContextCompat.getColor(context,R.color.Color13);
41 | case 14:
42 | return ContextCompat.getColor(context,R.color.Color14);
43 | case 15:
44 | return ContextCompat.getColor(context,R.color.Color15);
45 | case 16:
46 | return ContextCompat.getColor(context,R.color.Color16);
47 | default:
48 | return ContextCompat.getColor(context,R.color.ColorDefault);
49 | }
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #4CAF50
4 | #388E3C
5 | #C8E6C9
6 | #FFDB00
7 | #FFFFFF
8 | #616161
9 | #9E9E9E
10 | #F44336
11 | #616161
12 | #757575
13 | #EEEEEE
14 | #757575
15 | #FF6D00
16 | #FF9100
17 | #FFAB40
18 | #FFD180
19 | #B9F6CA
20 | #69F0AE
21 | #00E676
22 | #00C853
23 | #F44336
24 | #3F51B5
25 | #009688
26 | #FF9800
27 | #E91E63
28 | #2196F3
29 | #4CAF50
30 | #FF5722
31 | #9C27B0
32 | #03A9F4
33 | #8BC34A
34 | #795548
35 | #673AB7
36 | #00BCD4
37 | #FFC107
38 | #607D8B
39 | #9E9E9E
40 | #ffffff
41 | #d4d4d4
42 | #dddddd
43 | #F44336
44 | #FF9800
45 | #FFC107
46 | #CDDC39
47 | #8BC34A
48 | #4CAF50
49 | #ffffff
50 | #BEFFFFFF
51 |
52 |
53 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/seekbar_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
13 |
21 |
22 |
25 |
36 |
37 |
51 |
52 |
53 |
66 |
67 |
68 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/app/src/main/java/lingaraj/hourglass/in/getmyparkingchallenge/cloud/service/Response/KickStarterResponse.java:
--------------------------------------------------------------------------------
1 | package lingaraj.hourglass.in.getmyparkingchallenge.cloud.service.Response;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * Created by lingaraj on 5/7/17.
9 | */
10 |
11 | public class KickStarterResponse implements Serializable {
12 | @SerializedName("s.no")
13 | private int sNo;
14 |
15 | @SerializedName("amt.pledged")
16 | private int amtPledged;
17 |
18 | private String blurb;
19 |
20 | private String by;
21 |
22 | private String country;
23 |
24 | private String currency;
25 |
26 | @SerializedName("end.time")
27 | private String date;
28 |
29 | private String location;
30 |
31 | @SerializedName("percentage.funded")
32 | private int percentageFunded;
33 |
34 | @SerializedName("num.backers")
35 | private String backers;
36 |
37 | private String state;
38 |
39 | private String title;
40 |
41 | private String type;
42 |
43 | private String url;
44 |
45 | public int getsNo() {
46 | return sNo;
47 | }
48 |
49 | public void setsNo(int sNo) {
50 | this.sNo = sNo;
51 | }
52 |
53 | public int getAmtPledged() {
54 | return amtPledged;
55 | }
56 |
57 | public void setAmtPledged(int amtPledged) {
58 | this.amtPledged = amtPledged;
59 | }
60 |
61 | public String getBlurb() {
62 | return blurb;
63 | }
64 |
65 | public void setBlurb(String blurb) {
66 | this.blurb = blurb;
67 | }
68 |
69 | public String getBy() {
70 | return by;
71 | }
72 |
73 | public void setBy(String by) {
74 | this.by = by;
75 | }
76 |
77 | public String getCountry() {
78 | return country;
79 | }
80 |
81 | public void setCountry(String country) {
82 | country = country;
83 | }
84 |
85 | public String getCurrency() {
86 | return currency;
87 | }
88 |
89 | public void setCurrency(String currency) {
90 | currency = currency;
91 | }
92 |
93 | public String getDate() {
94 | return date;
95 | }
96 |
97 | public void setDate(String date) {
98 | this.date = date;
99 | }
100 |
101 | public String getLocation() {
102 | return location;
103 | }
104 |
105 | public void setLocation(String location) {
106 | location = location;
107 | }
108 |
109 | public int getPercentageFunded() {
110 | return percentageFunded;
111 | }
112 |
113 | public void setPercentageFunded(int percentageFunded) {
114 | this.percentageFunded = percentageFunded;
115 | }
116 |
117 | public String getBackers() {
118 | return backers;
119 | }
120 |
121 | public void setBackers(String backers) {
122 | this.backers = backers;
123 | }
124 |
125 | public String getState() {
126 | return state;
127 | }
128 |
129 | public void setState(String state) {
130 | this.state = state;
131 | }
132 |
133 | public String getTitle() {
134 | return title;
135 | }
136 |
137 | public void setTitle(String title) {
138 | this.title = title;
139 | }
140 |
141 | public String getType() {
142 | return type;
143 | }
144 |
145 | public void setType(String type) {
146 | this.type = type;
147 | }
148 |
149 | public String getUrl() {
150 | return url;
151 | }
152 |
153 | public void setUrl(String url) {
154 | this.url = url;
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/app/src/main/java/lingaraj/hourglass/in/getmyparkingchallenge/KickStarterApp.java:
--------------------------------------------------------------------------------
1 | package lingaraj.hourglass.in.getmyparkingchallenge;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import android.net.ConnectivityManager;
6 | import android.util.Log;
7 |
8 | import com.squareup.okhttp.OkHttpClient;
9 |
10 | import java.security.cert.CertificateException;
11 |
12 | import javax.net.ssl.HostnameVerifier;
13 | import javax.net.ssl.SSLContext;
14 | import javax.net.ssl.SSLSession;
15 | import javax.net.ssl.SSLSocketFactory;
16 | import javax.net.ssl.TrustManager;
17 | import javax.net.ssl.X509TrustManager;
18 |
19 | import retrofit.RestAdapter;
20 | import retrofit.android.AndroidLog;
21 | import retrofit.client.OkClient;
22 |
23 | /**
24 | * Created by lingaraj on 5/7/17.
25 | */
26 |
27 | public class KickStarterApp extends Application {
28 |
29 | public static final String TAG = "APP_KICKSTARTER";
30 | private RestAdapter cloudAdapter;
31 | private ConnectivityManager mConnectivity;
32 |
33 |
34 | @Override
35 | public void onCreate() {
36 | super.onCreate();
37 | }
38 |
39 | /**
40 | * The method to check if network is available or not
41 | * @return boolean
42 | */
43 | public boolean isNetworkAvailable() {
44 | if (mConnectivity == null) {
45 | mConnectivity = ((ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE));
46 | }
47 | return mConnectivity.getActiveNetworkInfo() != null && mConnectivity.getActiveNetworkInfo().isConnected();
48 | }
49 | private void setCloudAdapter()
50 | {
51 | Log.d(TAG, "set cloud adapter");
52 | OkHttpClient okHttpClient = getUnsafeOkHttpClient();
53 | //OkHttpClient okHttpClient = new OkHttpClient();
54 | cloudAdapter = new RestAdapter.Builder()
55 | .setClient(new OkClient(okHttpClient))
56 | .setEndpoint(Constants.rest_server_url)
57 | .setLogLevel(RestAdapter.LogLevel.FULL).setLog(new AndroidLog("CLOUD_API_REQUESTS"))
58 | .build();
59 | return;
60 |
61 | }
62 |
63 | private OkHttpClient getUnsafeOkHttpClient() {
64 | try {
65 | // Create a trust manager that does not validate certificate chains
66 | final TrustManager[] trustAllCerts = new TrustManager[] {
67 | new X509TrustManager() {
68 | @Override
69 | public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
70 | }
71 |
72 | @Override
73 | public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
74 | }
75 |
76 | @Override
77 | public java.security.cert.X509Certificate[] getAcceptedIssuers() {
78 | return null;
79 | }
80 | }
81 | };
82 |
83 | // Install the all-trusting trust manager
84 | final SSLContext sslContext = SSLContext.getInstance("SSL");
85 | sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
86 | // Create an ssl socket factory with our all-trusting manager
87 | final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
88 |
89 | OkHttpClient okHttpClient = new OkHttpClient();
90 | okHttpClient.setSslSocketFactory(sslSocketFactory);
91 | okHttpClient.setHostnameVerifier(new HostnameVerifier() {
92 | @Override
93 | public boolean verify(String hostname, SSLSession session) {
94 | return true;
95 | }
96 | });
97 |
98 | return okHttpClient;
99 | } catch (Exception e) {
100 | throw new RuntimeException(e);
101 | }
102 | }
103 |
104 |
105 | synchronized public RestAdapter getCloudAdapter()
106 | {
107 | Log.d(TAG, "get cloud adapter");
108 | if(cloudAdapter == null) {
109 | Log.d(TAG, "new cloud adapter");
110 | setCloudAdapter();
111 | }
112 | return cloudAdapter;
113 | }
114 |
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
19 |
20 |
33 |
34 |
42 |
43 |
49 |
50 |
55 |
56 |
65 |
66 |
78 |
79 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/lingaraj/hourglass/in/getmyparkingchallenge/adapters/KickStarterAdapter.java:
--------------------------------------------------------------------------------
1 | package lingaraj.hourglass.in.getmyparkingchallenge.adapters;
2 |
3 | /**
4 | * Created by lingaraj on 5/7/17.
5 | */
6 |
7 | import android.content.Context;
8 | import android.support.v4.content.ContextCompat;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.util.Log;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.widget.TextView;
15 |
16 | import java.io.File;
17 | import java.text.NumberFormat;
18 | import java.text.ParseException;
19 | import java.text.SimpleDateFormat;
20 | import java.util.ArrayList;
21 | import java.util.Calendar;
22 | import java.util.Date;
23 | import java.util.HashMap;
24 | import java.util.List;
25 | import java.util.Locale;
26 | import java.util.Map;
27 | import java.util.Random;
28 |
29 | import lingaraj.hourglass.in.getmyparkingchallenge.Helpers;
30 | import lingaraj.hourglass.in.getmyparkingchallenge.R;
31 | import lingaraj.hourglass.in.getmyparkingchallenge.activities.MainActivity;
32 | import lingaraj.hourglass.in.getmyparkingchallenge.cloud.service.Response.KickStarterResponse;
33 |
34 |
35 |
36 | public class KickStarterAdapter extends RecyclerView.Adapter {
37 |
38 | private final MainActivity.CardClick click;
39 | private String TAG = "KICKSTARTADAP";
40 | private Context mContext;
41 | private List project_titles = new ArrayList();
42 | private Map project_map =new HashMap<>();
43 | private String regex_alphabet_check = File.separator+".*[a-zA-Z]+.*"+File.separator;
44 |
45 |
46 | public KickStarterAdapter(Context context,MainActivity.CardClick click) {
47 | this.click = click;
48 | this.mContext = context;
49 | }
50 |
51 | @Override
52 | public KickStarterAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
53 | View view = null;
54 | view = LayoutInflater.from(this.mContext).inflate(R.layout.card_layout_main,parent,false);
55 | view.setOnClickListener(click);
56 | ViewHolder vh = new ViewHolder(view);
57 | return vh;
58 | }
59 |
60 |
61 | @Override
62 | public int getItemViewType(int position) {
63 | return super.getItemViewType(position);
64 | }
65 |
66 | private void applyFilter() {
67 |
68 | }
69 |
70 | @Override
71 | public void onBindViewHolder(KickStarterAdapter.ViewHolder holder, int position) {
72 | String project_title = project_titles.get(position);
73 | KickStarterResponse record = this.project_map.get(project_title);
74 | holder.location.setText(record.getLocation());
75 | holder.author.setText("By"+" "+record.getBy());
76 | holder.title.setText(project_title);
77 | holder.author.setTextColor(ContextCompat.getColor(this.mContext,R.color.colorTextDefault));
78 | holder.title.setTextColor(Helpers.getClassColor(this.mContext,getRandomInt()));
79 |
80 | if (record.getBackers().matches(".*[a-zA-Z]+.*"))
81 | {
82 | holder.backedBy.setText(record.getBackers());
83 | //In backer value one object contains a string value named cambridge instead of numbers, so checking it before processing for commas here.
84 | }
85 | else
86 | {
87 | holder.backedBy.setText(String.valueOf(NumberFormat.getNumberInstance(Locale.US).format(Integer.parseInt(record.getBackers()))));
88 |
89 | }
90 | String amount_pledged = String.valueOf(record.getAmtPledged());
91 | holder.pledgedAmount.setText("$"+" "+String.valueOf(NumberFormat.getNumberInstance(Locale.US).format(Integer.parseInt(amount_pledged))));
92 | holder.daysRemaining.setText(String.valueOf(String.valueOf(NumberFormat.getNumberInstance(Locale.US).format(Integer.parseInt(findRemainingDays(record.getDate()))))));
93 | }
94 |
95 | private String findRemainingDays(String date_input) {
96 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
97 | int daysdiff = 0;
98 | Date date1;
99 | Date date2;
100 | try {
101 | date1 = dateFormat.parse(date_input);
102 | Calendar c = Calendar.getInstance();
103 | date2 = dateFormat.parse(dateFormat.format(new Date()));
104 | long diff = date2.getTime() - date1.getTime() ;
105 | long diffDays = diff / (24 * 60 * 60 * 1000)+1;
106 | daysdiff = (int) diffDays;
107 | } catch (ParseException e) {
108 | e.printStackTrace();
109 | }
110 | Log.d(TAG,"Day Difference:"+daysdiff);
111 | return String.valueOf(daysdiff);
112 |
113 | }
114 |
115 | @Override
116 | public int getItemCount() {
117 |
118 | return project_titles.size();
119 | }
120 |
121 | public void setData(Map kick_starter_map)
122 | {
123 | this.project_map = kick_starter_map;
124 | this.project_titles = new ArrayList<>(kick_starter_map.keySet());
125 | notifyDataSetChanged();
126 | }
127 |
128 | public String getWebLink(int position) {
129 | String project_title = this.project_titles.get(position);
130 | String web_url = this.project_map.get(project_title).getUrl();
131 | String proper_url = "https://www.kickstarter.com"+web_url;
132 | Log.d(TAG,"Chosen Project URl:"+proper_url);
133 | return proper_url;
134 | }
135 |
136 | public String getProjectTitle(int position) {
137 | return this.project_titles.get(position);
138 | }
139 |
140 | private int getRandomInt() {
141 | Random r = new Random();
142 | int Low = 1;
143 | int High = 16;
144 | return r.nextInt(High - Low) + Low;
145 | }
146 |
147 | public static class ViewHolder extends RecyclerView.ViewHolder {
148 | // each data item is just a string in this case
149 | TextView title;
150 | TextView author;
151 | TextView backedBy;
152 | TextView location;
153 | TextView pledgedAmount;
154 | TextView daysRemaining;
155 |
156 | public ViewHolder(View v) {
157 | super(v);
158 | title = (TextView) v.findViewById(R.id.title);
159 | author = (TextView) v.findViewById(R.id.author);
160 | backedBy = (TextView) v.findViewById(R.id.backed_by);
161 | location = (TextView) v.findViewById(R.id.location);
162 | pledgedAmount = (TextView) v.findViewById(R.id.pledged_amount);
163 | daysRemaining = (TextView) v.findViewById(R.id.days_remaining);
164 | }
165 |
166 | }
167 |
168 |
169 | }
170 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/card_layout_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
15 |
16 |
21 |
22 |
33 |
34 |
35 |
46 |
47 |
48 |
49 |
50 |
56 |
57 |
63 |
64 |
74 |
75 |
76 |
84 |
85 |
92 |
93 |
99 |
100 |
104 |
105 |
110 |
111 |
116 |
117 |
118 |
122 |
123 |
128 |
129 |
134 |
135 |
136 |
140 |
141 |
146 |
147 |
152 |
153 |
154 |
155 |
159 |
160 |
166 |
167 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
--------------------------------------------------------------------------------
/app/src/main/java/lingaraj/hourglass/in/getmyparkingchallenge/activities/MainActivity.java:
--------------------------------------------------------------------------------
1 | package lingaraj.hourglass.in.getmyparkingchallenge.activities;
2 |
3 | import android.databinding.DataBindingUtil;
4 | import android.os.Bundle;
5 | import android.support.v4.content.ContextCompat;
6 | import android.support.v4.view.MenuItemCompat;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.support.v7.widget.LinearLayoutManager;
9 | import android.util.Log;
10 | import android.view.Menu;
11 | import android.view.MenuItem;
12 | import android.view.View;
13 | import android.widget.SeekBar;
14 |
15 | import com.thefinestartist.finestwebview.FinestWebView;
16 |
17 | import java.util.ArrayList;
18 | import java.util.HashMap;
19 | import java.util.List;
20 | import java.util.Map;
21 |
22 | import lingaraj.hourglass.in.getmyparkingchallenge.KickStarterApp;
23 | import lingaraj.hourglass.in.getmyparkingchallenge.R;
24 | import lingaraj.hourglass.in.getmyparkingchallenge.adapters.KickStarterAdapter;
25 | import lingaraj.hourglass.in.getmyparkingchallenge.cloud.service.KickStarter;
26 | import lingaraj.hourglass.in.getmyparkingchallenge.cloud.service.Response.KickStarterResponse;
27 | import lingaraj.hourglass.in.getmyparkingchallenge.databinding.ActivityMainBinding;
28 | import retrofit.Callback;
29 | import retrofit.RestAdapter;
30 | import retrofit.RetrofitError;
31 | import retrofit.client.Response;
32 |
33 | public class MainActivity extends AppCompatActivity implements android.support.v7.widget.SearchView.OnQueryTextListener {
34 |
35 | ActivityMainBinding activity_binding;
36 | private String TAG="MAINACT";
37 | private List project_list;
38 | private Map project_map = new HashMap<>();
39 | private KickStarterAdapter mAdapter;
40 | private boolean show_menu = false;
41 | int progress_tracker = 0;
42 | int progress_filter = 0;
43 | private int maximum_backed_by_value = 0;
44 |
45 | @Override
46 | protected void onCreate(Bundle savedInstanceState) {
47 | super.onCreate(savedInstanceState);
48 | setContentView(R.layout.activity_main);
49 | activity_binding = DataBindingUtil.setContentView(this,R.layout.activity_main);
50 | setUpViews();
51 | setToolbar();
52 | showLoading();
53 | makerNetworkCall();
54 | activity_binding.loaderInclude.retryButton.setOnClickListener(new View.OnClickListener() {
55 | @Override
56 | public void onClick(View view) {
57 | makerNetworkCall();
58 | }
59 |
60 |
61 | });
62 |
63 | activity_binding.seekbrInclude.seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
64 | @Override
65 | public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
66 | progress_tracker = progress;
67 | activity_binding.seekbrInclude.progressDisplayText.setText(String.valueOf(progress));
68 |
69 | }
70 |
71 | @Override
72 | public void onStartTrackingTouch(SeekBar seekBar) {
73 |
74 | }
75 |
76 | @Override
77 | public void onStopTrackingTouch(SeekBar seekBar) {
78 |
79 | }
80 | });
81 |
82 | activity_binding.seekbrInclude.saveProgress.setOnClickListener(new View.OnClickListener() {
83 | @Override
84 | public void onClick(View view) {
85 | progress_filter = progress_tracker;
86 | activity_binding.seekbrInclude.progressDisplayText.setText(String.valueOf(progress_filter));
87 | hidefilter();
88 | updateAdapter();
89 | }
90 | });
91 | activity_binding.seekbrInclude.cancelProgress.setOnClickListener(new View.OnClickListener() {
92 | @Override
93 | public void onClick(View view) {
94 | progress_tracker = 0;
95 | activity_binding.seekbrInclude.progressDisplayText.setText(String.valueOf(progress_filter));
96 | }
97 | });
98 |
99 | }
100 |
101 | private void setToolbar() {
102 | setSupportActionBar(activity_binding.toolbar);
103 | if (getSupportActionBar()!=null)
104 | {
105 | getSupportActionBar().setTitle(getString(R.string.main_activity_title));
106 | }
107 | }
108 |
109 | private void setUpViews() {
110 | mAdapter = new KickStarterAdapter(getApplicationContext(),new CardClick());
111 | }
112 |
113 | private void makerNetworkCall() {
114 |
115 | KickStarterApp app = (KickStarterApp) getApplication();
116 | if (app.isNetworkAvailable())
117 | {
118 | RestAdapter restAdapter = app.getCloudAdapter();
119 | KickStarter service = restAdapter.create(KickStarter.class);
120 | service.getKickstarterDemo(new Callback>() {
121 | @Override
122 | public void success(List kickStarterResponses, Response response) {
123 | if (kickStarterResponses.size()>0)
124 | {
125 | project_list = kickStarterResponses;
126 | generateDataMaps();
127 | setData();
128 | showContainer();
129 | }
130 | }
131 |
132 | @Override
133 | public void failure(RetrofitError error) {
134 | Log.d(TAG,"Network Call Failed");
135 | showError();
136 | Log.d(TAG,error.toString());
137 | }
138 | });
139 | }
140 | else
141 | {
142 | Log.d(TAG,"Network Unavailable to make Network Call");
143 | showError();
144 | }
145 |
146 | }
147 |
148 | private void showContainer() {
149 | showMenu();
150 | if (activity_binding.viewSwitcher.getDisplayedChild()!=1)
151 | {
152 | activity_binding.viewSwitcher.showNext();
153 | }
154 | Log.d(TAG,"Showing Data Container");
155 | }
156 |
157 |
158 |
159 | private void generateDataMaps() {
160 | int highest_backed_by_value = 0;
161 | for (KickStarterResponse record: project_list) {
162 | //add the current data to map with it's title as key, useful when searched by title.
163 | this.project_map.put(record.getTitle(),record);
164 | if (!record.getBackers().matches(".*[a-zA-Z]+.*"))
165 | {
166 | int backed_by_count = Integer.valueOf(record.getBackers());
167 | if (highest_backed_by_value titles = new ArrayList<>(this.project_map.keySet());
252 | Map filtered_name_list_map = new HashMap<>();
253 | query = query.toLowerCase();
254 | for (int index = 0 ; index 0) {
265 | mAdapter.setData(filtered_name_list_map);
266 | }
267 | }
268 |
269 | @Override
270 | public boolean onCreateOptionsMenu(Menu menu) {
271 | getMenuInflater().inflate(R.menu.menu_main_activity,menu);
272 | MenuItem search_menu_toolbar = menu.findItem(R.id.action_search_evaluated);
273 | final android.support.v7.widget.SearchView view_search = (android.support.v7.widget.SearchView) MenuItemCompat.getActionView(search_menu_toolbar);
274 | view_search.setOnQueryTextListener(this);
275 | return true;
276 | }
277 |
278 | @Override
279 | public boolean onPrepareOptionsMenu(Menu menu) {
280 | if (show_menu)
281 | {
282 | menu.getItem(0).setVisible(true);
283 | menu.getItem(1).setVisible(false);
284 |
285 | }
286 | else
287 | {
288 | menu.getItem(0).setVisible(false);
289 | menu.getItem(1).setVisible(false);
290 |
291 | }
292 | return super.onPrepareOptionsMenu(menu);
293 | }
294 |
295 | @Override
296 | public boolean onOptionsItemSelected(MenuItem item) {
297 | if (item.getItemId()==R.id.action_filter)
298 | {
299 | showFilter();
300 | }
301 | return super.onOptionsItemSelected(item);
302 | }
303 |
304 | public class CardClick implements View.OnClickListener
305 | {
306 |
307 | @Override
308 | public void onClick(View view) {
309 | Log.d(TAG,"Card Clicked");
310 | int position = activity_binding.mRecyclerview.getChildAdapterPosition(view);
311 | Log.d(TAG,"Clicked Position:"+position);
312 | String project_web_link = mAdapter.getWebLink(position);
313 | String project_title = mAdapter.getProjectTitle(position);
314 | loadWebPage(project_web_link,project_title);
315 | }
316 | }
317 |
318 | private void loadWebPage(String project_web_link,String project_title) {
319 | new FinestWebView.Builder(getApplicationContext()).theme(R.style.KickStarterTheme).titleDefault(project_title)
320 | .webViewBuiltInZoomControls(true)
321 | .webViewDisplayZoomControls(true)
322 | .webViewMixedContentMode(0)
323 | .showUrl(true)
324 | .swipeRefreshColorRes(R.color.colorPrimary)
325 | .statusBarColorRes(R.color.colorPrimaryDark)
326 | .toolbarColorRes(R.color.colorPrimary)
327 | .titleColorRes(R.color.finestWhite)
328 | .urlColorRes(R.color.colorPrimary)
329 | .iconDefaultColorRes(R.color.finestWhite)
330 | .progressBarColorRes(R.color.finestWhite)
331 | .stringResCopiedToClipboard(R.string.copied_to_clipboard)
332 | .stringResCopiedToClipboard(R.string.copied_to_clipboard)
333 | .stringResCopiedToClipboard(R.string.copied_to_clipboard)
334 | .dividerHeight(0)
335 | .gradientDivider(false)
336 | .setCustomAnimations(R.anim.activity_open_enter, R.anim.activity_open_exit,
337 | R.anim.activity_close_enter, R.anim.activity_close_exit)
338 | .show(project_web_link);
339 |
340 |
341 | }
342 |
343 | private void updateAdapter() {
344 | List titles = new ArrayList(this.project_map.keySet());
345 | Map seekbar_filter_map = new HashMap<>();
346 | for (String title:titles) {
347 | if (!this.project_map.get(title).getBackers().matches(".*[a-zA-Z]+.*"))
348 | {
349 | int backers = Integer.valueOf(this.project_map.get(title).getBackers());
350 | if (backers<=progress_filter)
351 | {
352 | seekbar_filter_map.put(title,this.project_map.get(title));
353 | }
354 | }
355 |
356 | }
357 | mAdapter.setData(seekbar_filter_map);
358 | }
359 |
360 | private void showFilter()
361 | {
362 | activity_binding.seekbrInclude.parentView.setVisibility(View.VISIBLE);
363 | activity_binding.toolbar.setVisibility(View.GONE);
364 |
365 | }
366 |
367 | private void hidefilter() {
368 | activity_binding.seekbrInclude.parentView.setVisibility(View.GONE);
369 | activity_binding.toolbar.setVisibility(View.VISIBLE);
370 |
371 | }
372 | }
373 |
--------------------------------------------------------------------------------