mirror of
https://codeberg.org/gitnex/GitNex
synced 2025-03-20 21:40:18 +01:00
Improvements and fixes (#1407)
As title Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1407 Co-authored-by: M M Arif <mmarif@swatian.com> Co-committed-by: M M Arif <mmarif@swatian.com>
This commit is contained in:
parent
acb8d160dc
commit
d3ccf1cedb
@ -19,10 +19,10 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityCreateLabelBinding;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.viewmodels.LabelsViewModel;
|
||||
import org.mian.gitnex.viewmodels.OrganizationLabelsViewModel;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
@ -37,6 +37,8 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
private String labelColor = "";
|
||||
private String labelColorDefault = "";
|
||||
private ColorPickerPreferenceManager colorManager;
|
||||
private int page = 1;
|
||||
private int resultLimit;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -61,6 +63,8 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
|
||||
activityCreateLabelBinding.topAppBar.setNavigationOnClickListener(v -> finish());
|
||||
|
||||
resultLimit = Constants.getCurrentResultLimit(ctx);
|
||||
|
||||
colorManager = ColorPickerPreferenceManager.getInstance(this);
|
||||
colorManager.clearSavedAllData();
|
||||
activityCreateLabelBinding.colorPicker.setBackgroundColor(
|
||||
@ -161,7 +165,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
updateLabelColor = labelColor;
|
||||
}
|
||||
|
||||
if (updateLabelName.equals("")) {
|
||||
if (updateLabelName.isEmpty()) {
|
||||
|
||||
SnackBar.error(
|
||||
ctx, findViewById(android.R.id.content), getString(R.string.labelEmptyError));
|
||||
@ -198,7 +202,7 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
newLabelColor = labelColor;
|
||||
}
|
||||
|
||||
if (newLabelName.equals("")) {
|
||||
if (newLabelName.isEmpty()) {
|
||||
|
||||
SnackBar.error(
|
||||
ctx, findViewById(android.R.id.content), getString(R.string.labelEmptyError));
|
||||
@ -386,12 +390,24 @@ public class CreateLabelActivity extends BaseActivity {
|
||||
getIntent().getStringExtra("type"))
|
||||
.equals("org")) {
|
||||
|
||||
OrganizationLabelsViewModel.loadOrgLabelsList(
|
||||
getIntent().getStringExtra("orgName"), ctx, null, null);
|
||||
LabelsViewModel.loadLabelsList(
|
||||
getIntent().getStringExtra("orgName"),
|
||||
null,
|
||||
"org",
|
||||
ctx,
|
||||
null,
|
||||
page,
|
||||
resultLimit);
|
||||
} else {
|
||||
|
||||
LabelsViewModel.loadLabelsList(
|
||||
repository.getOwner(), repository.getName(), ctx);
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
"repo",
|
||||
ctx,
|
||||
null,
|
||||
page,
|
||||
resultLimit);
|
||||
}
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
@ -103,7 +103,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
if (newRepoName.equals("")) {
|
||||
if (newRepoName.isEmpty()) {
|
||||
|
||||
SnackBar.error(
|
||||
ctx,
|
||||
@ -251,7 +251,7 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
private void getOrganizations(final String userLogin) {
|
||||
|
||||
Call<List<Organization>> call =
|
||||
RetrofitClient.getApiInterface(ctx).orgListCurrentUserOrgs(1, 50);
|
||||
RetrofitClient.getApiInterface(ctx).orgListCurrentUserOrgs(1, 100);
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
@ -270,15 +270,15 @@ public class CreateRepoActivity extends BaseActivity {
|
||||
organizationsList.add(userLogin);
|
||||
assert organizationsList_ != null;
|
||||
|
||||
if (organizationsList_.size() > 0) {
|
||||
if (!organizationsList_.isEmpty()) {
|
||||
|
||||
for (int i = 0; i < organizationsList_.size(); i++) {
|
||||
|
||||
if (getIntent().getStringExtra("orgName") != null
|
||||
&& !"".equals(getIntent().getStringExtra("orgName"))) {
|
||||
if (getIntent()
|
||||
.getStringExtra("orgName")
|
||||
.equals(organizationsList_.get(i).getUsername())) {
|
||||
if (Objects.equals(
|
||||
getIntent().getStringExtra("orgName"),
|
||||
organizationsList_.get(i).getUsername())) {
|
||||
organizationId = i + 1;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.google.android.material.card.MaterialCardView;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -42,10 +41,8 @@ import org.mian.gitnex.database.models.UserAccount;
|
||||
import org.mian.gitnex.databinding.ActivityMainBinding;
|
||||
import org.mian.gitnex.fragments.AccountSettingsFragment;
|
||||
import org.mian.gitnex.fragments.AdministrationFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetDraftsFragment;
|
||||
import org.mian.gitnex.fragments.BottomSheetMyIssuesFilterFragment;
|
||||
import org.mian.gitnex.fragments.DashboardFragment;
|
||||
import org.mian.gitnex.fragments.DraftsFragment;
|
||||
import org.mian.gitnex.fragments.ExploreFragment;
|
||||
import org.mian.gitnex.fragments.MostVisitedReposFragment;
|
||||
import org.mian.gitnex.fragments.MyIssuesFragment;
|
||||
@ -150,8 +147,6 @@ public class MainActivity extends BaseActivity
|
||||
toolbarTitle.setText(getResources().getString(R.string.navMostVisited));
|
||||
} else if (fragmentById instanceof NotesFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.navNotes));
|
||||
} else if (fragmentById instanceof DraftsFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||
} else if (fragmentById instanceof AdministrationFragment) {
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration));
|
||||
} else if (fragmentById instanceof MyIssuesFragment) {
|
||||
@ -329,15 +324,6 @@ public class MainActivity extends BaseActivity
|
||||
mainIntent.removeExtra("launchFragment");
|
||||
|
||||
switch (launchFragment) {
|
||||
case "drafts":
|
||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, new DraftsFragment())
|
||||
.commit();
|
||||
navigationView.setCheckedItem(R.id.nav_comments_draft);
|
||||
return;
|
||||
|
||||
case "notifications":
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleNotifications));
|
||||
getSupportFragmentManager()
|
||||
@ -456,15 +442,6 @@ public class MainActivity extends BaseActivity
|
||||
break;
|
||||
|
||||
case 6:
|
||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, new DraftsFragment())
|
||||
.commit();
|
||||
navigationView.setCheckedItem(R.id.nav_comments_draft);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleNotifications));
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
@ -473,7 +450,7 @@ public class MainActivity extends BaseActivity
|
||||
navigationView.setCheckedItem(R.id.nav_notifications);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
case 7:
|
||||
toolbarTitle.setText(getResources().getString(R.string.navMyIssues));
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
@ -481,7 +458,7 @@ public class MainActivity extends BaseActivity
|
||||
.commit();
|
||||
navigationView.setCheckedItem(R.id.nav_my_issues);
|
||||
break;
|
||||
case 9:
|
||||
case 8:
|
||||
toolbarTitle.setText(getResources().getString(R.string.navMostVisited));
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
@ -489,7 +466,7 @@ public class MainActivity extends BaseActivity
|
||||
.commit();
|
||||
navigationView.setCheckedItem(R.id.nav_most_visited);
|
||||
break;
|
||||
case 10:
|
||||
case 9:
|
||||
toolbarTitle.setText(getResources().getString(R.string.navNotes));
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
@ -497,7 +474,7 @@ public class MainActivity extends BaseActivity
|
||||
.commit();
|
||||
navigationView.setCheckedItem(R.id.nav_notes);
|
||||
break;
|
||||
case 11:
|
||||
case 10:
|
||||
toolbarTitle.setText(getResources().getString(R.string.dashboard));
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
@ -505,7 +482,7 @@ public class MainActivity extends BaseActivity
|
||||
.commit();
|
||||
navigationView.setCheckedItem(R.id.nav_dashboard);
|
||||
break;
|
||||
case 12:
|
||||
case 11:
|
||||
toolbarTitle.setText(getResources().getString(R.string.navWatchedRepositories));
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
@ -612,41 +589,8 @@ public class MainActivity extends BaseActivity
|
||||
|
||||
@Override
|
||||
public void onButtonClicked(String text) {
|
||||
int currentActiveAccountId = tinyDB.getInt("currentActiveAccountId");
|
||||
|
||||
switch (text) {
|
||||
case "deleteDrafts":
|
||||
if (currentActiveAccountId > 0) {
|
||||
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
DraftsFragment frag =
|
||||
(DraftsFragment) fm.findFragmentById(R.id.fragment_container);
|
||||
|
||||
if (frag != null) {
|
||||
|
||||
new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.deleteAllDrafts)
|
||||
.setCancelable(false)
|
||||
.setMessage(R.string.deleteAllDraftsDialogMessage)
|
||||
.setPositiveButton(
|
||||
R.string.menuDeleteText,
|
||||
(dialog, which) -> {
|
||||
frag.deleteAllDrafts(currentActiveAccountId);
|
||||
dialog.dismiss();
|
||||
})
|
||||
.setNeutralButton(R.string.cancelButton, null)
|
||||
.show();
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericError));
|
||||
}
|
||||
break;
|
||||
|
||||
case "openMyIssues":
|
||||
if (getFragmentRefreshListener() != null) {
|
||||
getFragmentRefreshListener().onRefresh("open");
|
||||
@ -725,13 +669,6 @@ public class MainActivity extends BaseActivity
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, new NotificationsFragment())
|
||||
.commit();
|
||||
} else if (id == R.id.nav_comments_draft) {
|
||||
|
||||
toolbarTitle.setText(getResources().getString(R.string.titleDrafts));
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, new DraftsFragment())
|
||||
.commit();
|
||||
} else if (id == R.id.nav_administration) {
|
||||
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration));
|
||||
@ -792,12 +729,7 @@ public class MainActivity extends BaseActivity
|
||||
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.genericMenu) {
|
||||
|
||||
BottomSheetDraftsFragment bottomSheet = new BottomSheetDraftsFragment();
|
||||
bottomSheet.show(getSupportFragmentManager(), "draftsBottomSheet");
|
||||
return true;
|
||||
} else if (id == R.id.filter) {
|
||||
if (id == R.id.filter) {
|
||||
|
||||
BottomSheetMyIssuesFilterFragment filterBottomSheet =
|
||||
new BottomSheetMyIssuesFilterFragment();
|
||||
|
@ -347,7 +347,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
Call<List<Milestone>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueGetMilestonesList(
|
||||
repository.getOwner(), repository.getName(), "open", null, 1, 50);
|
||||
repository.getOwner(), repository.getName(), "open", null, 1, 100);
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
@ -1,16 +1,16 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.UserGridAdapter;
|
||||
import org.mian.gitnex.databinding.ActivityRepoStargazersBinding;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.viewmodels.RepoStargazersViewModel;
|
||||
|
||||
@ -23,6 +23,10 @@ public class RepoStargazersActivity extends BaseActivity {
|
||||
private UserGridAdapter adapter;
|
||||
private RepositoryContext repository;
|
||||
private ActivityRepoStargazersBinding activityRepoStargazersBinding;
|
||||
private RepoStargazersViewModel repoStargazersModel;
|
||||
private List<User> dataList;
|
||||
private int page = 1;
|
||||
private int resultLimit;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -34,6 +38,11 @@ public class RepoStargazersActivity extends BaseActivity {
|
||||
|
||||
setSupportActionBar(activityRepoStargazersBinding.toolbar);
|
||||
|
||||
resultLimit = Constants.getCurrentResultLimit(ctx);
|
||||
repoStargazersModel = new ViewModelProvider(this).get(RepoStargazersViewModel.class);
|
||||
|
||||
dataList = new ArrayList<>();
|
||||
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
final String repoOwner = repository.getOwner();
|
||||
final String repoName = repository.getName();
|
||||
@ -48,24 +57,50 @@ public class RepoStargazersActivity extends BaseActivity {
|
||||
|
||||
private void fetchDataAsync(String repoOwner, String repoName) {
|
||||
|
||||
RepoStargazersViewModel repoStargazersModel =
|
||||
new ViewModelProvider(this).get(RepoStargazersViewModel.class);
|
||||
|
||||
repoStargazersModel
|
||||
.getRepoStargazers(repoOwner, repoName, ctx)
|
||||
.getRepoStargazers(repoOwner, repoName, ctx, page, resultLimit)
|
||||
.observe(
|
||||
this,
|
||||
stargazersListMain -> {
|
||||
adapter = new UserGridAdapter(ctx, stargazersListMain);
|
||||
RepoStargazersActivity.this,
|
||||
mainList -> {
|
||||
adapter = new UserGridAdapter(ctx, mainList);
|
||||
|
||||
if (adapter.getCount() > 0) {
|
||||
adapter.setLoadMoreListener(
|
||||
new UserGridAdapter.OnLoadMoreListener() {
|
||||
|
||||
@Override
|
||||
public void onLoadMore() {
|
||||
|
||||
page += 1;
|
||||
repoStargazersModel.loadMore(
|
||||
repoOwner,
|
||||
repoName,
|
||||
ctx,
|
||||
page,
|
||||
resultLimit,
|
||||
adapter,
|
||||
activityRepoStargazersBinding);
|
||||
activityRepoStargazersBinding.progressBar.setVisibility(
|
||||
View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished() {
|
||||
|
||||
activityRepoStargazersBinding.progressBar.setVisibility(
|
||||
View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(this, 2);
|
||||
activityRepoStargazersBinding.gridView.setLayoutManager(layoutManager);
|
||||
|
||||
if (adapter.getItemCount() > 0) {
|
||||
activityRepoStargazersBinding.gridView.setAdapter(adapter);
|
||||
activityRepoStargazersBinding.noDataStargazers.setVisibility(
|
||||
View.GONE);
|
||||
dataList.addAll(mainList);
|
||||
} else {
|
||||
|
||||
adapter.notifyDataSetChanged();
|
||||
adapter.notifyDataChanged();
|
||||
activityRepoStargazersBinding.gridView.setAdapter(adapter);
|
||||
activityRepoStargazersBinding.noDataStargazers.setVisibility(
|
||||
View.VISIBLE);
|
||||
@ -86,35 +121,21 @@ public class RepoStargazersActivity extends BaseActivity {
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||
private void filter(String text) {
|
||||
|
||||
final MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
List<User> arr = new ArrayList<>();
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
SearchView searchView = (SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
for (User d : dataList) {
|
||||
if (d == null || d.getLogin() == null || d.getFullName() == null) {
|
||||
continue;
|
||||
}
|
||||
if (d.getLogin().toLowerCase().contains(text)
|
||||
|| d.getFullName().toLowerCase().contains(text)) {
|
||||
arr.add(d);
|
||||
}
|
||||
}
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
|
||||
if (activityRepoStargazersBinding.gridView.getAdapter() != null) {
|
||||
adapter.getFilter().filter(newText);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
adapter.setMoreDataAvailable(false);
|
||||
adapter.updateList(arr);
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,13 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.UserGridAdapter;
|
||||
import org.mian.gitnex.databinding.ActivityRepoWatchersBinding;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.viewmodels.RepoWatchersViewModel;
|
||||
|
||||
@ -23,6 +20,9 @@ public class RepoWatchersActivity extends BaseActivity {
|
||||
private UserGridAdapter adapter;
|
||||
private ActivityRepoWatchersBinding activityRepoWatchersBinding;
|
||||
private RepositoryContext repository;
|
||||
private RepoWatchersViewModel repoWatchersModel;
|
||||
private int page = 1;
|
||||
private int resultLimit;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -34,6 +34,9 @@ public class RepoWatchersActivity extends BaseActivity {
|
||||
|
||||
setSupportActionBar(activityRepoWatchersBinding.toolbar);
|
||||
|
||||
resultLimit = Constants.getCurrentResultLimit(ctx);
|
||||
repoWatchersModel = new ViewModelProvider(this).get(RepoWatchersViewModel.class);
|
||||
|
||||
repository = RepositoryContext.fromIntent(getIntent());
|
||||
final String repoOwner = repository.getOwner();
|
||||
final String repoName = repository.getName();
|
||||
@ -48,23 +51,47 @@ public class RepoWatchersActivity extends BaseActivity {
|
||||
|
||||
private void fetchDataAsync(String repoOwner, String repoName) {
|
||||
|
||||
RepoWatchersViewModel repoWatchersModel =
|
||||
new ViewModelProvider(this).get(RepoWatchersViewModel.class);
|
||||
|
||||
repoWatchersModel
|
||||
.getRepoWatchers(repoOwner, repoName, ctx)
|
||||
.getRepoWatchers(repoOwner, repoName, ctx, page, resultLimit)
|
||||
.observe(
|
||||
this,
|
||||
watchersListMain -> {
|
||||
adapter = new UserGridAdapter(ctx, watchersListMain);
|
||||
RepoWatchersActivity.this,
|
||||
mainList -> {
|
||||
adapter = new UserGridAdapter(ctx, mainList);
|
||||
adapter.setLoadMoreListener(
|
||||
new UserGridAdapter.OnLoadMoreListener() {
|
||||
|
||||
if (adapter.getCount() > 0) {
|
||||
@Override
|
||||
public void onLoadMore() {
|
||||
|
||||
page += 1;
|
||||
repoWatchersModel.loadMore(
|
||||
repoOwner,
|
||||
repoName,
|
||||
ctx,
|
||||
page,
|
||||
resultLimit,
|
||||
adapter,
|
||||
activityRepoWatchersBinding);
|
||||
activityRepoWatchersBinding.progressBar.setVisibility(
|
||||
View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished() {
|
||||
|
||||
activityRepoWatchersBinding.progressBar.setVisibility(
|
||||
View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(this, 2);
|
||||
activityRepoWatchersBinding.gridView.setLayoutManager(layoutManager);
|
||||
|
||||
if (adapter.getItemCount() > 0) {
|
||||
activityRepoWatchersBinding.gridView.setAdapter(adapter);
|
||||
activityRepoWatchersBinding.noDataWatchers.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
||||
adapter.notifyDataSetChanged();
|
||||
adapter.notifyDataChanged();
|
||||
activityRepoWatchersBinding.gridView.setAdapter(adapter);
|
||||
activityRepoWatchersBinding.noDataWatchers.setVisibility(
|
||||
View.VISIBLE);
|
||||
@ -84,35 +111,4 @@ public class RepoWatchersActivity extends BaseActivity {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||
|
||||
final MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
SearchView searchView = (SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
|
||||
if (activityRepoWatchersBinding.gridView.getAdapter() != null) {
|
||||
adapter.getFilter().filter(newText);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -136,28 +136,6 @@ public class SettingsGeneralActivity extends BaseActivity {
|
||||
v -> viewBinding.switchTabs.setChecked(!viewBinding.switchTabs.isChecked()));
|
||||
// custom tabs switcher
|
||||
|
||||
// drafts deletion switcher
|
||||
viewBinding.commentsDeletionSwitch.setChecked(
|
||||
Boolean.parseBoolean(
|
||||
AppDatabaseSettings.getSettingsValue(
|
||||
ctx, AppDatabaseSettings.APP_DRAFTS_DELETION_KEY)));
|
||||
viewBinding.commentsDeletionSwitch.setOnCheckedChangeListener(
|
||||
(buttonView, isChecked) -> {
|
||||
AppDatabaseSettings.updateSettingsValue(
|
||||
ctx,
|
||||
String.valueOf(isChecked),
|
||||
AppDatabaseSettings.APP_DRAFTS_DELETION_KEY);
|
||||
SnackBar.success(
|
||||
ctx,
|
||||
findViewById(android.R.id.content),
|
||||
getString(R.string.settingsSave));
|
||||
});
|
||||
viewBinding.enableDraftsCommentsDeletion.setOnClickListener(
|
||||
v ->
|
||||
viewBinding.commentsDeletionSwitch.setChecked(
|
||||
!viewBinding.commentsDeletionSwitch.isChecked()));
|
||||
// drafts deletion switcher
|
||||
|
||||
// crash reports switcher
|
||||
viewBinding.crashReportsSwitch.setChecked(
|
||||
Boolean.parseBoolean(
|
||||
|
@ -7,9 +7,10 @@ import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import java.util.List;
|
||||
@ -21,10 +22,12 @@ import org.mian.gitnex.helpers.AppUtil;
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
public class CollaboratorsAdapter extends BaseAdapter {
|
||||
public class CollaboratorsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final List<User> collaboratorsList;
|
||||
private List<User> collaboratorsList;
|
||||
private final Context context;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public CollaboratorsAdapter(Context ctx, List<User> collaboratorsListMain) {
|
||||
|
||||
@ -32,75 +35,76 @@ public class CollaboratorsAdapter extends BaseAdapter {
|
||||
this.collaboratorsList = collaboratorsListMain;
|
||||
}
|
||||
|
||||
@NonNull @Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
return new CollaboratorsAdapter.DataHolder(
|
||||
inflater.inflate(R.layout.list_collaborators, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
|
||||
if (position >= getItemCount() - 1
|
||||
&& isMoreDataAvailable
|
||||
&& !isLoading
|
||||
&& loadMoreListener != null) {
|
||||
|
||||
isLoading = true;
|
||||
loadMoreListener.onLoadMore();
|
||||
}
|
||||
((CollaboratorsAdapter.DataHolder) holder).bindData(collaboratorsList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return collaboratorsList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
@Override
|
||||
public View getView(int position, View finalView, ViewGroup parent) {
|
||||
|
||||
ViewHolder viewHolder;
|
||||
|
||||
if (finalView == null) {
|
||||
|
||||
finalView = LayoutInflater.from(context).inflate(R.layout.list_collaborators, null);
|
||||
viewHolder = new ViewHolder(finalView);
|
||||
finalView.setTag(viewHolder);
|
||||
} else {
|
||||
|
||||
viewHolder = (ViewHolder) finalView.getTag();
|
||||
}
|
||||
|
||||
initData(viewHolder, position);
|
||||
return finalView;
|
||||
}
|
||||
|
||||
private void initData(ViewHolder viewHolder, int position) {
|
||||
|
||||
User currentItem = collaboratorsList.get(position);
|
||||
|
||||
Glide.with(context)
|
||||
.load(currentItem.getAvatarUrl())
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.centerCrop()
|
||||
.into(viewHolder.collaboratorAvatar);
|
||||
|
||||
viewHolder.userLoginId = currentItem.getLogin();
|
||||
|
||||
if (!currentItem.getFullName().isEmpty()) {
|
||||
|
||||
viewHolder.collaboratorName.setText(Html.fromHtml(currentItem.getFullName()));
|
||||
viewHolder.userName.setText(
|
||||
context.getResources()
|
||||
.getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||
} else {
|
||||
|
||||
viewHolder.collaboratorName.setText(currentItem.getLogin());
|
||||
viewHolder.userName.setVisibility(View.GONE);
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if (!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
private class ViewHolder {
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<User> list) {
|
||||
collaboratorsList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
}
|
||||
|
||||
class DataHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ImageView collaboratorAvatar;
|
||||
private final TextView collaboratorName;
|
||||
private final TextView userName;
|
||||
private String userLoginId;
|
||||
|
||||
ViewHolder(View v) {
|
||||
DataHolder(View v) {
|
||||
super(v);
|
||||
|
||||
collaboratorAvatar = v.findViewById(R.id.collaboratorAvatar);
|
||||
collaboratorName = v.findViewById(R.id.collaboratorName);
|
||||
@ -122,5 +126,29 @@ public class CollaboratorsAdapter extends BaseAdapter {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void bindData(User dataModel) {
|
||||
|
||||
Glide.with(context)
|
||||
.load(dataModel.getAvatarUrl())
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.centerCrop()
|
||||
.into(collaboratorAvatar);
|
||||
|
||||
userLoginId = dataModel.getLogin();
|
||||
|
||||
if (!dataModel.getFullName().isEmpty()) {
|
||||
|
||||
collaboratorName.setText(Html.fromHtml(dataModel.getFullName()));
|
||||
userName.setText(
|
||||
context.getResources()
|
||||
.getString(R.string.usernameWithAt, dataModel.getLogin()));
|
||||
} else {
|
||||
|
||||
collaboratorName.setText(dataModel.getLogin());
|
||||
userName.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package org.mian.gitnex.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -11,9 +10,7 @@ import android.widget.TextView;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
|
||||
@ -106,32 +103,32 @@ public class DiffAdapter extends BaseAdapter {
|
||||
}
|
||||
});
|
||||
|
||||
convertView.setOnLongClickListener(
|
||||
v -> {
|
||||
if (selectedLines.contains(position)) {
|
||||
/*convertView.setOnLongClickListener(
|
||||
v -> {
|
||||
if (selectedLines.contains(position)) {
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("```\n");
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("```\n");
|
||||
|
||||
for (Integer selectedLine :
|
||||
selectedLines.stream().sorted().collect(Collectors.toList())) {
|
||||
stringBuilder.append(lines.get(selectedLine));
|
||||
stringBuilder.append("\n");
|
||||
}
|
||||
for (Integer selectedLine :
|
||||
selectedLines.stream().sorted().collect(Collectors.toList())) {
|
||||
stringBuilder.append(lines.get(selectedLine));
|
||||
stringBuilder.append("\n");
|
||||
}
|
||||
|
||||
stringBuilder.append("```\n\n");
|
||||
selectedLines.clear();
|
||||
stringBuilder.append("```\n\n");
|
||||
selectedLines.clear();
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("commentBody", stringBuilder.toString());
|
||||
bundle.putBoolean("cursorToEnd", true);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("commentBody", stringBuilder.toString());
|
||||
bundle.putBoolean("cursorToEnd", true);
|
||||
|
||||
BottomSheetReplyFragment.newInstance(bundle, issue)
|
||||
.show(fragmentManager, "replyBottomSheet");
|
||||
}
|
||||
//BottomSheetReplyFragment.newInstance(bundle, issue)
|
||||
// .show(fragmentManager, "replyBottomSheet");
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
return true;
|
||||
});*/
|
||||
}
|
||||
|
||||
String line = lines.get(position);
|
||||
|
@ -1,191 +0,0 @@
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spanned;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import java.util.List;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.DraftsApi;
|
||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||
import org.mian.gitnex.helpers.Markdown;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsViewHolder> {
|
||||
|
||||
private final FragmentManager fragmentManager;
|
||||
private final Context context;
|
||||
private List<DraftWithRepository> draftsList;
|
||||
|
||||
public DraftsAdapter(
|
||||
Context ctx,
|
||||
FragmentManager fragmentManager,
|
||||
List<DraftWithRepository> draftsListMain) {
|
||||
this.context = ctx;
|
||||
this.fragmentManager = fragmentManager;
|
||||
this.draftsList = draftsListMain;
|
||||
}
|
||||
|
||||
private void deleteDraft(int position) {
|
||||
|
||||
draftsList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, draftsList.size());
|
||||
Toasty.success(
|
||||
context, context.getResources().getString(R.string.draftsSingleDeleteSuccess));
|
||||
}
|
||||
|
||||
@NonNull @Override
|
||||
public DraftsAdapter.DraftsViewHolder onCreateViewHolder(
|
||||
@NonNull ViewGroup parent, int viewType) {
|
||||
View v =
|
||||
LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.list_drafts, parent, false);
|
||||
return new DraftsViewHolder(v);
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull DraftsAdapter.DraftsViewHolder holder, int position) {
|
||||
|
||||
DraftWithRepository currentItem = draftsList.get(position);
|
||||
|
||||
String issueNumber =
|
||||
"<font color='"
|
||||
+ ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null)
|
||||
+ "'>"
|
||||
+ context.getResources().getString(R.string.hash)
|
||||
+ currentItem.getIssueId()
|
||||
+ "</font>";
|
||||
Spanned headTitle =
|
||||
HtmlCompat.fromHtml(
|
||||
issueNumber
|
||||
+ " "
|
||||
+ currentItem.getRepositoryOwner()
|
||||
+ " / "
|
||||
+ currentItem.getRepositoryName(),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY);
|
||||
|
||||
holder.repoInfo.setText(headTitle);
|
||||
holder.draftWithRepository = currentItem;
|
||||
|
||||
Markdown.render(context, currentItem.getDraftText(), holder.draftText);
|
||||
|
||||
if (!currentItem.getCommentId().equalsIgnoreCase("new")) {
|
||||
holder.editCommentStatus.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.editCommentStatus.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return draftsList.size();
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void updateList(List<DraftWithRepository> list) {
|
||||
|
||||
draftsList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
public class DraftsViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView draftText;
|
||||
private final TextView repoInfo;
|
||||
private final ImageView editCommentStatus;
|
||||
private DraftWithRepository draftWithRepository;
|
||||
|
||||
private DraftsViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
draftText = itemView.findViewById(R.id.draftText);
|
||||
repoInfo = itemView.findViewById(R.id.repoInfo);
|
||||
ImageView deleteDraft = itemView.findViewById(R.id.deleteDraft);
|
||||
editCommentStatus = itemView.findViewById(R.id.editCommentStatus);
|
||||
|
||||
deleteDraft.setOnClickListener(
|
||||
itemDelete -> {
|
||||
int getDraftId = draftWithRepository.getDraftId();
|
||||
deleteDraft(getBindingAdapterPosition());
|
||||
|
||||
DraftsApi draftsApi = BaseApi.getInstance(context, DraftsApi.class);
|
||||
assert draftsApi != null;
|
||||
draftsApi.deleteSingleDraft(getDraftId);
|
||||
});
|
||||
|
||||
itemView.setOnClickListener(
|
||||
itemEdit -> {
|
||||
RepositoryContext repository =
|
||||
new RepositoryContext(
|
||||
draftWithRepository.getRepositoryOwner(),
|
||||
draftWithRepository.getRepositoryName(),
|
||||
context);
|
||||
repository.setRepositoryId(draftWithRepository.getRepositoryId());
|
||||
IssueContext issue =
|
||||
new IssueContext(
|
||||
repository,
|
||||
draftWithRepository.getIssueId(),
|
||||
draftWithRepository.getIssueType());
|
||||
Bundle bundle = issue.getBundle();
|
||||
|
||||
bundle.putString("commentBody", draftWithRepository.getDraftText());
|
||||
bundle.putString(
|
||||
"issueNumber", String.valueOf(draftWithRepository.getIssueId()));
|
||||
bundle.putString("draftTitle", repoInfo.getText().toString());
|
||||
bundle.putString("commentId", draftWithRepository.getCommentId());
|
||||
bundle.putString(
|
||||
"draftId", String.valueOf(draftWithRepository.getDraftId()));
|
||||
|
||||
if (!draftWithRepository.getCommentId().isEmpty()) {
|
||||
bundle.putString("commentAction", "edit");
|
||||
}
|
||||
|
||||
BottomSheetReplyFragment bottomSheetReplyFragment =
|
||||
BottomSheetReplyFragment.newInstance(bundle, issue);
|
||||
bottomSheetReplyFragment.setOnInteractedListener(
|
||||
() -> {
|
||||
Intent i =
|
||||
new IssueContext(
|
||||
new RepositoryContext(
|
||||
draftWithRepository
|
||||
.getRepositoryOwner(),
|
||||
draftWithRepository
|
||||
.getRepositoryName(),
|
||||
context),
|
||||
draftWithRepository.getIssueId(),
|
||||
draftWithRepository.getIssueType())
|
||||
.getIntent(context, IssueDetailActivity.class);
|
||||
i.putExtra("openedFromLink", "true");
|
||||
context.startActivity(i);
|
||||
});
|
||||
bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -28,45 +28,46 @@ import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsViewHolder> {
|
||||
public class LabelsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final List<Label> labelsList;
|
||||
private final Context context;
|
||||
private List<Label> labelsList;
|
||||
private final String type;
|
||||
private final String orgName;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
public LabelsAdapter(Context ctx, List<Label> labelsMain, String type, String orgName) {
|
||||
|
||||
this.context = ctx;
|
||||
this.labelsList = labelsMain;
|
||||
this.type = type;
|
||||
this.orgName = orgName;
|
||||
}
|
||||
|
||||
@NonNull @Override
|
||||
public LabelsAdapter.LabelsViewHolder onCreateViewHolder(
|
||||
@NonNull ViewGroup parent, int viewType) {
|
||||
View v =
|
||||
LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.list_labels, parent, false);
|
||||
return new LabelsAdapter.LabelsViewHolder(v);
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
return new LabelsAdapter.DataHolder(inflater.inflate(R.layout.list_labels, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull LabelsAdapter.LabelsViewHolder holder, int position) {
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
|
||||
Label currentItem = labelsList.get(position);
|
||||
holder.labels = currentItem;
|
||||
if (position >= getItemCount() - 1
|
||||
&& isMoreDataAvailable
|
||||
&& !isLoading
|
||||
&& loadMoreListener != null) {
|
||||
|
||||
String labelColor = currentItem.getColor();
|
||||
String labelName = currentItem.getName();
|
||||
isLoading = true;
|
||||
loadMoreListener.onLoadMore();
|
||||
}
|
||||
((LabelsAdapter.DataHolder) holder).bindData(labelsList.get(position));
|
||||
}
|
||||
|
||||
int color = Color.parseColor("#" + labelColor);
|
||||
int contrastColor = new ColorInverter().getContrastColor(color);
|
||||
|
||||
ImageViewCompat.setImageTintList(holder.labelIcon, ColorStateList.valueOf(contrastColor));
|
||||
|
||||
holder.labelName.setTextColor(contrastColor);
|
||||
holder.labelName.setText(labelName);
|
||||
holder.labelView.setCardBackgroundColor(color);
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -74,19 +75,51 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
||||
return labelsList.size();
|
||||
}
|
||||
|
||||
private void updateAdapter(int position) {
|
||||
labelsList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, labelsList.size());
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if (!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public class LabelsViewHolder extends RecyclerView.ViewHolder {
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<Label> list) {
|
||||
labelsList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
}
|
||||
|
||||
class DataHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final MaterialCardView labelView;
|
||||
private final ImageView labelIcon;
|
||||
private final TextView labelName;
|
||||
private Label labels;
|
||||
|
||||
private LabelsViewHolder(View itemView) {
|
||||
DataHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
labelView = itemView.findViewById(R.id.labelView);
|
||||
@ -165,5 +198,23 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
void bindData(Label dataModel) {
|
||||
|
||||
labels = dataModel;
|
||||
|
||||
String labelColor_ = dataModel.getColor();
|
||||
String labelName_ = dataModel.getName();
|
||||
|
||||
int color = Color.parseColor("#" + labelColor_);
|
||||
int contrastColor = new ColorInverter().getContrastColor(color);
|
||||
|
||||
ImageViewCompat.setImageTintList(labelIcon, ColorStateList.valueOf(contrastColor));
|
||||
|
||||
labelName.setTextColor(contrastColor);
|
||||
labelName.setText(labelName_);
|
||||
labelView.setCardBackgroundColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ public class OrganizationTeamRepositoriesAdapter
|
||||
|
||||
if (getItemCount() > 0) {
|
||||
Call<List<Repository>> call =
|
||||
RetrofitClient.getApiInterface(context).orgListTeamRepos((long) teamId, 1, 50);
|
||||
RetrofitClient.getApiInterface(context).orgListTeamRepos((long) teamId, 1, 100);
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
@ -7,14 +7,12 @@ import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
@ -24,21 +22,90 @@ import org.mian.gitnex.helpers.AppUtil;
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
public class UserGridAdapter extends BaseAdapter implements Filterable {
|
||||
public class UserGridAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final List<User> membersList;
|
||||
private List<User> membersList;
|
||||
private final Context context;
|
||||
private final List<User> membersListFull;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
|
||||
private class ViewHolder {
|
||||
public UserGridAdapter(Context ctx, List<User> membersListMain) {
|
||||
|
||||
this.context = ctx;
|
||||
this.membersList = membersListMain;
|
||||
}
|
||||
|
||||
@NonNull @Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
return new UserGridAdapter.DataHolder(
|
||||
inflater.inflate(R.layout.list_users_grid, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
|
||||
if (position >= getItemCount() - 1
|
||||
&& isMoreDataAvailable
|
||||
&& !isLoading
|
||||
&& loadMoreListener != null) {
|
||||
|
||||
isLoading = true;
|
||||
loadMoreListener.onLoadMore();
|
||||
}
|
||||
((UserGridAdapter.DataHolder) holder).bindData(membersList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return membersList.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if (!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<User> list) {
|
||||
membersList = list;
|
||||
notifyDataChanged();
|
||||
}
|
||||
|
||||
public interface OnLoadMoreListener {
|
||||
|
||||
void onLoadMore();
|
||||
|
||||
void onLoadFinished();
|
||||
}
|
||||
|
||||
class DataHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private String userLoginId;
|
||||
|
||||
private final ImageView memberAvatar;
|
||||
private final TextView memberName;
|
||||
private final TextView userName;
|
||||
|
||||
ViewHolder(View v) {
|
||||
DataHolder(View v) {
|
||||
|
||||
super(v);
|
||||
|
||||
memberAvatar = v.findViewById(R.id.userAvatarImageView);
|
||||
memberName = v.findViewById(R.id.userNameTv);
|
||||
@ -60,114 +127,29 @@ public class UserGridAdapter extends BaseAdapter implements Filterable {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public UserGridAdapter(Context ctx, List<User> membersListMain) {
|
||||
void bindData(User dataModel) {
|
||||
|
||||
this.context = ctx;
|
||||
this.membersList = membersListMain;
|
||||
membersListFull = new ArrayList<>(membersList);
|
||||
}
|
||||
Glide.with(context)
|
||||
.load(dataModel.getAvatarUrl())
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.centerCrop()
|
||||
.into(memberAvatar);
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return membersList.size();
|
||||
}
|
||||
userLoginId = dataModel.getLogin();
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
if (!dataModel.getFullName().isEmpty()) {
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
memberName.setText(Html.fromHtml(dataModel.getFullName()));
|
||||
userName.setText(
|
||||
context.getResources()
|
||||
.getString(R.string.usernameWithAt, dataModel.getLogin()));
|
||||
} else {
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
@Override
|
||||
public View getView(int position, View finalView, ViewGroup parent) {
|
||||
|
||||
UserGridAdapter.ViewHolder viewHolder;
|
||||
|
||||
if (finalView == null) {
|
||||
|
||||
finalView = LayoutInflater.from(context).inflate(R.layout.list_users_grid, null);
|
||||
viewHolder = new ViewHolder(finalView);
|
||||
finalView.setTag(viewHolder);
|
||||
} else {
|
||||
|
||||
viewHolder = (UserGridAdapter.ViewHolder) finalView.getTag();
|
||||
}
|
||||
|
||||
initData(viewHolder, position);
|
||||
return finalView;
|
||||
}
|
||||
|
||||
private void initData(UserGridAdapter.ViewHolder viewHolder, int position) {
|
||||
|
||||
User currentItem = membersList.get(position);
|
||||
|
||||
Glide.with(context)
|
||||
.load(currentItem.getAvatarUrl())
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.centerCrop()
|
||||
.into(viewHolder.memberAvatar);
|
||||
|
||||
viewHolder.userLoginId = currentItem.getLogin();
|
||||
|
||||
if (!currentItem.getFullName().isEmpty()) {
|
||||
|
||||
viewHolder.memberName.setText(Html.fromHtml(currentItem.getFullName()));
|
||||
viewHolder.userName.setText(
|
||||
context.getResources()
|
||||
.getString(R.string.usernameWithAt, currentItem.getLogin()));
|
||||
} else {
|
||||
|
||||
viewHolder.memberName.setText(currentItem.getLogin());
|
||||
viewHolder.userName.setVisibility(View.GONE);
|
||||
memberName.setText(dataModel.getLogin());
|
||||
userName.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return membersFilter;
|
||||
}
|
||||
|
||||
private final Filter membersFilter =
|
||||
new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
List<User> filteredList = new ArrayList<>();
|
||||
|
||||
if (constraint == null || constraint.length() == 0) {
|
||||
|
||||
filteredList.addAll(membersListFull);
|
||||
} else {
|
||||
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for (User item : membersListFull) {
|
||||
if (item.getFullName().toLowerCase().contains(filterPattern)
|
||||
|| item.getLogin().toLowerCase().contains(filterPattern)) {
|
||||
filteredList.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
results.values = filteredList;
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
membersList.clear();
|
||||
membersList.addAll((List) results.values);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ public class RetrofitClient {
|
||||
String token,
|
||||
File cacheFile) {
|
||||
|
||||
// HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||
// logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
// HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||
// logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
try {
|
||||
|
||||
@ -75,7 +75,7 @@ public class RetrofitClient {
|
||||
auth.setApiKey(token);
|
||||
OkHttpClient.Builder okHttpClient =
|
||||
new OkHttpClient.Builder()
|
||||
// .addInterceptor(logging)
|
||||
// .addInterceptor(logging)
|
||||
.addInterceptor(auth)
|
||||
.sslSocketFactory(sslContext.getSocketFactory(), memorizingTrustManager)
|
||||
.hostnameVerifier(
|
||||
|
@ -1,89 +0,0 @@
|
||||
package org.mian.gitnex.database.api;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import java.util.List;
|
||||
import org.mian.gitnex.database.dao.DraftsDao;
|
||||
import org.mian.gitnex.database.models.Draft;
|
||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
public class DraftsApi extends BaseApi {
|
||||
|
||||
private final DraftsDao draftsDao;
|
||||
|
||||
DraftsApi(Context context) {
|
||||
super(context);
|
||||
draftsDao = gitnexDatabase.draftsDao();
|
||||
}
|
||||
|
||||
public long insertDraft(
|
||||
int repositoryId,
|
||||
int draftAccountId,
|
||||
int issueId,
|
||||
String draftText,
|
||||
String draftType,
|
||||
String commentId,
|
||||
String issueType) {
|
||||
|
||||
Draft draft = new Draft();
|
||||
draft.setDraftRepositoryId(repositoryId);
|
||||
draft.setDraftAccountId(draftAccountId);
|
||||
draft.setIssueId(issueId);
|
||||
draft.setDraftText(draftText);
|
||||
draft.setDraftType(draftType);
|
||||
draft.setCommentId(commentId);
|
||||
draft.setIssueType(issueType);
|
||||
|
||||
return insertDraftAsyncTask(draft);
|
||||
}
|
||||
|
||||
private long insertDraftAsyncTask(final Draft draft) {
|
||||
return draftsDao.insertDraft(draft);
|
||||
}
|
||||
|
||||
public long getDraftIdAsync(int issueId, int draftRepositoryId) {
|
||||
return draftsDao.getDraftId(issueId, draftRepositoryId);
|
||||
}
|
||||
|
||||
public Integer checkDraft(int issueId, int draftRepositoryId, String commentId) {
|
||||
return draftsDao.checkDraftDao(issueId, draftRepositoryId, commentId);
|
||||
}
|
||||
|
||||
public LiveData<List<DraftWithRepository>> getDrafts(int accountId) {
|
||||
return draftsDao.fetchAllDrafts(accountId);
|
||||
}
|
||||
|
||||
public LiveData<Draft> getDraftByIssueId(int issueId) {
|
||||
return draftsDao.fetchDraftByIssueId(issueId);
|
||||
}
|
||||
|
||||
public void deleteSingleDraft(final int draftId) {
|
||||
final LiveData<Draft> draft = draftsDao.fetchDraftById(draftId);
|
||||
|
||||
if (draft != null) {
|
||||
executorService.execute(() -> draftsDao.deleteByDraftId(draftId));
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteAllDrafts(final int accountId) {
|
||||
executorService.execute(() -> draftsDao.deleteAllDrafts(accountId));
|
||||
}
|
||||
|
||||
public void updateDraft(final String draftText, final int draftId, final String commentId) {
|
||||
executorService.execute(() -> draftsDao.updateDraft(draftText, draftId, commentId));
|
||||
}
|
||||
|
||||
public void updateDraftByIssueIdAsyncTask(
|
||||
final String draftText,
|
||||
final int issueId,
|
||||
final int draftRepositoryId,
|
||||
final String commentId) {
|
||||
executorService.execute(
|
||||
() ->
|
||||
draftsDao.updateDraftByIssueId(
|
||||
draftText, issueId, draftRepositoryId, commentId));
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package org.mian.gitnex.database.dao;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
import java.util.List;
|
||||
import org.mian.gitnex.database.models.Draft;
|
||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
@Dao
|
||||
public interface DraftsDao {
|
||||
|
||||
@Insert
|
||||
long insertDraft(Draft drafts);
|
||||
|
||||
@Query(
|
||||
"SELECT * FROM Drafts JOIN Repositories ON Repositories.repositoryId = Drafts.draftRepositoryId WHERE draftAccountId = :accountId"
|
||||
+ " ORDER BY "
|
||||
+ "draftId DESC")
|
||||
LiveData<List<DraftWithRepository>> fetchAllDrafts(int accountId);
|
||||
|
||||
@Query("SELECT * FROM Drafts WHERE draftAccountId = :accountId ORDER BY draftId DESC")
|
||||
LiveData<List<Draft>> fetchDrafts(int accountId);
|
||||
|
||||
@Query(
|
||||
"SELECT * FROM Drafts WHERE draftAccountId = :accountId and draftRepositoryId = :repositoryId")
|
||||
LiveData<Draft> fetchSingleDraftByAccountIdAndRepositoryId(int accountId, int repositoryId);
|
||||
|
||||
@Query("SELECT * FROM Drafts WHERE draftId = :draftId")
|
||||
LiveData<Draft> fetchDraftById(int draftId);
|
||||
|
||||
@Query("SELECT * FROM Drafts WHERE issueId = :issueId")
|
||||
LiveData<Draft> fetchDraftByIssueId(int issueId);
|
||||
|
||||
@Query(
|
||||
"SELECT count(draftId) FROM Drafts WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId AND commentId = :commentId")
|
||||
Integer checkDraftDao(int issueId, int draftRepositoryId, String commentId);
|
||||
|
||||
@Query(
|
||||
"UPDATE Drafts SET draftText = :draftText, commentId = :commentId WHERE draftId = :draftId")
|
||||
void updateDraft(String draftText, int draftId, String commentId);
|
||||
|
||||
@Query(
|
||||
"UPDATE Drafts SET draftText = :draftText WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId AND commentId = :commentId")
|
||||
void updateDraftByIssueId(
|
||||
String draftText, int issueId, int draftRepositoryId, String commentId);
|
||||
|
||||
@Query(
|
||||
"SELECT draftId FROM Drafts WHERE issueId = :issueId AND draftRepositoryId = :draftRepositoryId")
|
||||
Integer getDraftId(int issueId, int draftRepositoryId);
|
||||
|
||||
@Query("DELETE FROM Drafts WHERE draftId = :draftId")
|
||||
void deleteByDraftId(int draftId);
|
||||
|
||||
@Query("DELETE FROM Drafts WHERE draftAccountId = :accountId")
|
||||
void deleteAllDrafts(int accountId);
|
||||
}
|
@ -8,12 +8,10 @@ import androidx.room.RoomDatabase;
|
||||
import androidx.room.migration.Migration;
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase;
|
||||
import org.mian.gitnex.database.dao.AppSettingsDao;
|
||||
import org.mian.gitnex.database.dao.DraftsDao;
|
||||
import org.mian.gitnex.database.dao.NotesDao;
|
||||
import org.mian.gitnex.database.dao.RepositoriesDao;
|
||||
import org.mian.gitnex.database.dao.UserAccountsDao;
|
||||
import org.mian.gitnex.database.models.AppSettings;
|
||||
import org.mian.gitnex.database.models.Draft;
|
||||
import org.mian.gitnex.database.models.Notes;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.database.models.UserAccount;
|
||||
@ -22,14 +20,8 @@ import org.mian.gitnex.database.models.UserAccount;
|
||||
* @author M M Arif
|
||||
*/
|
||||
@Database(
|
||||
entities = {
|
||||
Draft.class,
|
||||
Repository.class,
|
||||
UserAccount.class,
|
||||
Notes.class,
|
||||
AppSettings.class
|
||||
},
|
||||
version = 9,
|
||||
entities = {Repository.class, UserAccount.class, Notes.class, AppSettings.class},
|
||||
version = 10,
|
||||
exportSchema = false)
|
||||
public abstract class GitnexDatabase extends RoomDatabase {
|
||||
|
||||
@ -109,6 +101,15 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
||||
"ALTER TABLE 'userAccounts' ADD COLUMN 'maxNumberOfAttachments' INTEGER NOT NULL DEFAULT 5");
|
||||
}
|
||||
};
|
||||
|
||||
private static final Migration MIGRATION_9_10 =
|
||||
new Migration(9, 10) {
|
||||
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
database.execSQL("DROP table Drafts");
|
||||
}
|
||||
};
|
||||
private static volatile GitnexDatabase gitnexDatabase;
|
||||
|
||||
public static GitnexDatabase getDatabaseInstance(Context context) {
|
||||
@ -129,7 +130,8 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
||||
MIGRATION_5_6,
|
||||
MIGRATION_6_7,
|
||||
MIGRATION_7_8,
|
||||
MIGRATION_8_9)
|
||||
MIGRATION_8_9,
|
||||
MIGRATION_9_10)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@ -138,8 +140,6 @@ public abstract class GitnexDatabase extends RoomDatabase {
|
||||
return gitnexDatabase;
|
||||
}
|
||||
|
||||
public abstract DraftsDao draftsDao();
|
||||
|
||||
public abstract RepositoriesDao repositoriesDao();
|
||||
|
||||
public abstract UserAccountsDao userAccountsDao();
|
||||
|
@ -1,116 +0,0 @@
|
||||
package org.mian.gitnex.database.models;
|
||||
|
||||
import static androidx.room.ForeignKey.CASCADE;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.ForeignKey;
|
||||
import androidx.room.Index;
|
||||
import androidx.room.PrimaryKey;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
@Entity(
|
||||
tableName = "Drafts",
|
||||
foreignKeys =
|
||||
@ForeignKey(
|
||||
entity = Repository.class,
|
||||
parentColumns = "repositoryId",
|
||||
childColumns = "draftRepositoryId",
|
||||
onDelete = CASCADE),
|
||||
indices = {@Index("draftRepositoryId")})
|
||||
public class Draft implements Serializable {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
private int draftId;
|
||||
|
||||
private int draftRepositoryId;
|
||||
private int draftAccountId;
|
||||
private int issueId;
|
||||
private String draftText;
|
||||
@Nullable private String draftType;
|
||||
@Nullable private String commentId;
|
||||
@Nullable private String issueType;
|
||||
|
||||
public int getDraftId() {
|
||||
|
||||
return draftId;
|
||||
}
|
||||
|
||||
public void setDraftId(int draftId) {
|
||||
|
||||
this.draftId = draftId;
|
||||
}
|
||||
|
||||
public int getDraftRepositoryId() {
|
||||
|
||||
return draftRepositoryId;
|
||||
}
|
||||
|
||||
public void setDraftRepositoryId(int draftRepositoryId) {
|
||||
|
||||
this.draftRepositoryId = draftRepositoryId;
|
||||
}
|
||||
|
||||
public int getDraftAccountId() {
|
||||
|
||||
return draftAccountId;
|
||||
}
|
||||
|
||||
public void setDraftAccountId(int draftAccountId) {
|
||||
|
||||
this.draftAccountId = draftAccountId;
|
||||
}
|
||||
|
||||
public int getIssueId() {
|
||||
|
||||
return issueId;
|
||||
}
|
||||
|
||||
public void setIssueId(int issueId) {
|
||||
|
||||
this.issueId = issueId;
|
||||
}
|
||||
|
||||
public String getDraftText() {
|
||||
|
||||
return draftText;
|
||||
}
|
||||
|
||||
public void setDraftText(String draftText) {
|
||||
|
||||
this.draftText = draftText;
|
||||
}
|
||||
|
||||
@Nullable public String getDraftType() {
|
||||
|
||||
return draftType;
|
||||
}
|
||||
|
||||
public void setDraftType(@Nullable String draftType) {
|
||||
|
||||
this.draftType = draftType;
|
||||
}
|
||||
|
||||
@Nullable public String getCommentId() {
|
||||
|
||||
return commentId;
|
||||
}
|
||||
|
||||
public void setCommentId(@Nullable String commentId) {
|
||||
|
||||
this.commentId = commentId;
|
||||
}
|
||||
|
||||
@Nullable public String getIssueType() {
|
||||
|
||||
return issueType;
|
||||
}
|
||||
|
||||
public void setIssueType(@Nullable String issueType) {
|
||||
|
||||
this.issueType = issueType;
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import org.mian.gitnex.databinding.BottomSheetDraftsBinding;
|
||||
import org.mian.gitnex.structs.BottomSheetListener;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
public class BottomSheetDraftsFragment extends BottomSheetDialogFragment {
|
||||
|
||||
private final String TAG = "BottomSheetDraftsFragment";
|
||||
private BottomSheetListener bmListener;
|
||||
|
||||
@Nullable @Override
|
||||
public View onCreateView(
|
||||
@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
|
||||
BottomSheetDraftsBinding bottomSheetDraftsBinding =
|
||||
BottomSheetDraftsBinding.inflate(inflater, container, false);
|
||||
|
||||
bottomSheetDraftsBinding.deleteAllDrafts.setOnClickListener(
|
||||
v1 -> {
|
||||
dismiss();
|
||||
bmListener.onButtonClicked("deleteDrafts");
|
||||
});
|
||||
|
||||
return bottomSheetDraftsBinding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
|
||||
try {
|
||||
bmListener = (BottomSheetListener) context;
|
||||
} catch (ClassCastException e) {
|
||||
Log.e(TAG, e.toString());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,334 +0,0 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import java.util.Objects;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.ActionResult;
|
||||
import org.mian.gitnex.actions.IssueActions;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.DraftsApi;
|
||||
import org.mian.gitnex.databinding.BottomSheetReplyLayoutBinding;
|
||||
import org.mian.gitnex.helpers.AppDatabaseSettings;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.IssueContext;
|
||||
|
||||
/**
|
||||
* @author opyale
|
||||
*/
|
||||
public class BottomSheetReplyFragment extends BottomSheetDialogFragment {
|
||||
|
||||
private Mode mode = Mode.SEND;
|
||||
private DraftsApi draftsApi;
|
||||
private int currentActiveAccountId;
|
||||
private IssueContext issue;
|
||||
private long draftId;
|
||||
private Runnable onInteractedListener;
|
||||
private TextView draftsHint;
|
||||
|
||||
public static BottomSheetReplyFragment newInstance(Bundle bundle, IssueContext issue) {
|
||||
|
||||
BottomSheetReplyFragment fragment = new BottomSheetReplyFragment();
|
||||
bundle.putSerializable(IssueContext.INTENT_EXTRA, issue);
|
||||
fragment.setArguments(bundle);
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
|
||||
super.onAttach(context);
|
||||
|
||||
draftsApi = BaseApi.getInstance(context, DraftsApi.class);
|
||||
|
||||
currentActiveAccountId =
|
||||
((BaseActivity) requireActivity()).getAccount().getAccount().getAccountId();
|
||||
issue = IssueContext.fromBundle(requireArguments());
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Nullable @Override
|
||||
public View onCreateView(
|
||||
@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
|
||||
BottomSheetReplyLayoutBinding bottomSheetReplyLayoutBinding =
|
||||
BottomSheetReplyLayoutBinding.inflate(inflater, container, false);
|
||||
Bundle arguments = requireArguments();
|
||||
|
||||
draftsHint = bottomSheetReplyLayoutBinding.draftsHint;
|
||||
|
||||
EditText comment = bottomSheetReplyLayoutBinding.comment;
|
||||
TextView toolbarTitle = bottomSheetReplyLayoutBinding.toolbarTitle;
|
||||
ImageButton close = bottomSheetReplyLayoutBinding.close;
|
||||
ImageButton drafts = bottomSheetReplyLayoutBinding.drafts;
|
||||
ImageButton send = bottomSheetReplyLayoutBinding.send;
|
||||
|
||||
send.setEnabled(false);
|
||||
|
||||
if (Objects.equals(arguments.getString("commentAction"), "edit")
|
||||
&& arguments.getString("draftId") == null) {
|
||||
|
||||
send.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_save));
|
||||
mode = Mode.EDIT;
|
||||
}
|
||||
|
||||
if (arguments.getString("draftId") != null) {
|
||||
|
||||
draftId = Long.parseLong(Objects.requireNonNull(arguments.getString("draftId")));
|
||||
}
|
||||
|
||||
if (issue.getIssue() != null && !issue.getIssue().getTitle().isEmpty()) {
|
||||
|
||||
toolbarTitle.setText(EmojiParser.parseToUnicode(issue.getIssue().getTitle()));
|
||||
} else if (arguments.getString("draftTitle") != null) {
|
||||
|
||||
toolbarTitle.setText(arguments.getString("draftTitle"));
|
||||
}
|
||||
|
||||
if (arguments.getString("commentBody") != null) {
|
||||
|
||||
send.setEnabled(true);
|
||||
send.setAlpha(1f);
|
||||
|
||||
comment.setText(arguments.getString("commentBody"));
|
||||
|
||||
if (arguments.getBoolean("cursorToEnd", false)) {
|
||||
|
||||
comment.setSelection(comment.length());
|
||||
}
|
||||
}
|
||||
|
||||
comment.requestFocus();
|
||||
comment.setOnTouchListener(
|
||||
(v, event) -> {
|
||||
BottomSheetBehavior<View> bottomSheetBehavior =
|
||||
BottomSheetBehavior.from(
|
||||
(View) bottomSheetReplyLayoutBinding.getRoot().getParent());
|
||||
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
case MotionEvent.ACTION_SCROLL:
|
||||
bottomSheetBehavior.setDraggable(false);
|
||||
break;
|
||||
|
||||
default:
|
||||
bottomSheetBehavior.setDraggable(true);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
comment.addTextChangedListener(
|
||||
new TextWatcher() {
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
String text = comment.getText().toString();
|
||||
|
||||
if (text.isEmpty()) {
|
||||
|
||||
send.setEnabled(false);
|
||||
send.setAlpha(0.5f);
|
||||
saveDraft(null, true);
|
||||
} else {
|
||||
|
||||
send.setEnabled(true);
|
||||
send.setAlpha(1f);
|
||||
saveDraft(text, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(
|
||||
CharSequence s, int start, int count, int after) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
||||
});
|
||||
|
||||
close.setOnClickListener(v -> dismiss());
|
||||
|
||||
drafts.setOnClickListener(
|
||||
v -> {
|
||||
Intent intent = new Intent(getContext(), MainActivity.class);
|
||||
intent.putExtra("launchFragment", "drafts");
|
||||
startActivity(intent);
|
||||
|
||||
dismiss();
|
||||
});
|
||||
|
||||
send.setOnClickListener(
|
||||
v -> {
|
||||
if (mode == Mode.SEND) {
|
||||
|
||||
IssueActions.reply(getContext(), comment.getText().toString(), issue)
|
||||
.accept(
|
||||
(status, result) -> {
|
||||
if (status == ActionResult.Status.SUCCESS) {
|
||||
|
||||
IssueDetailActivity.commentPosted = true;
|
||||
|
||||
Toasty.success(
|
||||
getContext(),
|
||||
getString(R.string.commentSuccess));
|
||||
|
||||
if (draftId != 0
|
||||
&& Boolean.parseBoolean(
|
||||
AppDatabaseSettings
|
||||
.getSettingsValue(
|
||||
getContext(),
|
||||
AppDatabaseSettings
|
||||
.APP_DRAFTS_DELETION_KEY))) {
|
||||
draftsApi.deleteSingleDraft((int) draftId);
|
||||
}
|
||||
|
||||
if (onInteractedListener != null) {
|
||||
onInteractedListener.run();
|
||||
}
|
||||
} else {
|
||||
|
||||
Toasty.error(
|
||||
getContext(),
|
||||
getString(R.string.genericError));
|
||||
}
|
||||
|
||||
dismiss();
|
||||
});
|
||||
} else {
|
||||
|
||||
IssueActions.edit(
|
||||
getContext(),
|
||||
comment.getText().toString(),
|
||||
arguments.getInt("commentId"),
|
||||
issue)
|
||||
.accept(
|
||||
(status, result) -> {
|
||||
FragmentActivity activity = requireActivity();
|
||||
if (activity instanceof IssueDetailActivity) {
|
||||
IssueDetailActivity.commentEdited = true;
|
||||
}
|
||||
|
||||
if (status == ActionResult.Status.SUCCESS) {
|
||||
|
||||
if (draftId != 0
|
||||
&& Boolean.parseBoolean(
|
||||
AppDatabaseSettings
|
||||
.getSettingsValue(
|
||||
getContext(),
|
||||
AppDatabaseSettings
|
||||
.APP_DRAFTS_DELETION_KEY))) {
|
||||
draftsApi.deleteSingleDraft((int) draftId);
|
||||
}
|
||||
|
||||
if (onInteractedListener != null) {
|
||||
onInteractedListener.run();
|
||||
}
|
||||
} else {
|
||||
|
||||
Toasty.error(
|
||||
getContext(),
|
||||
getString(R.string.genericError));
|
||||
}
|
||||
|
||||
dismiss();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return bottomSheetReplyLayoutBinding.getRoot();
|
||||
}
|
||||
|
||||
private void saveDraft(String text, boolean remove) {
|
||||
|
||||
@SuppressLint("Recycle")
|
||||
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0f, 1f);
|
||||
valueAnimator.setDuration(500);
|
||||
valueAnimator.addUpdateListener(
|
||||
animation -> {
|
||||
float value = (Float) animation.getAnimatedValue();
|
||||
|
||||
if (value == 0f) {
|
||||
draftsHint.setVisibility((remove) ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
draftsHint.setAlpha(value);
|
||||
});
|
||||
|
||||
if (remove) {
|
||||
|
||||
draftsApi.deleteSingleDraft((int) draftId);
|
||||
draftId = 0;
|
||||
|
||||
valueAnimator.reverse();
|
||||
} else {
|
||||
|
||||
String draftType;
|
||||
if (issue.getIssueType().equalsIgnoreCase("Issue")) {
|
||||
|
||||
draftType = Constants.draftTypeIssue;
|
||||
} else if (issue.getIssueType().equalsIgnoreCase("Pull")) {
|
||||
|
||||
draftType = Constants.draftTypePull;
|
||||
} else {
|
||||
|
||||
draftType = "";
|
||||
}
|
||||
|
||||
if (draftId == 0) {
|
||||
|
||||
draftId =
|
||||
draftsApi.insertDraft(
|
||||
issue.getRepository().saveToDB(requireContext()),
|
||||
currentActiveAccountId,
|
||||
issue.getIssueIndex(),
|
||||
text,
|
||||
draftType,
|
||||
"TODO",
|
||||
issue.getIssueType());
|
||||
} else {
|
||||
|
||||
draftsApi.updateDraft(text, (int) draftId, "TODO");
|
||||
}
|
||||
|
||||
draftsHint.setVisibility(View.VISIBLE);
|
||||
// valueAnimator.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnInteractedListener(Runnable onInteractedListener) {
|
||||
|
||||
this.onInteractedListener = onInteractedListener;
|
||||
}
|
||||
|
||||
private enum Mode {
|
||||
EDIT,
|
||||
SEND
|
||||
}
|
||||
}
|
@ -7,9 +7,11 @@ import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import org.mian.gitnex.activities.AddCollaboratorToRepositoryActivity;
|
||||
import org.mian.gitnex.adapters.CollaboratorsAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentCollaboratorsBinding;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.viewmodels.CollaboratorsViewModel;
|
||||
|
||||
@ -22,6 +24,9 @@ public class CollaboratorsFragment extends Fragment {
|
||||
private FragmentCollaboratorsBinding fragmentCollaboratorsBinding;
|
||||
private CollaboratorsAdapter adapter;
|
||||
private RepositoryContext repository;
|
||||
private CollaboratorsViewModel collaboratorsModel;
|
||||
private int page = 1;
|
||||
private int resultLimit;
|
||||
|
||||
public CollaboratorsFragment() {}
|
||||
|
||||
@ -44,6 +49,9 @@ public class CollaboratorsFragment extends Fragment {
|
||||
fragmentCollaboratorsBinding =
|
||||
FragmentCollaboratorsBinding.inflate(inflater, container, false);
|
||||
|
||||
collaboratorsModel = new ViewModelProvider(this).get(CollaboratorsViewModel.class);
|
||||
resultLimit = Constants.getCurrentResultLimit(requireContext());
|
||||
|
||||
if (repository.getPermissions().isAdmin()) {
|
||||
|
||||
fragmentCollaboratorsBinding.addCollaborator.setOnClickListener(
|
||||
@ -61,27 +69,57 @@ public class CollaboratorsFragment extends Fragment {
|
||||
return fragmentCollaboratorsBinding.getRoot();
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String owner, String repo) {
|
||||
|
||||
CollaboratorsViewModel collaboratorsModel =
|
||||
new ViewModelProvider(this).get(CollaboratorsViewModel.class);
|
||||
private void fetchDataAsync(String repoOwner, String repoName) {
|
||||
|
||||
collaboratorsModel
|
||||
.getCollaboratorsList(owner, repo, getContext())
|
||||
.getCollaboratorsList(repoOwner, repoName, requireContext(), page, resultLimit)
|
||||
.observe(
|
||||
getViewLifecycleOwner(),
|
||||
collaboratorsListMain -> {
|
||||
adapter = new CollaboratorsAdapter(getContext(), collaboratorsListMain);
|
||||
if (adapter.getCount() > 0) {
|
||||
mainList -> {
|
||||
adapter = new CollaboratorsAdapter(requireContext(), mainList);
|
||||
|
||||
adapter.setLoadMoreListener(
|
||||
new CollaboratorsAdapter.OnLoadMoreListener() {
|
||||
|
||||
@Override
|
||||
public void onLoadMore() {
|
||||
|
||||
page += 1;
|
||||
collaboratorsModel.loadMore(
|
||||
repoOwner,
|
||||
repoName,
|
||||
requireContext(),
|
||||
page,
|
||||
resultLimit,
|
||||
adapter,
|
||||
fragmentCollaboratorsBinding);
|
||||
fragmentCollaboratorsBinding.progressBar.setVisibility(
|
||||
View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished() {
|
||||
|
||||
fragmentCollaboratorsBinding.progressBar.setVisibility(
|
||||
View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
GridLayoutManager layoutManager =
|
||||
new GridLayoutManager(requireContext(), 2);
|
||||
fragmentCollaboratorsBinding.gridView.setLayoutManager(layoutManager);
|
||||
|
||||
if (adapter.getItemCount() > 0) {
|
||||
fragmentCollaboratorsBinding.gridView.setAdapter(adapter);
|
||||
fragmentCollaboratorsBinding.noDataCollaborators.setVisibility(
|
||||
View.GONE);
|
||||
} else {
|
||||
adapter.notifyDataSetChanged();
|
||||
adapter.notifyDataChanged();
|
||||
fragmentCollaboratorsBinding.gridView.setAdapter(adapter);
|
||||
fragmentCollaboratorsBinding.noDataCollaborators.setVisibility(
|
||||
View.VISIBLE);
|
||||
}
|
||||
|
||||
fragmentCollaboratorsBinding.progressBar.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
@ -91,7 +129,13 @@ public class CollaboratorsFragment extends Fragment {
|
||||
|
||||
super.onResume();
|
||||
if (refreshCollaborators) {
|
||||
fetchDataAsync(repository.getOwner(), repository.getName());
|
||||
page = 1;
|
||||
CollaboratorsViewModel.loadCollaboratorsListList(
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
requireContext(),
|
||||
page,
|
||||
resultLimit);
|
||||
refreshCollaborators = false;
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ public class CommitDetailFragment extends Fragment {
|
||||
repoOwner = repository.getOwner();
|
||||
repoName = repository.getName();
|
||||
sha = requireActivity().getIntent().getStringExtra("sha");
|
||||
assert sha != null;
|
||||
binding.toolbarTitle.setText(sha.substring(0, Math.min(sha.length(), 10)));
|
||||
|
||||
adapter = new DiffFilesAdapter(requireContext(), fileDiffViews, issue, "commit");
|
||||
|
@ -42,7 +42,6 @@ public class DashboardFragment extends Fragment {
|
||||
binding = FragmentDashboardBinding.inflate(inflater, container, false);
|
||||
|
||||
Context ctx = getContext();
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
((MainActivity) requireActivity())
|
||||
.setActionBarTitle(getResources().getString(R.string.dashboard));
|
||||
|
@ -1,176 +0,0 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.adapters.DraftsAdapter;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.DraftsApi;
|
||||
import org.mian.gitnex.database.models.DraftWithRepository;
|
||||
import org.mian.gitnex.databinding.FragmentDraftsBinding;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
public class DraftsFragment extends Fragment {
|
||||
|
||||
private FragmentDraftsBinding fragmentDraftsBinding;
|
||||
private Context ctx;
|
||||
private DraftsAdapter adapter;
|
||||
private DraftsApi draftsApi;
|
||||
private List<DraftWithRepository> draftsList_;
|
||||
private int currentActiveAccountId;
|
||||
|
||||
@Override
|
||||
public View onCreateView(
|
||||
@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
fragmentDraftsBinding = FragmentDraftsBinding.inflate(inflater, container, false);
|
||||
|
||||
ctx = getContext();
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
((MainActivity) requireActivity())
|
||||
.setActionBarTitle(getResources().getString(R.string.titleDrafts));
|
||||
|
||||
TinyDB tinyDb = TinyDB.getInstance(ctx);
|
||||
|
||||
draftsList_ = new ArrayList<>();
|
||||
draftsApi = BaseApi.getInstance(ctx, DraftsApi.class);
|
||||
|
||||
fragmentDraftsBinding.recyclerView.setHasFixedSize(true);
|
||||
fragmentDraftsBinding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
|
||||
adapter = new DraftsAdapter(getContext(), getChildFragmentManager(), draftsList_);
|
||||
currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||
fragmentDraftsBinding.pullToRefresh.setOnRefreshListener(
|
||||
() ->
|
||||
new Handler(Looper.getMainLooper())
|
||||
.postDelayed(
|
||||
() -> {
|
||||
draftsList_.clear();
|
||||
fetchDataAsync(currentActiveAccountId);
|
||||
},
|
||||
250));
|
||||
|
||||
fetchDataAsync(currentActiveAccountId);
|
||||
|
||||
return fragmentDraftsBinding.getRoot();
|
||||
}
|
||||
|
||||
private void fetchDataAsync(int accountId) {
|
||||
|
||||
draftsApi
|
||||
.getDrafts(accountId)
|
||||
.observe(
|
||||
getViewLifecycleOwner(),
|
||||
drafts -> {
|
||||
fragmentDraftsBinding.pullToRefresh.setRefreshing(false);
|
||||
assert drafts != null;
|
||||
if (drafts.size() > 0) {
|
||||
|
||||
draftsList_.clear();
|
||||
fragmentDraftsBinding.noData.setVisibility(View.GONE);
|
||||
draftsList_.addAll(drafts);
|
||||
adapter.notifyDataChanged();
|
||||
fragmentDraftsBinding.recyclerView.setAdapter(adapter);
|
||||
} else {
|
||||
|
||||
fragmentDraftsBinding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
draftsList_.clear();
|
||||
fetchDataAsync(currentActiveAccountId);
|
||||
}
|
||||
|
||||
public void deleteAllDrafts(int accountId) {
|
||||
|
||||
if (draftsList_.size() > 0) {
|
||||
|
||||
Objects.requireNonNull(BaseApi.getInstance(ctx, DraftsApi.class))
|
||||
.deleteAllDrafts(accountId);
|
||||
draftsList_.clear();
|
||||
adapter.notifyDataChanged();
|
||||
Toasty.success(ctx, getResources().getString(R.string.draftsDeleteSuccess));
|
||||
} else {
|
||||
Toasty.warning(ctx, getResources().getString(R.string.draftsListEmpty));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
SearchView searchView = (SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
|
||||
filter(newText);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void filter(String text) {
|
||||
|
||||
List<DraftWithRepository> arr = new ArrayList<>();
|
||||
|
||||
for (DraftWithRepository d : draftsList_) {
|
||||
|
||||
if (d == null
|
||||
|| d.getRepositoryOwner() == null
|
||||
|| d.getRepositoryName() == null
|
||||
|| d.getDraftText() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (d.getRepositoryOwner().toLowerCase().contains(text)
|
||||
|| d.getRepositoryName().toLowerCase().contains(text)
|
||||
|| d.getDraftText().toLowerCase().contains(text)
|
||||
|| String.valueOf(d.getIssueId()).contains(text)) {
|
||||
arr.add(d);
|
||||
}
|
||||
}
|
||||
|
||||
adapter.updateList(arr);
|
||||
}
|
||||
}
|
@ -18,7 +18,6 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.helpers.AppDatabaseSettings;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.ViewPager2Transformers;
|
||||
|
||||
/**
|
||||
@ -35,7 +34,6 @@ public class ExploreFragment extends Fragment {
|
||||
View view = inflater.inflate(R.layout.fragment_explore, container, false);
|
||||
|
||||
Context ctx = getContext();
|
||||
TinyDB tinyDB = TinyDB.getInstance(ctx);
|
||||
|
||||
((MainActivity) requireActivity())
|
||||
.setActionBarTitle(getResources().getString(R.string.pageTitleExplore));
|
||||
|
@ -105,7 +105,7 @@ public class ExplorePublicOrganizationsFragment extends Fragment {
|
||||
@NonNull Call<List<Organization>> call,
|
||||
@NonNull Response<List<Organization>> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (response.body() != null && response.body().size() > 0) {
|
||||
if (response.body() != null && !response.body().isEmpty()) {
|
||||
organizationsList.clear();
|
||||
organizationsList.addAll(response.body());
|
||||
adapter.notifyDataChanged();
|
||||
@ -147,7 +147,7 @@ public class ExplorePublicOrganizationsFragment extends Fragment {
|
||||
if (response.isSuccessful()) {
|
||||
List<Organization> result = response.body();
|
||||
if (result != null) {
|
||||
if (result.size() > 0) {
|
||||
if (!result.isEmpty()) {
|
||||
pageSize = result.size();
|
||||
organizationsList.addAll(result);
|
||||
} else {
|
||||
|
@ -15,7 +15,9 @@ import android.view.inputmethod.EditorInfo;
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.core.view.MenuProvider;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
@ -76,7 +78,6 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
binding = FragmentFilesBinding.inflate(inflater, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
boolean canPush = repository.getPermissions().isPush();
|
||||
boolean archived = repository.getRepository().isArchived();
|
||||
@ -184,6 +185,51 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
|
||||
binding.switchBranch.setOnClickListener(switchBranch -> chooseBranch());
|
||||
|
||||
requireActivity()
|
||||
.addMenuProvider(
|
||||
new MenuProvider() {
|
||||
@Override
|
||||
public void onCreateMenu(
|
||||
@NonNull Menu menu, @NonNull MenuInflater menuInflater) {
|
||||
|
||||
menuInflater.inflate(R.menu.search_menu, menu);
|
||||
menuInflater.inflate(R.menu.files_switch_branches_menu, menu);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView)
|
||||
searchItem.getActionView();
|
||||
assert searchView != null;
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
|
||||
if (binding.recyclerView.getAdapter() != null) {
|
||||
filesAdapter.getFilter().filter(newText);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(@NonNull MenuItem menuItem) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
getViewLifecycleOwner(),
|
||||
Lifecycle.State.RESUMED);
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@ -415,39 +461,4 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
menu.clear();
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
inflater.inflate(R.menu.files_switch_branches_menu, menu);
|
||||
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
|
||||
SearchView searchView = (SearchView) searchItem.getActionView();
|
||||
assert searchView != null;
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
searchView.setOnQueryTextListener(
|
||||
new SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
|
||||
if (binding.recyclerView.getAdapter() != null) {
|
||||
filesAdapter.getFilter().filter(newText);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,9 @@ import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.MenuProvider;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -41,7 +43,6 @@ public class IssuesFragment extends Fragment {
|
||||
private final String requestType = Constants.issuesRequestType;
|
||||
private FragmentIssuesBinding fragmentIssuesBinding;
|
||||
private Context context;
|
||||
private Menu menu;
|
||||
private List<Issue> issuesList;
|
||||
private List<Issue> pinnedIssuesList;
|
||||
private IssuesAdapter adapter;
|
||||
@ -63,7 +64,6 @@ public class IssuesFragment extends Fragment {
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
|
||||
fragmentIssuesBinding = FragmentIssuesBinding.inflate(inflater, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
context = getContext();
|
||||
|
||||
repository = RepositoryContext.fromBundle(requireArguments());
|
||||
@ -126,12 +126,6 @@ public class IssuesFragment extends Fragment {
|
||||
((RepoDetailActivity) requireActivity())
|
||||
.setFragmentRefreshListener(
|
||||
issueState -> {
|
||||
if (issueState.equals("closed")) {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter_closed);
|
||||
} else {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter);
|
||||
}
|
||||
|
||||
issuesList.clear();
|
||||
|
||||
adapter = new IssuesAdapter(context, issuesList, "");
|
||||
@ -247,6 +241,64 @@ public class IssuesFragment extends Fragment {
|
||||
fragmentIssuesBinding.createNewIssue.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
requireActivity()
|
||||
.addMenuProvider(
|
||||
new MenuProvider() {
|
||||
|
||||
@Override
|
||||
public void onCreateMenu(
|
||||
@NonNull Menu menu, @NonNull MenuInflater menuInflater) {
|
||||
|
||||
menuInflater.inflate(R.menu.search_menu, menu);
|
||||
menuInflater.inflate(R.menu.filter_menu, menu);
|
||||
|
||||
if (repository.getIssueState().toString().equals("closed")) {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter_closed);
|
||||
} else {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter);
|
||||
}
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView)
|
||||
searchItem.getActionView();
|
||||
assert searchView != null;
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView
|
||||
.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
loadInitial(
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
resultLimit,
|
||||
requestType,
|
||||
repository.getIssueState().toString(),
|
||||
repository.getIssueMilestoneFilterName(),
|
||||
query);
|
||||
searchView.setQuery(null, false);
|
||||
searchItem.collapseActionView();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(@NonNull MenuItem menuItem) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
getViewLifecycleOwner(),
|
||||
Lifecycle.State.RESUMED);
|
||||
|
||||
return fragmentIssuesBinding.getRoot();
|
||||
}
|
||||
|
||||
@ -438,48 +490,4 @@ public class IssuesFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
this.menu = menu;
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
inflater.inflate(R.menu.filter_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
if (repository.getIssueState().toString().equals("closed")) {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter_closed);
|
||||
} else {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter);
|
||||
}
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
loadInitial(
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
resultLimit,
|
||||
requestType,
|
||||
repository.getIssueState().toString(),
|
||||
repository.getIssueMilestoneFilterName(),
|
||||
query);
|
||||
searchView.setQuery(null, false);
|
||||
searchItem.collapseActionView();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -6,17 +6,15 @@ import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import org.mian.gitnex.activities.CreateLabelActivity;
|
||||
import org.mian.gitnex.adapters.LabelsAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentLabelsBinding;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.viewmodels.LabelsViewModel;
|
||||
|
||||
@ -25,11 +23,11 @@ import org.mian.gitnex.viewmodels.LabelsViewModel;
|
||||
*/
|
||||
public class LabelsFragment extends Fragment {
|
||||
|
||||
private ProgressBar mProgressBar;
|
||||
private RecyclerView mRecyclerView;
|
||||
private FragmentLabelsBinding fragmentLabelsBinding;
|
||||
private LabelsViewModel labelsViewModel;
|
||||
private LabelsAdapter adapter;
|
||||
private TextView noData;
|
||||
|
||||
private int page = 1;
|
||||
private int resultLimit;
|
||||
private RepositoryContext repository;
|
||||
|
||||
public LabelsFragment() {}
|
||||
@ -51,32 +49,35 @@ public class LabelsFragment extends Fragment {
|
||||
public View onCreateView(
|
||||
@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
FragmentLabelsBinding fragmentLabelsBinding =
|
||||
FragmentLabelsBinding.inflate(inflater, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
fragmentLabelsBinding = FragmentLabelsBinding.inflate(inflater, container, false);
|
||||
|
||||
boolean canPush = repository.getPermissions().isPush();
|
||||
boolean archived = repository.getRepository().isArchived();
|
||||
|
||||
final SwipeRefreshLayout swipeRefresh = fragmentLabelsBinding.pullToRefresh;
|
||||
noData = fragmentLabelsBinding.noData;
|
||||
|
||||
mRecyclerView = fragmentLabelsBinding.recyclerView;
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
labelsViewModel = new ViewModelProvider(this).get(LabelsViewModel.class);
|
||||
resultLimit = Constants.getCurrentResultLimit(requireContext());
|
||||
|
||||
mProgressBar = fragmentLabelsBinding.progressBar;
|
||||
fragmentLabelsBinding.recyclerView.setHasFixedSize(true);
|
||||
fragmentLabelsBinding.recyclerView.setLayoutManager(
|
||||
new LinearLayoutManager(requireContext()));
|
||||
|
||||
swipeRefresh.setOnRefreshListener(
|
||||
() ->
|
||||
new Handler(Looper.getMainLooper())
|
||||
.postDelayed(
|
||||
() -> {
|
||||
page = 1;
|
||||
swipeRefresh.setRefreshing(false);
|
||||
LabelsViewModel.loadLabelsList(
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
getContext());
|
||||
"repo",
|
||||
requireContext(),
|
||||
null,
|
||||
page,
|
||||
resultLimit);
|
||||
},
|
||||
200));
|
||||
|
||||
@ -88,7 +89,8 @@ public class LabelsFragment extends Fragment {
|
||||
|
||||
fragmentLabelsBinding.createLabel.setOnClickListener(
|
||||
v112 -> {
|
||||
startActivity(repository.getIntent(getContext(), CreateLabelActivity.class));
|
||||
startActivity(
|
||||
repository.getIntent(requireContext(), CreateLabelActivity.class));
|
||||
});
|
||||
|
||||
return fragmentLabelsBinding.getRoot();
|
||||
@ -101,36 +103,72 @@ public class LabelsFragment extends Fragment {
|
||||
|
||||
if (CreateLabelActivity.refreshLabels) {
|
||||
|
||||
page = 1;
|
||||
LabelsViewModel.loadLabelsList(
|
||||
repository.getOwner(), repository.getName(), getContext());
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
"repo",
|
||||
requireContext(),
|
||||
null,
|
||||
page,
|
||||
resultLimit);
|
||||
CreateLabelActivity.refreshLabels = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String owner, String repo) {
|
||||
|
||||
LabelsViewModel labelsModel = new ViewModelProvider(this).get(LabelsViewModel.class);
|
||||
|
||||
labelsModel
|
||||
.getLabelsList(owner, repo, getContext())
|
||||
labelsViewModel
|
||||
.getLabelsList(
|
||||
owner,
|
||||
repo,
|
||||
"repo",
|
||||
requireContext(),
|
||||
fragmentLabelsBinding,
|
||||
page,
|
||||
resultLimit)
|
||||
.observe(
|
||||
getViewLifecycleOwner(),
|
||||
labelsListMain -> {
|
||||
adapter =
|
||||
new LabelsAdapter(getContext(), labelsListMain, "repo", owner);
|
||||
mainList -> {
|
||||
adapter = new LabelsAdapter(requireContext(), mainList, "repo", owner);
|
||||
adapter.setLoadMoreListener(
|
||||
new LabelsAdapter.OnLoadMoreListener() {
|
||||
|
||||
@Override
|
||||
public void onLoadMore() {
|
||||
|
||||
page += 1;
|
||||
labelsViewModel.loadMore(
|
||||
owner,
|
||||
repo,
|
||||
"repo",
|
||||
requireContext(),
|
||||
fragmentLabelsBinding,
|
||||
page,
|
||||
resultLimit,
|
||||
adapter);
|
||||
fragmentLabelsBinding.progressBar.setVisibility(
|
||||
View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished() {
|
||||
|
||||
fragmentLabelsBinding.progressBar.setVisibility(
|
||||
View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
if (adapter.getItemCount() > 0) {
|
||||
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noData.setVisibility(View.GONE);
|
||||
fragmentLabelsBinding.recyclerView.setAdapter(adapter);
|
||||
fragmentLabelsBinding.noData.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
||||
adapter.notifyDataChanged();
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
fragmentLabelsBinding.recyclerView.setAdapter(adapter);
|
||||
fragmentLabelsBinding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
fragmentLabelsBinding.progressBar.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,9 @@ import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.MenuProvider;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import java.util.ArrayList;
|
||||
@ -34,7 +36,6 @@ public class MilestonesFragment extends Fragment {
|
||||
|
||||
private MilestonesViewModel milestonesViewModel;
|
||||
private FragmentMilestonesBinding viewBinding;
|
||||
private Menu menu;
|
||||
private List<Milestone> dataList;
|
||||
private MilestonesAdapter adapter;
|
||||
private RepositoryContext repository;
|
||||
@ -59,7 +60,6 @@ public class MilestonesFragment extends Fragment {
|
||||
@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
viewBinding = FragmentMilestonesBinding.inflate(inflater, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
Context ctx = getContext();
|
||||
milestonesViewModel = new ViewModelProvider(this).get(MilestonesViewModel.class);
|
||||
|
||||
@ -96,11 +96,6 @@ public class MilestonesFragment extends Fragment {
|
||||
.setFragmentRefreshListenerMilestone(
|
||||
milestoneState -> {
|
||||
state = milestoneState;
|
||||
if (milestoneState.equals("open")) {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter);
|
||||
} else {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter_closed);
|
||||
}
|
||||
|
||||
page = 1;
|
||||
dataList.clear();
|
||||
@ -119,6 +114,56 @@ public class MilestonesFragment extends Fragment {
|
||||
v13 -> startActivity(repository.getIntent(ctx, CreateMilestoneActivity.class)));
|
||||
|
||||
fetchDataAsync(repository.getOwner(), repository.getName(), state);
|
||||
|
||||
requireActivity()
|
||||
.addMenuProvider(
|
||||
new MenuProvider() {
|
||||
|
||||
@Override
|
||||
public void onCreateMenu(
|
||||
@NonNull Menu menu, @NonNull MenuInflater menuInflater) {
|
||||
|
||||
menuInflater.inflate(R.menu.search_menu, menu);
|
||||
menuInflater.inflate(R.menu.filter_menu_milestone, menu);
|
||||
|
||||
if (repository.getMilestoneState().toString().equals("open")) {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter);
|
||||
} else {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter_closed);
|
||||
}
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView)
|
||||
searchItem.getActionView();
|
||||
assert searchView != null;
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView
|
||||
.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
filter(newText);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(@NonNull MenuItem menuItem) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
getViewLifecycleOwner(),
|
||||
Lifecycle.State.RESUMED);
|
||||
|
||||
return viewBinding.getRoot();
|
||||
}
|
||||
|
||||
@ -127,7 +172,9 @@ public class MilestonesFragment extends Fragment {
|
||||
super.onResume();
|
||||
|
||||
if (RepoDetailActivity.updateFABActions) {
|
||||
fetchDataAsync(repository.getOwner(), repository.getName(), state);
|
||||
page = 1;
|
||||
MilestonesViewModel.loadMilestonesList(
|
||||
repository.getOwner(), repository.getName(), state, requireContext());
|
||||
RepoDetailActivity.updateFABActions = false;
|
||||
}
|
||||
}
|
||||
@ -195,37 +242,6 @@ public class MilestonesFragment extends Fragment {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
this.menu = menu;
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
inflater.inflate(R.menu.filter_menu_milestone, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
|
||||
filter(newText);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void filter(String text) {
|
||||
|
||||
List<Milestone> arr = new ArrayList<>();
|
||||
|
@ -27,7 +27,7 @@ import org.mian.gitnex.adapters.MostVisitedReposAdapter;
|
||||
import org.mian.gitnex.database.api.BaseApi;
|
||||
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||
import org.mian.gitnex.database.models.Repository;
|
||||
import org.mian.gitnex.databinding.FragmentDraftsBinding;
|
||||
import org.mian.gitnex.databinding.FragmentMostVisitedBinding;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
|
||||
@ -36,7 +36,7 @@ import org.mian.gitnex.helpers.Toasty;
|
||||
*/
|
||||
public class MostVisitedReposFragment extends Fragment {
|
||||
|
||||
private FragmentDraftsBinding fragmentDraftsBinding;
|
||||
private FragmentMostVisitedBinding fragmentDraftsBinding;
|
||||
private Context ctx;
|
||||
private MostVisitedReposAdapter adapter;
|
||||
private RepositoriesApi repositoriesApi;
|
||||
@ -47,7 +47,7 @@ public class MostVisitedReposFragment extends Fragment {
|
||||
public View onCreateView(
|
||||
@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
fragmentDraftsBinding = FragmentDraftsBinding.inflate(inflater, container, false);
|
||||
fragmentDraftsBinding = FragmentMostVisitedBinding.inflate(inflater, container, false);
|
||||
|
||||
ctx = getContext();
|
||||
|
||||
|
@ -12,7 +12,9 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.MenuProvider;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import java.util.ArrayList;
|
||||
@ -45,11 +47,8 @@ public class NotificationsFragment extends Fragment
|
||||
private final List<NotificationThread> notificationThreads = new ArrayList<>();
|
||||
private FragmentNotificationsBinding viewBinding;
|
||||
private NotificationsAdapter notificationsAdapter;
|
||||
|
||||
private Activity activity;
|
||||
private Context context;
|
||||
private Menu menu;
|
||||
|
||||
private int pageCurrentIndex = 1;
|
||||
private int pageResultLimit;
|
||||
private String currentFilterMode = "unread";
|
||||
@ -68,7 +67,6 @@ public class NotificationsFragment extends Fragment
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
|
||||
viewBinding = FragmentNotificationsBinding.inflate(inflater, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
activity = requireActivity();
|
||||
context = getContext();
|
||||
@ -133,37 +131,42 @@ public class NotificationsFragment extends Fragment
|
||||
loadNotifications(false);
|
||||
} else {
|
||||
|
||||
if (!emptyErrorResponse.isEmpty()) {
|
||||
if (emptyErrorResponse.contains(
|
||||
"205")) {
|
||||
if (emptyErrorResponse != null) {
|
||||
if (!emptyErrorResponse.isEmpty()) {
|
||||
if (emptyErrorResponse.contains(
|
||||
"205")) {
|
||||
|
||||
SnackBar.success(
|
||||
context,
|
||||
requireActivity()
|
||||
.findViewById(
|
||||
android.R.id
|
||||
.content),
|
||||
getString(
|
||||
R.string
|
||||
.markedNotificationsAsRead));
|
||||
pageCurrentIndex = 1;
|
||||
loadNotifications(false);
|
||||
SnackBar.success(
|
||||
context,
|
||||
requireActivity()
|
||||
.findViewById(
|
||||
android
|
||||
.R
|
||||
.id
|
||||
.content),
|
||||
getString(
|
||||
R.string
|
||||
.markedNotificationsAsRead));
|
||||
pageCurrentIndex = 1;
|
||||
loadNotifications(false);
|
||||
}
|
||||
} else {
|
||||
|
||||
activity.runOnUiThread(
|
||||
() ->
|
||||
SnackBar.error(
|
||||
context,
|
||||
requireActivity()
|
||||
.findViewById(
|
||||
android
|
||||
.R
|
||||
.id
|
||||
.content),
|
||||
getString(
|
||||
R
|
||||
.string
|
||||
.genericError)));
|
||||
}
|
||||
} else {
|
||||
|
||||
activity.runOnUiThread(
|
||||
() ->
|
||||
SnackBar.error(
|
||||
context,
|
||||
requireActivity()
|
||||
.findViewById(
|
||||
android
|
||||
.R
|
||||
.id
|
||||
.content),
|
||||
getString(
|
||||
R.string
|
||||
.genericError)));
|
||||
}
|
||||
}
|
||||
}));
|
||||
@ -176,6 +179,73 @@ public class NotificationsFragment extends Fragment
|
||||
});
|
||||
|
||||
loadNotifications(true);
|
||||
|
||||
requireActivity()
|
||||
.addMenuProvider(
|
||||
new MenuProvider() {
|
||||
|
||||
Menu menu;
|
||||
|
||||
@Override
|
||||
public void onCreateMenu(
|
||||
@NonNull Menu menu, @NonNull MenuInflater menuInflater) {
|
||||
|
||||
this.menu = menu;
|
||||
menuInflater.inflate(R.menu.filter_menu_notifications, menu);
|
||||
|
||||
int filterIcon =
|
||||
currentFilterMode.equalsIgnoreCase("read")
|
||||
? R.drawable.ic_filter_closed
|
||||
: R.drawable.ic_filter;
|
||||
|
||||
menu.getItem(0).setIcon(filterIcon);
|
||||
|
||||
if (currentFilterMode.equalsIgnoreCase("read")) {
|
||||
viewBinding.markAllAsRead.setVisibility(View.GONE);
|
||||
} else {
|
||||
viewBinding.markAllAsRead.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(@NonNull MenuItem menuItem) {
|
||||
|
||||
if (menu.getItem(0).getItemId() == R.id.filterNotifications) {
|
||||
|
||||
BottomSheetNotificationsFilterFragment
|
||||
bottomSheetNotificationsFilterFragment =
|
||||
new BottomSheetNotificationsFilterFragment();
|
||||
bottomSheetNotificationsFilterFragment.show(
|
||||
getChildFragmentManager(),
|
||||
"notificationsFilterBottomSheet");
|
||||
bottomSheetNotificationsFilterFragment.setOnClickListener(
|
||||
(text) -> {
|
||||
currentFilterMode = text;
|
||||
pageCurrentIndex = 1;
|
||||
loadNotifications(false);
|
||||
|
||||
int filterIcon =
|
||||
currentFilterMode.equalsIgnoreCase("read")
|
||||
? R.drawable.ic_filter_closed
|
||||
: R.drawable.ic_filter;
|
||||
|
||||
menu.getItem(0).setIcon(filterIcon);
|
||||
|
||||
if (currentFilterMode.equalsIgnoreCase("read")) {
|
||||
viewBinding.markAllAsRead.setVisibility(
|
||||
View.GONE);
|
||||
} else {
|
||||
viewBinding.markAllAsRead.setVisibility(
|
||||
View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
getViewLifecycleOwner(),
|
||||
Lifecycle.State.RESUMED);
|
||||
|
||||
return viewBinding.getRoot();
|
||||
}
|
||||
|
||||
@ -216,9 +286,9 @@ public class NotificationsFragment extends Fragment
|
||||
}
|
||||
|
||||
if (!append
|
||||
|| Objects.requireNonNull(listResponse.get().body())
|
||||
.size()
|
||||
> 0) {
|
||||
|| !Objects.requireNonNull(
|
||||
listResponse.get().body())
|
||||
.isEmpty()) {
|
||||
notificationsAdapter.notifyDataChanged();
|
||||
}
|
||||
}
|
||||
@ -241,53 +311,6 @@ public class NotificationsFragment extends Fragment
|
||||
});
|
||||
}
|
||||
|
||||
private void changeFilterMode() {
|
||||
|
||||
int filterIcon =
|
||||
currentFilterMode.equalsIgnoreCase("read")
|
||||
? R.drawable.ic_filter_closed
|
||||
: R.drawable.ic_filter;
|
||||
|
||||
menu.getItem(0).setIcon(filterIcon);
|
||||
|
||||
if (currentFilterMode.equalsIgnoreCase("read")) {
|
||||
viewBinding.markAllAsRead.setVisibility(View.GONE);
|
||||
} else {
|
||||
viewBinding.markAllAsRead.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
this.menu = menu;
|
||||
inflater.inflate(R.menu.filter_menu_notifications, menu);
|
||||
changeFilterMode();
|
||||
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
|
||||
if (item.getItemId() == R.id.filterNotifications) {
|
||||
|
||||
BottomSheetNotificationsFilterFragment bottomSheetNotificationsFilterFragment =
|
||||
new BottomSheetNotificationsFilterFragment();
|
||||
bottomSheetNotificationsFilterFragment.show(
|
||||
getChildFragmentManager(), "notificationsFilterBottomSheet");
|
||||
bottomSheetNotificationsFilterFragment.setOnClickListener(
|
||||
(text) -> {
|
||||
currentFilterMode = text;
|
||||
changeFilterMode();
|
||||
pageCurrentIndex = 1;
|
||||
loadNotifications(false);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotificationClicked(NotificationThread notificationThread) {
|
||||
|
||||
|
@ -7,34 +7,32 @@ import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import org.gitnex.tea4j.v2.models.OrganizationPermissions;
|
||||
import org.mian.gitnex.activities.CreateLabelActivity;
|
||||
import org.mian.gitnex.adapters.LabelsAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentLabelsBinding;
|
||||
import org.mian.gitnex.viewmodels.OrganizationLabelsViewModel;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.viewmodels.LabelsViewModel;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
public class OrganizationLabelsFragment extends Fragment {
|
||||
|
||||
private FragmentLabelsBinding fragmentLabelsBinding;
|
||||
private OrganizationPermissions permissions;
|
||||
private OrganizationLabelsViewModel organizationLabelsViewModel;
|
||||
private ProgressBar mProgressBar;
|
||||
private RecyclerView mRecyclerView;
|
||||
private LabelsViewModel labelsViewModel;
|
||||
private LabelsAdapter adapter;
|
||||
private TextView noData;
|
||||
private static final String getOrgName = null;
|
||||
private String repoOwner;
|
||||
private final String type = "org";
|
||||
private int page = 1;
|
||||
private int resultLimit;
|
||||
|
||||
public static OrganizationLabelsFragment newInstance(
|
||||
String repoOwner, OrganizationPermissions permissions) {
|
||||
@ -63,29 +61,32 @@ public class OrganizationLabelsFragment extends Fragment {
|
||||
public View onCreateView(
|
||||
@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
FragmentLabelsBinding fragmentLabelsBinding =
|
||||
FragmentLabelsBinding.inflate(inflater, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
organizationLabelsViewModel =
|
||||
new ViewModelProvider(this).get(OrganizationLabelsViewModel.class);
|
||||
fragmentLabelsBinding = FragmentLabelsBinding.inflate(inflater, container, false);
|
||||
labelsViewModel = new ViewModelProvider(this).get(LabelsViewModel.class);
|
||||
|
||||
final SwipeRefreshLayout swipeRefresh = fragmentLabelsBinding.pullToRefresh;
|
||||
noData = fragmentLabelsBinding.noData;
|
||||
|
||||
mRecyclerView = fragmentLabelsBinding.recyclerView;
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
resultLimit = Constants.getCurrentResultLimit(requireContext());
|
||||
|
||||
mProgressBar = fragmentLabelsBinding.progressBar;
|
||||
fragmentLabelsBinding.recyclerView.setHasFixedSize(true);
|
||||
fragmentLabelsBinding.recyclerView.setLayoutManager(
|
||||
new LinearLayoutManager(requireContext()));
|
||||
|
||||
swipeRefresh.setOnRefreshListener(
|
||||
() ->
|
||||
new Handler(Looper.getMainLooper())
|
||||
.postDelayed(
|
||||
() -> {
|
||||
page = 1;
|
||||
swipeRefresh.setRefreshing(false);
|
||||
OrganizationLabelsViewModel.loadOrgLabelsList(
|
||||
repoOwner, getContext(), mProgressBar, noData);
|
||||
LabelsViewModel.loadLabelsList(
|
||||
repoOwner,
|
||||
null,
|
||||
"org",
|
||||
requireContext(),
|
||||
fragmentLabelsBinding,
|
||||
page,
|
||||
resultLimit);
|
||||
},
|
||||
200));
|
||||
|
||||
@ -97,7 +98,7 @@ public class OrganizationLabelsFragment extends Fragment {
|
||||
|
||||
fragmentLabelsBinding.createLabel.setOnClickListener(
|
||||
v1 -> {
|
||||
Intent intent = new Intent(getContext(), CreateLabelActivity.class);
|
||||
Intent intent = new Intent(requireContext(), CreateLabelActivity.class);
|
||||
intent.putExtra("orgName", repoOwner);
|
||||
intent.putExtra("type", "org");
|
||||
startActivity(intent);
|
||||
@ -113,33 +114,72 @@ public class OrganizationLabelsFragment extends Fragment {
|
||||
|
||||
if (CreateLabelActivity.refreshLabels) {
|
||||
|
||||
OrganizationLabelsViewModel.loadOrgLabelsList(
|
||||
repoOwner, getContext(), mProgressBar, noData);
|
||||
page = 1;
|
||||
LabelsViewModel.loadLabelsList(
|
||||
repoOwner,
|
||||
null,
|
||||
"org",
|
||||
requireContext(),
|
||||
fragmentLabelsBinding,
|
||||
page,
|
||||
resultLimit);
|
||||
CreateLabelActivity.refreshLabels = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String owner) {
|
||||
|
||||
organizationLabelsViewModel
|
||||
.getOrgLabelsList(owner, getContext(), mProgressBar, noData)
|
||||
labelsViewModel
|
||||
.getLabelsList(
|
||||
owner,
|
||||
null,
|
||||
"org",
|
||||
requireContext(),
|
||||
fragmentLabelsBinding,
|
||||
page,
|
||||
resultLimit)
|
||||
.observe(
|
||||
getViewLifecycleOwner(),
|
||||
labelsListMain -> {
|
||||
adapter = new LabelsAdapter(getContext(), labelsListMain, type, owner);
|
||||
mainList -> {
|
||||
adapter = new LabelsAdapter(requireContext(), mainList, type, owner);
|
||||
adapter.setLoadMoreListener(
|
||||
new LabelsAdapter.OnLoadMoreListener() {
|
||||
|
||||
@Override
|
||||
public void onLoadMore() {
|
||||
|
||||
page += 1;
|
||||
labelsViewModel.loadMore(
|
||||
owner,
|
||||
null,
|
||||
"org",
|
||||
requireContext(),
|
||||
fragmentLabelsBinding,
|
||||
page,
|
||||
resultLimit,
|
||||
adapter);
|
||||
fragmentLabelsBinding.progressBar.setVisibility(
|
||||
View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished() {
|
||||
|
||||
fragmentLabelsBinding.progressBar.setVisibility(
|
||||
View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
if (adapter.getItemCount() > 0) {
|
||||
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noData.setVisibility(View.GONE);
|
||||
fragmentLabelsBinding.recyclerView.setAdapter(adapter);
|
||||
fragmentLabelsBinding.noData.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
||||
adapter.notifyDataChanged();
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
fragmentLabelsBinding.recyclerView.setAdapter(adapter);
|
||||
fragmentLabelsBinding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
fragmentLabelsBinding.progressBar.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -2,22 +2,15 @@ package org.mian.gitnex.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import org.mian.gitnex.R;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import org.mian.gitnex.adapters.UserGridAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentOrganizationMembersBinding;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.viewmodels.MembersByOrgViewModel;
|
||||
|
||||
/**
|
||||
@ -25,12 +18,13 @@ import org.mian.gitnex.viewmodels.MembersByOrgViewModel;
|
||||
*/
|
||||
public class OrganizationMembersFragment extends Fragment {
|
||||
|
||||
private TextView noDataMembers;
|
||||
private static String orgNameF = "param2";
|
||||
private FragmentOrganizationMembersBinding binding;
|
||||
private MembersByOrgViewModel membersModel;
|
||||
private static final String orgNameF = "param2";
|
||||
private String orgName;
|
||||
private UserGridAdapter adapter;
|
||||
private GridView mGridView;
|
||||
private ProgressBar progressBar;
|
||||
private int page = 1;
|
||||
private int resultLimit;
|
||||
|
||||
public OrganizationMembersFragment() {}
|
||||
|
||||
@ -54,76 +48,64 @@ public class OrganizationMembersFragment extends Fragment {
|
||||
public View onCreateView(
|
||||
@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
FragmentOrganizationMembersBinding fragmentMembersByOrgBinding =
|
||||
FragmentOrganizationMembersBinding.inflate(inflater, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
binding = FragmentOrganizationMembersBinding.inflate(inflater, container, false);
|
||||
|
||||
noDataMembers = fragmentMembersByOrgBinding.noDataMembers;
|
||||
membersModel = new ViewModelProvider(this).get(MembersByOrgViewModel.class);
|
||||
|
||||
progressBar = fragmentMembersByOrgBinding.progressBar;
|
||||
mGridView = fragmentMembersByOrgBinding.gridView;
|
||||
resultLimit = Constants.getCurrentResultLimit(requireContext());
|
||||
|
||||
fetchDataAsync(orgName);
|
||||
|
||||
return fragmentMembersByOrgBinding.getRoot();
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String owner) {
|
||||
|
||||
MembersByOrgViewModel membersModel =
|
||||
new ViewModelProvider(this).get(MembersByOrgViewModel.class);
|
||||
|
||||
membersModel
|
||||
.getMembersList(owner, getContext())
|
||||
.getMembersList(owner, requireContext(), page, resultLimit)
|
||||
.observe(
|
||||
getViewLifecycleOwner(),
|
||||
membersListMain -> {
|
||||
adapter = new UserGridAdapter(getContext(), membersListMain);
|
||||
if (adapter.getCount() > 0) {
|
||||
mGridView.setAdapter(adapter);
|
||||
noDataMembers.setVisibility(View.GONE);
|
||||
mainList -> {
|
||||
adapter = new UserGridAdapter(requireContext(), mainList);
|
||||
|
||||
adapter.setLoadMoreListener(
|
||||
new UserGridAdapter.OnLoadMoreListener() {
|
||||
|
||||
@Override
|
||||
public void onLoadMore() {
|
||||
|
||||
page += 1;
|
||||
membersModel.loadMore(
|
||||
owner,
|
||||
requireContext(),
|
||||
page,
|
||||
resultLimit,
|
||||
adapter,
|
||||
binding);
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished() {
|
||||
|
||||
binding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
GridLayoutManager layoutManager =
|
||||
new GridLayoutManager(requireContext(), 2);
|
||||
binding.gridView.setLayoutManager(layoutManager);
|
||||
|
||||
if (adapter.getItemCount() > 0) {
|
||||
binding.gridView.setAdapter(adapter);
|
||||
binding.noDataMembers.setVisibility(View.GONE);
|
||||
} else {
|
||||
adapter.notifyDataSetChanged();
|
||||
mGridView.setAdapter(adapter);
|
||||
noDataMembers.setVisibility(View.VISIBLE);
|
||||
adapter.notifyDataChanged();
|
||||
binding.gridView.setAdapter(adapter);
|
||||
binding.noDataMembers.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
binding.progressBar.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
boolean connToInternet = AppUtil.hasNetworkConnection(requireContext());
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
// searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
if (!connToInternet) {
|
||||
return;
|
||||
}
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
if (mGridView.getAdapter() != null) {
|
||||
adapter.getFilter().filter(newText);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,12 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.view.MenuProvider;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import java.util.Objects;
|
||||
import org.gitnex.tea4j.v2.models.OrganizationPermissions;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CreateRepoActivity;
|
||||
@ -65,7 +68,6 @@ public class OrganizationRepositoriesFragment extends Fragment {
|
||||
|
||||
fragmentRepositoriesBinding =
|
||||
FragmentRepositoriesBinding.inflate(inflater, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
repositoriesViewModel = new ViewModelProvider(this).get(RepositoriesViewModel.class);
|
||||
|
||||
resultLimit = Constants.getCurrentResultLimit(getContext());
|
||||
@ -102,10 +104,57 @@ public class OrganizationRepositoriesFragment extends Fragment {
|
||||
Intent intentRepo = new Intent(getContext(), CreateRepoActivity.class);
|
||||
intentRepo.putExtra("organizationAction", true);
|
||||
intentRepo.putExtra("orgName", orgName);
|
||||
intentRepo.putExtras(requireActivity().getIntent().getExtras());
|
||||
intentRepo.putExtras(
|
||||
Objects.requireNonNull(requireActivity().getIntent().getExtras()));
|
||||
startActivity(intentRepo);
|
||||
});
|
||||
|
||||
requireActivity()
|
||||
.addMenuProvider(
|
||||
new MenuProvider() {
|
||||
|
||||
@Override
|
||||
public void onCreateMenu(
|
||||
@NonNull Menu menu, @NonNull MenuInflater menuInflater) {
|
||||
|
||||
menuInflater.inflate(R.menu.search_menu, menu);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView)
|
||||
searchItem.getActionView();
|
||||
assert searchView != null;
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView
|
||||
.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
if (fragmentRepositoriesBinding.recyclerView
|
||||
.getAdapter()
|
||||
!= null) {
|
||||
adapter.getFilter().filter(newText);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(@NonNull MenuItem menuItem) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
getViewLifecycleOwner(),
|
||||
Lifecycle.State.RESUMED);
|
||||
|
||||
return fragmentRepositoriesBinding.getRoot();
|
||||
}
|
||||
|
||||
@ -176,32 +225,4 @@ public class OrganizationRepositoriesFragment extends Fragment {
|
||||
OrganizationDetailActivity.updateOrgFABActions = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
if (fragmentRepositoriesBinding.recyclerView.getAdapter() != null) {
|
||||
adapter.getFilter().filter(newText);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -8,20 +8,18 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.OrganizationPermissions;
|
||||
import org.gitnex.tea4j.v2.models.Team;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.AddNewTeamMemberActivity;
|
||||
import org.mian.gitnex.adapters.UserGridAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentOrganizationTeamInfoMembersBinding;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.viewmodels.MembersByOrgTeamViewModel;
|
||||
|
||||
/**
|
||||
* @author opyale
|
||||
@ -31,9 +29,12 @@ public class OrganizationTeamInfoMembersFragment extends Fragment {
|
||||
private final List<User> teamUserInfo = new ArrayList<>();
|
||||
private Context ctx;
|
||||
private FragmentOrganizationTeamInfoMembersBinding binding;
|
||||
private MembersByOrgTeamViewModel membersByOrgTeamViewModel;
|
||||
private Team team;
|
||||
private UserGridAdapter adapter;
|
||||
public static boolean refreshMembers = false;
|
||||
private int page = 1;
|
||||
private int resultLimit;
|
||||
|
||||
public OrganizationTeamInfoMembersFragment() {}
|
||||
|
||||
@ -55,14 +56,19 @@ public class OrganizationTeamInfoMembersFragment extends Fragment {
|
||||
|
||||
team = (Team) requireArguments().getSerializable("team");
|
||||
|
||||
membersByOrgTeamViewModel =
|
||||
new ViewModelProvider(this).get(MembersByOrgTeamViewModel.class);
|
||||
resultLimit = Constants.getCurrentResultLimit(ctx);
|
||||
|
||||
adapter = new UserGridAdapter(ctx, teamUserInfo);
|
||||
binding.members.setAdapter(adapter);
|
||||
fetchMembersAsync();
|
||||
fetchDataAsync();
|
||||
|
||||
OrganizationPermissions permissions =
|
||||
(OrganizationPermissions)
|
||||
requireActivity().getIntent().getSerializableExtra("permissions");
|
||||
|
||||
assert permissions != null;
|
||||
if (!permissions.isIsOwner()) {
|
||||
binding.addNewMember.setVisibility(View.GONE);
|
||||
}
|
||||
@ -81,48 +87,58 @@ public class OrganizationTeamInfoMembersFragment extends Fragment {
|
||||
super.onResume();
|
||||
|
||||
if (refreshMembers) {
|
||||
fetchMembersAsync();
|
||||
fetchDataAsync();
|
||||
refreshMembers = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchMembersAsync() {
|
||||
private void fetchDataAsync() {
|
||||
|
||||
Call<List<User>> call =
|
||||
RetrofitClient.getApiInterface(ctx).orgListTeamMembers(team.getId(), null, null);
|
||||
membersByOrgTeamViewModel
|
||||
.getMembersList(team.getId(), ctx, page, resultLimit)
|
||||
.observe(
|
||||
getViewLifecycleOwner(),
|
||||
mainList -> {
|
||||
adapter = new UserGridAdapter(ctx, mainList);
|
||||
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
adapter.setLoadMoreListener(
|
||||
new UserGridAdapter.OnLoadMoreListener() {
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
@Override
|
||||
public void onLoadMore() {
|
||||
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<User>> call,
|
||||
@NonNull Response<List<User>> response) {
|
||||
if (response.isSuccessful()
|
||||
&& response.body() != null
|
||||
&& response.body().size() > 0) {
|
||||
teamUserInfo.clear();
|
||||
teamUserInfo.addAll(response.body());
|
||||
page += 1;
|
||||
membersByOrgTeamViewModel.loadMore(
|
||||
team.getId(),
|
||||
ctx,
|
||||
page,
|
||||
resultLimit,
|
||||
adapter,
|
||||
binding);
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
adapter.notifyDataSetChanged();
|
||||
@Override
|
||||
public void onLoadFinished() {
|
||||
|
||||
binding.noDataMembers.setVisibility(View.GONE);
|
||||
binding.members.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
binding.members.setVisibility(View.GONE);
|
||||
binding.noDataMembers.setVisibility(View.VISIBLE);
|
||||
}
|
||||
binding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
binding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
GridLayoutManager layoutManager =
|
||||
new GridLayoutManager(requireContext(), 2);
|
||||
binding.members.setLayoutManager(layoutManager);
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {
|
||||
if (adapter.getItemCount() > 0) {
|
||||
binding.members.setAdapter(adapter);
|
||||
binding.noDataMembers.setVisibility(View.GONE);
|
||||
} else {
|
||||
adapter.notifyDataChanged();
|
||||
binding.members.setAdapter(adapter);
|
||||
binding.noDataMembers.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
binding.progressBar.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,12 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.view.MenuProvider;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import java.util.Objects;
|
||||
import org.gitnex.tea4j.v2.models.OrganizationPermissions;
|
||||
import org.gitnex.tea4j.v2.models.Team;
|
||||
import org.mian.gitnex.R;
|
||||
@ -58,7 +61,7 @@ public class OrganizationTeamInfoReposFragment extends Fragment {
|
||||
FragmentRepositoriesBinding.inflate(inflater, container, false);
|
||||
|
||||
resultLimit = Constants.getCurrentResultLimit(getContext());
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
team = (Team) requireArguments().getSerializable("team");
|
||||
|
||||
repositoriesViewModel = new ViewModelProvider(this).get(RepositoriesViewModel.class);
|
||||
@ -89,7 +92,8 @@ public class OrganizationTeamInfoReposFragment extends Fragment {
|
||||
(OrganizationPermissions)
|
||||
requireActivity().getIntent().getSerializableExtra("permissions");
|
||||
|
||||
if (!requireArguments().getBoolean("showRepo") || !permissions.isIsOwner()) {
|
||||
if (!requireArguments().getBoolean("showRepo")
|
||||
|| !Objects.requireNonNull(permissions).isIsOwner()) {
|
||||
fragmentRepositoriesBinding.addNewRepo.setVisibility(View.GONE);
|
||||
}
|
||||
fragmentRepositoriesBinding.addNewRepo.setOnClickListener(
|
||||
@ -102,6 +106,52 @@ public class OrganizationTeamInfoReposFragment extends Fragment {
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
requireActivity()
|
||||
.addMenuProvider(
|
||||
new MenuProvider() {
|
||||
|
||||
@Override
|
||||
public void onCreateMenu(
|
||||
@NonNull Menu menu, @NonNull MenuInflater menuInflater) {
|
||||
|
||||
menuInflater.inflate(R.menu.search_menu, menu);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView)
|
||||
searchItem.getActionView();
|
||||
assert searchView != null;
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView
|
||||
.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
if (fragmentRepositoriesBinding.recyclerView
|
||||
.getAdapter()
|
||||
!= null) {
|
||||
adapter.getFilter().filter(newText);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(@NonNull MenuItem menuItem) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
getViewLifecycleOwner(),
|
||||
Lifecycle.State.RESUMED);
|
||||
|
||||
return fragmentRepositoriesBinding.getRoot();
|
||||
}
|
||||
|
||||
@ -170,33 +220,4 @@ public class OrganizationTeamInfoReposFragment extends Fragment {
|
||||
MainActivity.reloadRepos = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
if (fragmentRepositoriesBinding.recyclerView.getAdapter() != null) {
|
||||
adapter.getFilter().filter(newText);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@ -14,11 +15,14 @@ import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.view.MenuProvider;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import java.util.Objects;
|
||||
import org.gitnex.tea4j.v2.models.OrganizationPermissions;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CreateTeamByOrgActivity;
|
||||
@ -69,7 +73,7 @@ public class OrganizationTeamsFragment extends Fragment {
|
||||
|
||||
FragmentOrganizationTeamsBinding fragmentTeamsByOrgBinding =
|
||||
FragmentOrganizationTeamsBinding.inflate(inflater, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
teamsByOrgViewModel = new ViewModelProvider(this).get(TeamsByOrgViewModel.class);
|
||||
|
||||
noDataTeams = fragmentTeamsByOrgBinding.noDataTeams;
|
||||
@ -105,10 +109,55 @@ public class OrganizationTeamsFragment extends Fragment {
|
||||
fragmentTeamsByOrgBinding.createTeam.setOnClickListener(
|
||||
v1 -> {
|
||||
Intent intentTeam = new Intent(getContext(), CreateTeamByOrgActivity.class);
|
||||
intentTeam.putExtras(requireActivity().getIntent().getExtras());
|
||||
intentTeam.putExtras(
|
||||
Objects.requireNonNull(requireActivity().getIntent().getExtras()));
|
||||
startActivity(intentTeam);
|
||||
});
|
||||
|
||||
requireActivity()
|
||||
.addMenuProvider(
|
||||
new MenuProvider() {
|
||||
|
||||
@Override
|
||||
public void onCreateMenu(
|
||||
@NonNull Menu menu, @NonNull MenuInflater menuInflater) {
|
||||
|
||||
menuInflater.inflate(R.menu.search_menu, menu);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView)
|
||||
searchItem.getActionView();
|
||||
assert searchView != null;
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView
|
||||
.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
if (mRecyclerView.getAdapter() != null) {
|
||||
adapter.getFilter().filter(newText);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(@NonNull MenuItem menuItem) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
getViewLifecycleOwner(),
|
||||
Lifecycle.State.RESUMED);
|
||||
|
||||
return fragmentTeamsByOrgBinding.getRoot();
|
||||
}
|
||||
|
||||
@ -122,6 +171,7 @@ public class OrganizationTeamsFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private void fetchDataAsync(String owner) {
|
||||
|
||||
teamsByOrgViewModel
|
||||
@ -143,32 +193,4 @@ public class OrganizationTeamsFragment extends Fragment {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
if (mRecyclerView.getAdapter() != null) {
|
||||
adapter.getFilter().filter(newText);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -14,12 +14,13 @@ import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.RelativeLayout;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.view.MenuProvider;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.Commit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.CommitsAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
@ -108,6 +109,48 @@ public class PullRequestCommitsFragment extends Fragment {
|
||||
|
||||
loadInitial(issue, resultLimit);
|
||||
|
||||
requireActivity()
|
||||
.addMenuProvider(
|
||||
new MenuProvider() {
|
||||
|
||||
@Override
|
||||
public void onCreateMenu(
|
||||
@NonNull Menu menu, @NonNull MenuInflater menuInflater) {
|
||||
|
||||
menuInflater.inflate(R.menu.search_menu, menu);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView)
|
||||
searchItem.getActionView();
|
||||
assert searchView != null;
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView
|
||||
.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
filter(newText);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(@NonNull MenuItem menuItem) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
getViewLifecycleOwner(),
|
||||
Lifecycle.State.RESUMED);
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@ -142,7 +185,7 @@ public class PullRequestCommitsFragment extends Fragment {
|
||||
if (response.code() == 200) {
|
||||
|
||||
assert response.body() != null;
|
||||
if (response.body().size() > 0) {
|
||||
if (!response.body().isEmpty()) {
|
||||
|
||||
commitsList.clear();
|
||||
commitsList.addAll(response.body());
|
||||
@ -203,7 +246,7 @@ public class PullRequestCommitsFragment extends Fragment {
|
||||
List<Commit> result = response.body();
|
||||
assert result != null;
|
||||
|
||||
if (result.size() > 0) {
|
||||
if (!result.isEmpty()) {
|
||||
|
||||
pageSize = result.size();
|
||||
commitsList.addAll(result);
|
||||
@ -230,34 +273,6 @@ public class PullRequestCommitsFragment extends Fragment {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NotNull Menu menu, MenuInflater inflater) {
|
||||
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
|
||||
filter(newText);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void filter(String text) {
|
||||
|
||||
List<Commit> arr = new ArrayList<>();
|
||||
|
@ -14,7 +14,9 @@ import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.MenuProvider;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import java.util.ArrayList;
|
||||
@ -41,7 +43,6 @@ public class PullRequestsFragment extends Fragment {
|
||||
public static boolean resumePullRequests = false;
|
||||
private final String TAG = "PullRequestFragment";
|
||||
private FragmentPullRequestsBinding fragmentPullRequestsBinding;
|
||||
private Menu menu;
|
||||
private List<PullRequest> prList;
|
||||
private PullRequestsAdapter adapter;
|
||||
private Context context;
|
||||
@ -64,7 +65,6 @@ public class PullRequestsFragment extends Fragment {
|
||||
|
||||
fragmentPullRequestsBinding =
|
||||
FragmentPullRequestsBinding.inflate(inflater, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
context = getContext();
|
||||
|
||||
final SwipeRefreshLayout swipeRefresh = fragmentPullRequestsBinding.pullToRefresh;
|
||||
@ -113,12 +113,6 @@ public class PullRequestsFragment extends Fragment {
|
||||
((RepoDetailActivity) requireActivity())
|
||||
.setFragmentRefreshListenerPr(
|
||||
prState -> {
|
||||
if (prState.equals("closed")) {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter_closed);
|
||||
} else {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter);
|
||||
}
|
||||
|
||||
prList.clear();
|
||||
|
||||
adapter = new PullRequestsAdapter(context, prList);
|
||||
@ -180,6 +174,55 @@ public class PullRequestsFragment extends Fragment {
|
||||
fragmentPullRequestsBinding.createPullRequest.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
requireActivity()
|
||||
.addMenuProvider(
|
||||
new MenuProvider() {
|
||||
|
||||
@Override
|
||||
public void onCreateMenu(
|
||||
@NonNull Menu menu, @NonNull MenuInflater menuInflater) {
|
||||
|
||||
menuInflater.inflate(R.menu.search_menu, menu);
|
||||
menuInflater.inflate(R.menu.filter_menu_pr, menu);
|
||||
|
||||
if (repository.getPrState().toString().equals("closed")) {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter_closed);
|
||||
} else {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter);
|
||||
}
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView)
|
||||
searchItem.getActionView();
|
||||
assert searchView != null;
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView
|
||||
.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
filter(newText);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(@NonNull MenuItem menuItem) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
getViewLifecycleOwner(),
|
||||
Lifecycle.State.RESUMED);
|
||||
|
||||
return fragmentPullRequestsBinding.getRoot();
|
||||
}
|
||||
|
||||
@ -226,7 +269,7 @@ public class PullRequestsFragment extends Fragment {
|
||||
if (response.code() == 200) {
|
||||
|
||||
assert response.body() != null;
|
||||
if (response.body().size() > 0) {
|
||||
if (!response.body().isEmpty()) {
|
||||
prList.clear();
|
||||
prList.addAll(response.body());
|
||||
adapter.notifyDataChanged();
|
||||
@ -285,7 +328,7 @@ public class PullRequestsFragment extends Fragment {
|
||||
List<PullRequest> result = response.body();
|
||||
|
||||
assert result != null;
|
||||
if (result.size() > 0) {
|
||||
if (!result.isEmpty()) {
|
||||
pageSize = result.size();
|
||||
prList.addAll(result);
|
||||
} else {
|
||||
@ -305,41 +348,6 @@ public class PullRequestsFragment extends Fragment {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
this.menu = menu;
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
inflater.inflate(R.menu.filter_menu_pr, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
if (repository.getPrState().toString().equals("closed")) {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter_closed);
|
||||
} else {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter);
|
||||
}
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView =
|
||||
(androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(
|
||||
new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
filter(newText);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void filter(String text) {
|
||||
|
||||
List<PullRequest> arr = new ArrayList<>();
|
||||
|
@ -11,13 +11,16 @@ import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.view.MenuProvider;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import java.io.IOException;
|
||||
@ -121,7 +124,6 @@ public class ReleasesFragment extends Fragment {
|
||||
|
||||
fetchDataAsync(repository.getOwner(), repository.getName());
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
((RepoDetailActivity) requireActivity())
|
||||
.setFragmentRefreshListenerReleases(
|
||||
type -> {
|
||||
@ -149,6 +151,25 @@ public class ReleasesFragment extends Fragment {
|
||||
startActivity(
|
||||
repository.getIntent(getContext(), CreateReleaseActivity.class)));
|
||||
|
||||
requireActivity()
|
||||
.addMenuProvider(
|
||||
new MenuProvider() {
|
||||
|
||||
@Override
|
||||
public void onCreateMenu(
|
||||
@NonNull Menu menu, @NonNull MenuInflater menuInflater) {
|
||||
|
||||
menuInflater.inflate(R.menu.filter_menu_releases, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(@NonNull MenuItem menuItem) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
getViewLifecycleOwner(),
|
||||
Lifecycle.State.RESUMED);
|
||||
|
||||
return fragmentReleasesBinding.getRoot();
|
||||
}
|
||||
|
||||
@ -282,14 +303,14 @@ public class ReleasesFragment extends Fragment {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
/*@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
if (!((BaseActivity) requireActivity()).getAccount().requiresVersion("1.15.0")) {
|
||||
return;
|
||||
}
|
||||
inflater.inflate(R.menu.filter_menu_releases, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
}*/
|
||||
|
||||
private void requestFileDownload(String url) {
|
||||
currentDownloadUrl = url;
|
||||
@ -400,8 +421,7 @@ public class ReleasesFragment extends Fragment {
|
||||
@NonNull Response response)
|
||||
throws IOException {
|
||||
|
||||
if (!response.isSuccessful()
|
||||
|| response.body() == null) {
|
||||
if (!response.isSuccessful()) {
|
||||
onFailure(call, new IOException());
|
||||
return;
|
||||
}
|
||||
@ -410,8 +430,10 @@ public class ReleasesFragment extends Fragment {
|
||||
requireContext()
|
||||
.getContentResolver()
|
||||
.openOutputStream(
|
||||
result.getData()
|
||||
.getData());
|
||||
Objects
|
||||
.requireNonNull(
|
||||
result.getData()
|
||||
.getData()));
|
||||
|
||||
AppUtil.copyProgress(
|
||||
Objects.requireNonNull(
|
||||
|
@ -51,7 +51,6 @@ public class WikiFragment extends Fragment {
|
||||
@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
fragmentWikiBinding = FragmentWikiBinding.inflate(inflater, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
AccountContext account = ((BaseActivity) requireActivity()).getAccount();
|
||||
boolean archived = repository.getRepository().isArchived();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
@ -8,7 +9,9 @@ import androidx.lifecycle.ViewModel;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.CollaboratorsAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentCollaboratorsBinding;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -19,20 +22,23 @@ import retrofit2.Response;
|
||||
*/
|
||||
public class CollaboratorsViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<List<User>> collaboratorsList;
|
||||
private static MutableLiveData<List<User>> collaboratorsList;
|
||||
|
||||
public LiveData<List<User>> getCollaboratorsList(String owner, String repo, Context ctx) {
|
||||
public LiveData<List<User>> getCollaboratorsList(
|
||||
String owner, String repo, Context ctx, int page, int resultLimit) {
|
||||
|
||||
collaboratorsList = new MutableLiveData<>();
|
||||
loadCollaboratorsListList(owner, repo, ctx);
|
||||
loadCollaboratorsListList(owner, repo, ctx, page, resultLimit);
|
||||
|
||||
return collaboratorsList;
|
||||
}
|
||||
|
||||
private void loadCollaboratorsListList(String owner, String repo, Context ctx) {
|
||||
public static void loadCollaboratorsListList(
|
||||
String owner, String repo, Context ctx, int page, int resultLimit) {
|
||||
|
||||
Call<List<User>> call =
|
||||
RetrofitClient.getApiInterface(ctx).repoListCollaborators(owner, repo, null, null);
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.repoListCollaborators(owner, repo, page, resultLimit);
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
@ -44,8 +50,50 @@ public class CollaboratorsViewModel extends ViewModel {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
collaboratorsList.postValue(response.body());
|
||||
} else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadMore(
|
||||
String owner,
|
||||
String repo,
|
||||
Context ctx,
|
||||
int page,
|
||||
int resultLimit,
|
||||
CollaboratorsAdapter adapter,
|
||||
FragmentCollaboratorsBinding binding) {
|
||||
|
||||
Call<List<User>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.repoListCollaborators(owner, repo, page, resultLimit);
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<User>> call,
|
||||
@NonNull Response<List<User>> response) {
|
||||
assert response.body() != null;
|
||||
if (response.isSuccessful()) {
|
||||
List<User> list = collaboratorsList.getValue();
|
||||
assert list != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if (!response.body().isEmpty()) {
|
||||
list.addAll(response.body());
|
||||
adapter.updateList(list);
|
||||
} else {
|
||||
adapter.setMoreDataAvailable(false);
|
||||
}
|
||||
binding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
@ -8,7 +9,9 @@ import androidx.lifecycle.ViewModel;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.LabelsAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentLabelsBinding;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -19,12 +22,40 @@ import retrofit2.Response;
|
||||
*/
|
||||
public class LabelsViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<Label>> labelsList;
|
||||
private static MutableLiveData<List<Label>> orgLabelsList;
|
||||
|
||||
public static void loadLabelsList(String owner, String repo, Context ctx) {
|
||||
public LiveData<List<Label>> getLabelsList(
|
||||
String owner,
|
||||
String repo,
|
||||
String type,
|
||||
Context ctx,
|
||||
FragmentLabelsBinding fragmentLabelsBinding,
|
||||
int page,
|
||||
int resultLimit) {
|
||||
|
||||
Call<List<Label>> call =
|
||||
RetrofitClient.getApiInterface(ctx).issueListLabels(owner, repo, null, null);
|
||||
orgLabelsList = new MutableLiveData<>();
|
||||
loadLabelsList(owner, repo, type, ctx, fragmentLabelsBinding, page, resultLimit);
|
||||
|
||||
return orgLabelsList;
|
||||
}
|
||||
|
||||
public static void loadLabelsList(
|
||||
String owner,
|
||||
String repo,
|
||||
String type,
|
||||
Context ctx,
|
||||
FragmentLabelsBinding fragmentLabelsBinding,
|
||||
int page,
|
||||
int resultLimit) {
|
||||
|
||||
Call<List<Label>> call;
|
||||
if (type.equalsIgnoreCase("repo")) {
|
||||
call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueListLabels(owner, repo, page, resultLimit);
|
||||
} else {
|
||||
call = RetrofitClient.getApiInterface(ctx).orgListLabels(owner, page, resultLimit);
|
||||
}
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
@ -35,9 +66,12 @@ public class LabelsViewModel extends ViewModel {
|
||||
@NonNull Response<List<Label>> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
labelsList.postValue(response.body());
|
||||
|
||||
orgLabelsList.postValue(response.body());
|
||||
} else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
fragmentLabelsBinding.progressBar.setVisibility(View.GONE);
|
||||
fragmentLabelsBinding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,11 +83,53 @@ public class LabelsViewModel extends ViewModel {
|
||||
});
|
||||
}
|
||||
|
||||
public LiveData<List<Label>> getLabelsList(String owner, String repo, Context ctx) {
|
||||
public void loadMore(
|
||||
String owner,
|
||||
String repo,
|
||||
String type,
|
||||
Context ctx,
|
||||
FragmentLabelsBinding fragmentLabelsBinding,
|
||||
int page,
|
||||
int resultLimit,
|
||||
LabelsAdapter adapter) {
|
||||
|
||||
labelsList = new MutableLiveData<>();
|
||||
loadLabelsList(owner, repo, ctx);
|
||||
Call<List<Label>> call;
|
||||
if (type.equalsIgnoreCase("repo")) {
|
||||
call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueListLabels(owner, repo, page, resultLimit);
|
||||
} else {
|
||||
call = RetrofitClient.getApiInterface(ctx).orgListLabels(owner, page, resultLimit);
|
||||
}
|
||||
|
||||
return labelsList;
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Label>> call,
|
||||
@NonNull Response<List<Label>> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
List<Label> list = orgLabelsList.getValue();
|
||||
assert list != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if (!response.body().isEmpty()) {
|
||||
list.addAll(response.body());
|
||||
adapter.updateList(list);
|
||||
} else {
|
||||
adapter.setMoreDataAvailable(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Label>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,103 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.UserGridAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentOrganizationTeamInfoMembersBinding;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
public class MembersByOrgTeamViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<List<User>> membersList;
|
||||
|
||||
public LiveData<List<User>> getMembersList(
|
||||
Long teamId, Context ctx, int page, int resultLimit) {
|
||||
|
||||
membersList = new MutableLiveData<>();
|
||||
loadMembersList(teamId, ctx, page, resultLimit);
|
||||
|
||||
return membersList;
|
||||
}
|
||||
|
||||
private void loadMembersList(Long teamId, Context ctx, int page, int resultLimit) {
|
||||
|
||||
Call<List<User>> call =
|
||||
RetrofitClient.getApiInterface(ctx).orgListTeamMembers(teamId, page, resultLimit);
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<User>> call,
|
||||
@NonNull Response<List<User>> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
membersList.postValue(response.body());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadMore(
|
||||
Long teamId,
|
||||
Context ctx,
|
||||
int page,
|
||||
int resultLimit,
|
||||
UserGridAdapter adapter,
|
||||
FragmentOrganizationTeamInfoMembersBinding binding) {
|
||||
|
||||
Call<List<User>> call =
|
||||
RetrofitClient.getApiInterface(ctx).orgListTeamMembers(teamId, page, resultLimit);
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<User>> call,
|
||||
@NonNull Response<List<User>> response) {
|
||||
assert response.body() != null;
|
||||
if (response.isSuccessful()) {
|
||||
List<User> list = membersList.getValue();
|
||||
assert list != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if (!response.body().isEmpty()) {
|
||||
list.addAll(response.body());
|
||||
adapter.updateList(list);
|
||||
} else {
|
||||
adapter.setMoreDataAvailable(false);
|
||||
}
|
||||
binding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
@ -8,7 +9,9 @@ import androidx.lifecycle.ViewModel;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.UserGridAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentOrganizationMembersBinding;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -21,18 +24,19 @@ public class MembersByOrgViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<List<User>> membersList;
|
||||
|
||||
public LiveData<List<User>> getMembersList(String owner, Context ctx) {
|
||||
public LiveData<List<User>> getMembersList(
|
||||
String owner, Context ctx, int page, int resultLimit) {
|
||||
|
||||
membersList = new MutableLiveData<>();
|
||||
loadMembersList(owner, ctx);
|
||||
loadMembersList(owner, ctx, page, resultLimit);
|
||||
|
||||
return membersList;
|
||||
}
|
||||
|
||||
private void loadMembersList(String owner, Context ctx) {
|
||||
private void loadMembersList(String owner, Context ctx, int page, int resultLimit) {
|
||||
|
||||
Call<List<User>> call =
|
||||
RetrofitClient.getApiInterface(ctx).orgListMembers(owner, null, null);
|
||||
RetrofitClient.getApiInterface(ctx).orgListMembers(owner, page, resultLimit);
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
@ -56,4 +60,46 @@ public class MembersByOrgViewModel extends ViewModel {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadMore(
|
||||
String owner,
|
||||
Context ctx,
|
||||
int page,
|
||||
int resultLimit,
|
||||
UserGridAdapter adapter,
|
||||
FragmentOrganizationMembersBinding binding) {
|
||||
|
||||
Call<List<User>> call =
|
||||
RetrofitClient.getApiInterface(ctx).orgListMembers(owner, page, resultLimit);
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<User>> call,
|
||||
@NonNull Response<List<User>> response) {
|
||||
assert response.body() != null;
|
||||
if (response.isSuccessful()) {
|
||||
List<User> list = membersList.getValue();
|
||||
assert list != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if (!response.body().isEmpty()) {
|
||||
list.addAll(response.body());
|
||||
adapter.updateList(list);
|
||||
} else {
|
||||
adapter.setMoreDataAvailable(false);
|
||||
}
|
||||
binding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ import retrofit2.Response;
|
||||
*/
|
||||
public class MilestonesViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<List<Milestone>> milestonesList;
|
||||
private int resultLimit;
|
||||
private static MutableLiveData<List<Milestone>> milestonesList;
|
||||
private static int resultLimit;
|
||||
|
||||
public LiveData<List<Milestone>> getMilestonesList(
|
||||
String repoOwner, String repoName, String milestoneState, Context ctx) {
|
||||
@ -33,7 +33,7 @@ public class MilestonesViewModel extends ViewModel {
|
||||
return milestonesList;
|
||||
}
|
||||
|
||||
public void loadMilestonesList(
|
||||
public static void loadMilestonesList(
|
||||
String repoOwner, String repoName, String milestoneState, Context ctx) {
|
||||
|
||||
Call<List<Milestone>> call =
|
||||
|
@ -1,68 +0,0 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
public class OrganizationLabelsViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<Label>> orgLabelsList;
|
||||
|
||||
public static void loadOrgLabelsList(
|
||||
String owner, Context ctx, ProgressBar progressBar, TextView noData) {
|
||||
|
||||
Call<List<Label>> call =
|
||||
RetrofitClient.getApiInterface(ctx).orgListLabels(owner, null, null);
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Label>> call,
|
||||
@NonNull Response<List<Label>> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
orgLabelsList.postValue(response.body());
|
||||
} else {
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Label>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public LiveData<List<Label>> getOrgLabelsList(
|
||||
String owner, Context ctx, ProgressBar progressBar, TextView noData) {
|
||||
|
||||
orgLabelsList = new MutableLiveData<>();
|
||||
loadOrgLabelsList(owner, ctx, progressBar, noData);
|
||||
|
||||
return orgLabelsList;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
@ -8,7 +9,9 @@ import androidx.lifecycle.ViewModel;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.UserGridAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityRepoStargazersBinding;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -21,19 +24,21 @@ public class RepoStargazersViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<List<User>> stargazersList;
|
||||
|
||||
public LiveData<List<User>> getRepoStargazers(String repoOwner, String repoName, Context ctx) {
|
||||
public LiveData<List<User>> getRepoStargazers(
|
||||
String repoOwner, String repoName, Context ctx, int page, int resultLimit) {
|
||||
|
||||
stargazersList = new MutableLiveData<>();
|
||||
loadRepoStargazers(repoOwner, repoName, ctx);
|
||||
loadRepoStargazers(repoOwner, repoName, ctx, page, resultLimit);
|
||||
|
||||
return stargazersList;
|
||||
}
|
||||
|
||||
private void loadRepoStargazers(String repoOwner, String repoName, Context ctx) {
|
||||
private void loadRepoStargazers(
|
||||
String repoOwner, String repoName, Context ctx, int page, int resultLimit) {
|
||||
|
||||
Call<List<User>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.repoListStargazers(repoOwner, repoName, null, null);
|
||||
.repoListStargazers(repoOwner, repoName, page, resultLimit);
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
@ -45,8 +50,50 @@ public class RepoStargazersViewModel extends ViewModel {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
stargazersList.postValue(response.body());
|
||||
} else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadMore(
|
||||
String repoOwner,
|
||||
String repoName,
|
||||
Context ctx,
|
||||
int page,
|
||||
int resultLimit,
|
||||
UserGridAdapter adapter,
|
||||
ActivityRepoStargazersBinding activityRepoStargazersBinding) {
|
||||
|
||||
Call<List<User>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.repoListStargazers(repoOwner, repoName, page, resultLimit);
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<User>> call,
|
||||
@NonNull Response<List<User>> response) {
|
||||
assert response.body() != null;
|
||||
if (response.isSuccessful()) {
|
||||
List<User> list = stargazersList.getValue();
|
||||
assert list != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if (!response.body().isEmpty()) {
|
||||
list.addAll(response.body());
|
||||
adapter.updateList(list);
|
||||
} else {
|
||||
adapter.setMoreDataAvailable(false);
|
||||
}
|
||||
activityRepoStargazersBinding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
@ -8,6 +9,7 @@ import androidx.lifecycle.ViewModel;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.UserGridAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import retrofit2.Call;
|
||||
@ -21,19 +23,21 @@ public class RepoWatchersViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<List<User>> watchersList;
|
||||
|
||||
public LiveData<List<User>> getRepoWatchers(String repoOwner, String repoName, Context ctx) {
|
||||
public LiveData<List<User>> getRepoWatchers(
|
||||
String repoOwner, String repoName, Context ctx, int page, int resultLimit) {
|
||||
|
||||
watchersList = new MutableLiveData<>();
|
||||
loadRepoWatchers(repoOwner, repoName, ctx);
|
||||
loadRepoWatchers(repoOwner, repoName, ctx, page, resultLimit);
|
||||
|
||||
return watchersList;
|
||||
}
|
||||
|
||||
private void loadRepoWatchers(String repoOwner, String repoName, Context ctx) {
|
||||
private void loadRepoWatchers(
|
||||
String repoOwner, String repoName, Context ctx, int page, int resultLimit) {
|
||||
|
||||
Call<List<User>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.repoListSubscribers(repoOwner, repoName, null, null);
|
||||
.repoListSubscribers(repoOwner, repoName, page, resultLimit);
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
@ -45,8 +49,50 @@ public class RepoWatchersViewModel extends ViewModel {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
watchersList.postValue(response.body());
|
||||
} else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadMore(
|
||||
String repoOwner,
|
||||
String repoName,
|
||||
Context ctx,
|
||||
int page,
|
||||
int resultLimit,
|
||||
UserGridAdapter adapter,
|
||||
org.mian.gitnex.databinding.ActivityRepoWatchersBinding activityRepoWatchersBinding) {
|
||||
|
||||
Call<List<User>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.repoListSubscribers(repoOwner, repoName, page, resultLimit);
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<User>> call,
|
||||
@NonNull Response<List<User>> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
List<User> list = watchersList.getValue();
|
||||
assert list != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if (!response.body().isEmpty()) {
|
||||
list.addAll(response.body());
|
||||
adapter.updateList(list);
|
||||
} else {
|
||||
adapter.setMoreDataAvailable(false);
|
||||
}
|
||||
activityRepoWatchersBinding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
@ -91,4 +91,4 @@
|
||||
android:textSize="@dimen/dimen20sp"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</RelativeLayout>
|
||||
|
@ -46,47 +46,38 @@
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
android:background="?attr/primaryBackgroundColor">
|
||||
android:layout_marginTop="@dimen/dimen56dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
||||
android:id="@+id/progress_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:indeterminate="true"
|
||||
style="@style/Widget.MaterialComponents.LinearProgressIndicator"
|
||||
app:indicatorColor="?attr/progressIndicatorColor"/>
|
||||
|
||||
<GridView
|
||||
android:id="@+id/gridView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none"
|
||||
android:numColumns="2"
|
||||
android:gravity="center"
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
android:padding="@dimen/dimen4dp"/>
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/gridView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/dimen4dp"
|
||||
android:gravity="center"
|
||||
android:background="?attr/primaryBackgroundColor" />
|
||||
|
||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
||||
android:id="@+id/progress_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminate="true"
|
||||
style="@style/Widget.MaterialComponents.LinearProgressIndicator"
|
||||
app:indicatorColor="?attr/progressIndicatorColor"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noDataStargazers"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="@string/noDataFound"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="@dimen/dimen20sp"
|
||||
android:visibility="gone"/>
|
||||
<TextView
|
||||
android:id="@+id/noDataStargazers"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="@string/noDataFound"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="@dimen/dimen20sp"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
@ -46,38 +46,29 @@
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
android:background="?attr/primaryBackgroundColor">
|
||||
android:layout_marginTop="@dimen/dimen56dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
||||
android:id="@+id/progress_bar"
|
||||
style="@style/Widget.MaterialComponents.LinearProgressIndicator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:indeterminate="true"
|
||||
app:indicatorColor="?attr/progressIndicatorColor"/>
|
||||
|
||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
||||
android:id="@+id/progress_bar"
|
||||
style="@style/Widget.MaterialComponents.LinearProgressIndicator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminate="true"
|
||||
app:indicatorColor="?attr/progressIndicatorColor"/>
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/gridView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
android:padding="@dimen/dimen4dp" />
|
||||
|
||||
<GridView
|
||||
android:id="@+id/gridView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
android:padding="@dimen/dimen4dp"
|
||||
android:scrollbars="none"
|
||||
android:numColumns="2"
|
||||
android:gravity="center"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noDataWatchers"
|
||||
|
@ -131,54 +131,6 @@
|
||||
android:contentDescription="@string/useCustomTabs"
|
||||
android:layout_weight=".10" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/enableDraftsCommentsDeletion"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dimen32dp"
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight=".90"
|
||||
android:text="@string/settingsEnableCommentsDeletionText"
|
||||
android:layout_marginTop="@dimen/dimen4dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="@dimen/dimen18sp" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/commentsDeletionSwitch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/settingsEnableCommentsDeletionText"
|
||||
android:layout_weight=".10" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dimen96dp"
|
||||
android:text="@string/settingsEnableCommentsDeletionHintText"
|
||||
android:textColor="?attr/hintColor"
|
||||
android:textSize="@dimen/dimen12sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
@ -1,85 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="@dimen/dimen6dp"
|
||||
android:paddingBottom="@dimen/dimen12dp">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/draftsHeadFrame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/dimen8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bottomSheetHeader"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/draftsHeader"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="@dimen/dimen16sp"/>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="?attr/materialCardViewFilledStyle"
|
||||
android:layout_width="@dimen/dimen28dp"
|
||||
android:layout_height="@dimen/dimen4dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="@dimen/dimen8dp"
|
||||
android:layout_marginBottom="@dimen/dimen16dp"
|
||||
app:cardCornerRadius="@dimen/dimen24dp"
|
||||
app:cardElevation="@dimen/dimen0dp">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/fabColor" />
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout
|
||||
android:id="@+id/draftsSection"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="@dimen/dimen4dp"
|
||||
app:alignContent="center"
|
||||
app:alignItems="flex_start"
|
||||
app:flexWrap="wrap"
|
||||
app:justifyContent="center">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/deleteAllDrafts"
|
||||
android:layout_width="@dimen/dimen132dp"
|
||||
android:layout_height="@dimen/dimen100dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:gravity="center"
|
||||
android:padding="@dimen/dimen4dp"
|
||||
android:text="@string/menuDeleteText"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="@dimen/dimen14sp"
|
||||
app:drawableTopCompat="@drawable/ic_delete"
|
||||
app:layout_alignSelf="flex_start"/>
|
||||
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</LinearLayout>
|
@ -1,117 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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:orientation="vertical">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/Widget.AppCompat.SearchView">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
app:contentInsetEnd="15dp"
|
||||
app:contentInsetStart="15dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/close"
|
||||
android:layout_width="26dp"
|
||||
android:layout_height="26dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:layout_weight="0"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/close"
|
||||
android:focusable="true"
|
||||
android:src="@drawable/ic_close"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/toolbar_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:text="@string/commentButtonText"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="14sp"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/drafts"
|
||||
android:layout_width="26dp"
|
||||
android:layout_height="26dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_weight="0"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/close"
|
||||
android:focusable="true"
|
||||
android:src="@drawable/ic_drafts"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/send"
|
||||
android:layout_width="26dp"
|
||||
android:layout_height="26dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_weight="0"
|
||||
android:alpha=".5"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/close"
|
||||
android:enabled="false"
|
||||
android:focusable="true"
|
||||
android:src="@drawable/ic_send"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="15dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/comment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:autofillHints="@string/commentButtonText"
|
||||
android:background="@drawable/shape_inputs"
|
||||
android:inputType="textMultiLine|textImeMultiLine|textCapSentences"
|
||||
android:labelFor="@+id/comment"
|
||||
android:maxLines="5"
|
||||
android:padding="10dp"
|
||||
android:scrollbars="vertical"
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHint="?attr/primaryBackgroundColor"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/drafts_hint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="@string/draftSaved"
|
||||
android:textColor="?attr/hintColor"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -7,15 +7,13 @@
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
android:orientation="vertical">
|
||||
|
||||
<GridView
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/gridView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none"
|
||||
android:numColumns="2"
|
||||
android:padding="@dimen/dimen4dp"
|
||||
android:gravity="center"
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
android:padding="@dimen/dimen4dp"/>
|
||||
android:background="?attr/primaryBackgroundColor" />
|
||||
|
||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
||||
android:id="@+id/progress_bar"
|
||||
|
@ -12,13 +12,11 @@
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
android:padding="@dimen/dimen4dp">
|
||||
|
||||
<GridView
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/gridView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none"
|
||||
android:numColumns="2"
|
||||
android:gravity="center"/>
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
@ -21,12 +21,10 @@
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
android:padding="@dimen/dimen4dp">
|
||||
|
||||
<GridView
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/members"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none"
|
||||
android:numColumns="2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="@dimen/dimen72dp" />
|
||||
|
@ -1,86 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/layoutDraftsFrame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="@dimen/dimen4dp"
|
||||
android:paddingBottom="@dimen/dimen4dp">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="?attr/materialCardViewElevatedStyle"
|
||||
app:cardElevation="@dimen/dimen0dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:background="?attr/materialCardBackgroundColor"
|
||||
android:padding="@dimen/dimen12dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/frameDraftInfo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/dimen10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/repoInfo"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="@dimen/dimen16sp"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/editCommentStatus"
|
||||
android:layout_width="@dimen/dimen20dp"
|
||||
android:layout_height="@dimen/dimen20dp"
|
||||
android:layout_marginStart="@dimen/dimen10dp"
|
||||
android:layout_marginEnd="@dimen/dimen10dp"
|
||||
android:contentDescription="@string/menuDeleteText"
|
||||
android:src="@drawable/ic_edit"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/deleteDraft"
|
||||
android:layout_width="@dimen/dimen20dp"
|
||||
android:layout_height="@dimen/dimen20dp"
|
||||
android:layout_marginStart="@dimen/dimen10dp"
|
||||
android:contentDescription="@string/menuDeleteText"
|
||||
android:src="@drawable/ic_delete"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/frameDraftInfo1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="@dimen/dimen10dp"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/draftText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/dimen0dp"
|
||||
android:layout_weight=".95"
|
||||
android:text="@string/noDataFound"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="@dimen/dimen14sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</LinearLayout>
|
@ -54,11 +54,6 @@
|
||||
android:icon="@drawable/ic_notes"
|
||||
android:title="@string/navNotes" />
|
||||
|
||||
<item android:id="@+id/nav_comments_draft"
|
||||
android:icon="@drawable/ic_drafts"
|
||||
android:visible="false"
|
||||
android:title="@string/titleDrafts"/>
|
||||
|
||||
<item android:id="@+id/nav_profile"
|
||||
android:icon="@drawable/ic_person"
|
||||
android:title="@string/navProfile"/>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<item
|
||||
android:id="@+id/branchCommits"
|
||||
android:icon="@drawable/ic_commit"
|
||||
android:orderInCategory="2"
|
||||
android:orderInCategory="0"
|
||||
android:title="@string/commitTitle"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
|
@ -63,7 +63,6 @@
|
||||
<item>@string/navRepos</item>
|
||||
<item>@string/navProfile</item>
|
||||
<item>@string/pageTitleExplore</item>
|
||||
<item>@string/titleDrafts</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="appDefaultHomeScreenNew">
|
||||
@ -73,7 +72,6 @@
|
||||
<item>@string/navRepos</item>
|
||||
<item>@string/navAccount</item>
|
||||
<item>@string/pageTitleExplore</item>
|
||||
<item>@string/titleDrafts</item>
|
||||
<item>@string/pageTitleNotifications</item>
|
||||
<item>@string/navMyIssues</item>
|
||||
<item>@string/navMostVisited</item>
|
||||
|
@ -240,10 +240,6 @@
|
||||
<string name="clearCacheSelectionSelectedText" translatable="false">0 B</string>
|
||||
<string name="clearCacheDialogHeader">Clear Cache?</string>
|
||||
<string name="clearCacheDialogMessage">This will delete all the cache data including files and images.\n\nProceed with deletion?</string>
|
||||
<string name="draftsHeader">Drafts</string>
|
||||
<string name="draftsHintText">Comments draft</string>
|
||||
<string name="settingsEnableCommentsDeletionText">Enable Drafts Deletion</string>
|
||||
<string name="settingsEnableCommentsDeletionHintText">Delete comment draft when comment is posted</string>
|
||||
<string name="settingsGeneralHeader">General</string>
|
||||
<string name="generalHintText">Home screen, crash reports, custom tabs</string>
|
||||
<string name="generalDeepLinkDefaultScreen">Default Link Handler</string>
|
||||
@ -567,7 +563,6 @@
|
||||
<string name="unStarRepositorySuccess">Repository removed from starred list</string>
|
||||
<string name="watchRepositorySuccess">Repository added to watch list</string>
|
||||
<string name="unWatchRepositorySuccess">Repository removed from watch list</string>
|
||||
<string name="titleDrafts">Drafts</string>
|
||||
<string name="filesBreadcrumbRoot" translatable="false">Root</string>
|
||||
|
||||
<string name="versionUnsupportedOld">Unsupported old version(%1$s) of Gitea detected. Please update to latest stable version. If you continue, some features may not work.</string>
|
||||
@ -664,13 +659,6 @@
|
||||
<string name="forceLogoutDialogHeader">Please sign in again</string>
|
||||
<string name="forceLogoutDialogDescription">Due to some major changes regarding the internal functioning of the app, we require you to login again. These changes allow us to make the app more flexible in the future.\n\nThank you for your patience and sorry for the inconvenience.</string>
|
||||
|
||||
<string name="deleteAllDrafts">Delete All Drafts</string>
|
||||
<string name="draftsListEmpty">No drafts found</string>
|
||||
<string name="draftsDeleteSuccess">Drafts deleted successfully</string>
|
||||
<string name="draftsSingleDeleteSuccess">Draft deleted successfully</string>
|
||||
<string name="deleteAllDraftsDialogMessage">This will delete all the drafts for this account. \n\nProceed with deletion?</string>
|
||||
<string name="draftSaved">Draft was saved automatically.</string>
|
||||
|
||||
<string name="resetMostReposCounter">Counter is reset successfully</string>
|
||||
<string name="resetCounterDialogMessage">Do you want to reset counter for repository %s?</string>
|
||||
<string name="resetCounterAllDialogMessage">This will reset all the counters for this account repositories.</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user