Skip to content

Change profile photo update progress bar #154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.Manifest;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.app.ProgressDialog;
Expand All @@ -18,13 +19,15 @@
import android.support.v4.app.ActivityCompat;
import android.util.Base64;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
Expand Down Expand Up @@ -70,6 +73,7 @@ public class EditProfileFragment extends Fragment {
private static Integer RECORD_REQUEST_CODE = 101;
Bitmap myBitmap;
ProgressDialog progressDialog;
ProgressBar progressBar;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Expand Down Expand Up @@ -115,7 +119,6 @@ public void onClick(View v) {
}
});


return rootView;
}

Expand All @@ -133,6 +136,7 @@ private void setupViews(View rootView) {
state_view = rootView.findViewById(R.id.edit_state);
achievements_view = rootView.findViewById(R.id.edit_achievements);
change_photo_button = rootView.findViewById(R.id.profile_fab);
progressBar=rootView.findViewById(R.id.edit_profile_photo_progress);
}

//Function that fills the views with the datas
Expand Down Expand Up @@ -351,15 +355,14 @@ public String getStringImage(Bitmap bmp) {
}

private void uploadFile() {

progressDialog = new ProgressDialog(getActivity());
progressDialog.setMessage("Uploading image....");
progressDialog.show();
progressBar.setVisibility(View.VISIBLE);
change_photo_button.hide();
StringRequest stringRequest = new StringRequest(Request.Method.POST, Constant.UPDATE_PROFILE_IMAGE, new Response.Listener<String>() {

@Override
public void onResponse(String response) {
progressDialog.dismiss();
progressBar.setVisibility(View.INVISIBLE);
change_photo_button.show();
Toast.makeText(getActivity(), response, Toast.LENGTH_LONG).show();

try {
Expand Down Expand Up @@ -394,7 +397,8 @@ public void onResponse(String response) {

@Override
public void onErrorResponse(VolleyError error) {
progressDialog.dismiss();
progressBar.setVisibility(View.INVISIBLE);
change_photo_button.show();
Toast.makeText(getActivity(), error.toString(), Toast.LENGTH_LONG).show();
}

Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/layout/fragment_edit_profile.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/fragments_activities_background_color"
Expand Down Expand Up @@ -38,6 +39,17 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<android.support.v4.widget.ContentLoadingProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/edit_profile_photo_progress"
style="@style/Widget.AppCompat.ProgressBar"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"/>

<android.support.design.widget.FloatingActionButton
android:id="@+id/profile_fab"
android:layout_width="wrap_content"
Expand Down