Releasing 1.0.0

This commit is contained in:
ChronosX88 2019-02-27 18:04:34 +04:00
commit 60ebb68e76
No known key found for this signature in database
GPG Key ID: 8F92E090A87804AA
49 changed files with 521 additions and 263 deletions

View File

@ -147,7 +147,7 @@
<PersistentState> <PersistentState>
<option name="values"> <option name="values">
<map> <map>
<entry key="url" value="jar:file:/home/chronosx/%D0%94%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82%D1%8B/bin/Android%20Studio/plugins/android/lib/android.jar!/images/material_design_icons/action/ic_favorite_black_24dp.xml" /> <entry key="url" value="jar:file:/home/chronosx/%D0%94%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82%D1%8B/bin/Android%20Studio/plugins/android/lib/android.jar!/images/material_design_icons/content/ic_clear_black_24dp.xml" />
</map> </map>
</option> </option>
</PersistentState> </PersistentState>
@ -157,7 +157,8 @@
</option> </option>
<option name="values"> <option name="values">
<map> <map>
<entry key="outputName" value="ic_favorite_black_24dp" /> <entry key="color" value="d3d3d3" />
<entry key="outputName" value="ic_clear_gray_24dp" />
<entry key="sourceFile" value="$USER_HOME$" /> <entry key="sourceFile" value="$USER_HOME$" />
</map> </map>
</option> </option>

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

@ -0,0 +1,42 @@
package ru.volgorobot.vrcatalog.additional;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import androidx.viewpager.widget.ViewPager;
/**
* ViewPager fixer class (which fix bug with zooming)
*/
public class HackyViewPager extends ViewPager {
public HackyViewPager(Context context) {
super(context);
}
public HackyViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
try {
return super.onTouchEvent(ev);
} catch (IllegalArgumentException ex) {
ex.printStackTrace();
}
return false;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
try {
return super.onInterceptTouchEvent(ev);
} catch (IllegalArgumentException ex) {
ex.printStackTrace();
}
return false;
}
}

View File

@ -23,9 +23,9 @@ public class SearchableNodeViewFactory extends BaseNodeViewFactory {
public BaseNodeViewBinder getNodeViewBinder(View view, int level) { public BaseNodeViewBinder getNodeViewBinder(View view, int level) {
switch (level) { switch (level) {
case 0: case 0:
return new FirstLevelNodeViewBinder(view); return new FirstLevelNodeViewBinder(view, mView);
case 1: case 1:
return new SecondLevelNodeViewBinder(view); return new SecondLevelNodeViewBinder(view, mView);
case 2: case 2:
return new ThirdLevelNodeViewBinder(view, context, mView); return new ThirdLevelNodeViewBinder(view, context, mView);
default: default:

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

@ -32,6 +32,7 @@ public class FirstLevelNodeViewBinder extends BaseNodeViewBinder implements Main
@Override @Override
public void bindView(TreeNode treeNode) { public void bindView(TreeNode treeNode) {
textView.setText(treeNode.getValue().toString()); textView.setText(treeNode.getValue().toString());
imageView.setRotation(treeNode.isExpanded() ? 90 : 0);
} }
@Override @Override
@ -48,4 +49,5 @@ public class FirstLevelNodeViewBinder extends BaseNodeViewBinder implements Main
public void rotateImageView() { public void rotateImageView() {
imageView.animate().rotation(90).setDuration(200).start(); imageView.animate().rotation(90).setDuration(200).start();
} }
} }

View File

@ -1,8 +1,10 @@
package ru.volgorobot.vrcatalog.nodeViewBinders; package ru.volgorobot.vrcatalog.nodeViewBinders;
import android.content.Context; import android.content.Context;
import android.graphics.Color;
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,7 +1,9 @@
package ru.volgorobot.vrcatalog.nodeViewBinders; package ru.volgorobot.vrcatalog.nodeViewBinders;
import android.content.Context; import android.content.Context;
import android.graphics.Color;
import android.view.View; import android.view.View;
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

@ -32,7 +32,7 @@ public class ViewBinderPresenter implements MainContract.LevelLoaderPresenter {
@Override @Override
public void fetchSecondLevel(FirstLevelModel firstLevelModel, TreeNode treeNode) { public void fetchSecondLevel(FirstLevelModel firstLevelModel, TreeNode treeNode) {
new AsyncTask<FirstLevelModel, Void, ResultWithErrorCode<ArrayList<SecondLevelModel>>>() { new AsyncTask<FirstLevelModel, Void, ResultWithErrorCode<ArrayList<TreeNode>>>() {
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
super.onPreExecute(); super.onPreExecute();
@ -40,31 +40,32 @@ public class ViewBinderPresenter implements MainContract.LevelLoaderPresenter {
} }
@Override @Override
protected ResultWithErrorCode<ArrayList<SecondLevelModel>> doInBackground(FirstLevelModel... firstLevelModel) { protected ResultWithErrorCode<ArrayList<TreeNode>> doInBackground(FirstLevelModel... firstLevelModel) {
ArrayList<SecondLevelModel> secondLevelModels = null; ArrayList<SecondLevelModel> secondLevelModels = null;
ArrayList<TreeNode> treeNodes = new ArrayList<>();
try { try {
secondLevelModels = coreModel.fetchSecondLevelByParentID(firstLevelModel[0].getID()); secondLevelModels = coreModel.fetchSecondLevelByParentID(firstLevelModel[0].getID());
} catch (NetworkErrorException networkErrorException) { } catch (NetworkErrorException networkErrorException) {
return new ResultWithErrorCode<>(secondLevelModels, networkErrorException.getErrorCode()); return new ResultWithErrorCode<>(null, networkErrorException.getErrorCode());
} catch (NullPointerException nullPointerException) { } catch (NullPointerException nullPointerException) {
return new ResultWithErrorCode<>(secondLevelModels, 3); return new ResultWithErrorCode<>(null, 3);
} }
return new ResultWithErrorCode<>(secondLevelModels, 0); for (int i = 0; i < secondLevelModels.size(); i++) {
TreeNode treeNode = new TreeNode(secondLevelModels.get(i));
treeNode.setLevel(1);
treeNodes.add(treeNode);
}
return new ResultWithErrorCode<>(treeNodes, 0);
} }
@Override @Override
protected void onPostExecute(ResultWithErrorCode<ArrayList<SecondLevelModel>> result) { protected void onPostExecute(ResultWithErrorCode<ArrayList<TreeNode>> result) {
super.onPostExecute(result); super.onPostExecute(result);
switch (result.getErrorCode()) { switch (result.getErrorCode()) {
case 0: { case 0: {
ArrayList<TreeNode> treeNodes = new ArrayList<>(); treeNode.setChildren(result.getData());
for (int i = 0; i < result.getData().size(); i++) {
TreeNode treeNode1 = new TreeNode(result.getData().get(i));
treeNode1.setLevel(1);
treeNodes.add(treeNode1);
}
treeNode.setChildren(treeNodes);
mView.refreshTree(); mView.refreshTree();
viewBinder.rotateImageView(); viewBinder.rotateImageView();
break; break;
@ -89,7 +90,7 @@ public class ViewBinderPresenter implements MainContract.LevelLoaderPresenter {
@Override @Override
public void fetchThirdLevel(SecondLevelModel secondLevelModel, TreeNode treeNode) { public void fetchThirdLevel(SecondLevelModel secondLevelModel, TreeNode treeNode) {
new AsyncTask<SecondLevelModel, Void, ResultWithErrorCode<ArrayList<ThirdLevelModel>>>() { new AsyncTask<SecondLevelModel, Void, ResultWithErrorCode<ArrayList<TreeNode>>>() {
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
super.onPreExecute(); super.onPreExecute();
@ -97,30 +98,32 @@ public class ViewBinderPresenter implements MainContract.LevelLoaderPresenter {
} }
@Override @Override
protected ResultWithErrorCode<ArrayList<ThirdLevelModel>> doInBackground(SecondLevelModel... secondLevelModel) { protected ResultWithErrorCode<ArrayList<TreeNode>> doInBackground(SecondLevelModel... secondLevelModel) {
ArrayList<ThirdLevelModel> thirdLevelModels = null; ArrayList<ThirdLevelModel> thirdLevelModels = null;
ArrayList<TreeNode> treeNodes = new ArrayList<>();
try { try {
thirdLevelModels = coreModel.fetchThirdLevelByParentID(secondLevelModel[0].getID()); thirdLevelModels = coreModel.fetchThirdLevelByParentID(secondLevelModel[0].getID());
} catch (NetworkErrorException networkErrorException) { } catch (NetworkErrorException networkErrorException) {
return new ResultWithErrorCode<>(thirdLevelModels, networkErrorException.getErrorCode()); return new ResultWithErrorCode<>(null, networkErrorException.getErrorCode());
} catch (NullPointerException nullPointerException) { } catch (NullPointerException nullPointerException) {
return new ResultWithErrorCode<>(thirdLevelModels, 3); return new ResultWithErrorCode<>(null, 3);
}
return new ResultWithErrorCode<>(thirdLevelModels, 0);
} }
@Override for (int i = 0; i < thirdLevelModels.size(); i++) {
protected void onPostExecute(ResultWithErrorCode<ArrayList<ThirdLevelModel>> result) { TreeNode treeNode1 = new TreeNode(thirdLevelModels.get(i));
super.onPostExecute(result);
switch (result.getErrorCode()) {
case 0: {
ArrayList<TreeNode> treeNodes = new ArrayList<>();
for (int i = 0; i < result.getData().size(); i++) {
TreeNode treeNode1 = new TreeNode(result.getData().get(i));
treeNode1.setLevel(2); treeNode1.setLevel(2);
treeNodes.add(treeNode1); treeNodes.add(treeNode1);
} }
treeNode.setChildren(treeNodes);
return new ResultWithErrorCode<>(treeNodes, 0);
}
@Override
protected void onPostExecute(ResultWithErrorCode<ArrayList<TreeNode>> result) {
super.onPostExecute(result);
switch (result.getErrorCode()) {
case 0: {
treeNode.setChildren(result.getData());
mView.refreshTree(); mView.refreshTree();
viewBinder.rotateImageView(); viewBinder.rotateImageView();
break; break;

View File

@ -1,18 +1,21 @@
package ru.volgorobot.vrcatalog.searchNodeViewBinders; package ru.volgorobot.vrcatalog.searchNodeViewBinders;
import android.graphics.Color;
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;
import me.texy.treeview.base.BaseNodeViewBinder; import me.texy.treeview.base.BaseNodeViewBinder;
import ru.volgorobot.vrcatalog.MainContract;
import ru.volgorobot.vrcatalog.R; import ru.volgorobot.vrcatalog.R;
public class FirstLevelNodeViewBinder extends BaseNodeViewBinder { public class FirstLevelNodeViewBinder extends BaseNodeViewBinder {
TextView textView; TextView textView;
ImageView imageView; ImageView imageView;
public FirstLevelNodeViewBinder(View itemView) { public FirstLevelNodeViewBinder(View itemView, MainContract.MainActivityView mView) {
super(itemView); super(itemView);
textView = (TextView) itemView.findViewById(R.id.node_name_view); textView = (TextView) itemView.findViewById(R.id.node_name_view);
imageView = (ImageView) itemView.findViewById(R.id.arrow_img); imageView = (ImageView) itemView.findViewById(R.id.arrow_img);
@ -26,6 +29,7 @@ public class FirstLevelNodeViewBinder extends BaseNodeViewBinder {
@Override @Override
public void bindView(TreeNode treeNode) { public void bindView(TreeNode treeNode) {
textView.setText(treeNode.getValue().toString()); textView.setText(treeNode.getValue().toString());
imageView.setRotation(treeNode.isExpanded() ? 90 : 0);
} }
@Override @Override

View File

@ -1,18 +1,21 @@
package ru.volgorobot.vrcatalog.searchNodeViewBinders; package ru.volgorobot.vrcatalog.searchNodeViewBinders;
import android.graphics.Color;
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;
import me.texy.treeview.base.BaseNodeViewBinder; import me.texy.treeview.base.BaseNodeViewBinder;
import ru.volgorobot.vrcatalog.MainContract;
import ru.volgorobot.vrcatalog.R; import ru.volgorobot.vrcatalog.R;
public class SecondLevelNodeViewBinder extends BaseNodeViewBinder { public class SecondLevelNodeViewBinder extends BaseNodeViewBinder {
TextView textView; TextView textView;
ImageView imageView; ImageView imageView;
public SecondLevelNodeViewBinder(View itemView) { public SecondLevelNodeViewBinder(View itemView, MainContract.MainActivityView mView) {
super(itemView); super(itemView);
textView = (TextView) itemView.findViewById(R.id.node_name_view); textView = (TextView) itemView.findViewById(R.id.node_name_view);
imageView = (ImageView) itemView.findViewById(R.id.arrow_img); imageView = (ImageView) itemView.findViewById(R.id.arrow_img);
@ -26,6 +29,7 @@ public class SecondLevelNodeViewBinder extends BaseNodeViewBinder {
@Override @Override
public void bindView(TreeNode treeNode) { public void bindView(TreeNode treeNode) {
textView.setText(treeNode.getValue().toString()); textView.setText(treeNode.getValue().toString());
imageView.setRotation(treeNode.isExpanded() ? 90 : 0);
} }
@Override @Override

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,17 +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();
} }
} }
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
@ -115,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();
@ -143,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;
@ -205,7 +206,6 @@ public class MainActivity extends AppCompatActivity
search.setQueryHint("Имя детали"); search.setQueryHint("Имя детали");
return true; return true;
} }
} }

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;
@ -35,6 +34,9 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
private ImageView mConnectionErrorImageView; private ImageView mConnectionErrorImageView;
private NestedScrollView mTreeViewContainer; private NestedScrollView mTreeViewContainer;
private TextView mErrorTextView; private TextView mErrorTextView;
private ImageView mEmptySearchImageView;
private TextView mEmptySearchTextView;
private boolean isInErrorState = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -53,9 +55,12 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
mTreeViewContainer = findViewById(R.id.searchableTreeViewContainer); mTreeViewContainer = findViewById(R.id.searchableTreeViewContainer);
mErrorTextView = findViewById(R.id.searchableErrorTextView); mErrorTextView = findViewById(R.id.searchableErrorTextView);
mEmptySearchImageView = findViewById(R.id.emptySearchImage);
mEmptySearchTextView = findViewById(R.id.emptySearchText);
treeView = new TreeView(rootNode, SearchableActivity.this, new SearchableNodeViewFactory(SearchableActivity.this, this)); treeView = new TreeView(rootNode, SearchableActivity.this, new SearchableNodeViewFactory(SearchableActivity.this, this));
treeView.setItemAnimator(new DefaultItemAnimator()); treeView.setItemAnimator(new DefaultItemAnimator());
((ViewGroup) findViewById(R.id.searchableTreeViewContainer)).addView(treeView.getView()); mTreeViewContainer.addView(treeView.getView());
Intent intent = getIntent(); Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
detailName = intent.getStringExtra(SearchManager.QUERY); detailName = intent.getStringExtra(SearchManager.QUERY);
@ -72,6 +77,15 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
rootNode.setChildren(children); rootNode.setChildren(children);
treeView.expandAll(); treeView.expandAll();
treeView.refreshTreeView(); treeView.refreshTreeView();
if(children.size() == 0 && !isInErrorState) {
mEmptySearchImageView.setVisibility(View.VISIBLE);
mEmptySearchTextView.setVisibility(View.VISIBLE);
mTreeViewContainer.setVisibility(View.GONE);
} else {
mEmptySearchImageView.setVisibility(View.INVISIBLE);
mEmptySearchTextView.setVisibility(View.INVISIBLE);
mTreeViewContainer.setVisibility(View.VISIBLE);
}
} }
public void onFailureAnswer(int errorCode) { public void onFailureAnswer(int errorCode) {
@ -84,6 +98,7 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
mTreeViewContainer.setVisibility(View.GONE); mTreeViewContainer.setVisibility(View.GONE);
mConnectionErrorImageView.setVisibility(View.VISIBLE); mConnectionErrorImageView.setVisibility(View.VISIBLE);
mErrorTextView.setVisibility(View.VISIBLE); mErrorTextView.setVisibility(View.VISIBLE);
isInErrorState = true;
break; break;
} }
case 2: { case 2: {
@ -94,6 +109,7 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
mTreeViewContainer.setVisibility(View.GONE); mTreeViewContainer.setVisibility(View.GONE);
mConnectionErrorImageView.setVisibility(View.VISIBLE); mConnectionErrorImageView.setVisibility(View.VISIBLE);
mErrorTextView.setVisibility(View.VISIBLE); mErrorTextView.setVisibility(View.VISIBLE);
isInErrorState = true;
break; break;
} }
case 3: { case 3: {
@ -103,6 +119,7 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
mTreeViewContainer.setVisibility(View.GONE); mTreeViewContainer.setVisibility(View.GONE);
mConnectionErrorImageView.setVisibility(View.VISIBLE); mConnectionErrorImageView.setVisibility(View.VISIBLE);
mErrorTextView.setVisibility(View.VISIBLE); mErrorTextView.setVisibility(View.VISIBLE);
isInErrorState = true;
break; break;
} }
} }
@ -116,6 +133,7 @@ public class SearchableActivity extends AppCompatActivity implements MainContrac
rootNode.setChildren(new ArrayList<TreeNode>()); rootNode.setChildren(new ArrayList<TreeNode>());
treeView.refreshTreeView(); treeView.refreshTreeView();
searchablePresenter.fetchDetailsTreeByName(detailName); searchablePresenter.fetchDetailsTreeByName(detailName);
isInErrorState = false;
} }
@Override @Override

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#D3D3D3"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
</vector>

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

@ -9,12 +9,12 @@
tools:context="ru.volgorobot.vrcatalog.view.FullScreenImageActivity" tools:context="ru.volgorobot.vrcatalog.view.FullScreenImageActivity"
android:background="@android:color/black"> android:background="@android:color/black">
<android.support.v4.view.ViewPager <ru.volgorobot.vrcatalog.additional.HackyViewPager
android:id="@+id/fullscreen_mode_viewpager" android:id="@+id/fullscreen_mode_viewpager"
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"
@ -44,11 +44,42 @@
android:text="" android:text=""
android:textAppearance="@style/TextAppearance.AppCompat.Medium" android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:visibility="invisible" android:visibility="invisible"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/searchableConnectionErrorImageView" /> app:layout_constraintTop_toBottomOf="@+id/searchableConnectionErrorImageView" />
</android.support.constraint.ConstraintLayout> <ImageView
android:id="@+id/emptySearchImage"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="70dp"
android:layout_marginBottom="52dp"
android:src="@drawable/ic_clear_gray_24dp"
android:visibility="invisible"
app:layout_constraintBottom_toTopOf="@+id/emptySearchText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.v4.widget.SwipeRefreshLayout> <TextView
android:id="@+id/emptySearchText"
android:layout_width="0dp"
android:layout_height="77dp"
android:layout_marginStart="9dp"
android:layout_marginEnd="9dp"
android:layout_marginBottom="68dp"
android:text="@string/empty_search"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:visibility="invisible"
android:textSize="18sp"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/emptySearchImage" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

View File

@ -1,27 +1,27 @@
<?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"
android:background="?attr/colorPrimary" android:background="?attr/colorPrimary"
android:theme="@style/CustomSearchStyle" android:theme="@style/MainActivity"
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

@ -1,9 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/parent_node_container_1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="80dp" android:layout_height="50dp"
android:background="?android:selectableItemBackground"> android:background="?android:selectableItemBackground">
<View android:background="#D3D3D3"
android:layout_width = "match_parent"
android:layout_height="1dp"/>
<LinearLayout <LinearLayout
android:id="@+id/node_container" android:id="@+id/node_container"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -1,10 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/parent_node_container_2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="60dp" android:layout_height="50dp"
android:orientation="vertical" android:orientation="vertical"
android:background="?android:selectableItemBackground"> android:background="?android:selectableItemBackground">
<View android:background="#D3D3D3"
android:layout_width = "match_parent"
android:layout_height="1dp"/>
<LinearLayout <LinearLayout
android:id="@+id/node_container" android:id="@+id/node_container"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -1,10 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/parent_node_container_3"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:background="?android:selectableItemBackground"> android:background="?android:selectableItemBackground">
<View android:background="#D3D3D3"
android:layout_width = "match_parent"
android:layout_height="1dp"/>
<LinearLayout <LinearLayout
android:id="@+id/node_container" android:id="@+id/node_container"
android:layout_width="wrap_content" android:layout_width="wrap_content"

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

@ -25,7 +25,9 @@
<item name="android:textColorPrimary">@android:color/black</item> <item name="android:textColorPrimary">@android:color/black</item>
<item name="android:textColorSecondary">@android:color/black</item> <item name="android:textColorSecondary">@android:color/black</item>
</style> </style>
<style name="CustomSearchStyle" parent="AppTheme"> <style name="MainActivity" parent="AppTheme.NoActionBar">
<item name="android:editTextColor">@android:color/white</item>
<item name="android:textColorHint">@android:color/white</item>
<item name="suggestionRowLayout">@layout/light_suggestion_hint</item> <item name="suggestionRowLayout">@layout/light_suggestion_hint</item>
<item name="colorControlNormal">@android:color/white</item> <item name="colorControlNormal">@android:color/white</item>
<item name="android:colorControlNormal">@android:color/white</item> <item name="android:colorControlNormal">@android:color/white</item>

View File

@ -3,4 +3,5 @@
<string name="navigation_drawer_open">Open navigation drawer</string> <string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string> <string name="navigation_drawer_close">Close navigation drawer</string>
<string name="favorites_empty">Ваш список избранного пуст</string> <string name="favorites_empty">Ваш список избранного пуст</string>
<string name="empty_search">По вашему запросу ничего не найдено.</string>
</resources> </resources>

View File

@ -8,9 +8,6 @@
<style name="MainActivity" parent="AppTheme.NoActionBar"> <style name="MainActivity" parent="AppTheme.NoActionBar">
<item name="android:editTextColor">@android:color/white</item> <item name="android:editTextColor">@android:color/white</item>
<item name="android:textColorHint">@android:color/white</item> <item name="android:textColorHint">@android:color/white</item>
</style>
<style name="CustomSearchStyle" parent="AppTheme">
<item name="suggestionRowLayout">@layout/light_suggestion_hint</item> <item name="suggestionRowLayout">@layout/light_suggestion_hint</item>
<item name="colorControlNormal">@android:color/white</item> <item name="colorControlNormal">@android:color/white</item>
</style> </style>

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