Skip to content

Commit

Permalink
first commit after about 2 mounth. Today I create Api ServiceGenerato…
Browse files Browse the repository at this point in the history
…r and RentalHouseApi classes.
  • Loading branch information
iMohamadAmin committed Nov 29, 2018
1 parent a5843ba commit a5e63da
Show file tree
Hide file tree
Showing 20 changed files with 250 additions and 37 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
8 changes: 0 additions & 8 deletions .idea/dictionaries/Amin.xml

This file was deleted.

10 changes: 7 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,17 @@ dependencies {
implementation 'me.relex:circleindicator:1.2.2@aar'
implementation 'com.orhanobut:dialogplus:1.11@aar'
implementation 'co.ronash.android:pushe-base:1.4.0'
implementation 'com.google.android.gms:play-services-gcm:11.8.0'
implementation 'com.google.android.gms:play-services-location:11.8.0'
implementation 'com.google.android.gms:play-services-gcm:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.aldoapps:autoformatedittext:0.9.3'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.11.0'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<!-- Optional permissions -->
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:name=".App.MyApplication"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import android.widget.SeekBar;
import android.widget.Toast;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.orhanobut.dialogplus.DialogPlus;
import com.orhanobut.dialogplus.ViewHolder;
import com.yarolegovich.slidingrootnav.SlideGravity;
Expand All @@ -37,6 +39,8 @@
import mohamadamin.soft.com.rentalhouseproject.PagerTransformers.SimpleCardsPagerTransformer;
import mohamadamin.soft.com.rentalhouseproject.Adapters.HousesViewPagerAdapter;
import mohamadamin.soft.com.rentalhouseproject.R;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;

public class MainActivity extends AppCompatActivity
Expand All @@ -53,7 +57,7 @@ public class MainActivity extends AppCompatActivity
private CircleIndicator IndicatorMain;
private final int SlidingDelay = 3000;
private DialogPlus filterDialog;

public static final String BASE_URL = "http://api.myservice.com/";

@Override
protected void attachBaseContext(Context newBase)
Expand Down Expand Up @@ -92,6 +96,16 @@ protected void onCreate(Bundle savedInstanceState)
setupChangeItemsSeekBar();
setupFilterDialog();
Pushe.initialize(this,true);


Gson gson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
.create();

Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
}

private void initializeComponents()
Expand Down Expand Up @@ -212,15 +226,6 @@ public void openDrawerMenu(View view)
DrawerMenu.openMenu(true);
}

public void openSlidingFilter(View view)
{
if (DrawerMenu.isMenuOpened())
{
DrawerMenu.closeMenu();
}
SlidingFilter.openMenu(true);
}

private void slide()
{
if (currentPage == MainSliderViewPager.getAdapter().getCount())
Expand Down Expand Up @@ -261,11 +266,13 @@ private void setupFilterDialog()

public void goToOwnerManagement(View view)
{
DrawerMenu.closeMenu(true);
startActivity(new Intent(MainActivity.this, OwnerManagementActivity.class));
}

public void goToOwnerRegistration(View view)
{
DrawerMenu.closeMenu(true);
startActivity(new Intent(MainActivity.this, OwnerRegistrationActivity.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ private void initViews(View view)
{
btnAddHouse = view.findViewById(R.id.btn_add_house);
recOwnerHouseList = view.findViewById(R.id.rec_OwnerHouseList);
//-------------
VectorDrawablePreLollipopHelper.SetVectors(getResources(), new VectorView(R.drawable.ic_add_house, btnAddHouse, VectorDrawablePreLollipopHelper.MyDirType.end));
LoadUpOwnerHouseList();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package mohamadamin.soft.com.rentalhouseproject.Models;

public class ActiveUserModel
{
public String UserMobileNumber;
public String UserActiveCode;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package mohamadamin.soft.com.rentalhouseproject.Models;

public class FilterModel
{
public String Zone;
public int FromMortgage;
public int ToMortgage;
public int FromRent;
public int ToRent;
public int Type;
public int Gender;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package mohamadamin.soft.com.rentalhouseproject.Models;

public class LoginUserModel
{
public String UserMobileNumber;
public String UserPassword;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package mohamadamin.soft.com.rentalhouseproject.Models;

public class RegisterUserModel
{
public static final int UserSignedUp = 3;
public static final int UserActivated = 2;
public static final int UserNotActivated = 1;
public static final int UserExist = 0;
public static final int UserNotExist = -1;

public String UserFirstName;
public String UserLastName;
public int UserStateCode;
public int UserCityCode ;
public int UserRole;
public String UserMobileNumber;
public String UserPassword;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package mohamadamin.soft.com.rentalhouseproject.Models;

public class Slide {

private String SliderTitle;
private String SliderImage;

public String getSliderTitle() {
return SliderTitle;
}

public String getSliderImage() {
return SliderImage;
}

public void setSliderTitle(String sliderTitle) {
SliderTitle = sliderTitle;
}

public void setSliderImage(String sliderImage) {
SliderImage = sliderImage;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package mohamadamin.soft.com.rentalhouseproject.ServerApi;

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

import java.io.IOException;
import java.util.concurrent.TimeUnit;

import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class ApiServiceGenerator {

private static Retrofit RetrofitInstance;
private static Gson GsonInstance;
private static OkHttpClient Client;
private static OkHttpClient.Builder HttpClient;
private final static String BASE_URL = "http://rentalhouse.aryasoft.org/";

public static RentalHouseApi getApiService()
{
initializeComponents();
return RetrofitInstance.create(RentalHouseApi.class);
}

private static void initializeComponents()
{
if(HttpClient == null)
{
initializeHttpClient();
}
if (Client == null)
{
Client = HttpClient.build();
}
if (GsonInstance == null)
{
GsonInstance = new GsonBuilder().setLenient().serializeNulls().create();
}
if (RetrofitInstance == null)
{
initializeRetrofit();
}
}

private static void initializeHttpClient()
{
HttpClient = new OkHttpClient.Builder()
.retryOnConnectionFailure(true)
.connectTimeout(60, TimeUnit.SECONDS)
.writeTimeout(60, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS);
}

private static void initializeRetrofit()
{
RetrofitInstance = new Retrofit.Builder()
.baseUrl(BASE_URL)
.client(Client)
.addConverterFactory(GsonConverterFactory.create(GsonInstance))
.build();
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package mohamadamin.soft.com.rentalhouseproject.ServerApi;

import java.util.List;

import mohamadamin.soft.com.rentalhouseproject.Models.ActiveUserModel;
import mohamadamin.soft.com.rentalhouseproject.Models.FilterModel;
import mohamadamin.soft.com.rentalhouseproject.Models.House;
import mohamadamin.soft.com.rentalhouseproject.Models.LoginUserModel;
import mohamadamin.soft.com.rentalhouseproject.Models.RegisterUserModel;
import mohamadamin.soft.com.rentalhouseproject.Models.SecondaryHouse;
import mohamadamin.soft.com.rentalhouseproject.Models.Slide;
import mohamadamin.soft.com.rentalhouseproject.Models.SliderModel;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;

public interface RentalHouseApi {

@Headers("User-Agent: <RentalHouse>")
@GET("Api/HouseApi/GetHouseSliders")
Call<List<Slide>> getSlides();

@Headers("User-Agent: <RentalHouse>")
@POST("Api/HouseApi/SearchHouse")
Call<List<Slide>> searchHouse(String searchTerm, int skipItem, int takeItem);/*???*/

@Headers("User-Agent: <RentalHouse>")
@GET("Api/HouseApi/GetHouseDetails")
Call<List<House>> getHouseDetails(@Query("houseId")int houseId);/*3???*/

@Headers("User-Agent: <RentalHouse>")
@GET("Api/HouseApi/GetAllHouses")
Call<List<SecondaryHouse>> getAllHouses(@Query("houseId")int skipNumber, @Query("houseId")int takeNumber);

@Headers("User-Agent: <RentalHouse>")
@GET("Api/HouseApi/GetHousesWithFilter")
Call<List<SecondaryHouse>> getHousesWithFilter(FilterModel filter, int skipNumber, int takeNumber);/*???*/

@Headers("User-Agent: <RentalHouse>")
@POST("Api/RegisterationApi/RegisterUser")
Call<Integer> signUp(@Body RegisterUserModel registerUserModel);/*???*/
/*Conditions:
If Success=> return ActiveCode and SMS ActiveCode;
ELSE => RegisterUserState(ENUM)*/

@Headers("User-Agent: <RentalHouse>")
@POST("Api/RegisterationApi/LoginUser")
Call<Integer> signIn(@Body LoginUserModel loginUserObject);
/*IF UserExistAnd Active THEN
IF USERNAME AND PASSWORD ARE CORRECT THEN
return user.UserId;
ELSE
return 0;//password incorrect
ELSE => RegisterUserState(ENUM)*/

@Headers("User-Agent: <RentalHouse>")
@POST("Api/RegisterationApi/ActiveUser")
Call<Boolean> activeUser(@Body ActiveUserModel activeUserObject);

@Headers("User-Agent: <RentalHouse>")
@POST("Api/RegisterationApi/GenerateActiveCode")
Call<Integer> generateActivationCode(@Query("") String userMobileNumber);
/*CONDITION->LIKE ARACHOOB*/

}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
app:cardCornerRadius="10dp"
app:cardCornerRadius="1dp"
app:cardElevation="3dp">


Expand Down
Loading

0 comments on commit a5e63da

Please sign in to comment.