Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
e18caebad7
@ -147,7 +147,7 @@
|
||||
<PersistentState>
|
||||
<option name="values">
|
||||
<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/file/ic_cloud_off_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/action/ic_favorite_black_24dp.xml" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
@ -157,8 +157,7 @@
|
||||
</option>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="color" value="a9a9a9" />
|
||||
<entry key="outputName" value="ic_cloud_off_black_24dp" />
|
||||
<entry key="outputName" value="ic_favorite_black_24dp" />
|
||||
<entry key="sourceFile" value="$USER_HOME$" />
|
||||
</map>
|
||||
</option>
|
||||
|
Binary file not shown.
@ -6,8 +6,8 @@ android {
|
||||
applicationId "ru.volgorobot.vrcatalog"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 27
|
||||
versionCode 5
|
||||
versionName "0.3.1"
|
||||
versionCode 7
|
||||
versionName "0.5.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
compileOptions {
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?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"
|
||||
package="ru.volgorobot.vrcatalog">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
@ -12,10 +11,11 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".view.FavoritesActivity"></activity>
|
||||
<activity
|
||||
android:name=".view.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
android:theme="@style/MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@ -28,24 +28,29 @@
|
||||
android:name=".view.FullScreenImageActivity"
|
||||
android:theme="@style/AppTheme.Fullscreen" />
|
||||
<activity
|
||||
android:name=".view.DetailActivity"
|
||||
android:name=".view.ItemActivity"
|
||||
android:theme="@style/ItemActivityTheme" />
|
||||
<activity
|
||||
android:name=".view.SearchableActivity"
|
||||
android:label="Поиск"
|
||||
android:parentActivityName="ru.volgorobot.vrcatalog.view.MainActivity">
|
||||
android:parentActivityName=".view.MainActivity">
|
||||
|
||||
<!-- Parent activity meta-data to support 4.0 and lower -->
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="ru.volgorobot.vrcatalog.view.MainActivity" />
|
||||
<!-- meta tag and intent filter go into results activity -->
|
||||
<meta-data android:name="android.app.searchable"
|
||||
<meta-data
|
||||
android:name="android.app.searchable"
|
||||
android:resource="@xml/searchable" />
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEARCH" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<provider android:name=".additional.RecentSuggestionProvider"
|
||||
|
||||
<provider
|
||||
android:name=".additional.RecentSuggestionProvider"
|
||||
android:authorities="ru.volgorobot.vrcatalog.additional.RecentSuggestionProvider" />
|
||||
</application>
|
||||
|
||||
|
@ -27,12 +27,21 @@ public interface MainContract {
|
||||
CoreModel getCoreModel();
|
||||
}
|
||||
|
||||
interface ViewBinderPresenter {
|
||||
interface LevelLoaderPresenter {
|
||||
void fetchSecondLevel(FirstLevelModel firstLevelModel, TreeNode treeNode);
|
||||
void fetchThirdLevel(SecondLevelModel secondLevelModel, TreeNode treeNode);
|
||||
void fetchDetail(ThirdLevelModel thirdLevelModel);
|
||||
}
|
||||
|
||||
interface FavoritesPresenter {
|
||||
void fetchItem(int itemID);
|
||||
}
|
||||
|
||||
interface FavoritesActivityView {
|
||||
void onFailruleAnswer(int errorCode);
|
||||
void startActivityByIntent(Intent intent);
|
||||
}
|
||||
|
||||
interface ViewBinder {
|
||||
void rotateImageView();
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package ru.volgorobot.vrcatalog.additional;
|
||||
|
||||
public class DatabaseProperties {
|
||||
public final static String DATABASE_NAME = "database";
|
||||
public final static String FAVORITES_TABLE_NAME = "favorites";
|
||||
public final static int DATABASE_VERSION = 1;
|
||||
|
||||
public final static String FAVORITES_COLUMN_ID = "_id";
|
||||
public final static String FAVORITES_COLUMN_ITEM_ID = "itemID";
|
||||
public final static String FAVORITES_COLUMN_ITEM_NAME = "itemName";
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package ru.volgorobot.vrcatalog.additional;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
public class SqliteHelper extends SQLiteOpenHelper {
|
||||
public SqliteHelper(Context context) {
|
||||
super(context, DatabaseProperties.DATABASE_NAME, null, DatabaseProperties.DATABASE_VERSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase sqLiteDatabase) {
|
||||
String query = "CREATE TABLE " +
|
||||
DatabaseProperties.FAVORITES_TABLE_NAME + "(" +
|
||||
DatabaseProperties.FAVORITES_COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
|
||||
DatabaseProperties.FAVORITES_COLUMN_ITEM_ID + " INTEGER," +
|
||||
DatabaseProperties.FAVORITES_COLUMN_ITEM_NAME + " TEXT);";
|
||||
sqLiteDatabase.execSQL(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
|
||||
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + DatabaseProperties.FAVORITES_TABLE_NAME);
|
||||
onCreate(sqLiteDatabase);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package ru.volgorobot.vrcatalog.additional.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ru.volgorobot.vrcatalog.model.FavoritesListModel;
|
||||
import ru.volgorobot.vrcatalog.presenters.FavoritesDBPresenter;
|
||||
|
||||
public class FavoritesListAdapter extends ArrayAdapter<FavoritesListModel> {
|
||||
private FavoritesDBPresenter db;
|
||||
|
||||
public FavoritesListAdapter(Context context, int resource, List<FavoritesListModel> objects) {
|
||||
super(context, resource, objects);
|
||||
db = new FavoritesDBPresenter(context);
|
||||
}
|
||||
|
||||
public void updateData() {
|
||||
super.clear();
|
||||
super.addAll(db.selectAll());
|
||||
}
|
||||
|
||||
public int getArraySize() {
|
||||
return db.selectAll().size();
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ru.volgorobot.vrcatalog.additional;
|
||||
package ru.volgorobot.vrcatalog.additional.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
@ -16,7 +16,7 @@ import com.squareup.picasso.Picasso;
|
||||
|
||||
public class FullscreenImagePagerAdapter extends PagerAdapter {
|
||||
/**
|
||||
* This class is designed to control the ViewPager (images of item) in the activity of viewing details of items (DetailActivity).
|
||||
* This class is designed to control the ViewPager (images of item) in FullscreenImageActivity.
|
||||
*/
|
||||
|
||||
private Context context;
|
||||
@ -64,6 +64,9 @@ public class FullscreenImagePagerAdapter extends PagerAdapter {
|
||||
container.removeView((View) object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener for hiding the actionbar when you click on the picture
|
||||
*/
|
||||
private class PhotoTapListener implements OnPhotoTapListener, View.OnSystemUiVisibilityChangeListener {
|
||||
@Override
|
||||
public void onPhotoTap(ImageView view, float x, float y) {
|
@ -1,4 +1,4 @@
|
||||
package ru.volgorobot.vrcatalog.additional;
|
||||
package ru.volgorobot.vrcatalog.additional.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -13,16 +13,14 @@ import android.widget.ImageView;
|
||||
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
import ru.volgorobot.vrcatalog.R;
|
||||
import ru.volgorobot.vrcatalog.view.DetailActivity;
|
||||
import ru.volgorobot.vrcatalog.view.FullScreenImageActivity;
|
||||
|
||||
public class ImagePagerAdapter extends PagerAdapter {
|
||||
/**
|
||||
* This class is designed to control the ViewPager (images of item) in the activity of viewing details of items (DetailActivity).
|
||||
* This class is designed to control the ViewPager (images of item) in the activity of viewing details of items (ItemActivity).
|
||||
*/
|
||||
|
||||
private Context context;
|
@ -1,4 +1,4 @@
|
||||
package ru.volgorobot.vrcatalog.additional;
|
||||
package ru.volgorobot.vrcatalog.additional.adapters;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
@ -0,0 +1,35 @@
|
||||
package ru.volgorobot.vrcatalog.model;
|
||||
|
||||
public class FavoritesListModel {
|
||||
private int id;
|
||||
private int itemID;
|
||||
private String itemName;
|
||||
|
||||
public FavoritesListModel(int itemID, String itemName) {
|
||||
this.itemID = itemID;
|
||||
this.itemName = itemName;
|
||||
}
|
||||
|
||||
public FavoritesListModel(int id, int itemID, String itemName) {
|
||||
this.id = id;
|
||||
this.itemID = itemID;
|
||||
this.itemName = itemName;
|
||||
}
|
||||
|
||||
public int getItemID() {
|
||||
return itemID;
|
||||
}
|
||||
|
||||
public String getItemName() {
|
||||
return itemName;
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getItemName();
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ import ru.volgorobot.vrcatalog.model.SecondLevelModel;
|
||||
public class SecondLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder {
|
||||
TextView textView;
|
||||
ImageView imageView;
|
||||
MainContract.ViewBinderPresenter viewBinderPresenter;
|
||||
MainContract.LevelLoaderPresenter viewBinderPresenter;
|
||||
|
||||
|
||||
public SecondLevelNodeViewBinder(View itemView, MainContract.MainActivityView mView, Context context) {
|
||||
|
@ -13,7 +13,7 @@ import ru.volgorobot.vrcatalog.model.ThirdLevelModel;
|
||||
|
||||
public class ThirdLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder {
|
||||
TextView textView;
|
||||
MainContract.ViewBinderPresenter viewBinderPresenter;
|
||||
MainContract.LevelLoaderPresenter viewBinderPresenter;
|
||||
|
||||
public ThirdLevelNodeViewBinder(View itemView, Context context, MainContract.MainActivityView mView) {
|
||||
super(itemView);
|
||||
|
@ -0,0 +1,83 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package ru.volgorobot.vrcatalog.presenters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import ru.volgorobot.vrcatalog.MainContract;
|
||||
import ru.volgorobot.vrcatalog.additional.NetworkErrorException;
|
||||
import ru.volgorobot.vrcatalog.additional.ResultWithErrorCode;
|
||||
import ru.volgorobot.vrcatalog.model.CoreModel;
|
||||
import ru.volgorobot.vrcatalog.model.DetailModel;
|
||||
import ru.volgorobot.vrcatalog.view.FavoritesActivity;
|
||||
import ru.volgorobot.vrcatalog.view.ItemActivity;
|
||||
|
||||
public class FavoritesPresenter implements MainContract.FavoritesPresenter {
|
||||
private Context mContext;
|
||||
private MainContract.MainModel mainModel;
|
||||
private MainContract.FavoritesActivityView mView;
|
||||
|
||||
public FavoritesPresenter(Context context, FavoritesActivity view) {
|
||||
this.mContext = context;
|
||||
this.mainModel = new CoreModel(context);
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchItem(int itemID) {
|
||||
new AsyncTask<Integer, Void, ResultWithErrorCode<DetailModel>>() {
|
||||
@Override
|
||||
protected ResultWithErrorCode<DetailModel> doInBackground(Integer... integers) {
|
||||
ArrayList<DetailModel> detail = null;
|
||||
try {
|
||||
detail = mainModel.fetchDetailByID(integers[0]);
|
||||
} catch (NetworkErrorException networkErrorException) {
|
||||
return new ResultWithErrorCode<>(detail.get(0), networkErrorException.getErrorCode());
|
||||
} catch (NullPointerException nullPointerException) {
|
||||
return new ResultWithErrorCode<>(detail.get(0), 3);
|
||||
}
|
||||
return new ResultWithErrorCode<>(detail.get(0), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(ResultWithErrorCode<DetailModel> result) {
|
||||
super.onPostExecute(result);
|
||||
switch (result.getErrorCode()) {
|
||||
case 0: {
|
||||
Intent intent = new Intent(mContext, ItemActivity.class);
|
||||
intent.putExtra("itemID", result.getData().getID().toString());
|
||||
intent.putExtra("detailName", result.getData().getName());
|
||||
intent.putExtra("detailQuantity", result.getData().getNumber().toString());
|
||||
intent.putExtra("detailPrice", result.getData().getPrice());
|
||||
intent.putExtra("detailCountry", result.getData().getCountry());
|
||||
intent.putExtra("detailAnalogue", result.getData().getAnalogue());
|
||||
intent.putExtra("detailDatasheet", result.getData().getDocURL());
|
||||
intent.putExtra("detailNotes", result.getData().getNotes());
|
||||
mView.startActivityByIntent(intent);
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
mView.onFailruleAnswer(1);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
mView.onFailruleAnswer(2);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
mView.onFailruleAnswer(3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}.execute(itemID);
|
||||
}
|
||||
}
|
@ -22,9 +22,6 @@ import ru.volgorobot.vrcatalog.model.CoreModel;
|
||||
import ru.volgorobot.vrcatalog.model.ImageItemModel;
|
||||
|
||||
public class ItemPresenter implements MainContract.ItemPresenter {
|
||||
|
||||
// TODO
|
||||
|
||||
private MainContract.ItemView mView;
|
||||
private Context context;
|
||||
private MainContract.MainModel coreModel;
|
||||
|
@ -15,9 +15,9 @@ import ru.volgorobot.vrcatalog.model.DetailModel;
|
||||
import ru.volgorobot.vrcatalog.model.FirstLevelModel;
|
||||
import ru.volgorobot.vrcatalog.model.SecondLevelModel;
|
||||
import ru.volgorobot.vrcatalog.model.ThirdLevelModel;
|
||||
import ru.volgorobot.vrcatalog.view.DetailActivity;
|
||||
import ru.volgorobot.vrcatalog.view.ItemActivity;
|
||||
|
||||
public class ViewBinderPresenter implements MainContract.ViewBinderPresenter {
|
||||
public class ViewBinderPresenter implements MainContract.LevelLoaderPresenter {
|
||||
private MainContract.MainActivityView mView;
|
||||
private MainContract.MainModel coreModel;
|
||||
private MainContract.ViewBinder viewBinder;
|
||||
@ -170,7 +170,7 @@ public class ViewBinderPresenter implements MainContract.ViewBinderPresenter {
|
||||
super.onPostExecute(result);
|
||||
switch (result.getErrorCode()) {
|
||||
case 0: {
|
||||
Intent intent = new Intent(context, DetailActivity.class);
|
||||
Intent intent = new Intent(context, ItemActivity.class);
|
||||
intent.putExtra("itemID", result.getData().getID().toString());
|
||||
intent.putExtra("detailName", result.getData().getName());
|
||||
intent.putExtra("detailQuantity", result.getData().getNumber().toString());
|
||||
|
@ -0,0 +1,149 @@
|
||||
package ru.volgorobot.vrcatalog.view;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import ru.volgorobot.vrcatalog.MainContract;
|
||||
import ru.volgorobot.vrcatalog.R;
|
||||
import ru.volgorobot.vrcatalog.additional.adapters.FavoritesListAdapter;
|
||||
import ru.volgorobot.vrcatalog.model.FavoritesListModel;
|
||||
import ru.volgorobot.vrcatalog.presenters.FavoritesDBPresenter;
|
||||
import ru.volgorobot.vrcatalog.presenters.FavoritesPresenter;
|
||||
|
||||
public class FavoritesActivity extends AppCompatActivity implements MainContract.FavoritesActivityView {
|
||||
private FavoritesDBPresenter db;
|
||||
private FavoritesListAdapter adapter;
|
||||
private MainContract.FavoritesPresenter mPresenter;
|
||||
|
||||
private ListView listView;
|
||||
private ImageView favoritesEmptyImage;
|
||||
private TextView favoritesEmptyText;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_favorites);
|
||||
|
||||
mPresenter = new FavoritesPresenter(FavoritesActivity.this, this);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setHomeButtonEnabled(true);
|
||||
actionBar.setTitle("Избранное");
|
||||
|
||||
db = new FavoritesDBPresenter(FavoritesActivity.this);
|
||||
|
||||
initViews();
|
||||
}
|
||||
|
||||
public void initViews() {
|
||||
listView = findViewById(R.id.favorites_list_view);
|
||||
registerForContextMenu(listView);
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
FavoritesListModel model = (FavoritesListModel) listView.getItemAtPosition(i);
|
||||
mPresenter.fetchItem(model.getItemID());
|
||||
}
|
||||
});
|
||||
favoritesEmptyImage = findViewById(R.id.favorites_empty_image);
|
||||
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() {
|
||||
if(adapter.getArraySize() == 0) {
|
||||
listView.setVisibility(View.GONE);
|
||||
favoritesEmptyImage.setVisibility(View.VISIBLE);
|
||||
favoritesEmptyText.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
listView.setVisibility(View.VISIBLE);
|
||||
favoritesEmptyImage.setVisibility(View.INVISIBLE);
|
||||
favoritesEmptyText.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
|
||||
switch (item.getItemId()) {
|
||||
case 0: {
|
||||
FavoritesListModel model = (FavoritesListModel) listView.getItemAtPosition(info.position);
|
||||
db.removeItem(model.getID());
|
||||
updateListView();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateListView() {
|
||||
adapter.updateData();
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
||||
if (v.getId() == R.id.favorites_list_view) {
|
||||
menu.add(0, 0, 0,"Удалить");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch(item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailruleAnswer(int errorCode) {
|
||||
switch (errorCode) {
|
||||
case 1: {
|
||||
Toast.makeText(FavoritesActivity.this, "Ошибка сети. Проверьте подключение к сети или данные подключения к API!", Toast.LENGTH_LONG).show();
|
||||
Log.e("FavoritesActivity", "Network Error! Re-check your connection credentials or network settings!");
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
Toast.makeText(FavoritesActivity.this, "Ответ от сервера неверен! Перепроверьте данные подключения!", Toast.LENGTH_LONG).show();
|
||||
Log.e("FavoritesActivity", "Answer of server is wrong! Re-check your connection credentials!");
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
Toast.makeText(FavoritesActivity.this, "Вы ввели неверный URL. Пример: http://example.ru", Toast.LENGTH_LONG).show();
|
||||
Log.e("MainActivity", "Invalid-formatted URL. Please, check URL (change his if it need) and try again.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityByIntent(Intent intent) {
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
updateListView();
|
||||
checkForEmptyContent();
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import ru.volgorobot.vrcatalog.R;
|
||||
import ru.volgorobot.vrcatalog.additional.FullscreenImagePagerAdapter;
|
||||
import ru.volgorobot.vrcatalog.additional.adapters.FullscreenImagePagerAdapter;
|
||||
|
||||
public class FullScreenImageActivity extends AppCompatActivity {
|
||||
private Toolbar mToolbar;
|
||||
|
@ -9,27 +9,33 @@ import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
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.MainContract;
|
||||
import ru.volgorobot.vrcatalog.R;
|
||||
import ru.volgorobot.vrcatalog.additional.ImagePagerAdapter;
|
||||
import ru.volgorobot.vrcatalog.additional.PropertiesListAdapter;
|
||||
import ru.volgorobot.vrcatalog.additional.adapters.ImagePagerAdapter;
|
||||
import ru.volgorobot.vrcatalog.additional.adapters.PropertiesListAdapter;
|
||||
|
||||
public class DetailActivity extends AppCompatActivity implements MainContract.ItemView {
|
||||
public class ItemActivity extends AppCompatActivity implements MainContract.ItemView {
|
||||
private MainContract.ItemPresenter mPresenter;
|
||||
private ViewPager viewPager;
|
||||
private ListView propertiesList;
|
||||
private ImagePagerAdapter imagePagerAdapter;
|
||||
private boolean inFavorites;
|
||||
private FavoritesDBPresenter db;
|
||||
private int itemID;
|
||||
private String itemName;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -41,10 +47,11 @@ public class DetailActivity extends AppCompatActivity implements MainContract.It
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||
initializeViews();
|
||||
mPresenter = new ItemPresenter(DetailActivity.this, this);
|
||||
mPresenter = new ItemPresenter(ItemActivity.this, this);
|
||||
Intent intent = getIntent();
|
||||
|
||||
((TextView) findViewById(R.id.itemName)).setText(intent.getStringExtra("detailName"));
|
||||
itemName = intent.getStringExtra("detailName");
|
||||
((TextView) findViewById(R.id.itemName)).setText(itemName);
|
||||
String tmp = intent.getStringExtra("detailPrice");
|
||||
if(tmp.equals("0")) {
|
||||
tmp = "Уточните у продавца";
|
||||
@ -53,13 +60,18 @@ public class DetailActivity extends AppCompatActivity implements MainContract.It
|
||||
}
|
||||
((TextView) findViewById(R.id.itemPrice)).setText(tmp);
|
||||
|
||||
LinkedHashMap<String, String> extrasMap = getIntentExtras(intent);
|
||||
LinkedHashMap<String, String> intentDataForListView = getIntentExtras(intent);
|
||||
itemID = Integer.parseInt(intent.getStringExtra("itemID"));
|
||||
intentDataForListView.get("detailName");
|
||||
db = new FavoritesDBPresenter(ItemActivity.this);
|
||||
|
||||
propertiesList = findViewById(R.id.propertiesList);
|
||||
PropertiesListAdapter propertiesListAdapter = new PropertiesListAdapter(extrasMap);
|
||||
PropertiesListAdapter propertiesListAdapter = new PropertiesListAdapter(intentDataForListView);
|
||||
propertiesList.setAdapter(propertiesListAdapter);
|
||||
|
||||
mPresenter.getImagesByItemID(Integer.parseInt(intent.getStringExtra("itemID")));
|
||||
|
||||
inFavorites = db.inFavoritesList(itemID);
|
||||
}
|
||||
|
||||
void initializeViews() {
|
||||
@ -119,18 +131,18 @@ public class DetailActivity extends AppCompatActivity implements MainContract.It
|
||||
public void onFailureAnswer(int errorCode) {
|
||||
switch (errorCode) {
|
||||
case 1: {
|
||||
Toast.makeText(DetailActivity.this, "Ошибка сети. Проверьте подключение к сети или данные подключения к API!", Toast.LENGTH_LONG).show();
|
||||
Log.e("DetailActivity", "Network Error! Re-check your connection credentials or network settings!");
|
||||
Toast.makeText(ItemActivity.this, "Ошибка сети. Проверьте подключение к сети или данные подключения к API!", Toast.LENGTH_LONG).show();
|
||||
Log.e("ItemActivity", "Network Error! Re-check your connection credentials or network settings!");
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
Toast.makeText(DetailActivity.this, "Ответ от сервера неверен! Перепроверьте данные подключения!", Toast.LENGTH_LONG).show();
|
||||
Log.e("DetailActivity", "Answer of server is wrong! Re-check your connection credentials!");
|
||||
Toast.makeText(ItemActivity.this, "Ответ от сервера неверен! Перепроверьте данные подключения!", Toast.LENGTH_LONG).show();
|
||||
Log.e("ItemActivity", "Answer of server is wrong! Re-check your connection credentials!");
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
Toast.makeText(DetailActivity.this, "Вы ввели неверный URL. Пример: http://example.ru", Toast.LENGTH_LONG).show();
|
||||
Log.e("DetailActivity", "Invalid-formatted URL. Please, check URL (change his if it need) and try again.");
|
||||
Toast.makeText(ItemActivity.this, "Вы ввели неверный URL. Пример: http://example.ru", Toast.LENGTH_LONG).show();
|
||||
Log.e("ItemActivity", "Invalid-formatted URL. Please, check URL (change his if it need) and try again.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -138,7 +150,7 @@ public class DetailActivity extends AppCompatActivity implements MainContract.It
|
||||
|
||||
@Override
|
||||
public void setViewPagerContent(String[] uris) {
|
||||
imagePagerAdapter = new ImagePagerAdapter(DetailActivity.this, uris);
|
||||
imagePagerAdapter = new ImagePagerAdapter(ItemActivity.this, uris);
|
||||
TabLayout tabLayout = findViewById(R.id.tabDots);
|
||||
viewPager.setAdapter(imagePagerAdapter);
|
||||
setViewPagerScrollListener();
|
||||
@ -203,4 +215,34 @@ public class DetailActivity extends AppCompatActivity implements MainContract.It
|
||||
};
|
||||
viewPager.setOnPageChangeListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.item_activity_menu, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
MenuItem addToFavorites = menu.findItem(R.id.action_favorite);
|
||||
MenuItem deleteFromFavorites = menu.findItem(R.id.action_unfavorite);
|
||||
|
||||
addToFavorites.setOnMenuItemClickListener((MenuItem menuItem) -> {
|
||||
db.add(new FavoritesListModel(0, itemID, itemName));
|
||||
inFavorites = true;
|
||||
this.invalidateOptionsMenu();
|
||||
return true;
|
||||
});
|
||||
deleteFromFavorites.setOnMenuItemClickListener((MenuItem menuItem) -> {
|
||||
db.removeItem(db.getFavoriteID(itemID));
|
||||
inFavorites = false;
|
||||
this.invalidateOptionsMenu();
|
||||
return true;
|
||||
});
|
||||
|
||||
addToFavorites.setVisible(!inFavorites);
|
||||
deleteFromFavorites.setVisible(inFavorites);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -101,7 +101,6 @@ public class MainActivity extends AppCompatActivity
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@SuppressWarnings("StatementWithEmptyBody")
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(MenuItem item) {
|
||||
// Handle navigation view item clicks here.
|
||||
@ -113,6 +112,8 @@ public class MainActivity extends AppCompatActivity
|
||||
|
||||
} else if (id == R.id.nav_about) {
|
||||
startActivity(new Intent(this, AboutActivity.class));
|
||||
} else if(id == R.id.nav_favorites) {
|
||||
startActivity(new Intent(this, FavoritesActivity.class));
|
||||
}
|
||||
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
|
9
app/src/main/res/drawable/ic_favorite_black_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_favorite_black_24dp.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>
|
||||
</vector>
|
@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#000000"
|
||||
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="M16.5,3c-1.74,0 -3.41,0.81 -4.5,2.09C10.91,3.81 9.24,3 7.5,3 4.42,3 2,5.42 2,8.5c0,3.78 3.4,6.86 8.55,11.54L12,21.35l1.45,-1.32C18.6,15.36 22,12.28 22,8.5 22,5.42 19.58,3 16.5,3zM12.1,18.55l-0.1,0.1 -0.1,-0.1C7.14,14.24 4,11.39 4,8.5 4,6.5 5.5,5 7.5,5c1.54,0 3.04,0.99 3.57,2.36h1.87C13.46,5.99 14.96,5 16.5,5c2,0 3.5,1.5 3.5,3.5 0,2.89 -3.14,5.74 -7.9,10.05z"/>
|
||||
</vector>
|
@ -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="M16.5,3c-1.74,0 -3.41,0.81 -4.5,2.09C10.91,3.81 9.24,3 7.5,3 4.42,3 2,5.42 2,8.5c0,3.78 3.4,6.86 8.55,11.54L12,21.35l1.45,-1.32C18.6,15.36 22,12.28 22,8.5 22,5.42 19.58,3 16.5,3zM12.1,18.55l-0.1,0.1 -0.1,-0.1C7.14,14.24 4,11.39 4,8.5 4,6.5 5.5,5 7.5,5c1.54,0 3.04,0.99 3.57,2.36h1.87C13.46,5.99 14.96,5 16.5,5c2,0 3.5,1.5 3.5,3.5 0,2.89 -3.14,5.74 -7.9,10.05z"/>
|
||||
</vector>
|
5
app/src/main/res/drawable/ic_favorite_red_24dp.xml
Normal file
5
app/src/main/res/drawable/ic_favorite_red_24dp.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#FF0000"
|
||||
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="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>
|
||||
</vector>
|
@ -17,7 +17,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="VRCatalog"
|
||||
android:text="uCatalog"
|
||||
android:textAppearance="@android:style/TextAppearance.Large" />
|
||||
|
||||
<TextView
|
||||
@ -25,7 +25,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Программа для просмотра каталога деталей Volgorobot" />
|
||||
android:gravity="center"
|
||||
android:text="Программа для просмотра каталогов" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
47
app/src/main/res/layout/activity_favorites.xml
Normal file
47
app/src/main/res/layout/activity_favorites.xml
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.FavoritesActivity">
|
||||
|
||||
<ListView
|
||||
android:id="@+id/favorites_list_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/favorites_empty_image"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="70dp"
|
||||
android:layout_marginBottom="52dp"
|
||||
android:src="@drawable/ic_favorite_border_grey_24dp"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintBottom_toTopOf="@+id/favorites_empty_text"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/favorites_empty_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="77dp"
|
||||
android:layout_marginStart="9dp"
|
||||
android:layout_marginEnd="9dp"
|
||||
android:layout_marginBottom="68dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/favorites_empty"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textSize="24sp"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/favorites_empty_image" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
@ -16,6 +16,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:theme="@style/CustomSearchStyle"
|
||||
app:titleTextColor="@android:color/white"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
@ -52,6 +52,8 @@
|
||||
android:text=""
|
||||
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"
|
||||
|
95
app/src/main/res/layout/light_suggestion_hint.xml
Normal file
95
app/src/main/res/layout/light_suggestion_hint.xml
Normal file
@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="58dip"
|
||||
android:background="@android:color/white"
|
||||
style="@style/RtlOverlay.Widget.AppCompat.Search.DropDown">
|
||||
|
||||
<!-- Icons come first in the layout, since their placement doesn't depend on
|
||||
the placement of the text views. -->
|
||||
<ImageView
|
||||
android:id="@android:id/icon1"
|
||||
android:layout_width="48dip"
|
||||
android:layout_height="48dip"
|
||||
android:scaleType="centerInside"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:tint="@android:color/black"
|
||||
android:visibility="invisible"
|
||||
style="@style/RtlOverlay.Widget.AppCompat.Search.DropDown.Icon1" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/edit_query"
|
||||
android:layout_width="48dip"
|
||||
android:layout_height="48dip"
|
||||
android:scaleType="centerInside"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:visibility="gone"
|
||||
style="@style/RtlOverlay.Widget.AppCompat.Search.DropDown.Query" />
|
||||
|
||||
<ImageView
|
||||
android:id="@android:id/icon2"
|
||||
android:layout_width="48dip"
|
||||
android:layout_height="48dip"
|
||||
android:scaleType="centerInside"
|
||||
android:layout_alignWithParentIfMissing="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:visibility="gone"
|
||||
style="@style/RtlOverlay.Widget.AppCompat.Search.DropDown.Icon2" />
|
||||
|
||||
|
||||
<!-- The subtitle comes before the title, since the height of the title depends on whether the
|
||||
subtitle is visible or gone. -->
|
||||
<TextView android:id="@android:id/text2"
|
||||
style="?android:attr/dropDownItemStyle"
|
||||
android:singleLine="true"
|
||||
android:layout_width="match_parent"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="16sp"
|
||||
tools:text="id/text2"
|
||||
android:layout_height="29dip"
|
||||
android:paddingBottom="4dip"
|
||||
android:gravity="top"
|
||||
android:layout_alignWithParentIfMissing="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<!-- The title is placed above the subtitle, if there is one. If there is no
|
||||
subtitle, it fills the parent. -->
|
||||
<TextView android:id="@android:id/text1"
|
||||
style="?android:attr/dropDownItemStyle"
|
||||
android:singleLine="true"
|
||||
android:textColor="@android:color/black"
|
||||
tools:text="id/text1"
|
||||
android:textStyle="bold"
|
||||
android:textSize="18sp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_above="@android:id/text2" />
|
||||
|
||||
</RelativeLayout>
|
@ -8,6 +8,10 @@
|
||||
android:icon="@drawable/ic_home"
|
||||
android:title="Главная"
|
||||
android:checked="true" />
|
||||
<item
|
||||
android:id="@+id/nav_favorites"
|
||||
android:icon="@drawable/ic_favorite_black_24dp"
|
||||
android:title="Избранное" />
|
||||
<item
|
||||
android:id="@+id/nav_settings"
|
||||
android:icon="@drawable/ic_settings_applications"
|
||||
@ -16,5 +20,4 @@
|
||||
android:id="@+id/nav_about"
|
||||
android:icon="@drawable/ic_help"
|
||||
android:title="О программе" />
|
||||
|
||||
</menu>
|
||||
|
16
app/src/main/res/menu/item_activity_menu.xml
Normal file
16
app/src/main/res/menu/item_activity_menu.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_favorite"
|
||||
android:icon="@drawable/ic_favorite_border_black_24dp"
|
||||
app:showAsAction="always|collapseActionView"
|
||||
android:title="Добавить в избранные"
|
||||
android:visible="false"/>
|
||||
<item
|
||||
android:id="@+id/action_unfavorite"
|
||||
android:icon="@drawable/ic_favorite_red_24dp"
|
||||
app:showAsAction="always|collapseActionView"
|
||||
android:title="Удалить из избранного"
|
||||
android:visible="false"/>
|
||||
</menu>
|
@ -22,7 +22,12 @@
|
||||
<item name="background">@android:color/transparent</item>
|
||||
</style>
|
||||
<style name="ItemActionBar" parent="ItemActivityTheme">
|
||||
<item name="android:textColorPrimary">@android:color/white</item>
|
||||
<item name="android:textColorSecondary">@android:color/white</item>
|
||||
<item name="android:textColorPrimary">@android:color/black</item>
|
||||
<item name="android:textColorSecondary">@android:color/black</item>
|
||||
</style>
|
||||
<style name="CustomSearchStyle" parent="AppTheme">
|
||||
<item name="suggestionRowLayout">@layout/light_suggestion_hint</item>
|
||||
<item name="colorControlNormal">@android:color/white</item>
|
||||
<item name="android:colorControlNormal">@android:color/white</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
@ -1,5 +1,6 @@
|
||||
<resources>
|
||||
<string name="app_name">VRCatalog</string>
|
||||
<string name="app_name">uCatalog</string>
|
||||
<string name="navigation_drawer_open">Open navigation drawer</string>
|
||||
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||
<string name="favorites_empty">Ваш список избранного пуст</string>
|
||||
</resources>
|
||||
|
@ -1,13 +1,20 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="MainActivity" parent="AppTheme.NoActionBar">
|
||||
<item name="android:editTextColor">@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="colorControlNormal">@android:color/white</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
@ -16,14 +23,24 @@
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
|
||||
<style name="ItemActivityTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<item name="android:windowTranslucentStatus">true</item>
|
||||
</style>
|
||||
<style name="AppTheme.Fullscreen">
|
||||
<item name="android:windowFullscreen">true</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="android:windowTranslucentStatus">true</item>
|
||||
<item name="android:windowTranslucentNavigation">true</item>
|
||||
</style>
|
||||
<style name="ItemActivityTheme" parent="AppTheme">
|
||||
<item name="android:windowTranslucentStatus">true</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
<style name="TransparentActionBar" parent="Widget.AppCompat.ActionBar.Solid">
|
||||
<item name="android:background">@android:color/transparent</item>
|
||||
<item name="background">@android:color/transparent</item>
|
||||
</style>
|
||||
<style name="ItemActionBar" parent="ItemActivityTheme">
|
||||
<item name="android:textColorPrimary">@android:color/black</item>
|
||||
<item name="android:textColorSecondary">@android:color/black</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user