improved list item style
This commit is contained in:
parent
bddf6c8dd0
commit
343e8ab757
|
@ -30,10 +30,6 @@ class SimpleParcelableUserListsAdapter(
|
|||
context: Context
|
||||
) : BaseArrayAdapter<ParcelableUserList>(context, R.layout.list_item_two_line) {
|
||||
|
||||
fun appendData(data: List<ParcelableUserList>) {
|
||||
setData(data, false)
|
||||
}
|
||||
|
||||
override fun getItemId(position: Int): Long {
|
||||
return (if (getItem(position) != null) getItem(position).hashCode() else -1).toLong()
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.mariotaku.twidere.extension.model
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.model.FiltersSubscription
|
||||
import org.mariotaku.twidere.util.JsonSerializer
|
||||
import org.mariotaku.twidere.util.filter.FiltersSubscriptionProvider
|
||||
|
@ -20,6 +22,19 @@ fun FiltersSubscription.instantiateComponent(context: Context): FiltersSubscript
|
|||
return null
|
||||
}
|
||||
|
||||
fun FiltersSubscription.getComponentLabel(context: Context): CharSequence {
|
||||
val component = this.component ?: return context.getString(R.string.title_filters_subscription_invalid)
|
||||
if (component.startsWith(":")) {
|
||||
when (component.substringAfter(":")) {
|
||||
"url" -> return context.getString(R.string.title_filters_subscription_url)
|
||||
}
|
||||
return context.getString(R.string.title_filters_subscription_invalid)
|
||||
}
|
||||
val cn = ComponentName.unflattenFromString(component) ?:
|
||||
return context.getString(R.string.title_filters_subscription_invalid)
|
||||
val pm = context.packageManager
|
||||
return pm.getServiceInfo(cn, 0).loadLabel(pm)
|
||||
}
|
||||
|
||||
fun FiltersSubscription.setupUrl(url: String) {
|
||||
this.component = ":url"
|
||||
|
|
|
@ -136,7 +136,7 @@ class FilteredUsersFragment : BaseFiltersFragment() {
|
|||
|
||||
class FilterUsersListAdapter(
|
||||
context: Context
|
||||
) : SimpleCursorAdapter(context, R.layout.simple_list_item_activated_2, null,
|
||||
) : SimpleCursorAdapter(context, R.layout.list_item_two_line, null,
|
||||
emptyArray(), IntArray(0), 0) {
|
||||
|
||||
@Inject
|
||||
|
@ -156,8 +156,12 @@ class FilteredUsersFragment : BaseFiltersFragment() {
|
|||
override fun bindView(view: View, context: Context?, cursor: Cursor) {
|
||||
super.bindView(view, context, cursor)
|
||||
val indices = this.indices!!
|
||||
val icon = view.findViewById(android.R.id.icon)
|
||||
val text1 = view.findViewById(android.R.id.text1) as TextView
|
||||
val text2 = view.findViewById(android.R.id.text2) as TextView
|
||||
|
||||
icon.visibility = View.GONE
|
||||
|
||||
val userId = UserKey.valueOf(cursor.getString(indices.userKey))
|
||||
val name = cursor.getString(indices.name)
|
||||
val screenName = cursor.getString(indices.screenName)
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.support.v4.content.Loader
|
|||
import android.support.v4.widget.SimpleCursorAdapter
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.*
|
||||
import android.widget.TextView
|
||||
import com.rengwuxian.materialedittext.MaterialEditText
|
||||
import kotlinx.android.synthetic.main.layout_list_with_empty_view.*
|
||||
import okhttp3.HttpUrl
|
||||
|
@ -18,11 +19,13 @@ import org.mariotaku.abstask.library.TaskStarter
|
|||
import org.mariotaku.ktextension.empty
|
||||
import org.mariotaku.ktextension.isEmpty
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.extension.model.getComponentLabel
|
||||
import org.mariotaku.twidere.extension.model.setupUrl
|
||||
import org.mariotaku.twidere.fragment.BaseDialogFragment
|
||||
import org.mariotaku.twidere.fragment.BaseFragment
|
||||
import org.mariotaku.twidere.fragment.ProgressDialogFragment
|
||||
import org.mariotaku.twidere.model.FiltersSubscription
|
||||
import org.mariotaku.twidere.model.FiltersSubscriptionCursorIndices
|
||||
import org.mariotaku.twidere.model.FiltersSubscriptionValuesCreator
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Filters
|
||||
import org.mariotaku.twidere.task.filter.RefreshFiltersSubscriptionsTask
|
||||
|
@ -103,12 +106,26 @@ class FiltersSubscriptionsFragment : BaseFragment(), LoaderManager.LoaderCallbac
|
|||
}
|
||||
|
||||
class FilterSubscriptionsAdapter(context: Context) : SimpleCursorAdapter(context,
|
||||
R.layout.list_item_two_line_small, null, arrayOf(Filters.Subscriptions.NAME),
|
||||
R.layout.list_item_two_line, null, arrayOf(Filters.Subscriptions.NAME),
|
||||
intArrayOf(android.R.id.text1), 0) {
|
||||
private var indices: FiltersSubscriptionCursorIndices? = null
|
||||
private var tempObject: FiltersSubscription = FiltersSubscription()
|
||||
|
||||
override fun swapCursor(c: Cursor?): Cursor? {
|
||||
indices = if (c != null) FiltersSubscriptionCursorIndices(c) else null
|
||||
return super.swapCursor(c)
|
||||
}
|
||||
|
||||
override fun bindView(view: View, context: Context, cursor: Cursor) {
|
||||
super.bindView(view, context, cursor)
|
||||
val indices = this.indices!!
|
||||
val iconView = view.findViewById(android.R.id.icon)
|
||||
val summaryView = view.findViewById(android.R.id.text2) as TextView
|
||||
|
||||
indices.parseFields(tempObject, cursor)
|
||||
|
||||
iconView.visibility = View.GONE
|
||||
summaryView.text = tempObject.getComponentLabel(context)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,3 +170,4 @@ class FiltersSubscriptionsFragment : BaseFragment(), LoaderManager.LoaderCallbac
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,15 +19,18 @@
|
|||
|
||||
<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:layout_gravity="center_vertical"
|
||||
android:background="?android:activatedBackgroundIndicator"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:orientation="horizontal"
|
||||
android:padding="@dimen/element_spacing_normal"
|
||||
app:backgroundTint="?colorControlActivated"
|
||||
tools:layout_gravity="center">
|
||||
|
||||
<ImageView
|
||||
|
@ -55,9 +58,9 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textAppearance="?textAppearanceListItem"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textStyle="bold"
|
||||
android:textStyle="normal"
|
||||
tools:text="Title"/>
|
||||
|
||||
<TextView
|
||||
|
@ -67,6 +70,7 @@
|
|||
android:maxLines="1"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textStyle="normal"
|
||||
tools:text="summary"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -24,9 +24,8 @@
|
|||
android:gravity="center_vertical"
|
||||
android:minHeight="?android:listPreferredItemHeightSmall"
|
||||
android:paddingEnd="?android:listPreferredItemPaddingEnd"
|
||||
android:paddingLeft="?android:listPreferredItemPaddingLeft"
|
||||
android:paddingRight="?android:listPreferredItemPaddingRight"
|
||||
android:paddingLeft="?listPreferredItemPaddingLeft"
|
||||
android:paddingRight="?listPreferredItemPaddingRight"
|
||||
android:paddingStart="?android:listPreferredItemPaddingStart"
|
||||
android:tag="tint_background|accent_color"
|
||||
android:textAppearance="?android:textAppearanceListItemSmall"
|
||||
android:textAppearance="?textAppearanceListItemSmall"
|
||||
app:backgroundTint="?colorControlActivated"/>
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2010 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<TwoLineListItem
|
||||
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="?android:activatedBackgroundIndicator"
|
||||
android:minHeight="?android:listPreferredItemHeight"
|
||||
android:mode="twoLine"
|
||||
android:paddingBottom="2dip"
|
||||
android:paddingTop="2dip"
|
||||
android:tag="tint_background|accent_color"
|
||||
app:backgroundTint="?colorControlActivated">
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="?android:listPreferredItemPaddingLeft"
|
||||
android:layout_marginStart="?android:listPreferredItemPaddingStart"
|
||||
android:layout_marginTop="6dip"
|
||||
android:textAppearance="?android:textAppearanceListItem"/>
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/text2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@android:id/text1"
|
||||
android:layout_alignStart="@android:id/text1"
|
||||
android:layout_below="@android:id/text1"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:textColor="?android:textColorSecondary"/>
|
||||
|
||||
</TwoLineListItem>
|
|
@ -900,4 +900,6 @@
|
|||
<string name="hint_empty_filters_subscriptions">No subscriptions</string>
|
||||
<string name="title_subscription_name">Name</string>
|
||||
<string name="title_subscription_url">URL</string>
|
||||
<string name="title_filters_subscription_invalid">Invalid subscription</string>
|
||||
<string name="title_filters_subscription_url">URL</string>
|
||||
</resources>
|
Loading…
Reference in New Issue