-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from iabdelgawaad/develop
Merge Develop Release 0.0.1
- Loading branch information
Showing
56 changed files
with
2,175 additions
and
53 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# FoodMenuApp | ||
Sample android app developed in Java to show case RxJava, Retrofit, MVP, Room and Clean code architecture. | ||
|
||
#Tools & Technologies | ||
- RXAndroid | ||
- Retrofit | ||
- Picasso | ||
- Butter Knife | ||
- Data Caching (Room) | ||
|
||
#TODO | ||
- Caching (Realm) | ||
- Unit Testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
app/src/main/java/com/insta2apps/ibrahim/mfoodmenuapplication/MFoodMenuApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.insta2apps.ibrahim.mfoodmenuapplication; | ||
|
||
import android.app.Application; | ||
|
||
import com.insta2apps.ibrahim.mfoodmenuapplication.di.components.ApplicationComponent; | ||
import com.insta2apps.ibrahim.mfoodmenuapplication.di.components.DaggerApplicationComponent; | ||
import com.insta2apps.ibrahim.mfoodmenuapplication.di.modules.ApplicationModule; | ||
|
||
/** | ||
* Created by Ibrahim AbdelGawad on 3/11/2018. | ||
*/ | ||
|
||
public class MFoodMenuApplication extends Application { | ||
private static MFoodMenuApplication instance; | ||
protected ApplicationComponent daggerComponent; | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
instance = this; | ||
initDagger(); | ||
} | ||
|
||
public static MFoodMenuApplication getInstance() { | ||
return instance; | ||
} | ||
|
||
protected void initDagger() { | ||
daggerComponent = DaggerApplicationComponent.builder().applicationModule(new ApplicationModule(this)).build(); | ||
} | ||
public ApplicationComponent getDaggerComponent() { | ||
return daggerComponent; | ||
} | ||
|
||
} |
13 changes: 0 additions & 13 deletions
13
app/src/main/java/com/insta2apps/ibrahim/mfoodmenuapplication/MainActivity.java
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
.../java/com/insta2apps/ibrahim/mfoodmenuapplication/data/repository/FoodMenuRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.insta2apps.ibrahim.mfoodmenuapplication.data.repository; | ||
|
||
import android.support.annotation.NonNull; | ||
|
||
import com.insta2apps.ibrahim.mfoodmenuapplication.data.source.FoodMenuModel; | ||
import com.insta2apps.ibrahim.mfoodmenuapplication.data.source.Item; | ||
import com.insta2apps.ibrahim.mfoodmenuapplication.data.source.database.room.FoodMenuItemDao; | ||
import com.insta2apps.ibrahim.mfoodmenuapplication.data.source.network.API; | ||
import com.insta2apps.ibrahim.mfoodmenuapplication.data.source.network.RequestManager; | ||
|
||
import java.util.List; | ||
|
||
import javax.inject.Inject; | ||
|
||
import io.reactivex.Flowable; | ||
import io.reactivex.Observable; | ||
import io.reactivex.ObservableEmitter; | ||
import io.reactivex.ObservableOnSubscribe; | ||
|
||
/** | ||
* Created by Ibrahim AbdelGawad on 3/11/2018. | ||
*/ | ||
|
||
public class FoodMenuRepository { | ||
|
||
private final RequestManager requestManager; | ||
private final FoodMenuItemDao foodMenuItemDao; | ||
|
||
@Inject | ||
public FoodMenuRepository(@NonNull RequestManager requestManager, FoodMenuItemDao foodMenuItemDao) { | ||
this.requestManager = requestManager; | ||
this.foodMenuItemDao = foodMenuItemDao; | ||
} | ||
|
||
public Observable<FoodMenuModel> loadFoodMenuListRemotely() { | ||
return requestManager.startRequest(API.class).getFoodMenuList(); | ||
} | ||
|
||
public Observable<List<Item>> loadFoodMenuListLocally() { | ||
return Observable.create(new ObservableOnSubscribe<List<Item>>() { | ||
@Override | ||
public void subscribe(ObservableEmitter<List<Item>> emitter) { | ||
List<Item> itemList = null; | ||
itemList = foodMenuItemDao.getAll(); | ||
emitter.onNext(itemList); | ||
emitter.onComplete(); | ||
} | ||
}); | ||
} | ||
|
||
public Flowable<Long> getLocalFoodMenuItemsCount() { | ||
return foodMenuItemDao.countFoodMenuItems(); | ||
} | ||
|
||
public void saveFoodMenuListLocally(List<Item> items) { | ||
for (Item item : items) { | ||
foodMenuItemDao.insertAll(item); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/com/insta2apps/ibrahim/mfoodmenuapplication/data/source/BaseModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.insta2apps.ibrahim.mfoodmenuapplication.data.source; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* Created by Ibrahim AbdelGawad on 3/11/2018. | ||
*/ | ||
|
||
public class BaseModel implements Serializable { | ||
private String errorCode; | ||
|
||
public String getError() { | ||
return error; | ||
} | ||
|
||
public void setError(String error) { | ||
this.error = error; | ||
} | ||
|
||
private String error; | ||
|
||
public String getErrorCode() { | ||
return errorCode; | ||
} | ||
|
||
public void setErrorCode(String errorCode) { | ||
this.errorCode = errorCode; | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/com/insta2apps/ibrahim/mfoodmenuapplication/data/source/FoodMenuModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.insta2apps.ibrahim.mfoodmenuapplication.data.source; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by Ibrahim AbdelGawad on 3/12/2018. | ||
*/ | ||
|
||
public class FoodMenuModel { | ||
|
||
private List<Item> items = null; | ||
|
||
public List<Item> getItems() { | ||
return items; | ||
} | ||
|
||
public void setItems(List<Item> items) { | ||
this.items = items; | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
app/src/main/java/com/insta2apps/ibrahim/mfoodmenuapplication/data/source/Item.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.insta2apps.ibrahim.mfoodmenuapplication.data.source; | ||
|
||
import android.arch.persistence.room.Entity; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
/** | ||
* Created by Ibrahim AbdelGawad on 3/11/2018. | ||
*/ | ||
@Entity(tableName = "FoodMenuItem") | ||
public class Item extends BaseModel { | ||
@android.arch.persistence.room.PrimaryKey | ||
@SerializedName("id") | ||
private Integer id; | ||
@SerializedName("name") | ||
private String name; | ||
@SerializedName("photoUrl") | ||
private String photoUrl; | ||
@SerializedName("description") | ||
private String description; | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Integer id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getPhotoUrl() { | ||
return photoUrl; | ||
} | ||
|
||
public void setPhotoUrl(String photoUrl) { | ||
this.photoUrl = photoUrl; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...va/com/insta2apps/ibrahim/mfoodmenuapplication/data/source/database/room/AppDatabase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.insta2apps.ibrahim.mfoodmenuapplication.data.source.database.room; | ||
|
||
import android.arch.persistence.room.Database; | ||
import android.arch.persistence.room.RoomDatabase; | ||
|
||
import com.insta2apps.ibrahim.mfoodmenuapplication.data.source.Item; | ||
|
||
/** | ||
* Created by Ibrahim AbdelGawad on 3/12/2018. | ||
*/ | ||
@Database(entities = {Item.class}, version = AppDatabase.VERSION, exportSchema = false) | ||
public abstract class AppDatabase extends RoomDatabase { | ||
|
||
static final int VERSION = 1; | ||
|
||
public abstract FoodMenuItemDao getFoodMenuItemDao(); | ||
} |
Oops, something went wrong.