From b529f8111586a8f2e8ac19a7509bad8c6b77c19b Mon Sep 17 00:00:00 2001 From: M M Arif Date: Sun, 19 Jul 2020 15:44:08 +0200 Subject: [PATCH] Fix some bugs (#596) remove redundant casting Fix edittext layout when typing(reduce size), fix refresh drafts. Minor improvements Co-authored-by: M M Arif Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/596 Reviewed-by: 6543 <6543@noreply.codeberg.org> --- app/build.gradle | 4 ++-- .../org/mian/gitnex/adapters/DraftsAdapter.java | 13 ++++++++----- .../org/mian/gitnex/fragments/DraftsFragment.java | 13 +++++++------ app/src/main/res/layout/activity_create_issue.xml | 4 ++-- app/src/main/res/layout/activity_create_release.xml | 2 +- app/src/main/res/layout/activity_edit_issue.xml | 4 ++-- app/src/main/res/layout/activity_new_file.xml | 2 +- app/src/main/res/layout/activity_new_milestone.xml | 2 +- .../main/res/layout/activity_new_organization.xml | 2 +- app/src/main/res/layout/activity_new_repo.xml | 2 +- app/src/main/res/layout/activity_reply_to_issue.xml | 2 +- build.gradle | 2 +- 12 files changed, 28 insertions(+), 24 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c67c7c31..e3ed9bd2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -50,14 +50,14 @@ dependencies { androidTestImplementation "androidx.test:runner:1.2.0" androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0" implementation "com.github.vihtarb:tooltip:0.2.0" - implementation 'com.squareup.okhttp3:okhttp:4.7.2' + implementation 'com.squareup.okhttp3:okhttp:4.8.0' implementation "com.google.code.gson:gson:2.8.6" implementation "com.squareup.picasso:picasso:2.71828" implementation "com.amulyakhare:com.amulyakhare.textdrawable:1.0.1" implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation 'com.squareup.retrofit2:converter-scalars:2.9.0' - implementation 'com.squareup.okhttp3:logging-interceptor:4.7.2' + implementation 'com.squareup.okhttp3:logging-interceptor:4.8.0' implementation 'org.ocpsoft.prettytime:prettytime:4.0.5.Final' implementation "com.vdurmont:emoji-java:5.1.1" implementation "com.pes.materialcolorpicker:library:1.2.5" diff --git a/app/src/main/java/org/mian/gitnex/adapters/DraftsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/DraftsAdapter.java index dba1788a..adba8820 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/DraftsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/DraftsAdapter.java @@ -3,6 +3,7 @@ package org.mian.gitnex.adapters; import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; +import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -64,10 +65,10 @@ public class DraftsAdapter extends RecyclerView.Adapter { Intent intent = new Intent(mCtx, ReplyToIssueActivity.class); - intent.putExtra("commentBody", draftText.getText()); - intent.putExtra("issueNumber", issueNumber.getText()); - intent.putExtra("repositoryId", repoId.getText()); - intent.putExtra("draftTitle", repoInfo.getText()); + intent.putExtra("commentBody", draftText.getText().toString()); + intent.putExtra("issueNumber", issueNumber.getText().toString()); + intent.putExtra("repositoryId", repoId.getText().toString()); + intent.putExtra("draftTitle", repoInfo.getText().toString()); TinyDB tinyDb = new TinyDB(mCtx); tinyDb.putString("issueNumber", issueNumber.getText().toString()); @@ -116,7 +117,9 @@ public class DraftsAdapter extends RecyclerView.Adapter" + mCtx.getResources().getString(R.string.hash) + currentItem.getIssueId() + ""; + holder.repoInfo.setText(Html.fromHtml(issueNumber + " " + currentItem.getRepositoryOwner() + " / " + currentItem.getRepositoryName())); } diff --git a/app/src/main/java/org/mian/gitnex/fragments/DraftsFragment.java b/app/src/main/java/org/mian/gitnex/fragments/DraftsFragment.java index a437df46..ddd217d2 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/DraftsFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/DraftsFragment.java @@ -40,6 +40,7 @@ public class DraftsFragment extends Fragment { private TextView noData; private List draftsList_; private int currentActiveAccountId; + private SwipeRefreshLayout swipeRefresh; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -56,7 +57,7 @@ public class DraftsFragment extends Fragment { noData = v.findViewById(R.id.noData); mRecyclerView = v.findViewById(R.id.recyclerView); - final SwipeRefreshLayout swipeRefresh = v.findViewById(R.id.pullToRefresh); + swipeRefresh = v.findViewById(R.id.pullToRefresh); mRecyclerView.setHasFixedSize(true); mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx)); @@ -67,16 +68,15 @@ public class DraftsFragment extends Fragment { adapter = new DraftsAdapter(getContext(), draftsList_); + currentActiveAccountId = tinyDb.getInt("currentActiveAccountId"); + swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> { draftsList_.clear(); - swipeRefresh.setRefreshing(false); - fetchDataAsync(1); + fetchDataAsync(currentActiveAccountId); }, 250)); - currentActiveAccountId = tinyDb.getInt("currentActiveAccountId"); - fetchDataAsync(currentActiveAccountId); return v; @@ -87,6 +87,7 @@ public class DraftsFragment extends Fragment { draftsApi.getDrafts(accountId).observe(getViewLifecycleOwner(), drafts -> { + swipeRefresh.setRefreshing(false); assert drafts != null; if(drafts.size() > 0) { @@ -141,7 +142,7 @@ public class DraftsFragment extends Fragment { SearchView searchView = (SearchView) searchItem.getActionView(); searchView.setImeOptions(EditorInfo.IME_ACTION_DONE); - ((SearchView) searchView).setOnQueryTextListener(new SearchView.OnQueryTextListener() { + searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { diff --git a/app/src/main/res/layout/activity_create_issue.xml b/app/src/main/res/layout/activity_create_issue.xml index 30705c00..e17a920b 100644 --- a/app/src/main/res/layout/activity_create_issue.xml +++ b/app/src/main/res/layout/activity_create_issue.xml @@ -90,7 +90,7 @@ - \ No newline at end of file + diff --git a/app/src/main/res/layout/activity_create_release.xml b/app/src/main/res/layout/activity_create_release.xml index c102c437..0035cfba 100644 --- a/app/src/main/res/layout/activity_create_release.xml +++ b/app/src/main/res/layout/activity_create_release.xml @@ -139,7 +139,7 @@ - \ No newline at end of file + diff --git a/app/src/main/res/layout/activity_new_file.xml b/app/src/main/res/layout/activity_new_file.xml index 117e97e0..9dd88202 100644 --- a/app/src/main/res/layout/activity_new_file.xml +++ b/app/src/main/res/layout/activity_new_file.xml @@ -100,7 +100,7 @@