use of com.fastaccess.data.dao.FilesListModel in project FastHub by k0shk0sh.
the class AbstractGist method getDisplayTitle.
@NonNull
public SpannableBuilder getDisplayTitle(boolean isFromProfile, boolean gistView) {
SpannableBuilder spannableBuilder = SpannableBuilder.builder();
boolean addDescription = true;
if (!isFromProfile) {
if (owner != null) {
spannableBuilder.bold(owner.getLogin());
} else if (user != null) {
spannableBuilder.bold(user.getLogin());
} else {
spannableBuilder.bold("Anonymous");
}
if (!gistView) {
List<FilesListModel> files = getFilesAsList();
if (!files.isEmpty()) {
FilesListModel filesListModel = files.get(0);
if (!InputHelper.isEmpty(filesListModel.getFilename()) && filesListModel.getFilename().trim().length() > 2) {
spannableBuilder.append(" ").append("/").append(" ").append(filesListModel.getFilename());
addDescription = false;
}
}
}
}
if (!InputHelper.isEmpty(description) && addDescription) {
if (!InputHelper.isEmpty(spannableBuilder.toString())) {
spannableBuilder.append(" ").append("/").append(" ");
}
spannableBuilder.append(description);
}
if (InputHelper.isEmpty(spannableBuilder.toString())) {
if (isFromProfile) {
List<FilesListModel> files = getFilesAsList();
if (!files.isEmpty()) {
FilesListModel filesListModel = files.get(0);
if (!InputHelper.isEmpty(filesListModel.getFilename()) && filesListModel.getFilename().trim().length() > 2) {
spannableBuilder.append(" ").append(filesListModel.getFilename());
}
}
}
}
return spannableBuilder;
}
use of com.fastaccess.data.dao.FilesListModel in project FastHub by k0shk0sh.
the class GistFilesListFragment method onInitFiles.
@Override
public void onInitFiles(@Nullable ArrayList<FilesListModel> filesListModel, boolean isOwner) {
if (filesListModel == null) {
// DO NOT PASS NULL TO ADAPTER
filesListModel = new ArrayList<>();
}
if (getPresenter().getFilesMap().isEmpty()) {
for (FilesListModel listModel : filesListModel) {
getPresenter().getFilesMap().put(listModel.getFilename(), listModel);
}
}
adapter.setOwner(isOwner);
getPresenter().onSetList(filesListModel);
adapter.insertItems(filesListModel);
}
use of com.fastaccess.data.dao.FilesListModel in project FastHub by k0shk0sh.
the class GistFilesListFragment method onFileAdded.
@Override
public void onFileAdded(@NonNull FilesListModel file, Integer position) {
if (position == null || position == -1) {
adapter.addItem(file);
getPresenter().getFilesMap().put(file.getFilename(), file);
} else {
FilesListModel current = adapter.getItem(position);
if (getPresenter().getFilesMap().get(current.getFilename()) != null) {
FilesListModel toUpdate = getPresenter().getFilesMap().get(current.getFilename());
toUpdate.setFilename(file.getFilename());
toUpdate.setContent(file.getContent());
getPresenter().getFilesMap().put(current.getFilename(), toUpdate);
}
adapter.swapItem(file, position);
}
}
use of com.fastaccess.data.dao.FilesListModel in project FastHub by k0shk0sh.
the class GistFilesListFragment method onFragmentCreated.
@Override
protected void onFragmentCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
stateLayout.setEmptyText(R.string.no_files);
stateLayout.showEmptyState();
recycler.setEmptyView(stateLayout, refresh);
refresh.setEnabled(false);
adapter = new GistFilesAdapter(getPresenter().getFiles(), getPresenter(), isOwner);
recycler.setAdapter(adapter);
if (getArguments() != null && savedInstanceState == null) {
ArrayList<FilesListModel> filesListModel = getArguments().getParcelableArrayList(BundleConstant.ITEM);
isOwner = getArguments().getBoolean(BundleConstant.EXTRA_TYPE);
onInitFiles(filesListModel, isOwner);
// CLEAR
setArguments(null);
} else {
onInitFiles(getPresenter().getFiles(), isOwner);
}
fastScroller.attachRecyclerView(recycler);
}
use of com.fastaccess.data.dao.FilesListModel in project FastHub by k0shk0sh.
the class CreateGistActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getPresenter().setEnterprise(PrefGetter.isEnterprise());
setTaskName(getString(R.string.create_gist));
if (savedInstanceState == null) {
if (getIntent() != null && getIntent().getExtras() != null) {
Bundle bundle = getIntent().getExtras();
ArrayList<FilesListModel> models = bundle.getParcelableArrayList(BundleConstant.ITEM);
boolean isOwner = bundle.getBoolean(BundleConstant.EXTRA);
id = bundle.getString(BundleConstant.ID);
String descriptionText = bundle.getString(BundleConstant.EXTRA_TWO);
if (description.getEditText() != null)
description.getEditText().setText(descriptionText);
getFilesFragment().onInitFiles(models, isOwner);
} else {
getFilesFragment().onInitFiles(new ArrayList<>(), true);
}
}
buttonsHolder.setVisibility(!InputHelper.isEmpty(id) ? View.GONE : View.VISIBLE);
}
Aggregations