Skip to content

Commit

Permalink
myLife: async background transactions (fixes #2748) (#2762)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Okuro3499 and dogi authored Nov 30, 2023
1 parent 3cb7a2b commit 49ecde8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1169
versionName "0.11.69"
versionCode 1170
versionName "0.11.70"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
Expand Down Expand Up @@ -115,19 +117,18 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, final int
else changeVisibility(holder, R.drawable.ic_visibility_off, SHOW);

}


}

public void updateVisibility(RecyclerView.ViewHolder holder, int position, boolean isVisible) {
RealmMyLife.updateVisibility(!isVisible, myLifeList.get(position).get_id(), mRealm, myLifeList.get(position).getUserId());
if (isVisible) {
changeVisibility(holder, R.drawable.ic_visibility, HIDE);
Utilities.toast(context, myLifeList.get(position).getTitle() + R.string.is_now_hidden);
} else {
changeVisibility(holder, R.drawable.ic_visibility_off, SHOW);
Utilities.toast(context, myLifeList.get(position).getTitle() + R.string.is_now_shown);
}
public void updateVisibility(final RecyclerView.ViewHolder holder, final int position, final boolean isVisible) {
mRealm.executeTransactionAsync(realm -> RealmMyLife.updateVisibility(!isVisible, myLifeList.get(position).get_id(), realm, myLifeList.get(position).getUserId()), () -> new Handler(Looper.getMainLooper()).post(() -> {
if (isVisible) {
changeVisibility(holder, R.drawable.ic_visibility, HIDE);
Utilities.toast(context, myLifeList.get(position).getTitle() + context.getString(R.string.is_now_hidden));
} else {
changeVisibility(holder, R.drawable.ic_visibility_off, SHOW);
Utilities.toast(context, myLifeList.get(position).getTitle() + context.getString(R.string.is_now_shown));
}
}), error -> Utilities.log(String.valueOf(error)));
}

public void changeVisibility(RecyclerView.ViewHolder holder, int imageId, float alpha) {
Expand Down

0 comments on commit 49ecde8

Please sign in to comment.