Browse Source

added spinner in record overview

Julien Clauter 10 years ago
parent
commit
3f37fa4aa6

+ 8 - 0
res/layout/fragment_record_list.xml

@@ -5,6 +5,14 @@
     android:background="@android:color/transparent"
     >
 
+    <ProgressBar
+        android:id="@+id/progressBar1"
+        style="?android:attr/progressBarStyleLarge"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerHorizontal="true"
+        android:layout_centerVertical="true"/>
+
             <ExpandableListView
                 xmlns:android="http://schemas.android.com/apk/res/android"
                 android:id="@+id/loglistview"

+ 13 - 0
src/de/tudarmstadt/informatik/hostage/ui2/fragment/RecordOverviewFragment.java

@@ -12,6 +12,7 @@ import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ExpandableListView;
 import android.widget.ImageButton;
+import android.widget.ProgressBar;
 
 import com.google.android.gms.maps.model.LatLng;
 
@@ -68,6 +69,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
     public String groupingKey;
 
     private ExpandableListView expListView;
+    private ProgressBar spinner;
 
     UglyDbHelper dbh;
 
@@ -104,6 +106,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 
 	    // Get the message from the intent
 
+
         if (this.filter == null){
             Intent intent = this.getActivity().getIntent();
             LogFilter filter = intent.getParcelableExtra(LogFilter.LOG_FILTER_INTENT_KEY);
@@ -122,6 +125,9 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 		View rootView = inflater.inflate(this.getLayoutId(), container, false);
 		ExpandableListView mylist = (ExpandableListView) rootView.findViewById(R.id.loglistview);
 
+        this.spinner =(ProgressBar) rootView.findViewById(R.id.progressBar1);
+        this.spinner.setVisibility(View.GONE);
+
 		this.expListView = mylist;
 
         this.initialiseListView();
@@ -158,6 +164,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
     private void initialiseListView(){
         if (loader != null) loader.interrupt();
 
+        this.spinner.setVisibility(View.VISIBLE);
+
         loader = new Thread(new Runnable(){
 
             private void updateUI(final RecordListAdapter currentAdapter)
@@ -200,6 +208,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
                             mListPosition = -1;
                             mItemPosition = -1;
                             registerListClickCallback(RecordOverviewFragment.this.expListView);
+                            RecordOverviewFragment.this.spinner.setVisibility(View.GONE);
                         }
                     });
                 }
@@ -213,6 +222,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
             @Override
             public void run()
             {
+                //RecordOverviewFragment.this.addRecordToDB(5, 10);
                 updateUI(doInBackground());
             }
 
@@ -395,6 +405,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 
         loader = null;
 
+        this.spinner.setVisibility(View.VISIBLE);
+
         loader = new Thread(new Runnable() {
             @Override
             public void run() {
@@ -417,6 +429,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
                             if (adapter != null){
                                 RecordOverviewFragment.this.expListView.setAdapter(adapter);
                                 adapter.notifyDataSetChanged();
+                                RecordOverviewFragment.this.spinner.setVisibility(View.GONE);
                             }
                         }
                     });