From 95235eff1acf295c91ac3179b88e8253f09925ef Mon Sep 17 00:00:00 2001 From: Divya Raj Date: Fri, 30 Mar 2018 16:40:08 +0530 Subject: [PATCH] Firebase offline persistence removed --- app/build.gradle | 4 +-- app/src/main/AndroidManifest.xml | 3 +-- .../com/unipool/UniPool.java | 16 ------------ .../com/unipool/activities/BaseActivity.java | 5 ---- .../com/unipool/activities/HomeActivity.java | 7 ++++- .../activities/MessageListActivity.java | 2 -- .../unipool/activities/NewEntryActivity.java | 26 ++++++++----------- .../unipool/activities/SplashActivity.java | 5 ---- app/src/main/res/layout/activity_about.xml | 10 +++++++ 9 files changed, 30 insertions(+), 48 deletions(-) delete mode 100644 app/src/main/java/garbagecollectors/com/unipool/UniPool.java diff --git a/app/build.gradle b/app/build.gradle index d53d7d7..87d61d8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,8 +16,8 @@ android { applicationId 'garbagecollectors.com.unipool' minSdkVersion 16 targetSdkVersion 27 - versionCode 4 - versionName "1.04" + versionCode 6 + versionName "1.06" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true //important diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d4c7d6f..58295c8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,8 +12,7 @@ android:largeHeap="true" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/AppTheme" - android:name=".UniPool"> + android:theme="@style/AppTheme"> diff --git a/app/src/main/java/garbagecollectors/com/unipool/UniPool.java b/app/src/main/java/garbagecollectors/com/unipool/UniPool.java deleted file mode 100644 index 7d5f7a1..0000000 --- a/app/src/main/java/garbagecollectors/com/unipool/UniPool.java +++ /dev/null @@ -1,16 +0,0 @@ -package garbagecollectors.com.unipool; - -import android.app.Application; - -import com.google.firebase.database.FirebaseDatabase; - -public class UniPool extends Application -{ - @Override - public void onCreate() - { - super.onCreate(); - - FirebaseDatabase.getInstance().setPersistenceEnabled(true); - } -} diff --git a/app/src/main/java/garbagecollectors/com/unipool/activities/BaseActivity.java b/app/src/main/java/garbagecollectors/com/unipool/activities/BaseActivity.java index b46b875..90cd7fa 100644 --- a/app/src/main/java/garbagecollectors/com/unipool/activities/BaseActivity.java +++ b/app/src/main/java/garbagecollectors/com/unipool/activities/BaseActivity.java @@ -85,11 +85,6 @@ protected void onCreate(Bundle savedInstanceState) userDatabaseReference = FirebaseDatabase.getInstance().getReference("users/" + finalCurrentUser.getUserId()); userMessageDatabaseReference = FirebaseDatabase.getInstance().getReference("messages/" + finalCurrentUser.getUserId()); - entryDatabaseReference.keepSynced(true); - pairUpDatabaseReference.keepSynced(true); - userDatabaseReference.keepSynced(true); - userMessageDatabaseReference.keepSynced(true); - MessageDBTask.addOnCompleteListener(task -> { DataSnapshot messageData = (DataSnapshot) MessageDBTask.getResult(); diff --git a/app/src/main/java/garbagecollectors/com/unipool/activities/HomeActivity.java b/app/src/main/java/garbagecollectors/com/unipool/activities/HomeActivity.java index e1a3712..c7edab8 100644 --- a/app/src/main/java/garbagecollectors/com/unipool/activities/HomeActivity.java +++ b/app/src/main/java/garbagecollectors/com/unipool/activities/HomeActivity.java @@ -42,7 +42,6 @@ protected void onCreate(Bundle savedInstanceState) drawerLayout = findViewById(R.id.home_layout); noEntryRelativeLayout = findViewById(R.id.no_entry_message); - noEntryRelativeLayout.setVisibility(View.INVISIBLE); navDrawerStateListener(); @@ -60,6 +59,12 @@ protected void onCreate(Bundle savedInstanceState) recycle = findViewById(R.id.recycle); + if(tripEntryList.isEmpty()) + noEntryRelativeLayout.setVisibility(View.VISIBLE); + + else + noEntryRelativeLayout.setVisibility(View.INVISIBLE); + recyclerAdapter = new HomeActivityTEA(tripEntryList,HomeActivity.this); RecyclerView.LayoutManager layoutManager = new GridLayoutManager(HomeActivity.this,1); diff --git a/app/src/main/java/garbagecollectors/com/unipool/activities/MessageListActivity.java b/app/src/main/java/garbagecollectors/com/unipool/activities/MessageListActivity.java index 62e4f61..d81f330 100644 --- a/app/src/main/java/garbagecollectors/com/unipool/activities/MessageListActivity.java +++ b/app/src/main/java/garbagecollectors/com/unipool/activities/MessageListActivity.java @@ -67,8 +67,6 @@ protected void onCreate(Bundle savedInstanceState) DatabaseReference userMessageDatabaseReference = FirebaseDatabase.getInstance(). getReference("messages/" + BaseActivity.getFinalCurrentUser().getUserId()); - userMessageDatabaseReference.keepSynced(true); - userMessageDatabaseReference.addChildEventListener(new ChildEventListener() { @Override diff --git a/app/src/main/java/garbagecollectors/com/unipool/activities/NewEntryActivity.java b/app/src/main/java/garbagecollectors/com/unipool/activities/NewEntryActivity.java index d63cb41..fe136f1 100644 --- a/app/src/main/java/garbagecollectors/com/unipool/activities/NewEntryActivity.java +++ b/app/src/main/java/garbagecollectors/com/unipool/activities/NewEntryActivity.java @@ -190,19 +190,28 @@ public void onTimeSet(TimePicker view, int hourOfDay, int minute) }; public void findSource(View view) + { + showPlaceAutocomplete(1); + } + + public void findDestination(View view) + { + showPlaceAutocomplete(2); + } + + private void showPlaceAutocomplete(int i) { try { Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY) .build(this); - startActivityForResult(intent, 1); + startActivityForResult(intent, i); } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) { Toast.makeText(this, "Google Play Service Error!", Toast.LENGTH_SHORT).show(); } - } // A place has been received; use requestCode to track the request. @@ -251,19 +260,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) } } - public void findDestination(View view) - { - try - { - Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY) - .build(this); - startActivityForResult(intent, 2); - } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) - { - Toast.makeText(this, "Google Play Service Error!", Toast.LENGTH_SHORT).show(); - } - } - public void finalSave(View view) throws ParseException { switch (checkInvalidEntry()) diff --git a/app/src/main/java/garbagecollectors/com/unipool/activities/SplashActivity.java b/app/src/main/java/garbagecollectors/com/unipool/activities/SplashActivity.java index 662f8e8..032e6df 100644 --- a/app/src/main/java/garbagecollectors/com/unipool/activities/SplashActivity.java +++ b/app/src/main/java/garbagecollectors/com/unipool/activities/SplashActivity.java @@ -72,11 +72,6 @@ protected void onCreate(Bundle savedInstanceState) messageDatabaseReference = FirebaseDatabase.getInstance().getReference("messages/" + currentUser.getUid()); - userDatabaseReference.keepSynced(true); - messageDatabaseReference.keepSynced(true); - entryDatabaseReference.keepSynced(true); - - new Handler().postDelayed(() -> delaySource.setResult(null), 2350); userDatabaseReference.addListenerForSingleValueEvent(new ValueEventListener() diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index f5b718c..afb84f3 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -124,9 +124,19 @@ android:onClick="onClickAbout" android:text="@string/saurabh_gangadharan"/> + +