fix some lint warnings, use kotlin view imports in ModalTimeLineActivity

This commit is contained in:
Conny Duck 2018-07-23 15:18:33 +02:00
parent 7c9114c440
commit 67f4479e86
7 changed files with 10 additions and 28 deletions

View File

@ -5,21 +5,17 @@ import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.support.design.widget.FloatingActionButton import android.support.design.widget.FloatingActionButton
import android.support.v4.app.Fragment import android.support.v4.app.Fragment
import android.support.v7.widget.Toolbar
import android.view.MenuItem import android.view.MenuItem
import android.widget.FrameLayout
import com.keylesspalace.tusky.fragment.TimelineFragment import com.keylesspalace.tusky.fragment.TimelineFragment
import com.keylesspalace.tusky.interfaces.ActionButtonActivity import com.keylesspalace.tusky.interfaces.ActionButtonActivity
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.DispatchingAndroidInjector import dagger.android.DispatchingAndroidInjector
import dagger.android.support.HasSupportFragmentInjector import dagger.android.support.HasSupportFragmentInjector
import kotlinx.android.synthetic.main.toolbar_basic.*
import javax.inject.Inject import javax.inject.Inject
class ModalTimelineActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportFragmentInjector { class ModalTimelineActivity : BottomSheetActivity(), ActionButtonActivity, HasSupportFragmentInjector {
@Inject
lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Fragment>
companion object { companion object {
private const val ARG_KIND = "kind" private const val ARG_KIND = "kind"
private const val ARG_ARG = "arg" private const val ARG_ARG = "arg"
@ -34,15 +30,13 @@ class ModalTimelineActivity : BottomSheetActivity(), ActionButtonActivity, HasSu
} }
} }
@Inject
lateinit var contentFrame: FrameLayout lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Fragment>
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_modal_timeline) setContentView(R.layout.activity_modal_timeline)
contentFrame = findViewById(R.id.content_frame)
val toolbar = findViewById<Toolbar>(R.id.toolbar)
setSupportActionBar(toolbar) setSupportActionBar(toolbar)
val bar = supportActionBar val bar = supportActionBar
if (bar != null) { if (bar != null) {
@ -51,19 +45,18 @@ class ModalTimelineActivity : BottomSheetActivity(), ActionButtonActivity, HasSu
bar.setDisplayShowHomeEnabled(true) bar.setDisplayShowHomeEnabled(true)
} }
if (supportFragmentManager.findFragmentById(R.id.content_frame) == null) { if (supportFragmentManager.findFragmentById(R.id.contentFrame) == null) {
val kind = intent?.getSerializableExtra(ARG_KIND) as? TimelineFragment.Kind val kind = intent?.getSerializableExtra(ARG_KIND) as? TimelineFragment.Kind
?: TimelineFragment.Kind.HOME ?: TimelineFragment.Kind.HOME
val argument = intent?.getStringExtra(ARG_ARG) val argument = intent?.getStringExtra(ARG_ARG)
supportFragmentManager.beginTransaction() supportFragmentManager.beginTransaction()
.replace(R.id.content_frame, TimelineFragment.newInstance(kind, argument)) .replace(R.id.contentFrame, TimelineFragment.newInstance(kind, argument))
.commit() .commit()
} }
} }
override fun getActionButton(): FloatingActionButton? = null override fun getActionButton(): FloatingActionButton? = null
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == android.R.id.home) { if (item.itemId == android.R.id.home) {
onBackPressed() onBackPressed()

View File

@ -23,7 +23,6 @@ import android.os.Bundle;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference; import android.preference.EditTextPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.support.annotation.XmlRes; import android.support.annotation.XmlRes;
import android.text.Editable; import android.text.Editable;

View File

@ -27,19 +27,9 @@ public class ListUtils {
return list == null || list.isEmpty(); return list == null || list.isEmpty();
} }
/** @return 0 if list is null, or else return list.size() */
public static int getSize(@Nullable List list) {
if (list == null) {
return 0;
} else {
return list.size();
}
}
/** @return a new ArrayList containing the elements without duplicates in the same order */ /** @return a new ArrayList containing the elements without duplicates in the same order */
public static <T> ArrayList<T> removeDuplicates(List<T> list) { public static <T> ArrayList<T> removeDuplicates(List<T> list) {
LinkedHashSet<T> set = new LinkedHashSet<>(); LinkedHashSet<T> set = new LinkedHashSet<>(list);
set.addAll(list);
return new ArrayList<>(set); return new ArrayList<>(set);
} }
} }

View File

@ -10,7 +10,7 @@
<include layout="@layout/toolbar_basic" /> <include layout="@layout/toolbar_basic" />
<FrameLayout <FrameLayout
android:id="@+id/content_frame" android:id="@+id/contentFrame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> app:layout_behavior="@string/appbar_scrolling_view_behavior" />

View File

@ -5,7 +5,7 @@
android:id="@+id/action_download" android:id="@+id/action_download"
android:icon="@drawable/ic_file_download_black_24dp" android:icon="@drawable/ic_file_download_black_24dp"
android:title="@string/dialog_download_image" android:title="@string/dialog_download_image"
app:showAsAction="always" /> app:showAsAction="ifRoom" />
<item <item
android:id="@+id/action_open_status" android:id="@+id/action_open_status"
android:title="@string/action_open_toot" android:title="@string/action_open_toot"

View File

@ -301,7 +301,7 @@
<string name="unreblog_private">nicht mehr teilen</string> <string name="unreblog_private">nicht mehr teilen</string>
<string name="license_description">Tusky enthält Code und Inhalte von den folgenden Open-Source-Projekten:</string> <string name="license_description">Tusky enthält Code und Inhalte von den folgenden Open-Source-Projekten:</string>
<string name="license_apache_2">Lizensiert unter der Apache-Lizenz (s. u.)</string> <string name="license_apache_2">Lizenziert unter der Apache-Lizenz (s. u.)</string>
<string name="license_cc_by_4">CC-BY 4.0</string> <string name="license_cc_by_4">CC-BY 4.0</string>
<string name="action_open_toot">Beitrag öffnen</string> <string name="action_open_toot">Beitrag öffnen</string>
<string name="action_hide_reblogs">Geteilte Beiträge verbergen</string> <string name="action_hide_reblogs">Geteilte Beiträge verbergen</string>

View File

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.2.50' ext.kotlin_version = '1.2.51'
repositories { repositories {
jcenter() jcenter()
google() google()