Skip to content
Snippets Groups Projects
Commit 1a7c86f4 authored by John Carlson's avatar John Carlson
Browse files

API models to Kotlin

parent e31b881c
No related branches found
No related tags found
No related merge requests found
Pipeline #
Loading
Loading
@@ -52,7 +52,7 @@ class ProjectViewHolder(view: View) : RecyclerView.ViewHolder(view) {
image.visibility = View.GONE
 
iconLetter.visibility = View.VISIBLE
iconLetter.letter = project.name.substring(0, 1)
iconLetter.letter = project.name!!.substring(0, 1)
iconLetter.letterColor = Color.WHITE
iconLetter.shapeColor = color
}
Loading
Loading
Loading
Loading
@@ -39,7 +39,7 @@ class TodoViewHolder(view: View) : RecyclerView.ViewHolder(view) {
}
 
fun bind(todo: Todo) {
textProject.text = todo.project.nameWithNamespace
textProject.text = todo.project!!.nameWithNamespace
if (todo.author != null) {
App.get().picasso
.load(ImageUtil.getAvatarUrl(todo.author, itemView.resources.getDimensionPixelSize(R.dimen.image_size)))
Loading
Loading
Loading
Loading
@@ -38,7 +38,7 @@ class AccountViewHolder(view: View) : TypedViewHolder<Account>(view) {
 
override fun bind(position: Int, item: Account) {
textServer.text = item.serverUrl.toString()
textUsername.text = item.user.username
textUsername.text = item.user!!.username
 
Picasso.with(context)
.load(ImageUtil.getAvatarUrl(item.user, itemView.resources.getDimensionPixelSize(R.dimen.user_list_image_size)))
Loading
Loading
Loading
Loading
@@ -15,7 +15,7 @@ import com.commit451.addendum.parceler.getParcelerParcelableExtra
import com.commit451.gitlab.R
import com.commit451.gitlab.activity.BaseActivity
import com.commit451.gitlab.data.Prefs
import com.commit451.gitlab.extension.getFeedUrl
import com.commit451.gitlab.extension.feedUrl
import com.commit451.gitlab.model.Account
import com.commit451.gitlab.model.api.Project
import timber.log.Timber
Loading
Loading
@@ -106,7 +106,7 @@ class ProjectFeedWidgetConfigureActivity : BaseActivity() {
 
fun saveWidgetConfig(account: Account, project: Project) {
ProjectFeedWidgetPrefs.setAccount(this, appWidgetId, account)
ProjectFeedWidgetPrefs.setFeedUrl(this, appWidgetId, project.getFeedUrl()!!.toString())
ProjectFeedWidgetPrefs.setFeedUrl(this, appWidgetId, project.feedUrl)
 
val resultValue = Intent()
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
Loading
Loading
Loading
Loading
@@ -24,6 +24,7 @@ import android.content.Intent
import android.net.Uri
import android.widget.RemoteViews
import com.commit451.gitlab.R
import com.commit451.gitlab.extension.feedUrl
import com.commit451.gitlab.navigation.DeepLinker
import timber.log.Timber
 
Loading
Loading
@@ -52,35 +53,35 @@ class UserFeedWidgetProvider : AppWidgetProvider() {
// Here we setup the intent which points to the StackViewService which will
// provide the views for this collection.
val account = UserFeedWidgetPrefs.getAccount(context, widgetId)
if (account == null || account.user.feedUrl == null) {
val feedUrl = account?.user?.feedUrl
if (account == null || feedUrl == null) {
//TODO alert the user to this misfortune?
Timber.e("Error getting account or feed url")
return
}
val feedUrl = account.user.feedUrl!!.toString()
Timber.d("Updating widget with url $feedUrl")
val intent = ProjectFeedWidgetService.newIntent(context, widgetId, account, feedUrl)
// When intents are compared, the extras are ignored, so we need to embed the extras
// into the data so that the extras will not be ignored.
intent.data = Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))
val rv = RemoteViews(context.packageName, R.layout.widget_layout_entry)
rv.setRemoteAdapter(R.id.list_view, intent)
} else {
Timber.d("Updating widget with url $feedUrl")
val intent = ProjectFeedWidgetService.newIntent(context, widgetId, account, feedUrl)
// When intents are compared, the extras are ignored, so we need to embed the extras
// into the data so that the extras will not be ignored.
intent.data = Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))
val rv = RemoteViews(context.packageName, R.layout.widget_layout_entry)
rv.setRemoteAdapter(R.id.list_view, intent)
 
rv.setEmptyView(R.id.list_view, R.id.empty_view)
rv.setEmptyView(R.id.list_view, R.id.empty_view)
 
// Here we setup the a pending intent template. Individuals items of a collection
// cannot setup their own pending intents, instead, the collection as a whole can
// setup a pending intent template, and the individual items can set a fillInIntent
// to create unique before on an item to item basis.
val actionIntent = Intent(context, UserFeedWidgetProvider::class.java)
actionIntent.action = UserFeedWidgetProvider.ACTION_FOLLOW_LINK
actionIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId)
intent.data = Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))
val actionPendingIntent = PendingIntent.getBroadcast(context, 0, actionIntent,
PendingIntent.FLAG_UPDATE_CURRENT)
rv.setPendingIntentTemplate(R.id.list_view, actionPendingIntent)
// Here we setup the a pending intent template. Individuals items of a collection
// cannot setup their own pending intents, instead, the collection as a whole can
// setup a pending intent template, and the individual items can set a fillInIntent
// to create unique before on an item to item basis.
val actionIntent = Intent(context, UserFeedWidgetProvider::class.java)
actionIntent.action = UserFeedWidgetProvider.ACTION_FOLLOW_LINK
actionIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId)
intent.data = Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))
val actionPendingIntent = PendingIntent.getBroadcast(context, 0, actionIntent,
PendingIntent.FLAG_UPDATE_CURRENT)
rv.setPendingIntentTemplate(R.id.list_view, actionPendingIntent)
 
appWidgetManager.updateAppWidget(widgetId, rv)
appWidgetManager.updateAppWidget(widgetId, rv)
}
}
super.onUpdate(context, appWidgetManager, appWidgetIds)
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment