Migrated to AndroidX
This commit is contained in:
+5
-4
@@ -20,9 +20,10 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "com.android.support:appcompat-v7:$supportLibVersion"
|
||||
compile "com.android.support:design:$supportLibVersion"
|
||||
compile "com.android.support:recyclerview-v7:$supportLibVersion"
|
||||
implementation deps.annotations
|
||||
implementation deps.androidxCompat
|
||||
implementation deps.designSupport
|
||||
implementation deps.recycler
|
||||
|
||||
compile project(':library')
|
||||
implementation project(':library')
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package com.yarolegovich.slidingrootnav.sample;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.ColorRes;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yarolegovich.slidingrootnav.SlidingRootNav;
|
||||
import com.yarolegovich.slidingrootnav.SlidingRootNavBuilder;
|
||||
@@ -87,11 +88,12 @@ public class SampleActivity extends AppCompatActivity implements DrawerAdapter.O
|
||||
}
|
||||
|
||||
private void showFragment(Fragment fragment) {
|
||||
getFragmentManager().beginTransaction()
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.container, fragment)
|
||||
.commit();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private DrawerItem createItemFor(int position) {
|
||||
return new SimpleItem(screenIcons[position], screenTitles[position])
|
||||
.withIconTint(color(R.color.textColorSecondary))
|
||||
|
||||
+5
-3
@@ -1,14 +1,15 @@
|
||||
package com.yarolegovich.slidingrootnav.sample.fragment;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.yarolegovich.slidingrootnav.sample.R;
|
||||
|
||||
|
||||
@@ -36,7 +37,8 @@ public class CenteredTextFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
final String text = getArguments().getString(EXTRA_TEXT);
|
||||
Bundle args = getArguments();
|
||||
final String text = args != null ? args.getString(EXTRA_TEXT) : "";
|
||||
TextView textView = view.findViewById(R.id.text);
|
||||
textView.setText(text);
|
||||
textView.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.yarolegovich.slidingrootnav.sample.menu;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -13,6 +15,7 @@ import java.util.Map;
|
||||
* Created by yarolegovich on 25.03.2017.
|
||||
*/
|
||||
|
||||
@SuppressWarnings({"rawtypes", "ConstantConditions"})
|
||||
public class DrawerAdapter extends RecyclerView.Adapter<DrawerAdapter.ViewHolder> {
|
||||
|
||||
private List<DrawerItem> items;
|
||||
@@ -29,8 +32,9 @@ public class DrawerAdapter extends RecyclerView.Adapter<DrawerAdapter.ViewHolder
|
||||
processViewTypes();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
ViewHolder holder = holderFactories.get(viewType).createViewHolder(parent);
|
||||
holder.adapter = this;
|
||||
return holder;
|
||||
@@ -38,7 +42,7 @@ public class DrawerAdapter extends RecyclerView.Adapter<DrawerAdapter.ViewHolder
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
items.get(position).bindViewHolder(holder);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ public abstract class DrawerItem<T extends DrawerAdapter.ViewHolder> {
|
||||
|
||||
public abstract void bindViewHolder(T holder);
|
||||
|
||||
public DrawerItem setChecked(boolean isChecked) {
|
||||
public DrawerItem<T> setChecked(boolean isChecked) {
|
||||
this.isChecked = isChecked;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
android:background="@android:color/white"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/colorPrimary" />
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/container"
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
android:layout_gravity="center"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="36sp" />
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:paddingLeft="24dp"
|
||||
@@ -10,7 +11,8 @@
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<Space
|
||||
android:layout_width="12dp"
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="56dp" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="240dp"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
Reference in New Issue
Block a user