Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 6d9ebfd

Browse files
kunall17niftynei
authored andcommitted
Show Spinner Loading on message send
1 parent cb5cf5f commit 6d9ebfd

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

app/src/main/java/com/zulip/android/activities/ZulipActivity.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import android.widget.EditText;
4747
import android.widget.FilterQueryProvider;
4848
import android.widget.ImageView;
49+
import android.widget.LinearLayout;
4950
import android.widget.ListView;
5051
import android.widget.SearchView;
5152
import android.widget.TextView;
@@ -440,6 +441,7 @@ public void onClick(View v) {
440441
sendMessage();
441442
}
442443
});
444+
composeStatus = (LinearLayout) findViewById(R.id.composeStatus);
443445
setUpAdapter();
444446
streamActv.setAdapter(streamActvAdapter);
445447
topicActv.setAdapter(subjectActvAdapter);
@@ -482,6 +484,7 @@ private void sendMessage() {
482484
messageEt.requestFocus();
483485
return;
484486
}
487+
sendingMessage(true);
485488
MessageType messageType = (isCurrentModeStream()) ? MessageType.STREAM_MESSAGE : MessageType.PRIVATE_MESSAGE;
486489
Message msg = new Message(app);
487490
msg.setSender(app.getYou());
@@ -500,15 +503,32 @@ private void sendMessage() {
500503
public void onTaskComplete(String result, JSONObject jsonObject) {
501504
Toast.makeText(ZulipActivity.this, R.string.message_sent, Toast.LENGTH_SHORT).show();
502505
messageEt.setText("");
506+
sendingMessage(false);
503507
}
504508
public void onTaskFailure(String result) {
505509
Log.d("onTaskFailure", "Result: " + result);
506510
Toast.makeText(ZulipActivity.this, R.string.message_error, Toast.LENGTH_SHORT).show();
511+
sendingMessage(false);
507512
}
508513
});
509514
sender.execute();
510515
}
511516

517+
private void sendingMessage(boolean isSending) {
518+
streamActv.setEnabled(!isSending);
519+
textView.setEnabled(!isSending);
520+
messageEt.setEnabled(!isSending);
521+
topicActv.setEnabled(!isSending);
522+
sendBtn.setEnabled(!isSending);
523+
togglePrivateStreamBtn.setEnabled(!isSending);
524+
if (isSending)
525+
composeStatus.setVisibility(View.VISIBLE);
526+
else
527+
composeStatus.setVisibility(View.GONE);
528+
}
529+
530+
LinearLayout composeStatus;
531+
512532
public void setUpAdapter() {
513533
streamActvAdapter = new SimpleCursorAdapter(
514534
that, R.layout.stream_tile, null,
@@ -587,6 +607,7 @@ public Cursor runQuery(CharSequence charSequence) {
587607
}
588608
});
589609

610+
sendingMessage(false);
590611
}
591612

592613
private Cursor makeStreamCursor(CharSequence streamName)

app/src/main/res/layout/main.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,28 @@
7676
android:tint="#757575" />
7777

7878
</LinearLayout>
79+
<LinearLayout
80+
android:id="@+id/composeStatus"
81+
android:layout_width="match_parent"
82+
android:layout_height="24dp"
83+
android:layout_gravity="center"
84+
android:background="#eeeeee"
85+
android:gravity="center|center_vertical"
86+
android:visibility="gone">
87+
88+
<ProgressBar
89+
android:id="@+id/composeSpinner"
90+
android:layout_width="15dp"
91+
android:layout_height="15dp" />
92+
93+
<TextView
94+
android:id="@+id/composeStatusText"
95+
android:layout_width="wrap_content"
96+
android:layout_height="wrap_content"
97+
android:paddingLeft="8dp"
98+
android:text="@string/sending_message"
99+
android:textSize="16sp" />
100+
</LinearLayout>
79101
</LinearLayout>
80102

81103
<!-- The navigation drawer -->

0 commit comments

Comments
 (0)