Browse Source

Profile crash fixes

master
Preyea Regmi 6 years ago
parent
commit
c44cc18ce3
  1. 12
      app/src/main/java/com/gmeremit/online/gmeremittance_native/settings/view/SettingsView.java
  2. 22
      app/src/main/java/com/gmeremit/online/gmeremittance_native/user_profile/presenter/UserProfilePresenter.java
  3. 99
      app/src/main/java/com/gmeremit/online/gmeremittance_native/user_profile/view/ProfileActivity.java
  4. 2
      app/src/main/res/layout/activity_profile.xml

12
app/src/main/java/com/gmeremit/online/gmeremittance_native/settings/view/SettingsView.java

@ -4,18 +4,11 @@ import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import com.gmeremit.online.gmeremittance_native.R;
import com.gmeremit.online.gmeremittance_native.changepasswordV2.view.ChangePasswordV2Activity;
import com.gmeremit.online.gmeremittance_native.home.events.DrawerEvent;
import com.gmeremit.online.gmeremittance_native.settings.events.PasswordEvent;
import com.gmeremit.online.gmeremittance_native.user_profile.view.ChangePasswordActivity;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import butterknife.ButterKnife;
import butterknife.OnClick;
@ -30,13 +23,12 @@ public class SettingsView extends AppCompatActivity {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
init();
}
private void init() {
ButterKnife.bind(this);
EventBus.getDefault().register(this);
// EventBus.getDefault().register(this);
}
@OnClick({R.id.view_change_password, R.id.iv_back})
@ -51,6 +43,4 @@ public class SettingsView extends AppCompatActivity {
break;
}
}
}

22
app/src/main/java/com/gmeremit/online/gmeremittance_native/user_profile/presenter/UserProfilePresenter.java

@ -1,7 +1,10 @@
package com.gmeremit.online.gmeremittance_native.user_profile.presenter;
import android.content.SharedPreferences;
import android.support.annotation.NonNull;
import com.gmeremit.online.gmeremittance_native.GmeApplication;
import com.gmeremit.online.gmeremittance_native.base.PrefKeys;
import com.gmeremit.online.gmeremittance_native.kycform.model.data.Occupation;
import com.gmeremit.online.gmeremittance_native.kycform.model.data.Province;
import com.gmeremit.online.gmeremittance_native.sendmoney.model.data.SourceOfFund;
@ -72,8 +75,23 @@ public class UserProfilePresenter implements UserProfileContract.UserProfilePres
@Override
public void userProfile(String userId) {
userProfileView.showProgressDialog();
userProfileModel.requestForUserProfile(this, userId);
// userProfileView.showProgressDialog();
// userProfileModel.requestForUserProfile(this, userId);
UserProfile userProfile=new UserProfile();
SharedPreferences storage = GmeApplication.getStorage();
userProfile.firstName=storage.getString(PrefKeys.USER_FIRST_NAME,"") ;
userProfile.middleName=storage.getString(PrefKeys.USER_MIDDLE_NAME,"");
userProfile.lastName=storage.getString(PrefKeys.USER_LAST_NAME,"");
userProfile.mobileNumber=storage.getString(PrefKeys.USER_MSISDN,"");
userProfile.email=storage.getString(PrefKeys.USER_EMAIL,"");
userProfile.availableBalance=storage.getString(PrefKeys.USER_AVAILABLE_BALANCE,"");
userProfile.walletNumber=storage.getString(PrefKeys.USER_WALLET_NUMBER,"");
userProfile.primaryBankName=storage.getString(PrefKeys.USER_PRIMARY_BANK_NAME,"");
userProfile.verified=storage.getBoolean(PrefKeys.USER_KYC_VERIFIED,false);
userProfileView.onSuccessUpdateUI(userProfile);
}
/***

99
app/src/main/java/com/gmeremit/online/gmeremittance_native/user_profile/view/ProfileActivity.java

@ -110,21 +110,21 @@ public class ProfileActivity extends AppCompatActivity implements UserProfileCon
finish();
break;
case R.id.iv_uploadImage:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int writePermission = ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE);
int cameraPermission = ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.CAMERA);
if (Settings.System.canWrite(this) && cameraPermission == PackageManager.PERMISSION_GRANTED) {
cameraorGalleryChooser(PROFILE_IMAGE_CAMERA, PROFILE_IMAGE_GALLERY);
} else {
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA}, REQUEST_PERMISSION);
}
} else {
cameraorGalleryChooser(PROFILE_IMAGE_CAMERA, PROFILE_IMAGE_GALLERY);
}
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// int writePermission = ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE);
// int cameraPermission = ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.CAMERA);
// if (Settings.System.canWrite(this) && cameraPermission == PackageManager.PERMISSION_GRANTED) {
// cameraorGalleryChooser(PROFILE_IMAGE_CAMERA, PROFILE_IMAGE_GALLERY);
// } else {
//
// requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,
// Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA}, REQUEST_PERMISSION);
//
// }
//
// } else {
// cameraorGalleryChooser(PROFILE_IMAGE_CAMERA, PROFILE_IMAGE_GALLERY);
// }
break;
case R.id.iv_edit_profile:
startActivity(new Intent(ProfileActivity.this, EditProfileDetailActivity.class));
@ -252,39 +252,44 @@ public class ProfileActivity extends AppCompatActivity implements UserProfileCon
tvEmail.setText(body.email);
tvBalance.setText(Utils.amountFormat(Double.parseDouble(body.availableBalance)));
setWalletNo(body.walletNumber, body.primaryBankName);
if (body.dpUrl != null && body.dpUrl.length() > 1) {
// Glide.with(ProfileActivity.this).load(body.dpUrl).diskCacheStrategy(DiskCacheStrategy.ALL).into(profileImage);
// Utility.showImageFromServer(this, profileImage, body.dpUrl);
// String image = body.dpUrl;
Target target = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
profileImage.setImageBitmap(bitmap);
}
@Override
public void onBitmapFailed(Exception e, Drawable errorDrawable) {
profileImage.setImageDrawable(errorDrawable);
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
profileImage.setImageDrawable(placeHolderDrawable);
}
};
// Picasso.get().load(body.dpUrl).memoryPolicy(MemoryPolicy.NO_CACHE,MemoryPolicy.NO_STORE).into(target);
Picasso.get().load(body.dpUrl).memoryPolicy(MemoryPolicy.NO_CACHE,MemoryPolicy.NO_STORE).into(profileImage);
// Glide.with(this).load(body.dpUrl).into(profileImage);
textProfileImage.setVisibility(View.GONE);
} else {
if (body.firstName != null && body.firstName.length() > 0) {
TextDrawable drawable = TextDrawable.builder().buildRound(String.valueOf(body.firstName.toUpperCase().charAt(0)), getResources().getColor(R.color.blue));
textProfileImage.setImageDrawable(drawable);
}
}
if (body.verified) {
ivEditProfile.setVisibility(View.VISIBLE);
// if (body.dpUrl != null && body.dpUrl.length() > 1) {
//// Glide.with(ProfileActivity.this).load(body.dpUrl).diskCacheStrategy(DiskCacheStrategy.ALL).into(profileImage);
//// Utility.showImageFromServer(this, profileImage, body.dpUrl);
//// String image = body.dpUrl;
// Target target = new Target() {
// @Override
// public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
// profileImage.setImageBitmap(bitmap);
// }
//
// @Override
// public void onBitmapFailed(Exception e, Drawable errorDrawable) {
// profileImage.setImageDrawable(errorDrawable);
// }
//
// @Override
// public void onPrepareLoad(Drawable placeHolderDrawable) {
// profileImage.setImageDrawable(placeHolderDrawable);
// }
// };
//// Picasso.get().load(body.dpUrl).memoryPolicy(MemoryPolicy.NO_CACHE,MemoryPolicy.NO_STORE).into(target);
// Picasso.get().load(body.dpUrl).memoryPolicy(MemoryPolicy.NO_CACHE,MemoryPolicy.NO_STORE).into(profileImage);
//// Glide.with(this).load(body.dpUrl).into(profileImage);
// textProfileImage.setVisibility(View.GONE);
// } else {
// if (body.firstName != null && body.firstName.length() > 0) {
// TextDrawable drawable = TextDrawable.builder().buildRound(String.valueOf(body.firstName.toUpperCase().charAt(0)), getResources().getColor(R.color.blue));
// textProfileImage.setImageDrawable(drawable);
// }
// }
if (body.firstName != null && body.firstName.length() > 0) {
TextDrawable drawable = TextDrawable.builder().buildRound(String.valueOf(body.firstName.toUpperCase().charAt(0)), getResources().getColor(R.color.blue));
textProfileImage.setImageDrawable(drawable);
}
// if (body.verified) {
// ivEditProfile.setVisibility(View.VISIBLE);
// }
// ivEditProfile.setVisibility(View.VISIBLE);
}

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

@ -50,7 +50,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_edit"
tools:visibility="visible"
tools:visibility="invisible"
android:visibility="gone"
android:layout_alignParentRight="true"
android:padding="14dp"/>

Loading…
Cancel
Save