Quick progressbar sample for network operations during group create

This commit is contained in:
Jake McGinty 2014-02-13 11:44:07 -08:00
parent fe55ac57d9
commit c5d010c86f
2 changed files with 59 additions and 1 deletions

View File

@ -12,6 +12,7 @@
android:layout_marginBottom="20dp"> android:layout_marginBottom="20dp">
<LinearLayout <LinearLayout
android:id="@+id/group_details_layout"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="106dp" android:layout_height="106dp"
android:orientation="horizontal" android:orientation="horizontal"
@ -36,6 +37,34 @@
android:layout_gravity="center_vertical" /> android:layout_gravity="center_vertical" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/creating_group_layout"
android:visibility="gone"
android:layout_width="fill_parent"
android:layout_height="106dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingLeft="18dp"
android:paddingRight="18dp"
android:paddingTop="18dp">
<ProgressBar
android:id="@+id/creating_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:indeterminate="true"
style="@android:style/Widget.ProgressBar.Large" />
<TextView
android:id="@+id/creating_group_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_gravity="center_vertical" />
</LinearLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/push_disabled" android:id="@+id/push_disabled"
android:layout_width="fill_parent" android:layout_width="fill_parent"

View File

@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
@ -12,6 +13,7 @@ import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView;
import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuInflater;
@ -204,8 +206,35 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
super.onOptionsItemSelected(item); super.onOptionsItemSelected(item);
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home: case android.R.id.home:
finish();
return true;
case R.id.menu_create_group: case R.id.menu_create_group:
finish(); // TODO not this findViewById(R.id.group_details_layout).setVisibility(View.GONE);
findViewById(R.id.creating_group_layout).setVisibility(View.VISIBLE);
((TextView)findViewById(R.id.creating_group_text)).setText("Creating " + groupName.getText().toString() + "...");
new AsyncTask<Void,Void,Void>() {
@Override
protected Void doInBackground(Void... voids) {
try {
Thread.sleep(5000); // todo network things
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
finish();
}
@Override
protected void onProgressUpdate(Void... values) {
super.onProgressUpdate(values);
}
}.execute();
return true; return true;
} }