migrating to kotlin

This commit is contained in:
Mariotaku Lee 2016-07-02 12:11:07 +08:00
parent 5ff715e77b
commit c6bc1041e2
12 changed files with 165 additions and 200 deletions

View File

@ -129,7 +129,7 @@ public class StaggeredGridParcelableStatusesAdapter extends ParcelableStatusesAd
public void onClick(View v) {
if (listener == null) return;
switch (v.getId()) {
case R.id.item_content: {
case R.id.itemContent: {
listener.onStatusClick(this, getLayoutPosition());
break;
}
@ -147,7 +147,7 @@ public class StaggeredGridParcelableStatusesAdapter extends ParcelableStatusesAd
@Override
public void setStatusClickListener(StatusClickListener listener) {
this.listener = listener;
itemView.findViewById(R.id.item_content).setOnClickListener(this);
itemView.findViewById(R.id.itemContent).setOnClickListener(this);
}
@Override

View File

@ -104,7 +104,7 @@ public class RetweetQuoteDialogFragment extends BaseDialogFragment {
final AlertDialog dialog = (AlertDialog) dialogInterface;
final View itemContent = dialog.findViewById(R.id.item_content);
final View itemContent = dialog.findViewById(R.id.itemContent);
final StatusTextCountView textCountView = (StatusTextCountView) dialog.findViewById(R.id.comment_text_count);
final View itemMenu = dialog.findViewById(R.id.itemMenu);
final View actionButtons = dialog.findViewById(R.id.actionButtons);

View File

@ -399,7 +399,7 @@ class UserListFragment : AbsToolbarTabPagesFragment(), OnClickListener, LoaderCa
private val extras: Bundle?,
private val accountKey: UserKey,
private val listId: String?,
private val listName: String,
private val listName: String?,
private val userKey: UserKey?,
private val screenName: String?
) : AsyncTaskLoader<SingleResponse<ParcelableUserList>>(context) {
@ -413,14 +413,20 @@ class UserListFragment : AbsToolbarTabPagesFragment(), OnClickListener, LoaderCa
true) ?: return SingleResponse.getInstance<ParcelableUserList>()
try {
val list: UserList
if (listId != null) {
list = twitter.showUserList(listId)
} else if (userKey != null) {
list = twitter.showUserList(listName, userKey.id)
} else if (screenName != null) {
list = twitter.showUserListByScrenName(listName, screenName)
} else
return SingleResponse.getInstance<ParcelableUserList>()
when {
listId != null -> {
list = twitter.showUserList(listId)
}
listName != null && userKey != null -> {
list = twitter.showUserList(listName, userKey.id)
}
listName != null && screenName != null -> {
list = twitter.showUserListByScrenName(listName, screenName)
}
else -> {
return SingleResponse.getInstance<ParcelableUserList>()
}
}
return SingleResponse.getInstance(ParcelableUserListUtils.from(list, accountKey))
} catch (e: MicroBlogException) {
return SingleResponse.getInstance<ParcelableUserList>(e)

View File

@ -57,7 +57,7 @@ class ActivityTitleSummaryViewHolder(private val adapter: ParcelableActivitiesAd
init {
itemContent = itemView.findViewById(R.id.item_content) as IColorLabelView
itemContent = itemView.findViewById(R.id.itemContent) as IColorLabelView
activityTypeView = itemView.findViewById(R.id.activity_type) as IconActionView
titleView = itemView.findViewById(R.id.title) as TextView
summaryView = itemView.findViewById(R.id.summary) as TextView
@ -168,7 +168,7 @@ class ActivityTitleSummaryViewHolder(private val adapter: ParcelableActivitiesAd
if (mActivityEventListener == null) return
val position = layoutPosition
when (v.id) {
R.id.item_content -> {
R.id.itemContent -> {
mActivityEventListener!!.onActivityClick(this, position)
}
}

View File

@ -57,7 +57,7 @@ public class GroupViewHolder extends ViewHolder implements View.OnClickListener,
public GroupViewHolder(IGroupsAdapter<?> adapter, View itemView) {
super(itemView);
itemContent = (IColorLabelView) itemView.findViewById(R.id.item_content);
itemContent = (IColorLabelView) itemView.findViewById(R.id.itemContent);
this.adapter = adapter;
profileImageView = (ImageView) itemView.findViewById(R.id.profileImage);
nameView = (NameView) itemView.findViewById(R.id.name);
@ -105,7 +105,7 @@ public class GroupViewHolder extends ViewHolder implements View.OnClickListener,
public void onClick(View v) {
if (groupClickListener == null) return;
switch (v.getId()) {
case R.id.item_content: {
case R.id.itemContent: {
groupClickListener.onGroupClick(this, getLayoutPosition());
break;
}
@ -116,7 +116,7 @@ public class GroupViewHolder extends ViewHolder implements View.OnClickListener,
public boolean onLongClick(View v) {
if (groupClickListener == null) return false;
switch (v.getId()) {
case R.id.item_content: {
case R.id.itemContent: {
return groupClickListener.onGroupLongClick(this, getLayoutPosition());
}
}

View File

@ -568,7 +568,7 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
val listener = holder.statusClickListener ?: return false
val position = holder.layoutPosition
when (v.id) {
R.id.item_content -> {
R.id.itemContent -> {
if (!holder.isCardActionsShown) {
holder.showCardActions()
return true

View File

@ -71,7 +71,7 @@ public class UserViewHolder extends ViewHolder implements OnClickListener, OnLon
public UserViewHolder(final IUsersAdapter<?> adapter, final View itemView) {
super(itemView);
this.adapter = adapter;
itemContent = (IColorLabelView) itemView.findViewById(R.id.item_content);
itemContent = (IColorLabelView) itemView.findViewById(R.id.itemContent);
profileImageView = (ImageView) itemView.findViewById(R.id.profileImage);
profileTypeView = (ImageView) itemView.findViewById(R.id.profileType);
nameView = (NameView) itemView.findViewById(R.id.name);
@ -173,7 +173,7 @@ public class UserViewHolder extends ViewHolder implements OnClickListener, OnLon
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.item_content: {
case R.id.itemContent: {
if (userClickListener == null) return;
userClickListener.onUserClick(this, getLayoutPosition());
break;
@ -200,7 +200,7 @@ public class UserViewHolder extends ViewHolder implements OnClickListener, OnLon
public boolean onLongClick(View v) {
if (userClickListener == null) return false;
switch (v.getId()) {
case R.id.item_content: {
case R.id.itemContent: {
return userClickListener.onUserLongClick(this, getLayoutPosition());
}
}

View File

@ -18,7 +18,7 @@
-->
<android.support.v7.widget.CardView
android:id="@+id/item_content"
android:id="@+id/itemContent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<org.mariotaku.twidere.view.ColorLabelFrameLayout
android:id="@+id/item_content"
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="?selectableItemBackground"
android:focusable="true"
android:focusableInTouchMode="false"
android:paddingLeft="@dimen/element_spacing_normal"
android:paddingRight="@dimen/element_spacing_normal"
app:ignorePadding="true">
<include layout="@layout/card_item_activity_summary_common"/>
</org.mariotaku.twidere.view.ColorLabelFrameLayout>

View File

@ -1,157 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/element_spacing_normal">
<org.mariotaku.twidere.view.IconActionView
android:id="@+id/activity_type"
android:layout_width="@dimen/element_size_small"
android:layout_height="@dimen/element_size_small"
android:layout_alignEnd="@+id/profile_image_space"
android:layout_alignRight="@+id/profile_image_space"
android:layout_alignTop="@+id/profile_images_container"
android:padding="@dimen/element_spacing_small"
android:scaleType="centerInside"
tools:src="@drawable/ic_indicator_retweet"
tools:tint="@color/highlight_retweet"/>
<Space
android:id="@+id/profile_image_space"
android:layout_width="@dimen/icon_size_status_profile_image"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/activity_type"
android:layout_alignTop="@+id/activity_type"
android:layout_below="@+id/profile_images_container"
tools:visibility="visible"/>
<LinearLayout
android:id="@+id/profile_images_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/title"
android:layout_alignStart="@+id/title"
android:layout_toEndOf="@+id/profile_image_space"
android:layout_toRightOf="@+id/profile_image_space"
android:gravity="center_vertical"
android:orientation="horizontal"
android:visibility="visible">
<org.mariotaku.twidere.view.ProfileImageView
android:id="@+id/activity_profile_image_0"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"
android:layout_height="@dimen/profile_image_size_activity_small"
android:layout_margin="2dp"
android:contentDescription="@string/profile_image"
tools:src="@mipmap/ic_launcher"/>
<org.mariotaku.twidere.view.ProfileImageView
android:id="@+id/activity_profile_image_1"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"
android:layout_height="@dimen/profile_image_size_activity_small"
android:layout_margin="2dp"
android:contentDescription="@string/profile_image"
tools:src="@mipmap/ic_launcher_hondajojo"/>
<org.mariotaku.twidere.view.ProfileImageView
android:id="@+id/activity_profile_image_2"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"
android:layout_height="@dimen/profile_image_size_activity_small"
android:layout_margin="2dp"
android:contentDescription="@string/profile_image"
tools:src="@mipmap/ic_launcher"/>
<org.mariotaku.twidere.view.ProfileImageView
android:id="@+id/activity_profile_image_3"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"
android:layout_height="@dimen/profile_image_size_activity_small"
android:layout_margin="2dp"
android:contentDescription="@string/profile_image"
tools:src="@mipmap/ic_launcher_hondajojo"/>
<org.mariotaku.twidere.view.ProfileImageView
android:id="@+id/activity_profile_image_4"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"
android:layout_height="@dimen/profile_image_size_activity_small"
android:layout_margin="2dp"
android:contentDescription="@string/profile_image"
tools:src="@mipmap/ic_launcher"/>
<org.mariotaku.twidere.view.BadgeView
android:id="@+id/activity_profile_image_more_number"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"
android:layout_height="@dimen/profile_image_size_activity_small"
android:layout_margin="2dp"
android:gravity="center"
android:textColor="?android:attr/textColorPrimary"
tools:src="@mipmap/ic_launcher_hondajojo"
tools:text="11"/>
</LinearLayout>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/profile_images_container"
android:layout_marginLeft="@dimen/element_spacing_normal"
android:layout_marginStart="@dimen/element_spacing_normal"
android:layout_toEndOf="@+id/activity_type"
android:layout_toLeftOf="@+id/time"
android:layout_toRightOf="@+id/activity_type"
android:layout_toStartOf="@+id/time"
android:gravity="center_vertical"
android:minHeight="@dimen/element_size_small"
android:singleLine="false"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="?android:textColorPrimary"
tools:text="User and 15 others favorited your tweet."/>
<org.mariotaku.twidere.view.ShortTimeView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/title"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
<TextView
android:id="@+id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/title"
android:layout_alignStart="@+id/title"
android:layout_below="@+id/title"
android:singleLine="false"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="?android:textColorSecondary"
tools:text="@string/sample_status_text"
tools:textSize="@dimen/text_size_extra_small"/>
</RelativeLayout>

View File

@ -1,14 +1,146 @@
<?xml version="1.0" encoding="utf-8"?>
<org.mariotaku.twidere.view.ColorLabelFrameLayout
android:id="@+id/item_content"
<org.mariotaku.twidere.view.ColorLabelRelativeLayout
android:id="@+id/itemContent"
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:background="?selectableItemBackground"
android:focusable="true"
android:focusableInTouchMode="false"
android:padding="@dimen/element_spacing_normal"
app:ignorePadding="true">
<include layout="@layout/card_item_activity_summary_common"/>
</org.mariotaku.twidere.view.ColorLabelFrameLayout>
<org.mariotaku.twidere.view.IconActionView
android:id="@+id/activity_type"
android:layout_width="@dimen/element_size_small"
android:layout_height="@dimen/element_size_small"
android:layout_alignEnd="@+id/profile_image_space"
android:layout_alignRight="@+id/profile_image_space"
android:layout_alignTop="@+id/profile_images_container"
android:padding="@dimen/element_spacing_small"
android:scaleType="centerInside"
tools:src="@drawable/ic_indicator_retweet"
tools:tint="@color/highlight_retweet"/>
<Space
android:id="@+id/profile_image_space"
android:layout_width="@dimen/icon_size_status_profile_image"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/activity_type"
android:layout_alignTop="@+id/activity_type"
android:layout_below="@+id/profile_images_container"
tools:visibility="visible"/>
<LinearLayout
android:id="@+id/profile_images_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/title"
android:layout_alignStart="@+id/title"
android:layout_toEndOf="@+id/profile_image_space"
android:layout_toRightOf="@+id/profile_image_space"
android:gravity="center_vertical"
android:orientation="horizontal"
android:visibility="visible">
<org.mariotaku.twidere.view.ProfileImageView
android:id="@+id/activity_profile_image_0"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"
android:layout_height="@dimen/profile_image_size_activity_small"
android:layout_margin="2dp"
android:contentDescription="@string/profile_image"
tools:src="@mipmap/ic_launcher"/>
<org.mariotaku.twidere.view.ProfileImageView
android:id="@+id/activity_profile_image_1"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"
android:layout_height="@dimen/profile_image_size_activity_small"
android:layout_margin="2dp"
android:contentDescription="@string/profile_image"
tools:src="@mipmap/ic_launcher_hondajojo"/>
<org.mariotaku.twidere.view.ProfileImageView
android:id="@+id/activity_profile_image_2"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"
android:layout_height="@dimen/profile_image_size_activity_small"
android:layout_margin="2dp"
android:contentDescription="@string/profile_image"
tools:src="@mipmap/ic_launcher"/>
<org.mariotaku.twidere.view.ProfileImageView
android:id="@+id/activity_profile_image_3"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"
android:layout_height="@dimen/profile_image_size_activity_small"
android:layout_margin="2dp"
android:contentDescription="@string/profile_image"
tools:src="@mipmap/ic_launcher_hondajojo"/>
<org.mariotaku.twidere.view.ProfileImageView
android:id="@+id/activity_profile_image_4"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"
android:layout_height="@dimen/profile_image_size_activity_small"
android:layout_margin="2dp"
android:contentDescription="@string/profile_image"
tools:src="@mipmap/ic_launcher"/>
<org.mariotaku.twidere.view.BadgeView
android:id="@+id/activity_profile_image_more_number"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"
android:layout_height="@dimen/profile_image_size_activity_small"
android:layout_margin="2dp"
android:gravity="center"
android:textColor="?android:attr/textColorPrimary"
tools:src="@mipmap/ic_launcher_hondajojo"
tools:text="11"/>
</LinearLayout>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/profile_images_container"
android:layout_marginLeft="@dimen/element_spacing_normal"
android:layout_marginStart="@dimen/element_spacing_normal"
android:layout_toEndOf="@+id/activity_type"
android:layout_toLeftOf="@+id/time"
android:layout_toRightOf="@+id/activity_type"
android:layout_toStartOf="@+id/time"
android:gravity="center_vertical"
android:minHeight="@dimen/element_size_small"
android:singleLine="false"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="?android:textColorPrimary"
tools:text="User and 15 others favorited your tweet."/>
<org.mariotaku.twidere.view.ShortTimeView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/title"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
<TextView
android:id="@+id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/title"
android:layout_alignStart="@+id/title"
android:layout_below="@+id/title"
android:singleLine="false"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="?android:textColorSecondary"
tools:text="@string/sample_status_text"
tools:textSize="@dimen/text_size_extra_small"/>
</org.mariotaku.twidere.view.ColorLabelRelativeLayout>

View File

@ -18,7 +18,7 @@
-->
<org.mariotaku.twidere.view.ColorLabelRelativeLayout
android:id="@+id/item_content"
android:id="@+id/itemContent"
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"