Commit c4860308 authored by Nadun K Bandara's avatar Nadun K Bandara

Merge remote-tracking branch 'origin/IT15006776-report-scan' into IT15006776-report-scan

parents cfe60c48 375de6e8
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.jachdev.consumerprotection"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
}
def retrofitVersion = '2.7.1'
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'com.google.android.gms:play-services-maps:18.0.0'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.jakewharton:butterknife:10.2.3'
implementation 'com.google.firebase:firebase-database:20.0.2'
implementation platform('com.google.firebase:firebase-bom:29.0.0')
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-moshi:$retrofitVersion"
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
implementation 'com.google.code.gson:gson:2.8.6'
compile 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'com.github.Pradyuman7:ChocoBar:V1.5'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation project(path: ':common-libs')
implementation 'com.github.esafirm.android-image-picker:imagepicker:2.2.0'
// for experimental rx picker
implementation 'com.github.esafirm.android-image-picker:rximagepicker:2.2.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'id.zelory:compressor:2.1.0'
implementation 'com.karumi:dexter:5.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.android.gms:play-services-safetynet:17.0.1'
implementation 'com.google.firebase:firebase-dynamic-links'
implementation 'com.google.firebase:firebase-analytics'
implementation 'org.tensorflow:tensorflow-android:1.2.0-preview'
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
notstudynotes
studynotes
phone
selfie
\ No newline at end of file
package com.jachdev.consumerprotection.data;
import com.google.gson.annotations.SerializedName;
import com.jachdev.consumerprotection.data.enums.UserType;
/**
* Created by Tharushaa on 9/20/2021.
*/
public class User {
private long id;
@SerializedName("user_type")
private int type;
@SerializedName("full_name")
private String name;
@SerializedName("email")
private String email;
@SerializedName("phone_number")
private String number;
@SerializedName("password")
private String password;
@SerializedName("birth_day")
private long birthDay;
@SerializedName("address")
private long address;
@SerializedName("gender")
private int gender;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public long getBirthDay() {
return birthDay;
}
public void setBirthDay(long birthDay) {
this.birthDay = birthDay;
}
public long getAddress() {
return address;
}
public void setAddress(long address) {
this.address = address;
}
public int getGender() {
return gender;
}
public void setGender(int gender) {
this.gender = gender;
}
public UserType getUserType(){
for (UserType type: UserType.values()) {
if (type.id == this.type) {
return type;
}
}
return UserType.CONSUMER;
}
@Override
public String toString() {
return "User{" +
"type=" + type +
", name='" + name + '\'' +
", email='" + email + '\'' +
", password='" + password + '\'' +
", birthDay=" + birthDay +
", address=" + address +
", gender=" + gender +
'}';
}
}
package com.jachdev.consumerprotection.data.enums;
/**
* Created by Tharushaa on 6/5/2021.
*/
public enum UserType {
CONSUMER(0), VENDOR(1), ADMIN(2);
UserType(int value) {
this.id = value;
switch (value){
case 0:
name = "Patient";
break;
case 1:
name = "Doctor";
break;
case 2:
name = "Admin";
break;
}
}
public int id;
public String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package com.jachdev.consumerprotection.network;
import com.jachdev.consumerprotection.AppConstant;
import com.jachdev.consumerprotection.data.AppResponse;
import com.jachdev.consumerprotection.data.Report;
import com.jachdev.consumerprotection.data.User;
import java.util.List;
import io.reactivex.Single;
import okhttp3.MultipartBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Query;
/**
* Created by Tharushaa on 9/20/2021.
*/
public interface ApiInterface {
@POST(AppConstant.PATH_SIGN_UP)
Single<AppResponse> signUp(@Body User user);
@POST(AppConstant.PATH_LOGIN)
Single<AppResponse> login(@Body User user);
@GET(AppConstant.PATH_GET_CATEGORIES)
Single<AppResponse> getCategories();
@POST(AppConstant.PATH_COMPLAINTS)
Single<AppResponse> complaints(@Body Report report);
@GET(AppConstant.PATH_GET_NOTIFICATIONS)
Single<AppResponse> getNotifications(@Query("uid") long uid);
}
package com.jachdev.consumerprotection.ui.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.jachdev.commonlibs.widget.CustomImageView;
import com.jachdev.commonlibs.widget.CustomTextView;
import com.jachdev.consumerprotection.R;
import com.jachdev.consumerprotection.data.FirebasePredictionData;
import com.jachdev.consumerprotection.data.Notification;
import com.jachdev.consumerprotection.util.Helper;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
* Created by Tharushaa on 7/30/2021.
*/
public class CommonAdaptor<T> extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
public static final int VIEW_TYPE_SHOP = R.layout.item_shop;
public static final int VIEW_TYPE_SHOP_MAP = R.layout.item_shop_map;
public static final int VIEW_TYPE_FIREBASE_PREDICTION = R.layout.item_prediction;
public static final int VIEW_TYPE_NOTIFICATION = R.layout.item_notification;
private Context context;
private CommonAdaptorCallback callback;
private final List<T> data;
private int viewType = 0;
public CommonAdaptor(Context context, List<T> data, CommonAdaptorCallback callback) {
viewType = VIEW_TYPE_SHOP;
this.context = context;
this.data = data;
this.callback = callback;
}
@Override
public @NotNull RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = null;
switch (viewType) {
case VIEW_TYPE_SHOP:
view = LayoutInflater.from(parent.getContext()).inflate(VIEW_TYPE_SHOP, parent, false);
return new ShopVH(view);
case VIEW_TYPE_SHOP_MAP:
view = LayoutInflater.from(parent.getContext()).inflate(VIEW_TYPE_SHOP_MAP, parent, false);
return new ShopMapVH(view);
case VIEW_TYPE_FIREBASE_PREDICTION:
view = LayoutInflater.from(parent.getContext()).inflate(VIEW_TYPE_FIREBASE_PREDICTION, parent, false);
return new PredictionVH(view);
case VIEW_TYPE_NOTIFICATION:
view = LayoutInflater.from(parent.getContext()).inflate(VIEW_TYPE_NOTIFICATION, parent, false);
return new NotificationVH(view);
default:
throw new IllegalArgumentException("Unexpected view type " + viewType);
}
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
T t = data.get(position);
switch (viewType){
case VIEW_TYPE_SHOP:
ShopVH vh = (ShopVH) holder;
vh.onBind((Shop) t, position);
break;
case VIEW_TYPE_SHOP_MAP:
ShopMapVH smvh = (ShopMapVH) holder;
smvh.onBind((AllShopResponse) t, position);
break;
case VIEW_TYPE_FIREBASE_PREDICTION:
PredictionVH pvh = (PredictionVH) holder;
pvh.onBind((FirebasePredictionData) t, position);
break;
case VIEW_TYPE_NOTIFICATION:
NotificationVH nvh = (NotificationVH) holder;
nvh.onBind((Notification) t, position);
break;
}
}
@Override
public int getItemCount() {
return data.size();
}
@Override
public int getItemViewType(int position) {
return viewType;
}
public void setViewType(int viewType) {
this.viewType = viewType;
}
public void add(T t) {
data.add(t);
notifyDataSetChanged();
}
public void remove(T t) {
data.remove(t);
notifyDataSetChanged();
}
public void update(int position, T t) {
data.add(position, t);
notifyDataSetChanged();
}
public void setItems(List<T> t) {
if (t == null) return;
this.data.clear();
this.data.addAll(t);
notifyDataSetChanged();
}
public List<T> getData() {
return data;
}
public void clearData() {
if(data!=null) {
data.clear();
notifyDataSetChanged();
}
}
public class NotificationVH extends RecyclerView.ViewHolder {
Context context;
@BindView(R.id.tvTitle)
CustomTextView tvTitle;
@BindView(R.id.tvContent)
CustomTextView tvContent;
int position;
public NotificationVH(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
context = itemView.getContext();
}
public void onBind(Notification item, int position) {
this.position = position;
tvTitle.setAnyText(item.getTitle());
tvContent.setAnyText(item.getDescription());
}
}
public class PredictionVH extends RecyclerView.ViewHolder {
Context context;
@BindView(R.id.tvTitle)
CustomTextView tvTitle;
@BindView(R.id.tvValue)
CustomTextView tvValue;
@BindView(R.id.tvMinMax)
CustomTextView tvMinMax;
int position;
public PredictionVH(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
context = itemView.getContext();
}
public void onBind(FirebasePredictionData item, int position) {
this.position = position;
tvTitle.setAnyText(item.getName());
tvValue.setCurrency("Rs", item.getRate());
String min = String.valueOf(item.getMin());
String max = String.valueOf(item.getMax());
tvMinMax.setAnyText(context.getString(R.string.min_max_ratio_10_100, min, max));
}
}
public class ShopVH extends RecyclerView.ViewHolder {
@BindView(R.id.tvShopName)
CustomTextView tvShopName;
@BindView(R.id.tvShopAddress)
CustomTextView tvShopAddress;
int position;
public ShopVH(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
public void onBind(Shop item, int position) {
this.position = position;
tvShopName.setAnyText(item.getName());
tvShopAddress.setText(item.getAddress());
}
@OnClick(R.id.btnCall)
void onCallClick(){
Shop shop = (Shop) data.get(position);
Helper.call(itemView.getContext(), shop.getPhoneNumber());
}
}
public class ShopMapVH extends RecyclerView.ViewHolder {
@BindView(R.id.iv_logo)
CustomImageView iv_logo;
@BindView(R.id.tvShopName)
CustomTextView tvShopName;
@BindView(R.id.tvOrganization)
CustomTextView tvOrganization;
@BindView(R.id.tvDescription)
CustomTextView tvDescription;
@BindView(R.id.tvShopAddress)
CustomTextView tvShopAddress;
int position;
public ShopMapVH(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(callback != null)
callback.onView(VIEW_TYPE_SHOP_MAP, position);
}
});
}
public void onBind(AllShopResponse item, int position) {
this.position = position;
Helper.loadImageByUrl(iv_logo, item.getLogo());
tvShopName.setAnyText(item.getName() + " - " + item.getDistance());
tvOrganization.setAnyText(item.getOrgName());
tvDescription.setAnyText(item.getDescription());
tvShopAddress.setText(item.getAddress());
}
@OnClick(R.id.btnCall)
void onCallClick(){
AllShopResponse shop = (AllShopResponse) data.get(position);
Helper.call(itemView.getContext(), shop.getPhoneNumber());
}
}
public interface CommonAdaptorCallback {
void onView(int viewType, int position);
}
}
package com.jachdev.consumerprotection.ui.home;
import android.util.Log;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.jachdev.consumerprotection.AppApplication;
import com.jachdev.consumerprotection.data.AppResponse;
import com.jachdev.consumerprotection.data.FirebasePredictionData;
import com.jachdev.consumerprotection.data.User;
import com.jachdev.consumerprotection.network.AppService;
import com.jachdev.consumerprotection.util.SessionManager;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Type;
import java.util.HashMap;
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import io.reactivex.SingleObserver;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
public class HomeViewModel extends ViewModel {
private static final String TAG = HomeViewModel.class.getSimpleName();
private MutableLiveData<User> mUser;
private MutableLiveData<Organization> mOrganization;
private MutableLiveData<HashMap<String, FirebasePredictionData>> salesPredictionData;
private MutableLiveData<HashMap<String, FirebasePredictionData>> pricePredictionData;
private MutableLiveData<HashMap<String, FirebasePredictionData>> importPredictionData;
private FirebaseDatabase database;
private SessionManager sessionManager;
private AppService service;
public HomeViewModel() {
sessionManager = SessionManager.getInstance();
service = AppApplication.getInstance().getAppService();
mUser = new MutableLiveData<User>();
mUser.postValue(sessionManager.getUser());
database = FirebaseDatabase.getInstance();
}
public LiveData<User> getUser() {
return mUser;
}
public LiveData<Organization> getOrganization() {
mOrganization = new MutableLiveData<>();
service.getServer().getOrganization(sessionManager.getUser().getId())
.subscribeOn(Schedulers.io())
.subscribe(new SingleObserver<AppResponse>() {
@Override
public void onSubscribe(@NotNull Disposable d) {
Log.d(TAG, "onSubscribe: ");
}
@Override
public void onSuccess(@NotNull AppResponse response) {
switch (response.getCode()){
case 0:
Organization organization = response.getObjectToType(Organization.class);
SessionManager.getInstance().setOrganization(organization);
mOrganization.postValue(organization);
break;
default:
mOrganization.postValue(null);
break;
}
}
@Override
public void onError(@NotNull Throwable e) {
mOrganization.postValue(null);
}
});
return mOrganization;
}
public LiveData<HashMap<String, FirebasePredictionData>> getSalesPredictionData() {
DatabaseReference ref = database.getReference("sales");
salesPredictionData = new MutableLiveData<>();
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull @NotNull DataSnapshot snapshot) {
Gson gson = new Gson();
String json = gson.toJson(snapshot.getValue());
Type empMapType = new TypeToken<HashMap<String, FirebasePredictionData>>() {}.getType();
HashMap<String, FirebasePredictionData> value = gson.fromJson(json, empMapType);
salesPredictionData.postValue(value);
}
@Override
public void onCancelled(@NonNull @NotNull DatabaseError error) {
salesPredictionData.postValue(null);
}
});
return salesPredictionData;
}
public LiveData<HashMap<String, FirebasePredictionData>> getPricePredictionData() {
DatabaseReference ref = database.getReference("price");
pricePredictionData = new MutableLiveData<>();
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull @NotNull DataSnapshot snapshot) {
Gson gson = new Gson();
String json = gson.toJson(snapshot.getValue());
Type empMapType = new TypeToken<HashMap<String, FirebasePredictionData>>() {}.getType();
HashMap<String, FirebasePredictionData> value = gson.fromJson(json, empMapType);
pricePredictionData.postValue(value);
}
@Override
public void onCancelled(@NonNull @NotNull DatabaseError error) {
pricePredictionData.postValue(null);
}
});
return pricePredictionData;
}
public LiveData<HashMap<String, FirebasePredictionData>> getImportPredictionData() {
DatabaseReference ref = database.getReference("imports");
importPredictionData = new MutableLiveData<>();
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull @NotNull DataSnapshot snapshot) {
Gson gson = new Gson();
String json = gson.toJson(snapshot.getValue());
Type empMapType = new TypeToken<HashMap<String, FirebasePredictionData>>() {}.getType();
HashMap<String, FirebasePredictionData> value = gson.fromJson(json, empMapType);
importPredictionData.postValue(value);
}
@Override
public void onCancelled(@NonNull @NotNull DatabaseError error) {
importPredictionData.postValue(null);
}
});
return importPredictionData;
}
}
\ No newline at end of file
package com.jachdev.consumerprotection.util;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Environment;
import android.widget.ImageView;
import com.jachdev.commonlibs.utils.DateTimeUtil;
import com.jachdev.consumerprotection.BuildConfig;
import com.pd.chocobar.ChocoBar;
import com.squareup.picasso.Picasso;
import java.io.File;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import id.zelory.compressor.Compressor;
/**
* Created by Tharushaa on 9/20/2021.
*/
public class Helper {
public static File compressToFile(Context context, File file) {
Compressor compressor = new Compressor(context);
compressor.setQuality(75);
File compressedFile = null;
try{
compressedFile = compressor.compressToFile(file);
}catch (Exception e){
e.printStackTrace();
}
return compressedFile;
}
public static void loadImageByFilePath(ImageView view, String path) {
if (path == null)
return;
File f = new File(path);
Picasso.get().load(f).into(view);
}
public static void loadImageByUrl(ImageView view, String path) {
if (path == null )
return;
File file = new File(path);
if (file.isFile()) {
Picasso.get()
.load(file)
.into(view);
} else {
Picasso.get()
.load(path)
.into(view);
}
view.setScaleType(ImageView.ScaleType.CENTER_CROP);
}
public static void call(Context context, String phone) {
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone));
context.startActivity(intent);
}
public static long dateTimeToUnix(String date) {
if (date == null || date.isEmpty())
date = DateTimeUtil.convertUnixToCustomFormat(DateTimeUtil.DATE_FORMAT_3);
try {
DateFormat dateFormat = new SimpleDateFormat(DateTimeUtil.DATE_FORMAT_3, Locale.getDefault());
Date dateObject = dateFormat.parse(date);
return (dateObject.getTime());
} catch (ParseException e) {
e.printStackTrace();
return System.currentTimeMillis();
}
}
public static String distance(double lat1, double lon1, double lat2, double lon2) {
double theta = lon1 - lon2;
double dist = Math.sin(deg2rad(lat1))
* Math.sin(deg2rad(lat2))
+ Math.cos(deg2rad(lat1))
* Math.cos(deg2rad(lat2))
* Math.cos(deg2rad(theta));
dist = Math.acos(dist);
dist = rad2deg(dist);
dist = dist * 60 * 1.1515;
if(dist < 1){
double distkm = milesTokm(dist);
if(distkm < 1){
return com.jachdev.commonlibs.utils.Helper.toCurrencyFormat(kmTom(distkm)) + "meters";
}
return com.jachdev.commonlibs.utils.Helper.toCurrencyFormat(milesTokm(dist)) + "km";
} else{
return com.jachdev.commonlibs.utils.Helper.toCurrencyFormat(dist) + "miles";
}
}
private static double deg2rad(double deg) {
return (deg * Math.PI / 180.0);
}
private static double rad2deg(double rad) {
return (rad * 180.0 / Math.PI);
}
private static double milesTokm(double distanceInMiles) {
return distanceInMiles * 1.60934;
}
private static double kmTom(double distanceInKm) {
return distanceInKm / 1000.0;
}
}
package com.jachdev.consumerprotection.util;
import android.util.Log;
import com.jachdev.commonlibs.utils.ContextManager;
import com.jachdev.commonlibs.utils.TinyDb;
import com.jachdev.consumerprotection.data.User;
/**
* singleton java class
* https://medium.com/@kevalpatel2106/how-to-make-the-perfect-singleton-de6b951dfdb0
*/
public class SessionManager {
private static volatile SessionManager sessionManagerInstance;
private static final String TAG = SessionManager.class.getName();
private static final String PACKAGE_NAME = SessionManager.class.getPackage() + ".";
private static final String KEY_USER = PACKAGE_NAME + "KEY_USER";
private static final String KEY_ORG = PACKAGE_NAME + "KEY_ORG";
private static final String KEY_LOGGED_IN = PACKAGE_NAME + "KEY_LOGGED_IN";
private TinyDb mTinyDB;
private SessionManager() {
mTinyDB = new TinyDb(ContextManager.getInstance());
//Prevent form the reflection api.
if (sessionManagerInstance != null) {
mTinyDB = new TinyDb(ContextManager.getInstance());
throw new RuntimeException("Use getInstance() method to get the single instance of this class.");
}
}
public static SessionManager getInstance() {
//Double check locking pattern
if (sessionManagerInstance == null) { //Check for the first time
synchronized (SessionManager.class) { //Check for the second time.
//if there is no instance available... create new one
if (sessionManagerInstance == null)
sessionManagerInstance = new SessionManager();
}
}
return sessionManagerInstance;
}
/**
* Logout user
*/
public void logoutSession() {
Log.d(TAG, "logoutSession");
try{
mTinyDB.remove(KEY_USER);
mTinyDB.remove(KEY_ORG);
mTinyDB.remove(KEY_LOGGED_IN);
}catch (Exception e){
e.printStackTrace();
}
}
public void setUser(User user) {
mTinyDB.putObject(KEY_USER, user);
}
public User getUser() {
return mTinyDB.getObject(KEY_USER, User.class);
}
public void setLoggedIn(boolean status) {
mTinyDB.putBoolean(KEY_LOGGED_IN, status);
}
public boolean isLoggedIn() {
return mTinyDB.getBoolean(KEY_LOGGED_IN);
}
public void setOrganization(Organization organization) {
mTinyDB.putObject(KEY_ORG, organization);
}
public Organization getOrganization() {
return mTinyDB.getObject(KEY_ORG, Organization.class);
}
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://www.jitpack.io'
}
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.2"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://www.jitpack.io'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
\ No newline at end of file
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
\ No newline at end of file
#Sat May 29 15:51:23 IST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
include ':common-libs'
include ':app'
project(':common-libs').projectDir = new File(rootDir, 'android-common-libs/common-libs/')
rootProject.name = "Consumer Protection"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment