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

View file

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

View file

@ -27,19 +27,9 @@ public class ListUtils {
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 */
public static <T> ArrayList<T> removeDuplicates(List<T> list) {
LinkedHashSet<T> set = new LinkedHashSet<>();
set.addAll(list);
LinkedHashSet<T> set = new LinkedHashSet<>(list);
return new ArrayList<>(set);
}
}

View file

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

View file

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

View file

@ -301,7 +301,7 @@
<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_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="action_open_toot">Beitrag öffnen</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.
buildscript {
ext.kotlin_version = '1.2.50'
ext.kotlin_version = '1.2.51'
repositories {
jcenter()
google()