Fix drafts from notifications view (#618)

Fix drafts when coming from notifications

Fix star/watchers layout

Co-authored-by: M M Arif <mmarif@swatian.com>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/618
Reviewed-by: 6543 <6543@noreply.codeberg.org>
This commit is contained in:
M M Arif 2020-07-29 20:04:40 +02:00 committed by 6543
parent ff537b79ff
commit a9ad91d954
6 changed files with 46 additions and 11 deletions

View File

@ -11,6 +11,9 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import org.mian.gitnex.R;
import org.mian.gitnex.database.api.RepositoriesApi;
import org.mian.gitnex.database.models.Repository;
import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.models.NotificationThread;
import java.util.List;
@ -24,9 +27,11 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
private List<NotificationThread> notificationThreads;
private OnMoreClickedListener onMoreClickedListener;
private OnNotificationClickedListener onNotificationClickedListener;
private TinyDB tinyDb;
public NotificationsAdapter(Context context, List<NotificationThread> notificationThreads, OnMoreClickedListener onMoreClickedListener, OnNotificationClickedListener onNotificationClickedListener) {
this.tinyDb = new TinyDB(context);
this.context = context;
this.notificationThreads = notificationThreads;
this.onMoreClickedListener = onMoreClickedListener;
@ -101,7 +106,33 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
}
holder.frame.setOnClickListener(v -> onNotificationClickedListener.onNotificationClicked(notificationThread));
holder.frame.setOnClickListener(v -> {
onNotificationClickedListener.onNotificationClicked(notificationThread);
String[] parts = notificationThread.getRepository().getFullname().split("/");
final String repoOwner = parts[0];
final String repoName = parts[1];
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
RepositoriesApi repositoryData = new RepositoriesApi(context);
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
if(count == 0) {
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", id);
}
else {
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", data.getRepositoryId());
}
});
holder.more.setOnClickListener(v -> onMoreClickedListener.onMoreClicked(notificationThread));
}

View File

@ -46,7 +46,6 @@
android:id="@+id/gridView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:horizontalSpacing="10dp"
android:numColumns="4"
android:columnWidth="80dp"
@ -58,7 +57,6 @@
android:id="@+id/noDataStargazers"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="15dp"
android:gravity="center"
android:text="@string/noDataFound"
android:textColor="?attr/primaryTextColor"
@ -73,4 +71,4 @@
android:indeterminate="true"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>

View File

@ -46,7 +46,6 @@
android:id="@+id/gridView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:horizontalSpacing="10dp"
android:numColumns="4"
android:columnWidth="80dp"
@ -58,7 +57,6 @@
android:id="@+id/noDataWatchers"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="15dp"
android:gravity="center"
android:text="@string/noDataFound"
android:textColor="?attr/primaryTextColor"
@ -73,4 +71,4 @@
android:indeterminate="true"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>

View File

@ -16,7 +16,7 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"
android:gravity="center_horizontal"
android:orientation="vertical">
@ -69,7 +69,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:background="@android:color/transparent"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_dotted_menu_horizontal" />

View File

@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/gridViewData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:orientation="vertical"
tools:ignore="UseCompoundDrawables">
<ImageView
android:id="@+id/memberAvatar"

View File

@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/gridViewData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:orientation="vertical"
tools:ignore="UseCompoundDrawables">
<ImageView
android:id="@+id/memberAvatar"