Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
21-22j-049
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
21-22J-049
21-22j-049
Commits
cfe60c48
Commit
cfe60c48
authored
May 16, 2022
by
Nadun K Bandara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code refactor
parent
4036c418
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
208 deletions
+0
-208
app/src/main/java/com/jachdev/consumerprotection/AppApplication.java
...n/java/com/jachdev/consumerprotection/AppApplication.java
+0
-43
app/src/main/java/com/jachdev/consumerprotection/AppConstant.java
...main/java/com/jachdev/consumerprotection/AppConstant.java
+0
-23
app/src/main/java/com/jachdev/consumerprotection/data/AppResponse.java
...java/com/jachdev/consumerprotection/data/AppResponse.java
+0
-57
app/src/main/java/com/jachdev/consumerprotection/network/AppService.java
...va/com/jachdev/consumerprotection/network/AppService.java
+0
-85
No files found.
app/src/main/java/com/jachdev/consumerprotection/AppApplication.java
deleted
100644 → 0
View file @
4036c418
package
com.jachdev.consumerprotection
;
import
android.app.Application
;
import
com.jachdev.consumerprotection.network.AppService
;
/**
* Created by Tharushaa on 9/20/2021.
*/
public
class
AppApplication
extends
Application
{
public
static
volatile
AppApplication
mApplication
;
private
AppService
mAppService
;
@Override
public
void
onCreate
()
{
super
.
onCreate
();
mApplication
=
this
;
mAppService
=
AppService
.
getInstance
();
}
/**
* this is Singleton class
* @return : application class
*/
public
static
AppApplication
getInstance
()
{
//Double check locking pattern
if
(
mApplication
==
null
)
{
//Check for the first time
synchronized
(
AppApplication
.
class
)
{
//Check for the second time.
//if there is no instance available... create new one
if
(
mApplication
==
null
)
mApplication
=
new
AppApplication
();
}
}
return
mApplication
;
}
public
AppService
getAppService
()
{
return
mAppService
;
}
}
app/src/main/java/com/jachdev/consumerprotection/AppConstant.java
deleted
100644 → 0
View file @
4036c418
package
com.jachdev.consumerprotection
;
/**
* Created by Tharushaa on 9/20/2021.
*/
public
class
AppConstant
{
public
static
final
String
BASE_URL
=
"http://192.168.1.4:5000/"
;
public
static
final
String
PATH_SIGN_UP
=
"register"
;
public
static
final
String
PATH_LOGIN
=
"login"
;
public
static
final
String
PATH_GET_CATEGORIES
=
"getCategories"
;
public
static
final
String
PATH_GET_ORGANIZATION
=
"getOrganization"
;
public
static
final
String
PATH_ADD_ORGANIZATION
=
"addOrganization"
;
public
static
final
String
PATH_ADD_SHOP
=
"addShop"
;
public
static
final
String
PATH_GET_SHOP
=
"getShops"
;
public
static
final
String
PATH_GET_ESSENTIALS
=
"getEssentials"
;
public
static
final
String
PATH_COMPLAINTS
=
"complaints"
;
public
static
final
String
PATH_GET_ALL_SHOPS
=
"getAllShops"
;
public
static
final
String
PATH_GET_NOTIFICATIONS
=
"getNotifications"
;
public
static
final
String
ORG_LOGO_KEY
=
"logo"
;
public
static
final
int
IMAGE_LIMIT
=
1
;
public
static
final
String
IMAGE_PATH
=
"img/"
;
}
app/src/main/java/com/jachdev/consumerprotection/data/AppResponse.java
deleted
100644 → 0
View file @
4036c418
package
com.jachdev.consumerprotection.data
;
import
com.google.gson.Gson
;
/**
* Created by Tharushaa on 9/20/2021.
*/
public
class
AppResponse
{
private
int
code
;
private
String
message
;
private
Object
data
;
public
int
getCode
()
{
return
code
;
}
public
void
setCode
(
int
code
)
{
this
.
code
=
code
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
<
T
>
T
getObjectToType
(
Class
<
T
>
t
)
{
try
{
Gson
gson
=
new
Gson
();
String
json
=
gson
.
toJson
(
data
);
Object
value
=
new
Gson
().
fromJson
(
json
,
t
);
return
(
T
)
value
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
null
;
}
public
<
T
>
T
getObjectToType
(
String
stringJson
,
Class
<
T
>
t
)
{
try
{
Gson
gson
=
new
Gson
();
Object
value
=
new
Gson
().
fromJson
(
stringJson
,
t
);
return
(
T
)
value
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
null
;
}
public
void
setData
(
Object
data
)
{
this
.
data
=
data
;
}
}
app/src/main/java/com/jachdev/consumerprotection/network/AppService.java
deleted
100644 → 0
View file @
4036c418
package
com.jachdev.consumerprotection.network
;
import
com.jachdev.consumerprotection.AppApplication
;
import
com.jachdev.consumerprotection.AppConstant
;
import
org.jetbrains.annotations.NotNull
;
import
java.io.IOException
;
import
okhttp3.HttpUrl
;
import
okhttp3.Interceptor
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.Response
;
import
okhttp3.logging.HttpLoggingInterceptor
;
import
retrofit2.Retrofit
;
import
retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
;
import
retrofit2.converter.gson.GsonConverterFactory
;
/**
* Created by Tharushaa on 9/20/2021.
*/
public
class
AppService
{
private
static
final
String
BASE_URL
=
AppConstant
.
BASE_URL
;
public
static
volatile
AppService
service
;
private
Retrofit
server
;
public
AppService
()
{
server
=
provideRetrofit
();
}
/**
* this is Singleton class
* @return : application class
*/
public
static
AppService
getInstance
()
{
//Double check locking pattern
if
(
service
==
null
)
{
//Check for the first time
synchronized
(
AppService
.
class
)
{
//Check for the second time.
//if there is no instance available... create new one
if
(
service
==
null
)
service
=
new
AppService
();
}
}
return
service
;
}
private
Retrofit
provideRetrofit
(){
HttpLoggingInterceptor
interceptor
=
new
HttpLoggingInterceptor
();
interceptor
.
level
(
HttpLoggingInterceptor
.
Level
.
BODY
);
Interceptor
queryInterceptor1
=
new
Interceptor
()
{
@NotNull
@Override
public
Response
intercept
(
@NotNull
Chain
chain
)
throws
IOException
{
Request
request
=
chain
.
request
();
HttpUrl
url
=
request
.
url
().
newBuilder
().
build
();
request
=
request
.
newBuilder
().
url
(
url
).
build
();
return
chain
.
proceed
(
request
);
}
};
OkHttpClient
client
=
new
OkHttpClient
.
Builder
()
// .connectTimeout(120, TimeUnit.SECONDS)
.
addInterceptor
(
interceptor
)
.
addInterceptor
(
queryInterceptor1
)
.
build
();
return
new
Retrofit
.
Builder
().
baseUrl
(
BASE_URL
)
.
addCallAdapterFactory
(
RxJava2CallAdapterFactory
.
create
())
.
addConverterFactory
(
GsonConverterFactory
.
create
())
.
client
(
client
)
.
build
();
}
private
ApiInterface
provideRetrofitService
(
Retrofit
retrofit
){
return
retrofit
.
create
(
ApiInterface
.
class
);
}
public
ApiInterface
getServer
()
{
return
provideRetrofitService
(
server
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment