Commit 1e242b79 authored by Sajal Narang's avatar Sajal Narang Committed by GitHub

Merge pull request #131 from pulsejet/myeventsperf

Fix performance of my events
parents dd920711 135d2321
...@@ -13,6 +13,9 @@ public interface DbDao { ...@@ -13,6 +13,9 @@ public interface DbDao {
@Query("SELECT * FROM events") @Query("SELECT * FROM events")
List<Event> getAllEvents(); List<Event> getAllEvents();
@Query("SELECT * FROM events WHERE user_ues <> 0")
List<Event> getFollowingEvents();
@Query("SELECT * FROM bodies") @Query("SELECT * FROM bodies")
List<Body> getAllBodies(); List<Body> getAllBodies();
......
...@@ -17,6 +17,7 @@ import android.view.ViewGroup; ...@@ -17,6 +17,7 @@ import android.view.ViewGroup;
import com.google.gson.Gson; import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import app.insti.ActivityBuffer; import app.insti.ActivityBuffer;
...@@ -103,6 +104,7 @@ public class MyEventsFragment extends BaseFragment { ...@@ -103,6 +104,7 @@ public class MyEventsFragment extends BaseFragment {
eventFragment.setArguments(bundle); eventFragment.setArguments(bundle);
FragmentManager manager = getActivity().getSupportFragmentManager(); FragmentManager manager = getActivity().getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction(); FragmentTransaction transaction = manager.beginTransaction();
transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right, R.anim.slide_out_right);
transaction.replace(R.id.framelayout_for_fragment, eventFragment, eventFragment.getTag()); transaction.replace(R.id.framelayout_for_fragment, eventFragment, eventFragment.getTag());
transaction.addToBackStack(eventFragment.getTag()).commit(); transaction.addToBackStack(eventFragment.getTag()).commit();
} }
...@@ -119,21 +121,15 @@ public class MyEventsFragment extends BaseFragment { ...@@ -119,21 +121,15 @@ public class MyEventsFragment extends BaseFragment {
} }
} }
}); });
getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
} }
private class showEvents extends AsyncTask<String, Void, List<Event>> { private class showEvents extends AsyncTask<String, Void, List<Event>> {
@Override @Override
protected List<Event> doInBackground(String... events) { protected List<Event> doInBackground(String... events) {
return appDatabase.dbDao().getFollowingEvents();
List<Event> temp = appDatabase.dbDao().getAllEvents();
List<Event> eventsfollowing = appDatabase.dbDao().getAllEvents();
eventsfollowing.clear();
int k = temp.size();
for (int i = 0; i < k; i++) {
if (temp.get(i).getEventUserUes() != 0) eventsfollowing.add(temp.get(i));
}
return eventsfollowing;
} }
protected void onPostExecute(List<Event> result) { protected void onPostExecute(List<Event> result) {
......
...@@ -28,4 +28,16 @@ ...@@ -28,4 +28,16 @@
android:src="@android:drawable/ic_input_add" android:src="@android:drawable/ic_input_add"
android:tint="@android:color/black" android:tint="@android:color/black"
android:visibility="invisible" /> android:visibility="invisible" />
<RelativeLayout
android:id="@+id/loadingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" />
</RelativeLayout>
</RelativeLayout> </RelativeLayout>
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