├── .gitignore
├── .idea
├── codeStyles
│ └── Project.xml
├── gradle.xml
├── misc.xml
└── runConfigurations.xml
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── project
│ │ └── semicolon
│ │ └── rxjava
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── project
│ │ │ └── semicolon
│ │ │ └── rxjava
│ │ │ ├── Const.java
│ │ │ ├── FlightsRecyclerAdapter.java
│ │ │ ├── GlideAdapter.java
│ │ │ ├── MainActivity.java
│ │ │ └── services
│ │ │ ├── ApiClient.java
│ │ │ ├── ApiService.java
│ │ │ └── model
│ │ │ ├── price
│ │ │ └── PriceResponse.java
│ │ │ └── ticktes
│ │ │ ├── Airline.java
│ │ │ └── TicketsResponse.java
│ └── res
│ │ ├── anim
│ │ ├── item_animation_fall_down.xml
│ │ └── layout_animator.xml
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── ic_arrow_forward_black_24dp.xml
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── ticket_list_item.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── project
│ └── semicolon
│ └── rxjava
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | xmlns:android
11 |
12 | ^$
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | xmlns:.*
22 |
23 | ^$
24 |
25 |
26 | BY_NAME
27 |
28 |
29 |
30 |
31 |
32 |
33 | .*:id
34 |
35 | http://schemas.android.com/apk/res/android
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | .*:name
45 |
46 | http://schemas.android.com/apk/res/android
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | name
56 |
57 | ^$
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | style
67 |
68 | ^$
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | .*
78 |
79 | ^$
80 |
81 |
82 | BY_NAME
83 |
84 |
85 |
86 |
87 |
88 |
89 | .*
90 |
91 | http://schemas.android.com/apk/res/android
92 |
93 |
94 | ANDROID_ATTRIBUTE_ORDER
95 |
96 |
97 |
98 |
99 |
100 |
101 | .*
102 |
103 | .*
104 |
105 |
106 | BY_NAME
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 29
5 | buildToolsVersion "29.0.1"
6 | defaultConfig {
7 | applicationId "com.project.semicolon.rxjava"
8 | minSdkVersion 15
9 | targetSdkVersion 29
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 |
21 | dataBinding {
22 | enabled = true
23 | }
24 | }
25 |
26 | dependencies {
27 | implementation fileTree(dir: 'libs', include: ['*.jar'])
28 | implementation 'androidx.appcompat:appcompat:1.1.0'
29 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
30 | testImplementation 'junit:junit:4.12'
31 | implementation "com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0"
32 | implementation "com.squareup.okhttp3:okhttp:4.0.0"
33 | implementation 'com.github.bumptech.glide:glide:4.10.0'
34 | annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
35 | implementation 'com.github.ybq:Android-SpinKit:1.4.0'
36 | implementation "com.squareup.okhttp3:okhttp-urlconnection:3.0.1"
37 | implementation "com.squareup.okhttp3:logging-interceptor:4.0.0"
38 | implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
39 | implementation 'io.reactivex.rxjava2:rxjava:2.2.14'
40 | implementation 'com.google.android.material:material:1.0.0'
41 | implementation 'com.squareup.retrofit2:retrofit:2.6.1'
42 | implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
43 | implementation 'com.google.code.gson:gson:2.8.6'
44 | androidTestImplementation 'androidx.test.ext:junit:1.1.0'
45 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
46 | }
47 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/project/semicolon/rxjava/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.project.semicolon.rxjava;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 |
25 | assertEquals("com.project.semicolon.rxjava", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/project/semicolon/rxjava/Const.java:
--------------------------------------------------------------------------------
1 | package com.project.semicolon.rxjava;
2 |
3 | public class Const {
4 | public static final String BASE_URL = "https://api.androidhive.info/json/";
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/app/src/main/java/com/project/semicolon/rxjava/FlightsRecyclerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.project.semicolon.rxjava;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.recyclerview.widget.RecyclerView;
10 |
11 | import com.project.semicolon.rxjava.databinding.TicketsListItemBind;
12 | import com.project.semicolon.rxjava.services.model.ticktes.TicketsResponse;
13 |
14 | import java.util.List;
15 |
16 | public class FlightsRecyclerAdapter extends
17 | RecyclerView.Adapter {
18 | private List ticketList;
19 | private Context context;
20 | private OnTicketSelected onTicketSelected;
21 |
22 | public FlightsRecyclerAdapter(Context context) {
23 | this.context = context;
24 | }
25 |
26 | public void setTicketList(List ticketList) {
27 | this.ticketList = ticketList;
28 | notifyDataSetChanged();
29 | }
30 |
31 | public void setOnTicketSelected(OnTicketSelected onTicketSelected) {
32 | this.onTicketSelected = onTicketSelected;
33 | }
34 |
35 | @NonNull
36 | @Override
37 | public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
38 | LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
39 | TicketsListItemBind binding = TicketsListItemBind
40 | .inflate(layoutInflater, parent, false);
41 | return new ViewHolder(binding);
42 | }
43 |
44 | @Override
45 | public void onBindViewHolder(@NonNull ViewHolder holder, final int position) {
46 | holder.binding.setTickets(ticketList.get(position));
47 | holder.binding.getRoot().setOnClickListener(new View.OnClickListener() {
48 | @Override
49 | public void onClick(View view) {
50 | if (onTicketSelected != null)
51 | onTicketSelected.onTicketSelect(ticketList.get(position));
52 | }
53 | });
54 |
55 |
56 | }
57 |
58 | @Override
59 | public int getItemCount() {
60 | if (ticketList == null)
61 | return 0;
62 |
63 | return ticketList.size();
64 | }
65 |
66 | public class ViewHolder extends RecyclerView.ViewHolder {
67 | private TicketsListItemBind binding;
68 |
69 | public ViewHolder(@NonNull TicketsListItemBind binding) {
70 | super(binding.getRoot());
71 | this.binding = binding;
72 | }
73 | }
74 |
75 | public interface OnTicketSelected {
76 | void onTicketSelect(TicketsResponse ticket);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/app/src/main/java/com/project/semicolon/rxjava/GlideAdapter.java:
--------------------------------------------------------------------------------
1 | package com.project.semicolon.rxjava;
2 |
3 | import android.content.Context;
4 | import android.widget.ImageView;
5 |
6 | import androidx.databinding.BindingAdapter;
7 |
8 | import com.bumptech.glide.Glide;
9 | import com.bumptech.glide.RequestBuilder;
10 | import com.bumptech.glide.request.RequestOptions;
11 |
12 | public class GlideAdapter {
13 | @BindingAdapter("loadImage")
14 | public static void displayImage(ImageView imageView, String imageRes){
15 | Context context = imageView.getContext();
16 | Glide.with(context)
17 | .load(imageRes)
18 | .apply(RequestOptions.circleCropTransform())
19 | .into(imageView);
20 |
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/project/semicolon/rxjava/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.project.semicolon.rxjava;
2 |
3 | import android.os.Bundle;
4 | import android.widget.Toast;
5 |
6 | import androidx.appcompat.app.AppCompatActivity;
7 | import androidx.databinding.DataBindingUtil;
8 | import androidx.recyclerview.widget.LinearLayoutManager;
9 |
10 | import com.project.semicolon.rxjava.databinding.MainActivityBind;
11 | import com.project.semicolon.rxjava.services.ApiClient;
12 | import com.project.semicolon.rxjava.services.ApiService;
13 | import com.project.semicolon.rxjava.services.model.price.PriceResponse;
14 | import com.project.semicolon.rxjava.services.model.ticktes.TicketsResponse;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | import io.reactivex.Observable;
20 | import io.reactivex.ObservableSource;
21 | import io.reactivex.android.schedulers.AndroidSchedulers;
22 | import io.reactivex.disposables.CompositeDisposable;
23 | import io.reactivex.functions.Function;
24 | import io.reactivex.observables.ConnectableObservable;
25 | import io.reactivex.observers.DisposableObserver;
26 | import io.reactivex.schedulers.Schedulers;
27 |
28 | public class MainActivity extends AppCompatActivity implements
29 | FlightsRecyclerAdapter.OnTicketSelected {
30 |
31 | private ApiService service;
32 | private CompositeDisposable compositeDisposable = new CompositeDisposable();
33 | private MainActivityBind binding;
34 | private FlightsRecyclerAdapter adapter;
35 | private List ticketsList;
36 |
37 | @Override
38 | protected void onCreate(Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
41 |
42 | service = ApiClient.getClient().create(ApiService.class);
43 |
44 | /**
45 | * You can notice replay() operator which is used to make
46 | * an Observable emits the data on new subscriptions without
47 | * executing the logic again.
48 | * In this case, the list of tickets will be emitted without making the HTTP call again.
49 | * Without the replay method,
50 | * you can notice the fetch tickets HTTP call get executed multiple times.
51 | */
52 | ConnectableObservable> ticketsObservable =
53 | getTickets("DEL", "HYD").replay();
54 |
55 | ticketsList = new ArrayList<>();
56 |
57 | //TODO 1 Run this code first and show how flatMap() operator works.
58 |
59 |
60 | adapter = new FlightsRecyclerAdapter(this);
61 | adapter.setOnTicketSelected(this);
62 |
63 | initRecyclerView();
64 | /**
65 | * Fetching all tickets first
66 | * Observable emits List at once.
67 | * All the items will be added to RecyclerView directly without price and number of seats.
68 | */
69 | compositeDisposable.add(ticketsObservable
70 | .subscribeOn(Schedulers.io())
71 | .observeOn(AndroidSchedulers.mainThread())
72 | .subscribeWith(new DisposableObserver>() {
73 | @Override
74 | public void onNext(List tickets) {
75 | ticketsList.clear();
76 | ticketsList.addAll(tickets);
77 | adapter.setTicketList(ticketsList);
78 |
79 | }
80 |
81 | @Override
82 | public void onError(Throwable e) {
83 | Toast.makeText(MainActivity.this,
84 | e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
85 |
86 | }
87 |
88 | @Override
89 | public void onComplete() {
90 |
91 | }
92 | }));
93 |
94 |
95 | //TODO 2- comment this code
96 | /**
97 | * In this subscription, first flatMap() is used to convert list of tickets
98 | * to individual ticket emissions.
99 | * Second flatMap() is chained to execute the getPrice() method on each ticket emissions
100 | * which fetches the price and available seats.
101 | */
102 | compositeDisposable.add(ticketsObservable
103 | .subscribeOn(Schedulers.io())
104 | .observeOn(AndroidSchedulers.mainThread())
105 | /**
106 | * Converting List emission to single Ticket emissions
107 | * */
108 | .flatMap(new Function, ObservableSource>() {
109 | @Override
110 | public ObservableSource apply(List ticketsList) throws Exception {
111 | return Observable.fromIterable(ticketsList);
112 | }
113 | })
114 | /**
115 | * Fetching price on each Ticket emission
116 | * */
117 | .flatMap(new Function>() {
118 | @Override
119 | public ObservableSource apply(TicketsResponse ticketsResponse) throws Exception {
120 | return getPrice(ticketsResponse);
121 | }
122 | })
123 | .subscribeWith(new DisposableObserver() {
124 | @Override
125 | public void onNext(TicketsResponse ticket) {
126 | int position = ticketsList.indexOf(ticket);
127 |
128 | /**
129 | * Ticket not found in the Tickets list
130 | */
131 | if (position == -1)
132 | return;
133 |
134 | ticketsList.set(position, ticket);
135 | adapter.notifyItemChanged(position);
136 |
137 |
138 | }
139 |
140 | @Override
141 | public void onError(Throwable e) {
142 | Toast.makeText(MainActivity.this, e.getLocalizedMessage(),
143 | Toast.LENGTH_SHORT).show();
144 |
145 | }
146 |
147 | @Override
148 | public void onComplete() {
149 |
150 | }
151 | }));
152 |
153 | //TODO 3- uncomment this gist and show how the concatMap() operator work.
154 | /* compositeDisposable.add(ticketsObservable
155 | .subscribeOn(Schedulers.io())
156 | .observeOn(AndroidSchedulers.mainThread())
157 | .flatMap(new Function, ObservableSource>() {
158 | @Override
159 | public ObservableSource apply(List ticketsList) throws Exception {
160 | return Observable.fromIterable(ticketsList);
161 | }
162 | }).concatMap(new Function>() {
163 | @Override
164 | public ObservableSource apply(TicketsResponse tickets) throws Exception {
165 | return getPrice(tickets);
166 | }
167 | }).subscribeWith(new DisposableObserver() {
168 | @Override
169 | public void onNext(TicketsResponse ticket) {
170 | int position = ticketsList.indexOf(ticket);
171 |
172 | *//**
173 | * Ticket not found in the Tickets list
174 | *//*
175 | if (position == -1)
176 | return;
177 |
178 | ticketsList.set(position, ticket);
179 | adapter.notifyItemChanged(position);
180 |
181 | }
182 |
183 | @Override
184 | public void onError(Throwable e) {
185 | Toast.makeText(MainActivity.this, e.getLocalizedMessage(),
186 | Toast.LENGTH_SHORT).show();
187 |
188 | }
189 |
190 | @Override
191 | public void onComplete() {
192 |
193 | }
194 | }));*/
195 |
196 |
197 | ticketsObservable.connect();
198 |
199 | //TODO 4- Read this https://proandroiddev.com/exploring-rxjava-in-android-operators-for-transforming-observables-367c22d86677
200 | //TODO 5- What the difference between concatMap() and flatMap()?
201 |
202 |
203 |
204 | }
205 |
206 |
207 | private void initRecyclerView() {
208 | LinearLayoutManager layoutManager = new LinearLayoutManager(this);
209 | binding.ticketsRecycler.setLayoutManager(layoutManager);
210 |
211 | binding.ticketsRecycler.setAdapter(adapter);
212 | binding.ticketsRecycler.setHasFixedSize(true);
213 | }
214 |
215 | /**
216 | * Making Retrofit call to fetch all tickets.
217 | */
218 | public Observable> getTickets(String from, String to) {
219 | return service.searchTickets(from, to)
220 | .toObservable()
221 | .subscribeOn(Schedulers.io())
222 | .observeOn(AndroidSchedulers.mainThread());
223 |
224 |
225 | }
226 |
227 | /**
228 | * Making Retrofit call to fetch single ticket price.
229 | * get price HTTP call returns Price Object, but
230 | * map() operator is used to change the return type to Ticket.
231 | */
232 | public Observable getPrice(final TicketsResponse ticket) {
233 | return service.ticketsPrice(ticket.getFlightNumber(), ticket.getFrom(), ticket.getTo())
234 | .toObservable()
235 | .subscribeOn(Schedulers.io())
236 | .observeOn(AndroidSchedulers.mainThread())
237 | .map(new Function() {
238 | @Override
239 | public TicketsResponse apply(PriceResponse price) throws Exception {
240 | ticket.setPrice(price);
241 | return ticket;
242 | }
243 | });
244 | }
245 |
246 | @Override
247 | protected void onDestroy() {
248 | super.onDestroy();
249 |
250 | compositeDisposable.dispose();
251 | binding.unbind();
252 | }
253 |
254 | @Override
255 | public void onTicketSelect(TicketsResponse ticket) {
256 | Toast.makeText(this, "Flight number: " +
257 | ticket.getFlightNumber(), Toast.LENGTH_SHORT).show();
258 |
259 | }
260 | }
261 |
--------------------------------------------------------------------------------
/app/src/main/java/com/project/semicolon/rxjava/services/ApiClient.java:
--------------------------------------------------------------------------------
1 | package com.project.semicolon.rxjava.services;
2 |
3 | import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
4 | import com.project.semicolon.rxjava.Const;
5 |
6 | import org.jetbrains.annotations.NotNull;
7 |
8 | import java.io.IOException;
9 | import java.util.concurrent.TimeUnit;
10 |
11 | import okhttp3.Interceptor;
12 | import okhttp3.OkHttpClient;
13 | import okhttp3.Request;
14 | import okhttp3.Response;
15 | import okhttp3.logging.HttpLoggingInterceptor;
16 | import retrofit2.Retrofit;
17 | import retrofit2.converter.gson.GsonConverterFactory;
18 |
19 | public class ApiClient {
20 | private static Retrofit retrofit = null;
21 | private static final String TAG = ApiClient.class.getSimpleName();
22 | private static int REQUEST_TIMEOUT = 60;
23 | private static OkHttpClient okHttpClient;
24 |
25 | public static Retrofit getClient() {
26 | if (okHttpClient == null)
27 | initHttpClient();
28 |
29 | if (retrofit == null) {
30 | retrofit = initRetrofit();
31 | }
32 |
33 | return retrofit;
34 |
35 | }
36 |
37 | private static Retrofit initRetrofit() {
38 | return new Retrofit.Builder().baseUrl(Const.BASE_URL).client(okHttpClient)
39 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
40 | .addConverterFactory(GsonConverterFactory.create())
41 | .build();
42 | }
43 |
44 | private static void initHttpClient() {
45 | OkHttpClient.Builder httpBuilder = new OkHttpClient.Builder();
46 | httpBuilder.connectTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS);
47 | httpBuilder.readTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS);
48 | httpBuilder.writeTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS);
49 |
50 | HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
51 | interceptor.level(HttpLoggingInterceptor.Level.BODY);
52 |
53 | httpBuilder.addInterceptor(interceptor);
54 |
55 | httpBuilder.addInterceptor(new Interceptor() {
56 | @NotNull
57 | @Override
58 | public Response intercept(@NotNull Chain chain) throws IOException {
59 | Request original = chain.request();
60 | Request.Builder requestBuilder = original.newBuilder();
61 | requestBuilder.addHeader("Accept", "application/json");
62 | requestBuilder.addHeader("Request-Type", "Android");
63 | requestBuilder.addHeader("Content-Type", "application/json");
64 |
65 | Request request = requestBuilder.build();
66 |
67 |
68 | return chain.proceed(request);
69 | }
70 | });
71 |
72 | okHttpClient = httpBuilder.build();
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/app/src/main/java/com/project/semicolon/rxjava/services/ApiService.java:
--------------------------------------------------------------------------------
1 | package com.project.semicolon.rxjava.services;
2 |
3 | import com.project.semicolon.rxjava.services.model.price.PriceResponse;
4 | import com.project.semicolon.rxjava.services.model.ticktes.TicketsResponse;
5 |
6 | import java.util.List;
7 |
8 | import io.reactivex.Single;
9 | import retrofit2.http.GET;
10 | import retrofit2.http.Query;
11 |
12 | public interface ApiService {
13 |
14 | @GET("airline-tickets.php")
15 | Single> searchTickets(@Query("from")String from,
16 | @Query("to")String to);
17 |
18 | @GET("airline-tickets-price.php")
19 | Single ticketsPrice(@Query("flight_number")String flightNumber,
20 | @Query("from")String from, @Query("to") String to);
21 |
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/project/semicolon/rxjava/services/model/price/PriceResponse.java:
--------------------------------------------------------------------------------
1 | package com.project.semicolon.rxjava.services.model.price;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | public class PriceResponse {
6 |
7 | @SerializedName("price")
8 | private int price;
9 |
10 | @SerializedName("flight_number")
11 | private String flightNumber;
12 |
13 | @SerializedName("currency")
14 | private String currency;
15 |
16 | @SerializedName("from")
17 | private String from;
18 |
19 | @SerializedName("to")
20 | private String to;
21 |
22 | @SerializedName("seats")
23 | private int seats;
24 |
25 | public void setPrice(int price) {
26 | this.price = price;
27 | }
28 |
29 | public int getPrice() {
30 | return price;
31 | }
32 |
33 | public void setFlightNumber(String flightNumber) {
34 | this.flightNumber = flightNumber;
35 | }
36 |
37 | public String getFlightNumber() {
38 | return flightNumber;
39 | }
40 |
41 | public void setCurrency(String currency) {
42 | this.currency = currency;
43 | }
44 |
45 | public String getCurrency() {
46 | return currency;
47 | }
48 |
49 | public void setFrom(String from) {
50 | this.from = from;
51 | }
52 |
53 | public String getFrom() {
54 | return from;
55 | }
56 |
57 | public void setTo(String to) {
58 | this.to = to;
59 | }
60 |
61 | public String getTo() {
62 | return to;
63 | }
64 |
65 | public void setSeats(int seats) {
66 | this.seats = seats;
67 | }
68 |
69 | public int getSeats() {
70 | return seats;
71 | }
72 |
73 | @Override
74 | public String toString() {
75 | return
76 | "PriceResponse{" +
77 | "price = '" + price + '\'' +
78 | ",flight_number = '" + flightNumber + '\'' +
79 | ",currency = '" + currency + '\'' +
80 | ",from = '" + from + '\'' +
81 | ",to = '" + to + '\'' +
82 | ",seats = '" + seats + '\'' +
83 | "}";
84 | }
85 |
86 | public String seats() {
87 | return seats + " Seats";
88 | }
89 |
90 | public String price() {
91 | return "$ " + price;
92 | }
93 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/project/semicolon/rxjava/services/model/ticktes/Airline.java:
--------------------------------------------------------------------------------
1 | package com.project.semicolon.rxjava.services.model.ticktes;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | public class Airline {
6 |
7 | @SerializedName("name")
8 | private String name;
9 |
10 | @SerializedName("logo")
11 | private String logo;
12 |
13 | @SerializedName("id")
14 | private int id;
15 |
16 | public void setName(String name) {
17 | this.name = name;
18 | }
19 |
20 | public String getName() {
21 | return name;
22 | }
23 |
24 | public void setLogo(String logo) {
25 | this.logo = logo;
26 | }
27 |
28 | public String getLogo() {
29 | return logo;
30 | }
31 |
32 | public void setId(int id) {
33 | this.id = id;
34 | }
35 |
36 | public int getId() {
37 | return id;
38 | }
39 |
40 | @Override
41 | public String toString() {
42 | return
43 | "Airline{" +
44 | "name = '" + name + '\'' +
45 | ",logo = '" + logo + '\'' +
46 | ",id = '" + id + '\'' +
47 | "}";
48 | }
49 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/project/semicolon/rxjava/services/model/ticktes/TicketsResponse.java:
--------------------------------------------------------------------------------
1 | package com.project.semicolon.rxjava.services.model.ticktes;
2 |
3 | import android.text.TextUtils;
4 |
5 | import com.google.gson.annotations.SerializedName;
6 | import com.project.semicolon.rxjava.services.model.price.PriceResponse;
7 |
8 | public class TicketsResponse {
9 |
10 | @SerializedName("duration")
11 | private String duration;
12 |
13 | @SerializedName("instructions")
14 | private String instructions;
15 |
16 | @SerializedName("arrival")
17 | private String arrival;
18 |
19 | @SerializedName("flight_number")
20 | private String flightNumber;
21 |
22 | @SerializedName("from")
23 | private String from;
24 |
25 | @SerializedName("to")
26 | private String to;
27 |
28 | @SerializedName("departure")
29 | private String departure;
30 |
31 | @SerializedName("stops")
32 | private int stops;
33 |
34 | @SerializedName("airline")
35 | private Airline airline;
36 |
37 | private PriceResponse price;
38 |
39 | public void setDuration(String duration) {
40 | this.duration = duration;
41 | }
42 |
43 | public String getDuration() {
44 | return duration;
45 | }
46 |
47 | public void setInstructions(String instructions) {
48 | this.instructions = instructions;
49 | }
50 |
51 | public String getInstructions() {
52 | return instructions;
53 | }
54 |
55 | public void setArrival(String arrival) {
56 | this.arrival = arrival;
57 | }
58 |
59 | public String getArrival() {
60 | return arrival + " DEST";
61 | }
62 |
63 | public void setFlightNumber(String flightNumber) {
64 | this.flightNumber = flightNumber;
65 | }
66 |
67 | public String getFlightNumber() {
68 | return flightNumber;
69 | }
70 |
71 | public void setFrom(String from) {
72 | this.from = from;
73 | }
74 |
75 | public String getFrom() {
76 | return from;
77 | }
78 |
79 | public void setTo(String to) {
80 | this.to = to;
81 | }
82 |
83 | public String getTo() {
84 | return to;
85 | }
86 |
87 | public void setDeparture(String departure) {
88 | this.departure = departure;
89 | }
90 |
91 | public String getDeparture() {
92 | return departure + " DEP";
93 | }
94 |
95 | public void setStops(int stops) {
96 | this.stops = stops;
97 | }
98 |
99 | public int getStops() {
100 | return stops;
101 | }
102 |
103 | public void setAirline(Airline airline) {
104 | this.airline = airline;
105 | }
106 |
107 | public Airline getAirline() {
108 | return airline;
109 | }
110 |
111 | public void setPrice(PriceResponse price) {
112 | this.price = price;
113 | }
114 |
115 | public PriceResponse getPrice() {
116 | return price;
117 | }
118 |
119 | @Override
120 | public String toString() {
121 | return
122 | "TicketsResponse{" +
123 | "duration = '" + duration + '\'' +
124 | ",instructions = '" + instructions + '\'' +
125 | ",arrival = '" + arrival + '\'' +
126 | ",flight_number = '" + flightNumber + '\'' +
127 | ",from = '" + from + '\'' +
128 | ",to = '" + to + '\'' +
129 | ",departure = '" + departure + '\'' +
130 | ",stops = '" + stops + '\'' +
131 | ",airline = '" + airline + '\'' +
132 | "}";
133 | }
134 |
135 | public String stop() {
136 | String stop;
137 | if (stops == 1) {
138 | stop = stops + " Stop";
139 | } else {
140 | stop = stops + " Stops";
141 | }
142 | return stop;
143 |
144 | }
145 |
146 | public String setInstruction() {
147 | String text = duration + ", " + flightNumber;
148 | if (!TextUtils.isEmpty(instructions)) {
149 | text = text + ", " + instructions;
150 | }
151 |
152 | return text;
153 | }
154 |
155 | public boolean isPriceExist(){
156 | return price != null;
157 | }
158 |
159 | public String setDestination(){
160 | return from + "Dest";
161 | }
162 | }
--------------------------------------------------------------------------------
/app/src/main/res/anim/item_animation_fall_down.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
14 |
15 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/layout_animator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_forward_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
13 |
14 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/ticket_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
10 |
11 |
14 |
15 |
16 |
17 |
21 |
22 |
29 |
30 |
35 |
36 |
42 |
43 |
48 |
49 |
57 |
58 |
70 |
71 |
72 |
83 |
84 |
94 |
95 |
96 |
97 |
103 |
104 |
117 |
118 |
126 |
127 |
140 |
141 |
146 |
147 |
157 |
158 |
167 |
168 |
169 |
170 |
171 |
172 |
177 |
178 |
188 |
189 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dracula151997/RetrofitWithRXJava/349daf71f75b173c1208e9b73ccc098a6f2feea2/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dracula151997/RetrofitWithRXJava/349daf71f75b173c1208e9b73ccc098a6f2feea2/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dracula151997/RetrofitWithRXJava/349daf71f75b173c1208e9b73ccc098a6f2feea2/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dracula151997/RetrofitWithRXJava/349daf71f75b173c1208e9b73ccc098a6f2feea2/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dracula151997/RetrofitWithRXJava/349daf71f75b173c1208e9b73ccc098a6f2feea2/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dracula151997/RetrofitWithRXJava/349daf71f75b173c1208e9b73ccc098a6f2feea2/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dracula151997/RetrofitWithRXJava/349daf71f75b173c1208e9b73ccc098a6f2feea2/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dracula151997/RetrofitWithRXJava/349daf71f75b173c1208e9b73ccc098a6f2feea2/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dracula151997/RetrofitWithRXJava/349daf71f75b173c1208e9b73ccc098a6f2feea2/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dracula151997/RetrofitWithRXJava/349daf71f75b173c1208e9b73ccc098a6f2feea2/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 | #515151
8 | #787878
9 | #dd000000
10 | #6E6E6E
11 | #dd595959
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RXJava
3 | price
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/project/semicolon/rxjava/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.project.semicolon.rxjava;
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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | google()
6 | jcenter()
7 |
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.5.2'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | jcenter()
21 |
22 | }
23 |
24 |
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 |
21 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dracula151997/RetrofitWithRXJava/349daf71f75b173c1208e9b73ccc098a6f2feea2/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Nov 08 21:07:05 EET 2019
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-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name='RXJava'
3 |
--------------------------------------------------------------------------------