Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Commit

Permalink
protect against no changes
Browse files Browse the repository at this point in the history
  • Loading branch information
k0shk0sh committed Mar 30, 2018
1 parent 744d2f3 commit 5ddff92
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ class EditRepoFileActivity : BaseActivity<EditRepoFileMvp.View, EditRepoFilePres
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.submit) {
val text = editText.text
if (text.isNotEmpty()) {
presenter.onSubmit(editText.text?.toString(), fileName.editText?.text?.toString(), description.editText?.text?.toString())
} else {
if (presenter.fileContent == text.toString() && presenter.model?.fileName == fileName.editText?.text.toString()) {
showErrorMessage(getString(R.string.commit_file_required))
return true
}
presenter.onSubmit(editText.text?.toString(), fileName.editText?.text?.toString(), description.editText?.text?.toString())
return true
}
return super.onOptionsItemSelected(item)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.util.Base64
import com.fastaccess.data.dao.CommitRequestModel
import com.fastaccess.data.dao.EditRepoFileModel
import com.fastaccess.helper.BundleConstant
import com.fastaccess.helper.Logger
import com.fastaccess.provider.rest.RestProvider
import com.fastaccess.ui.base.mvp.presenter.BasePresenter

Expand All @@ -15,6 +14,7 @@ import com.fastaccess.ui.base.mvp.presenter.BasePresenter
class EditRepoFilePresenter : BasePresenter<EditRepoFileMvp.View>(), EditRepoFileMvp.Presenter {

@com.evernote.android.state.State var model: EditRepoFileModel? = null
var fileContent: String? = null

var downloadedContent: String? = null

Expand All @@ -23,7 +23,6 @@ class EditRepoFilePresenter : BasePresenter<EditRepoFileMvp.View>(), EditRepoFil
intent?.let {
it.extras?.let {
model = it.getParcelable(BundleConstant.ITEM)
Logger.e(model)
loadContent()
}
}
Expand Down Expand Up @@ -61,7 +60,10 @@ class EditRepoFilePresenter : BasePresenter<EditRepoFileMvp.View>(), EditRepoFil
private fun loadContent() {
model?.contentUrl?.let {
makeRestCall(RestProvider.getRepoService(isEnterprise)
.getFileAsStream(it), { sendToView({ v -> v.onSetText(it) }) })
.getFileAsStream(it), {
fileContent = it
sendToView({ v -> v.onSetText(it) })
})
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -601,5 +601,5 @@
<string name="clear_image_cache">Clear Images Cache</string>
<string name="restart_app_message">Please restart the app</string>
<string name="menu_label">Menu</string>
<string name="commit_file_required">Please type something in your file</string>
<string name="commit_file_required">No file changes</string>
</resources>

0 comments on commit 5ddff92

Please sign in to comment.