Migration to AndroidX and transfer of communication with the database from a low-level implementation to Room.

This commit is contained in:
ChronosX88 2019-02-27 18:02:42 +04:00
parent 7ed5e7dd9a
commit d20de8da99
No known key found for this signature in database
GPG Key ID: 8F92E090A87804AA
35 changed files with 353 additions and 226 deletions

Binary file not shown.

View File

@ -2,6 +2,5 @@
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" /> <mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component> </component>
</project> </project>

View File

@ -1,14 +1,18 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
compileSdkVersion 27 compileSdkVersion 28
defaultConfig { defaultConfig {
applicationId "ru.volgorobot.vrcatalog" applicationId "ru.volgorobot.vrcatalog"
minSdkVersion 19 minSdkVersion 19
targetSdkVersion 27 targetSdkVersion 27
versionCode 7 versionCode 7
versionName "0.5.0" versionName "0.5.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
@ -24,15 +28,19 @@ android {
} }
dependencies { dependencies {
def room_version = "2.1.0-alpha04"
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.android.support:design:27.1.1' implementation 'com.google.android.material:material:1.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
implementation 'me.texy.treeview:treeview_lib:1.0.4' implementation 'me.texy.treeview:treeview_lib:1.0.4'
implementation 'com.google.code.gson:gson:2.8.2' implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.retrofit2:retrofit:2.4.0' implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0' implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.android.support:recyclerview-v7:27.1.1' implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01'
implementation 'com.squareup.picasso:picasso:2.71828' implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.chrisbanes:PhotoView:2.1.4' implementation 'com.github.chrisbanes:PhotoView:2.1.4'
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
} }

View File

@ -0,0 +1,46 @@
{
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "b484b5731c959dea19f42d92a1fccfcd",
"entities": [
{
"tableName": "favorites",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `itemID` INTEGER NOT NULL, `itemName` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "itemID",
"columnName": "itemID",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "itemName",
"columnName": "itemName",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"b484b5731c959dea19f42d92a1fccfcd\")"
]
}
}

View File

@ -0,0 +1,46 @@
{
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "b484b5731c959dea19f42d92a1fccfcd",
"entities": [
{
"tableName": "favorites",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `itemID` INTEGER NOT NULL, `itemName` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "itemID",
"columnName": "itemID",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "itemName",
"columnName": "itemName",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"b484b5731c959dea19f42d92a1fccfcd\")"
]
}
}

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="ru.volgorobot.vrcatalog"> package="ru.volgorobot.vrcatalog">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
@ -10,7 +12,8 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme"
android:name=".App">
<activity android:name=".view.FavoritesActivity"></activity> <activity android:name=".view.FavoritesActivity"></activity>
<activity <activity
android:name=".view.MainActivity" android:name=".view.MainActivity"

View File

@ -0,0 +1,25 @@
package ru.volgorobot.vrcatalog;
import android.app.Application;
import android.content.Context;
import androidx.room.Room;
import ru.volgorobot.vrcatalog.additional.DatabaseHelper;
public class App extends Application {
private static Application instance;
private static DatabaseHelper db;
@Override
public void onCreate() {
super.onCreate();
instance = this;
db = Room.databaseBuilder(getApplicationContext(), DatabaseHelper.class, "mainDatabase")
.allowMainThreadQueries()
.build();
}
public static Context getContext() { return instance.getApplicationContext(); }
public static DatabaseHelper getDatabaseInstance() { return db; }
}

View File

@ -6,8 +6,10 @@ import java.util.ArrayList;
import me.texy.treeview.TreeNode; import me.texy.treeview.TreeNode;
import ru.volgorobot.vrcatalog.additional.NetworkErrorException; import ru.volgorobot.vrcatalog.additional.NetworkErrorException;
import ru.volgorobot.vrcatalog.additional.adapters.FavoritesListAdapter;
import ru.volgorobot.vrcatalog.model.CoreModel; import ru.volgorobot.vrcatalog.model.CoreModel;
import ru.volgorobot.vrcatalog.model.DetailModel; import ru.volgorobot.vrcatalog.model.DetailModel;
import ru.volgorobot.vrcatalog.model.FavoritesModel;
import ru.volgorobot.vrcatalog.model.FirstLevelModel; import ru.volgorobot.vrcatalog.model.FirstLevelModel;
import ru.volgorobot.vrcatalog.model.ImageItemModel; import ru.volgorobot.vrcatalog.model.ImageItemModel;
import ru.volgorobot.vrcatalog.model.SecondLevelModel; import ru.volgorobot.vrcatalog.model.SecondLevelModel;
@ -34,12 +36,15 @@ public interface MainContract {
} }
interface FavoritesPresenter { interface FavoritesPresenter {
void getAllItems();
void removeItem(int id);
void fetchItem(int itemID); void fetchItem(int itemID);
} }
interface FavoritesActivityView { interface FavoritesActivityView {
void onFailruleAnswer(int errorCode); void onFailureAnswer(int errorCode);
void startActivityByIntent(Intent intent); void startActivityByIntent(Intent intent);
void updateListView(ArrayList<FavoritesModel> data);
} }
interface ViewBinder { interface ViewBinder {
@ -71,6 +76,10 @@ public interface MainContract {
interface ItemPresenter { interface ItemPresenter {
void getImagesByItemID(int id); void getImagesByItemID(int id);
boolean checkFavoriteListed(int itemID);
int getFavoriteID(int itemID);
void addToFavorites(int itemID, String itemName);
void removeFromFavorites(int favID);
} }
interface ItemView { interface ItemView {

View File

@ -17,11 +17,11 @@ package ru.volgorobot.vrcatalog.additional;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.support.annotation.LayoutRes; import androidx.annotation.LayoutRes;
import android.support.annotation.Nullable; import androidx.annotation.Nullable;
import android.support.v7.app.ActionBar; import androidx.appcompat.app.ActionBar;
import android.support.v7.app.AppCompatDelegate; import androidx.appcompat.app.AppCompatDelegate;
import android.support.v7.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;

View File

@ -0,0 +1,11 @@
package ru.volgorobot.vrcatalog.additional;
import androidx.room.Database;
import androidx.room.RoomDatabase;
import ru.volgorobot.vrcatalog.model.FavoritesDaoModel;
import ru.volgorobot.vrcatalog.model.FavoritesModel;
@Database(entities = {FavoritesModel.class}, version = 1)
public abstract class DatabaseHelper extends RoomDatabase {
public abstract FavoritesDaoModel getFavoritesDaoModel();
}

View File

@ -4,11 +4,13 @@ import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.MotionEvent; import android.view.MotionEvent;
import androidx.viewpager.widget.ViewPager;
/** /**
* ViewPager fixer class (which fix bug with zooming) * ViewPager fixer class (which fix bug with zooming)
*/ */
public class HackyViewPager extends android.support.v4.view.ViewPager { public class HackyViewPager extends ViewPager {
public HackyViewPager(Context context) { public HackyViewPager(Context context) {
super(context); super(context);

View File

@ -3,25 +3,22 @@ package ru.volgorobot.vrcatalog.additional.adapters;
import android.content.Context; import android.content.Context;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import ru.volgorobot.vrcatalog.model.FavoritesListModel; import ru.volgorobot.vrcatalog.model.FavoritesModel;
import ru.volgorobot.vrcatalog.presenters.FavoritesDBPresenter;
public class FavoritesListAdapter extends ArrayAdapter<FavoritesListModel> { public class FavoritesListAdapter extends ArrayAdapter<FavoritesModel> {
private FavoritesDBPresenter db; public FavoritesListAdapter(Context context, int resource, List<FavoritesModel> objects) {
public FavoritesListAdapter(Context context, int resource, List<FavoritesListModel> objects) {
super(context, resource, objects); super(context, resource, objects);
db = new FavoritesDBPresenter(context);
} }
public void updateData() { public void updateData(ArrayList<FavoritesModel> data) {
super.clear(); super.clear();
super.addAll(db.selectAll()); super.addAll(data);
} }
public int getArraySize() { public int getArraySize() {
return db.selectAll().size(); return super.getCount();
} }
} }

View File

@ -1,9 +1,9 @@
package ru.volgorobot.vrcatalog.additional.adapters; package ru.volgorobot.vrcatalog.additional.adapters;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull; import androidx.annotation.NonNull;
import android.support.v4.view.PagerAdapter; import androidx.viewpager.widget.PagerAdapter;
import android.support.v7.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator; import android.view.animation.AccelerateInterpolator;

View File

@ -5,8 +5,8 @@ import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.support.annotation.NonNull; import androidx.annotation.NonNull;
import android.support.v4.view.PagerAdapter; import androidx.viewpager.widget.PagerAdapter;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;

View File

@ -0,0 +1,22 @@
package ru.volgorobot.vrcatalog.model;
import java.util.List;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
@Dao
public interface FavoritesDaoModel {
@Query("SELECT * FROM favorites")
List<FavoritesModel> getAll();
@Query("SELECT * FROM favorites WHERE itemID = :itemID")
List<FavoritesModel> getFavoriteByItemID(int itemID);
@Insert
void add(FavoritesModel model);
@Query("DELETE FROM favorites WHERE id = :id")
void remove(int id);
}

View File

@ -1,17 +1,21 @@
package ru.volgorobot.vrcatalog.model; package ru.volgorobot.vrcatalog.model;
public class FavoritesListModel { import androidx.room.ColumnInfo;
private int id; import androidx.room.Entity;
private int itemID; import androidx.room.PrimaryKey;
private String itemName;
public FavoritesListModel(int itemID, String itemName) { @Entity(tableName = "favorites")
this.itemID = itemID; public class FavoritesModel {
this.itemName = itemName; @PrimaryKey(autoGenerate = true)
} public int id;
public FavoritesListModel(int id, int itemID, String itemName) { @ColumnInfo
this.id = id; public int itemID;
@ColumnInfo
public String itemName;
public FavoritesModel(int itemID, String itemName) {
this.itemID = itemID; this.itemID = itemID;
this.itemName = itemName; this.itemName = itemName;
} }

View File

@ -1,11 +1,8 @@
package ru.volgorobot.vrcatalog.nodeViewBinders; package ru.volgorobot.vrcatalog.nodeViewBinders;
import android.content.Context; import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import me.texy.treeview.TreeNode; import me.texy.treeview.TreeNode;

View File

@ -1,83 +0,0 @@
package ru.volgorobot.vrcatalog.presenters;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import java.util.ArrayList;
import ru.volgorobot.vrcatalog.additional.DatabaseProperties;
import ru.volgorobot.vrcatalog.additional.SqliteHelper;
import ru.volgorobot.vrcatalog.model.FavoritesListModel;
public class FavoritesDBPresenter {
private SqliteHelper mHelper;
private SQLiteDatabase mDB;
public FavoritesDBPresenter(Context context) {
this.mHelper = new SqliteHelper(context);
this.mDB = mHelper.getWritableDatabase();
}
public ArrayList<FavoritesListModel> selectAll() {
ArrayList<FavoritesListModel> models = new ArrayList<>();
String[] columns = {
DatabaseProperties.FAVORITES_COLUMN_ID,
DatabaseProperties.FAVORITES_COLUMN_ITEM_ID,
DatabaseProperties.FAVORITES_COLUMN_ITEM_NAME
};
Cursor cursor = mDB.query(DatabaseProperties.FAVORITES_TABLE_NAME, columns, null, null, null, null, null);
if(cursor == null)
return new ArrayList<>();
while(cursor.moveToNext()) {
models.add(new FavoritesListModel(
cursor.getInt(cursor.getColumnIndex(DatabaseProperties.FAVORITES_COLUMN_ID)),
cursor.getInt(cursor.getColumnIndex(DatabaseProperties.FAVORITES_COLUMN_ITEM_ID)),
cursor.getString(cursor.getColumnIndex(DatabaseProperties.FAVORITES_COLUMN_ITEM_NAME))));
}
cursor.close();
return models;
}
public void add(FavoritesListModel model) {
ContentValues contentValues = new ContentValues();
contentValues.put(DatabaseProperties.FAVORITES_COLUMN_ITEM_ID, model.getItemID());
contentValues.put(DatabaseProperties.FAVORITES_COLUMN_ITEM_NAME, model.getItemName());
mDB.insert(DatabaseProperties.FAVORITES_TABLE_NAME, null, contentValues);
}
public void removeItem(int id) {
mDB.delete(DatabaseProperties.FAVORITES_TABLE_NAME, "_id = " + id, null);
}
public boolean inFavoritesList(int itemID) {
String[] columns = { DatabaseProperties.FAVORITES_COLUMN_ITEM_ID };
String[] selectionArgs = { Integer.toString(itemID) };
Cursor cursor = mDB.query(DatabaseProperties.FAVORITES_TABLE_NAME, columns, DatabaseProperties.FAVORITES_COLUMN_ITEM_ID + " = ?", selectionArgs, null, null, null);
while(cursor.moveToNext()) {
if(cursor.getInt(cursor.getColumnIndex(DatabaseProperties.FAVORITES_COLUMN_ITEM_ID)) == itemID)
return true;
}
cursor.close();
return false;
}
public int getFavoriteID(int itemID) {
String[] columns = { DatabaseProperties.FAVORITES_COLUMN_ID, DatabaseProperties.FAVORITES_COLUMN_ITEM_ID };
Cursor cursor = mDB.query(DatabaseProperties.FAVORITES_TABLE_NAME, columns, DatabaseProperties.FAVORITES_COLUMN_ITEM_ID + " = " + Integer.toString(itemID), null, null, null, null);
int id = 0;
if( cursor != null && cursor.moveToFirst() ){
id = cursor.getInt(cursor.getColumnIndex(DatabaseProperties.FAVORITES_COLUMN_ID));
cursor.close();
}
return id;
}
}

View File

@ -1,16 +1,21 @@
package ru.volgorobot.vrcatalog.presenters; package ru.volgorobot.vrcatalog.presenters;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
import java.util.ArrayList; import java.util.ArrayList;
import androidx.room.Room;
import ru.volgorobot.vrcatalog.App;
import ru.volgorobot.vrcatalog.MainContract; import ru.volgorobot.vrcatalog.MainContract;
import ru.volgorobot.vrcatalog.additional.DatabaseHelper;
import ru.volgorobot.vrcatalog.additional.NetworkErrorException; import ru.volgorobot.vrcatalog.additional.NetworkErrorException;
import ru.volgorobot.vrcatalog.additional.ResultWithErrorCode; import ru.volgorobot.vrcatalog.additional.ResultWithErrorCode;
import ru.volgorobot.vrcatalog.model.CoreModel; import ru.volgorobot.vrcatalog.model.CoreModel;
import ru.volgorobot.vrcatalog.model.DetailModel; import ru.volgorobot.vrcatalog.model.DetailModel;
import ru.volgorobot.vrcatalog.model.FavoritesModel;
import ru.volgorobot.vrcatalog.view.FavoritesActivity; import ru.volgorobot.vrcatalog.view.FavoritesActivity;
import ru.volgorobot.vrcatalog.view.ItemActivity; import ru.volgorobot.vrcatalog.view.ItemActivity;
@ -18,13 +23,16 @@ public class FavoritesPresenter implements MainContract.FavoritesPresenter {
private Context mContext; private Context mContext;
private MainContract.MainModel mainModel; private MainContract.MainModel mainModel;
private MainContract.FavoritesActivityView mView; private MainContract.FavoritesActivityView mView;
private DatabaseHelper db;
public FavoritesPresenter(Context context, FavoritesActivity view) { public FavoritesPresenter(FavoritesActivity view) {
this.mContext = context; this.mContext = App.getContext();
this.mainModel = new CoreModel(context); this.mainModel = new CoreModel(mContext);
this.mView = view; this.mView = view;
this.db = App.getDatabaseInstance();
} }
@SuppressLint("StaticFieldLeak")
@Override @Override
public void fetchItem(int itemID) { public void fetchItem(int itemID) {
new AsyncTask<Integer, Void, ResultWithErrorCode<DetailModel>>() { new AsyncTask<Integer, Void, ResultWithErrorCode<DetailModel>>() {
@ -59,19 +67,30 @@ public class FavoritesPresenter implements MainContract.FavoritesPresenter {
break; break;
} }
case 1: { case 1: {
mView.onFailruleAnswer(1); mView.onFailureAnswer(1);
break; break;
} }
case 2: { case 2: {
mView.onFailruleAnswer(2); mView.onFailureAnswer(2);
break; break;
} }
case 3: { case 3: {
mView.onFailruleAnswer(3); mView.onFailureAnswer(3);
break; break;
} }
} }
} }
}.execute(itemID); }.execute(itemID);
} }
@Override
public void getAllItems() {
mView.updateListView((ArrayList<FavoritesModel>) db.getFavoritesDaoModel().getAll());
}
@Override
public void removeItem(int id) {
db.getFavoritesDaoModel().remove(id);
mView.updateListView((ArrayList<FavoritesModel>) db.getFavoritesDaoModel().getAll());
}
} }

View File

@ -15,21 +15,27 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.UUID; import java.util.UUID;
import androidx.room.Room;
import ru.volgorobot.vrcatalog.App;
import ru.volgorobot.vrcatalog.MainContract; import ru.volgorobot.vrcatalog.MainContract;
import ru.volgorobot.vrcatalog.additional.DatabaseHelper;
import ru.volgorobot.vrcatalog.additional.NetworkErrorException; import ru.volgorobot.vrcatalog.additional.NetworkErrorException;
import ru.volgorobot.vrcatalog.additional.ResultWithErrorCode; import ru.volgorobot.vrcatalog.additional.ResultWithErrorCode;
import ru.volgorobot.vrcatalog.model.CoreModel; import ru.volgorobot.vrcatalog.model.CoreModel;
import ru.volgorobot.vrcatalog.model.FavoritesModel;
import ru.volgorobot.vrcatalog.model.ImageItemModel; import ru.volgorobot.vrcatalog.model.ImageItemModel;
public class ItemPresenter implements MainContract.ItemPresenter { public class ItemPresenter implements MainContract.ItemPresenter {
private MainContract.ItemView mView; private MainContract.ItemView mView;
private Context context; private Context context;
private MainContract.MainModel coreModel; private MainContract.MainModel coreModel;
private DatabaseHelper db;
public ItemPresenter(Context context, MainContract.ItemView itemView) { public ItemPresenter(MainContract.ItemView itemView) {
this.mView = itemView; this.mView = itemView;
this.context = context; this.context = App.getContext();
this.coreModel = new CoreModel(context); this.coreModel = new CoreModel(context);
this.db = App.getDatabaseInstance();
} }
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
@ -101,4 +107,27 @@ public class ItemPresenter implements MainContract.ItemPresenter {
} }
return Uri.fromFile(cacheObject); return Uri.fromFile(cacheObject);
} }
@Override
public boolean checkFavoriteListed(int itemID) {
return db.getFavoritesDaoModel().getFavoriteByItemID(itemID).size() != 0;
}
@Override
public int getFavoriteID(int itemID) {
ArrayList<FavoritesModel> models = (ArrayList<FavoritesModel>) db.getFavoritesDaoModel().getFavoriteByItemID(itemID);
if(models.size() != 0)
return models.get(0).getID();
return 0;
}
@Override
public void addToFavorites(int itemID, String itemName) {
db.getFavoritesDaoModel().add(new FavoritesModel(itemID, itemName));
}
@Override
public void removeFromFavorites(int favID) {
db.getFavoritesDaoModel().remove(favID);
}
} }

View File

@ -1,7 +1,7 @@
package ru.volgorobot.vrcatalog.view; package ru.volgorobot.vrcatalog.view;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.view.MenuItem; import android.view.MenuItem;
import ru.volgorobot.vrcatalog.R; import ru.volgorobot.vrcatalog.R;

View File

@ -1,8 +1,8 @@
package ru.volgorobot.vrcatalog.view; package ru.volgorobot.vrcatalog.view;
import android.content.Intent; import android.content.Intent;
import android.support.v7.app.ActionBar; import androidx.appcompat.app.ActionBar;
import android.support.v7.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.ContextMenu; import android.view.ContextMenu;
@ -19,12 +19,10 @@ import java.util.ArrayList;
import ru.volgorobot.vrcatalog.MainContract; import ru.volgorobot.vrcatalog.MainContract;
import ru.volgorobot.vrcatalog.R; import ru.volgorobot.vrcatalog.R;
import ru.volgorobot.vrcatalog.additional.adapters.FavoritesListAdapter; import ru.volgorobot.vrcatalog.additional.adapters.FavoritesListAdapter;
import ru.volgorobot.vrcatalog.model.FavoritesListModel; import ru.volgorobot.vrcatalog.model.FavoritesModel;
import ru.volgorobot.vrcatalog.presenters.FavoritesDBPresenter;
import ru.volgorobot.vrcatalog.presenters.FavoritesPresenter; import ru.volgorobot.vrcatalog.presenters.FavoritesPresenter;
public class FavoritesActivity extends AppCompatActivity implements MainContract.FavoritesActivityView { public class FavoritesActivity extends AppCompatActivity implements MainContract.FavoritesActivityView {
private FavoritesDBPresenter db;
private FavoritesListAdapter adapter; private FavoritesListAdapter adapter;
private MainContract.FavoritesPresenter mPresenter; private MainContract.FavoritesPresenter mPresenter;
@ -37,15 +35,13 @@ public class FavoritesActivity extends AppCompatActivity implements MainContract
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_favorites); setContentView(R.layout.activity_favorites);
mPresenter = new FavoritesPresenter(FavoritesActivity.this, this); mPresenter = new FavoritesPresenter(this);
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true); actionBar.setHomeButtonEnabled(true);
actionBar.setTitle("Избранное"); actionBar.setTitle("Избранное");
db = new FavoritesDBPresenter(FavoritesActivity.this);
initViews(); initViews();
} }
@ -55,16 +51,14 @@ public class FavoritesActivity extends AppCompatActivity implements MainContract
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
FavoritesListModel model = (FavoritesListModel) listView.getItemAtPosition(i); FavoritesModel model = (FavoritesModel) listView.getItemAtPosition(i);
mPresenter.fetchItem(model.getItemID()); mPresenter.fetchItem(model.getItemID());
} }
}); });
adapter = new FavoritesListAdapter(FavoritesActivity.this, android.R.layout.simple_list_item_1, new ArrayList<>());
listView.setAdapter(adapter);
favoritesEmptyImage = findViewById(R.id.favorites_empty_image); favoritesEmptyImage = findViewById(R.id.favorites_empty_image);
favoritesEmptyText = findViewById(R.id.favorites_empty_text); favoritesEmptyText = findViewById(R.id.favorites_empty_text);
ArrayList<FavoritesListModel> models = db.selectAll();
adapter = new FavoritesListAdapter(FavoritesActivity.this, android.R.layout.simple_list_item_1, models);
listView.setAdapter(adapter);
checkForEmptyContent();
} }
public void checkForEmptyContent() { public void checkForEmptyContent() {
@ -84,18 +78,18 @@ public class FavoritesActivity extends AppCompatActivity implements MainContract
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
switch (item.getItemId()) { switch (item.getItemId()) {
case 0: { case 0: {
FavoritesListModel model = (FavoritesListModel) listView.getItemAtPosition(info.position); FavoritesModel model = (FavoritesModel) listView.getItemAtPosition(info.position);
db.removeItem(model.getID()); mPresenter.removeItem(model.getID());
updateListView();
checkForEmptyContent();
} }
} }
return true; return true;
} }
private void updateListView() { @Override
adapter.updateData(); public void updateListView(ArrayList<FavoritesModel> data) {
adapter.updateData(data);
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
checkForEmptyContent();
} }
@Override @Override
@ -116,7 +110,7 @@ public class FavoritesActivity extends AppCompatActivity implements MainContract
} }
@Override @Override
public void onFailruleAnswer(int errorCode) { public void onFailureAnswer(int errorCode) {
switch (errorCode) { switch (errorCode) {
case 1: { case 1: {
Toast.makeText(FavoritesActivity.this, "Ошибка сети. Проверьте подключение к сети или данные подключения к API!", Toast.LENGTH_LONG).show(); Toast.makeText(FavoritesActivity.this, "Ошибка сети. Проверьте подключение к сети или данные подключения к API!", Toast.LENGTH_LONG).show();
@ -144,7 +138,6 @@ public class FavoritesActivity extends AppCompatActivity implements MainContract
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
updateListView(); mPresenter.getAllItems();
checkForEmptyContent();
} }
} }

View File

@ -4,11 +4,11 @@ import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import androidx.annotation.Nullable;
import android.support.v4.content.ContextCompat; import androidx.core.content.ContextCompat;
import android.support.v4.view.ViewPager; import androidx.viewpager.widget.ViewPager;
import android.support.v7.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;

View File

@ -4,10 +4,11 @@ import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.TabLayout; import com.google.android.material.tabs.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity; import androidx.viewpager.widget.ViewPager;
import android.support.v7.widget.Toolbar; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log; import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -17,10 +18,7 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map;
import ru.volgorobot.vrcatalog.model.FavoritesListModel;
import ru.volgorobot.vrcatalog.presenters.FavoritesDBPresenter;
import ru.volgorobot.vrcatalog.presenters.ItemPresenter; import ru.volgorobot.vrcatalog.presenters.ItemPresenter;
import ru.volgorobot.vrcatalog.MainContract; import ru.volgorobot.vrcatalog.MainContract;
import ru.volgorobot.vrcatalog.R; import ru.volgorobot.vrcatalog.R;
@ -33,9 +31,9 @@ public class ItemActivity extends AppCompatActivity implements MainContract.Item
private ListView propertiesList; private ListView propertiesList;
private ImagePagerAdapter imagePagerAdapter; private ImagePagerAdapter imagePagerAdapter;
private boolean inFavorites; private boolean inFavorites;
private FavoritesDBPresenter db;
private int itemID; private int itemID;
private String itemName; private String itemName;
private int favoriteID;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -47,7 +45,7 @@ public class ItemActivity extends AppCompatActivity implements MainContract.Item
getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().setDisplayShowTitleEnabled(false);
initializeViews(); initializeViews();
mPresenter = new ItemPresenter(ItemActivity.this, this); mPresenter = new ItemPresenter(this);
Intent intent = getIntent(); Intent intent = getIntent();
itemName = intent.getStringExtra("detailName"); itemName = intent.getStringExtra("detailName");
@ -63,7 +61,6 @@ public class ItemActivity extends AppCompatActivity implements MainContract.Item
LinkedHashMap<String, String> intentDataForListView = getIntentExtras(intent); LinkedHashMap<String, String> intentDataForListView = getIntentExtras(intent);
itemID = Integer.parseInt(intent.getStringExtra("itemID")); itemID = Integer.parseInt(intent.getStringExtra("itemID"));
intentDataForListView.get("detailName"); intentDataForListView.get("detailName");
db = new FavoritesDBPresenter(ItemActivity.this);
propertiesList = findViewById(R.id.propertiesList); propertiesList = findViewById(R.id.propertiesList);
PropertiesListAdapter propertiesListAdapter = new PropertiesListAdapter(intentDataForListView); PropertiesListAdapter propertiesListAdapter = new PropertiesListAdapter(intentDataForListView);
@ -71,7 +68,8 @@ public class ItemActivity extends AppCompatActivity implements MainContract.Item
mPresenter.getImagesByItemID(Integer.parseInt(intent.getStringExtra("itemID"))); mPresenter.getImagesByItemID(Integer.parseInt(intent.getStringExtra("itemID")));
inFavorites = db.inFavoritesList(itemID); inFavorites = mPresenter.checkFavoriteListed(itemID);
favoriteID = mPresenter.getFavoriteID(itemID);
} }
void initializeViews() { void initializeViews() {
@ -229,13 +227,13 @@ public class ItemActivity extends AppCompatActivity implements MainContract.Item
MenuItem deleteFromFavorites = menu.findItem(R.id.action_unfavorite); MenuItem deleteFromFavorites = menu.findItem(R.id.action_unfavorite);
addToFavorites.setOnMenuItemClickListener((MenuItem menuItem) -> { addToFavorites.setOnMenuItemClickListener((MenuItem menuItem) -> {
db.add(new FavoritesListModel(0, itemID, itemName)); mPresenter.addToFavorites(itemID, itemName);
inFavorites = true; inFavorites = true;
this.invalidateOptionsMenu(); this.invalidateOptionsMenu();
return true; return true;
}); });
deleteFromFavorites.setOnMenuItemClickListener((MenuItem menuItem) -> { deleteFromFavorites.setOnMenuItemClickListener((MenuItem menuItem) -> {
db.removeItem(db.getFavoriteID(itemID)); mPresenter.removeFromFavorites(favoriteID);
inFavorites = false; inFavorites = false;
this.invalidateOptionsMenu(); this.invalidateOptionsMenu();
return true; return true;

View File

@ -5,16 +5,15 @@ import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.NavigationView; import androidx.drawerlayout.widget.DrawerLayout;
import android.support.v4.view.GravityCompat; import androidx.core.view.GravityCompat;
import android.support.v4.view.MenuItemCompat; import androidx.core.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import android.support.v4.widget.SwipeRefreshLayout; import androidx.appcompat.app.ActionBarDrawerToggle;
import android.support.v7.app.ActionBarDrawerToggle; import androidx.appcompat.app.AppCompatActivity;
import android.support.v7.app.AppCompatActivity; import androidx.recyclerview.widget.DefaultItemAnimator;
import android.support.v7.widget.DefaultItemAnimator; import androidx.appcompat.widget.SearchView;
import android.support.v7.widget.SearchView; import androidx.appcompat.widget.Toolbar;
import android.support.v7.widget.Toolbar;
import android.util.Log; import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -25,6 +24,8 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.google.android.material.navigation.NavigationView;
import java.util.ArrayList; import java.util.ArrayList;
import me.texy.treeview.TreeNode; import me.texy.treeview.TreeNode;

View File

@ -4,14 +4,13 @@ import android.app.SearchManager;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.provider.SearchRecentSuggestions; import android.provider.SearchRecentSuggestions;
import android.support.v4.widget.NestedScrollView; import androidx.core.widget.NestedScrollView;
import android.support.v4.widget.SwipeRefreshLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator; import androidx.recyclerview.widget.DefaultItemAnimator;
import android.util.Log; import android.util.Log;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;

View File

@ -1,25 +1,25 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<android.support.design.widget.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true"> android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout <com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"> app:layout_scrollFlags="scroll|enterAlways">
<android.support.v4.view.ViewPager <androidx.viewpager.widget.ViewPager
android:id="@+id/viewPager" android:id="@+id/viewPager"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="311dp" android:layout_height="311dp"
app:layout_collapseMode="parallax" /> app:layout_collapseMode="parallax" />
<android.support.design.widget.TabLayout <com.google.android.material.tabs.TabLayout
android:id="@+id/tabDots" android:id="@+id/tabDots"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="62dp" android:layout_height="62dp"
@ -27,7 +27,7 @@
app:tabBackground="@drawable/tab_selector" app:tabBackground="@drawable/tab_selector"
app:tabGravity="center" app:tabGravity="center"
app:tabIndicatorHeight="0dp" /> app:tabIndicatorHeight="0dp" />
<android.support.v7.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/itemactivity_toolbar" android:id="@+id/itemactivity_toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
@ -35,10 +35,10 @@
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:theme="@style/ItemActionBar"/> android:theme="@style/ItemActionBar"/>
</android.support.design.widget.CollapsingToolbarLayout> </com.google.android.material.appbar.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<android.support.v4.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="619dp" android:layout_height="619dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior" app:layout_behavior="@string/appbar_scrolling_view_behavior"
@ -74,5 +74,5 @@
app:layout_behavior="@string/appbar_scrolling_view_behavior" app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:nestedScrollingEnabled="false"/> android:nestedScrollingEnabled="false"/>
</LinearLayout> </LinearLayout>
</android.support.v4.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout" android:id="@+id/linearLayout"
@ -44,4 +44,4 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/favorites_empty_image" /> app:layout_constraintTop_toBottomOf="@+id/favorites_empty_image" />
</android.support.constraint.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -14,7 +14,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
<android.support.v7.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout" android:id="@+id/drawer_layout"
@ -13,7 +13,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
<android.support.design.widget.NavigationView <com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view" android:id="@+id/nav_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -22,4 +22,4 @@
app:headerLayout="@layout/nav_header_main" app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" /> app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout> </androidx.drawerlayout.widget.DrawerLayout>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -10,16 +10,16 @@
android:orientation="horizontal" android:orientation="horizontal"
android:id="@+id/searchableSwipeRefreshLayout"> android:id="@+id/searchableSwipeRefreshLayout">
<android.support.constraint.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:id="@+id/searchableTreeViewContainer" android:id="@+id/searchableTreeViewContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:scrollbarAlwaysDrawVerticalTrack="true"> android:scrollbarAlwaysDrawVerticalTrack="true">
</android.support.v4.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>
<ImageView <ImageView
android:id="@+id/searchableConnectionErrorImageView" android:id="@+id/searchableConnectionErrorImageView"
@ -80,6 +80,6 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/emptySearchImage" /> app:layout_constraintTop_toBottomOf="@+id/emptySearchImage" />
</android.support.constraint.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</android.support.v4.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".view.MainActivity"> tools:context=".view.MainActivity">
<android.support.design.widget.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
@ -20,8 +20,8 @@
app:titleTextColor="@android:color/white" app:titleTextColor="@android:color/white"
app:popupTheme="@style/AppTheme.PopupOverlay" /> app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<include layout="@layout/content_main" /> <include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -10,12 +10,12 @@
android:orientation="horizontal" android:orientation="horizontal"
android:id="@+id/swipeRefreshLayout"> android:id="@+id/swipeRefreshLayout">
<android.support.constraint.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/mainActivityConstraint" android:id="@+id/mainActivityConstraint"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:id="@+id/treeViewContainer" android:id="@+id/treeViewContainer"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
@ -27,7 +27,7 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"> app:layout_constraintVertical_bias="1.0">
</android.support.v4.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>
<ImageView <ImageView
android:id="@+id/connectionErrorImageView" android:id="@+id/connectionErrorImageView"
@ -59,6 +59,6 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/connectionErrorImageView" /> app:layout_constraintTop_toBottomOf="@+id/connectionErrorImageView" />
</android.support.constraint.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</android.support.v4.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

View File

@ -5,6 +5,6 @@
android:id="@+id/action_search" android:id="@+id/action_search"
android:icon="@drawable/ic_search_white_24dp" android:icon="@drawable/ic_search_white_24dp"
app:showAsAction="always|collapseActionView" app:showAsAction="always|collapseActionView"
app:actionViewClass="android.support.v7.widget.SearchView" app:actionViewClass="androidx.appcompat.widget.SearchView"
android:title="Поиск"/> android:title="Поиск"/>
</menu> </menu>

View File

@ -6,6 +6,8 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html # http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process. # Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings. # The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx512m org.gradle.jvmargs=-Xmx512m
# When configured, Gradle will run in incubating parallel mode. # When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit # This option should only be used with decoupled projects. More details, visit