Merge branch 'develop' into 'master'
v0.2.0 See merge request ChronosX88/VRCatalog!3
This commit is contained in:
commit
ddecb93884
@ -3,6 +3,11 @@
|
|||||||
<component name="WizardSettings">
|
<component name="WizardSettings">
|
||||||
<option name="children">
|
<option name="children">
|
||||||
<map>
|
<map>
|
||||||
|
<entry key="imageWizard">
|
||||||
|
<value>
|
||||||
|
<PersistentState />
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
<entry key="vectorWizard">
|
<entry key="vectorWizard">
|
||||||
<value>
|
<value>
|
||||||
<PersistentState>
|
<PersistentState>
|
||||||
@ -18,7 +23,7 @@
|
|||||||
<PersistentState>
|
<PersistentState>
|
||||||
<option name="values">
|
<option name="values">
|
||||||
<map>
|
<map>
|
||||||
<entry key="url" value="jar:file:/home/chronosx/Документы/bin/Android%20Studio/plugins/android/lib/android.jar!/images/material_design_icons/hardware/ic_keyboard_arrow_right_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_search_black_24dp.xml" />
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
</PersistentState>
|
</PersistentState>
|
||||||
@ -28,7 +33,8 @@
|
|||||||
</option>
|
</option>
|
||||||
<option name="values">
|
<option name="values">
|
||||||
<map>
|
<map>
|
||||||
<entry key="outputName" value="ic_keyboard_arrow_right_black_24dp" />
|
<entry key="color" value="ffffff" />
|
||||||
|
<entry key="outputName" value="ic_search_white_24dp" />
|
||||||
<entry key="sourceFile" value="$USER_HOME$" />
|
<entry key="sourceFile" value="$USER_HOME$" />
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
|
Binary file not shown.
BIN
.idea/caches/gradle_models.ser
Normal file
BIN
.idea/caches/gradle_models.ser
Normal file
Binary file not shown.
@ -3,6 +3,9 @@
|
|||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
<compositeConfiguration>
|
||||||
|
<compositeBuild compositeDefinitionSource="SCRIPT" />
|
||||||
|
</compositeConfiguration>
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
|
6
.idea/render.experimental.xml
Normal file
6
.idea/render.experimental.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RenderSettings">
|
||||||
|
<option name="showDecorations" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -23,7 +23,22 @@
|
|||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".view.SettingsActivity" />
|
<activity android:name=".view.SettingsActivity" />
|
||||||
<activity android:name=".view.AboutActivity" />
|
<activity android:name=".view.AboutActivity" />
|
||||||
<activity android:name=".view.DetailActivity"></activity>
|
<activity android:name=".view.DetailActivity" />
|
||||||
|
<activity
|
||||||
|
android:name=".view.SearchableActivity"
|
||||||
|
android:label="Поиск"
|
||||||
|
android:parentActivityName="ru.volgorobot.vrcatalog.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"
|
||||||
|
android:resource="@xml/searchable" />
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.SEARCH" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -43,5 +43,18 @@ public interface MainContract {
|
|||||||
ArrayList<DetailModel> fetchDetailByID(int detailID) throws NetworkErrorException, NullPointerException;
|
ArrayList<DetailModel> fetchDetailByID(int detailID) throws NetworkErrorException, NullPointerException;
|
||||||
void reinitializeApi() throws IllegalStateException;
|
void reinitializeApi() throws IllegalStateException;
|
||||||
boolean getApiState();
|
boolean getApiState();
|
||||||
|
ArrayList<ThirdLevelModel> fetchDetailsByName(String name) throws NetworkErrorException, NullPointerException;
|
||||||
|
ArrayList<FirstLevelModel> fetchCategoryByID(int id) throws NetworkErrorException, NullPointerException;
|
||||||
|
ArrayList<SecondLevelModel> fetchSubCategoryByID(int id) throws NetworkErrorException, NullPointerException;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SearchablePresenter {
|
||||||
|
void fetchDetailsTreeByName(String name);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SearchableActivityView {
|
||||||
|
void setTreeViewChildren(ArrayList<TreeNode> children);
|
||||||
|
void onFailureAnswer(int errorCode);
|
||||||
|
void swipeLayoutSetRefreshing(boolean state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,170 @@
|
|||||||
|
package ru.volgorobot.vrcatalog;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import me.texy.treeview.TreeNode;
|
||||||
|
import ru.volgorobot.vrcatalog.additional.NetworkErrorException;
|
||||||
|
import ru.volgorobot.vrcatalog.model.CoreModel;
|
||||||
|
import ru.volgorobot.vrcatalog.model.FirstLevelModel;
|
||||||
|
import ru.volgorobot.vrcatalog.model.SecondLevelModel;
|
||||||
|
import ru.volgorobot.vrcatalog.model.ThirdLevelModel;
|
||||||
|
|
||||||
|
public class SearchablePresenter implements MainContract.SearchablePresenter {
|
||||||
|
private MainContract.SearchableActivityView mView;
|
||||||
|
private MainContract.MainModel coreModel;
|
||||||
|
private Activity activity;
|
||||||
|
|
||||||
|
public SearchablePresenter(MainContract.SearchableActivityView mView, Context context, Activity activity) {
|
||||||
|
this.mView = mView;
|
||||||
|
this.coreModel = new CoreModel(context);
|
||||||
|
this.activity = activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fetchDetailsTreeByName(String name) {
|
||||||
|
mView.swipeLayoutSetRefreshing(true);
|
||||||
|
ArrayList<FirstLevelModel> categories = new ArrayList<>();
|
||||||
|
ArrayList<SecondLevelModel> subcategories = new ArrayList<>();
|
||||||
|
ArrayList<ThirdLevelModel> details = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
new AsyncTask<Void, Void, Integer>() {
|
||||||
|
@Override
|
||||||
|
protected Integer doInBackground(Void... voids) {
|
||||||
|
try {
|
||||||
|
try {
|
||||||
|
details.addAll(coreModel.fetchDetailsByName(name));
|
||||||
|
} catch (NetworkErrorException networkErrorException) {
|
||||||
|
return networkErrorException.getErrorCode();
|
||||||
|
} catch (NullPointerException nullPointerException) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < details.size(); i++) {
|
||||||
|
try {
|
||||||
|
if(isHaveDuplicate(subcategories,details.get(i).getDetailSubTypeId()))
|
||||||
|
continue;
|
||||||
|
subcategories.add(coreModel.fetchSubCategoryByID(details.get(i).getDetailSubTypeId()).get(0));
|
||||||
|
} catch (NetworkErrorException networkErrorException) {
|
||||||
|
return networkErrorException.getErrorCode();
|
||||||
|
} catch (NullPointerException nullPointerException) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < subcategories.size(); i++) {
|
||||||
|
try {
|
||||||
|
if(isHaveDuplicate(categories, subcategories.get(i).getDetailTypeId()))
|
||||||
|
continue;
|
||||||
|
categories.add(coreModel.fetchCategoryByID(subcategories.get(i).getDetailTypeId()).get(0));
|
||||||
|
} catch (NetworkErrorException networkErrorException) {
|
||||||
|
return networkErrorException.getErrorCode();
|
||||||
|
} catch (NullPointerException nullPointerException) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Integer resultCode) {
|
||||||
|
super.onPostExecute(resultCode);
|
||||||
|
switch (resultCode) {
|
||||||
|
case 0: {
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
mView.onFailureAnswer(1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
mView.onFailureAnswer(2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: {
|
||||||
|
mView.onFailureAnswer(3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
|
|
||||||
|
new AsyncTask<Void, Void, ArrayList<TreeNode>>() {
|
||||||
|
@Override
|
||||||
|
protected ArrayList<TreeNode> doInBackground(Void... voids) {
|
||||||
|
ArrayList<TreeNode> treeNodes = new ArrayList<>();
|
||||||
|
for (int i = 0; i < categories.size(); i++) {
|
||||||
|
treeNodes.add(new TreeNode(categories.get(i)));
|
||||||
|
treeNodes.get(i).setLevel(0);
|
||||||
|
ArrayList<SecondLevelModel> secondLevelModels = getSecondModelsByCategoryID(subcategories, categories.get(i).getID());
|
||||||
|
for (int j = 0; j < secondLevelModels.size(); j++) {
|
||||||
|
TreeNode treeNode = new TreeNode(secondLevelModels.get(j));
|
||||||
|
treeNode.setLevel(1);
|
||||||
|
treeNodes.get(i).addChild(treeNode);
|
||||||
|
}
|
||||||
|
ArrayList<TreeNode> subnodes = (ArrayList<TreeNode>) treeNodes.get(i).getChildren();
|
||||||
|
for (int j = 0; j < subnodes.size(); j++) {
|
||||||
|
ArrayList<ThirdLevelModel> thirdLevelModels = getDetailsByCategoryID(details, ((SecondLevelModel) subnodes.get(j).getValue()).getID());
|
||||||
|
for (int k = 0; k < thirdLevelModels.size(); k++) {
|
||||||
|
TreeNode treeNode = new TreeNode(thirdLevelModels.get(k));
|
||||||
|
treeNode.setLevel(2);
|
||||||
|
subnodes.get(j).addChild(treeNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return treeNodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(ArrayList<TreeNode> treeNodes) {
|
||||||
|
super.onPostExecute(treeNodes);
|
||||||
|
mView.setTreeViewChildren(treeNodes);
|
||||||
|
mView.swipeLayoutSetRefreshing(false);
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArrayList<SecondLevelModel> getSecondModelsByCategoryID(ArrayList<SecondLevelModel> secondLevelModels, int id) {
|
||||||
|
ArrayList<SecondLevelModel> secondLevelModelsByCategoryID = new ArrayList<>();
|
||||||
|
for (int i = 0; i < secondLevelModels.size(); i++) {
|
||||||
|
if(secondLevelModels.get(i).getDetailTypeId() == id)
|
||||||
|
secondLevelModelsByCategoryID.add(secondLevelModels.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return secondLevelModelsByCategoryID;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArrayList<ThirdLevelModel> getDetailsByCategoryID(ArrayList<ThirdLevelModel> thirdLevelModels, int id) {
|
||||||
|
ArrayList<ThirdLevelModel> thirdLevelModelsBySubcategoryID = new ArrayList<>();
|
||||||
|
for (int i = 0; i < thirdLevelModels.size(); i++) {
|
||||||
|
if(thirdLevelModels.get(i).getDetailSubTypeId() == id)
|
||||||
|
thirdLevelModelsBySubcategoryID.add(thirdLevelModels.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return thirdLevelModelsBySubcategoryID;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isHaveDuplicate(ArrayList<SecondLevelModel> secondLevelModels, int subcatID) {
|
||||||
|
for (int i = 0; i < secondLevelModels.size(); i++) {
|
||||||
|
if(secondLevelModels.get(i).getID() == subcatID)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isHaveDuplicate(ArrayList<FirstLevelModel> firstLevelModels, Integer catID) {
|
||||||
|
for (int i = 0; i < firstLevelModels.size(); i++) {
|
||||||
|
if(firstLevelModels.get(i).getID().equals(catID))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@ 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.ResultWithErrorCode;
|
import ru.volgorobot.vrcatalog.additional.ResultWithErrorCode;
|
||||||
|
import ru.volgorobot.vrcatalog.model.CoreModel;
|
||||||
import ru.volgorobot.vrcatalog.model.DetailModel;
|
import ru.volgorobot.vrcatalog.model.DetailModel;
|
||||||
import ru.volgorobot.vrcatalog.model.FirstLevelModel;
|
import ru.volgorobot.vrcatalog.model.FirstLevelModel;
|
||||||
import ru.volgorobot.vrcatalog.model.SecondLevelModel;
|
import ru.volgorobot.vrcatalog.model.SecondLevelModel;
|
||||||
@ -21,15 +22,9 @@ public class ViewBinderPresenter implements MainContract.ViewBinderPresenter {
|
|||||||
private MainContract.ViewBinder viewBinder;
|
private MainContract.ViewBinder viewBinder;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
public ViewBinderPresenter(MainContract.MainActivityView mView, MainContract.MainModel coreModel, MainContract.ViewBinder viewBinder) {
|
public ViewBinderPresenter(MainContract.MainActivityView mView, MainContract.ViewBinder viewBinder, Context context) {
|
||||||
this.mView = mView;
|
this.mView = mView;
|
||||||
this.coreModel = coreModel;
|
this.coreModel = new CoreModel(context);
|
||||||
this.viewBinder = viewBinder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ViewBinderPresenter(MainContract.MainActivityView mView, MainContract.MainModel coreModel, MainContract.ViewBinder viewBinder, Context context) {
|
|
||||||
this.mView = mView;
|
|
||||||
this.coreModel = coreModel;
|
|
||||||
this.viewBinder = viewBinder;
|
this.viewBinder = viewBinder;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,11 @@ public class NodeViewFactory 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, context, mView, coreModel);
|
return new FirstLevelNodeViewBinder(view, mView, context);
|
||||||
case 1:
|
case 1:
|
||||||
return new SecondLevelNodeViewBinder(view, context, mView, coreModel);
|
return new SecondLevelNodeViewBinder(view, mView, context);
|
||||||
case 2:
|
case 2:
|
||||||
return new ThirdLevelNodeViewBinder(view, context, mView, coreModel);
|
return new ThirdLevelNodeViewBinder(view, context, mView);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package ru.volgorobot.vrcatalog.additional;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import me.texy.treeview.base.BaseNodeViewBinder;
|
||||||
|
import me.texy.treeview.base.BaseNodeViewFactory;
|
||||||
|
import ru.volgorobot.vrcatalog.MainContract;
|
||||||
|
import ru.volgorobot.vrcatalog.nodeViewBinders.ThirdLevelNodeViewBinder;
|
||||||
|
import ru.volgorobot.vrcatalog.searchNodeViewBinders.SecondLevelNodeViewBinder;
|
||||||
|
import ru.volgorobot.vrcatalog.searchNodeViewBinders.FirstLevelNodeViewBinder;
|
||||||
|
|
||||||
|
public class SearchableNodeViewFactory extends BaseNodeViewFactory {
|
||||||
|
private Context context;
|
||||||
|
private MainContract.MainActivityView mView;
|
||||||
|
|
||||||
|
public SearchableNodeViewFactory(Context context, MainContract.MainActivityView mView) {
|
||||||
|
this.context = context;
|
||||||
|
this.mView = mView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseNodeViewBinder getNodeViewBinder(View view, int level) {
|
||||||
|
switch (level) {
|
||||||
|
case 0:
|
||||||
|
return new FirstLevelNodeViewBinder(view);
|
||||||
|
case 1:
|
||||||
|
return new SecondLevelNodeViewBinder(view);
|
||||||
|
case 2:
|
||||||
|
return new ThirdLevelNodeViewBinder(view, context, mView);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,5 @@
|
|||||||
package ru.volgorobot.vrcatalog.api;
|
package ru.volgorobot.vrcatalog.api;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
|
||||||
|
@ -23,4 +23,13 @@ public interface VRApi {
|
|||||||
|
|
||||||
@GET("/API/Api.php?action=getDetailByID")
|
@GET("/API/Api.php?action=getDetailByID")
|
||||||
Call<List<DetailModel>> getDetailByID(@Query("detailID") int detailID);
|
Call<List<DetailModel>> getDetailByID(@Query("detailID") int detailID);
|
||||||
|
|
||||||
|
@GET("/API/Api.php?action=getCategoryByID")
|
||||||
|
Call<List<FirstLevelModel>> getCategoryByID(@Query("id") int id);
|
||||||
|
|
||||||
|
@GET("/API/Api.php?action=getSubCategoryByID")
|
||||||
|
Call<List<SecondLevelModel>> getSubCategoryByID(@Query("id") int id);
|
||||||
|
|
||||||
|
@GET("/API/Api.php?action=getDetailsByName")
|
||||||
|
Call<List<ThirdLevelModel>> getDetailsByName(@Query("name") String name);
|
||||||
}
|
}
|
||||||
|
@ -125,4 +125,61 @@ public class CoreModel implements MainContract.MainModel {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<ThirdLevelModel> fetchDetailsByName(String name) throws NetworkErrorException, NullPointerException {
|
||||||
|
if(vrApi == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
final ArrayList<ThirdLevelModel> thirdLevelModels = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
Response<List<ThirdLevelModel>> response = vrApi.getDetailsByName(name).execute();
|
||||||
|
if(response.isSuccessful()) {
|
||||||
|
thirdLevelModels.addAll(response.body());
|
||||||
|
} else {
|
||||||
|
throw new NetworkErrorException(2);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new NetworkErrorException(1);
|
||||||
|
}
|
||||||
|
return thirdLevelModels;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<FirstLevelModel> fetchCategoryByID(int id) throws NetworkErrorException, NullPointerException {
|
||||||
|
if(vrApi == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
final ArrayList<FirstLevelModel> firstLevelModels = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
Response<List<FirstLevelModel>> response = vrApi.getCategoryByID(id).execute();
|
||||||
|
if(response.isSuccessful()) {
|
||||||
|
firstLevelModels.addAll(response.body());
|
||||||
|
} else {
|
||||||
|
throw new NetworkErrorException(2);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new NetworkErrorException(1);
|
||||||
|
}
|
||||||
|
return firstLevelModels;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<SecondLevelModel> fetchSubCategoryByID(int id) throws NetworkErrorException, NullPointerException {
|
||||||
|
if(vrApi == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
final ArrayList<SecondLevelModel> secondLevelModels = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
Response<List<SecondLevelModel>> response = vrApi.getSubCategoryByID(id).execute();
|
||||||
|
if(response.isSuccessful()) {
|
||||||
|
secondLevelModels.addAll(response.body());
|
||||||
|
} else {
|
||||||
|
throw new NetworkErrorException(2);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new NetworkErrorException(1);
|
||||||
|
}
|
||||||
|
return secondLevelModels;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,27 @@
|
|||||||
package ru.volgorobot.vrcatalog.nodeViewBinders;
|
package ru.volgorobot.vrcatalog.nodeViewBinders;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
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.MainContract;
|
||||||
import ru.volgorobot.vrcatalog.R;
|
import ru.volgorobot.vrcatalog.R;
|
||||||
import ru.volgorobot.vrcatalog.ViewBinderPresenter;
|
import ru.volgorobot.vrcatalog.ViewBinderPresenter;
|
||||||
import ru.volgorobot.vrcatalog.additional.NetworkErrorException;
|
|
||||||
import ru.volgorobot.vrcatalog.additional.ResultWithErrorCode;
|
|
||||||
import ru.volgorobot.vrcatalog.model.CoreModel;
|
|
||||||
import ru.volgorobot.vrcatalog.model.FirstLevelModel;
|
import ru.volgorobot.vrcatalog.model.FirstLevelModel;
|
||||||
import ru.volgorobot.vrcatalog.model.SecondLevelModel;
|
|
||||||
|
|
||||||
public class FirstLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder {
|
public class FirstLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder {
|
||||||
TextView textView;
|
TextView textView;
|
||||||
ImageView imageView;
|
ImageView imageView;
|
||||||
ViewBinderPresenter viewBinderPresenter;
|
ViewBinderPresenter viewBinderPresenter;
|
||||||
|
|
||||||
public FirstLevelNodeViewBinder(View itemView, Context context, MainContract.MainActivityView mView, MainContract.MainModel coreModel) {
|
public FirstLevelNodeViewBinder(View itemView, MainContract.MainActivityView mView, Context context) {
|
||||||
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);
|
||||||
viewBinderPresenter = new ViewBinderPresenter(mView, coreModel, this);
|
viewBinderPresenter = new ViewBinderPresenter(mView, this, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,23 +1,16 @@
|
|||||||
package ru.volgorobot.vrcatalog.nodeViewBinders;
|
package ru.volgorobot.vrcatalog.nodeViewBinders;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
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.MainContract;
|
||||||
import ru.volgorobot.vrcatalog.R;
|
import ru.volgorobot.vrcatalog.R;
|
||||||
import ru.volgorobot.vrcatalog.ViewBinderPresenter;
|
import ru.volgorobot.vrcatalog.ViewBinderPresenter;
|
||||||
import ru.volgorobot.vrcatalog.additional.NetworkErrorException;
|
|
||||||
import ru.volgorobot.vrcatalog.additional.ResultWithErrorCode;
|
|
||||||
import ru.volgorobot.vrcatalog.model.CoreModel;
|
|
||||||
import ru.volgorobot.vrcatalog.model.SecondLevelModel;
|
import ru.volgorobot.vrcatalog.model.SecondLevelModel;
|
||||||
import ru.volgorobot.vrcatalog.model.ThirdLevelModel;
|
|
||||||
|
|
||||||
public class SecondLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder {
|
public class SecondLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder {
|
||||||
TextView textView;
|
TextView textView;
|
||||||
@ -25,11 +18,11 @@ public class SecondLevelNodeViewBinder extends BaseNodeViewBinder implements Mai
|
|||||||
MainContract.ViewBinderPresenter viewBinderPresenter;
|
MainContract.ViewBinderPresenter viewBinderPresenter;
|
||||||
|
|
||||||
|
|
||||||
public SecondLevelNodeViewBinder(View itemView, Context context, MainContract.MainActivityView mView, CoreModel coreModel) {
|
public SecondLevelNodeViewBinder(View itemView, MainContract.MainActivityView mView, Context context) {
|
||||||
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);
|
||||||
viewBinderPresenter = new ViewBinderPresenter(mView, coreModel, this);
|
viewBinderPresenter = new ViewBinderPresenter(mView, this, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,33 +1,24 @@
|
|||||||
package ru.volgorobot.vrcatalog.nodeViewBinders;
|
package ru.volgorobot.vrcatalog.nodeViewBinders;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
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.MainContract;
|
||||||
import ru.volgorobot.vrcatalog.R;
|
import ru.volgorobot.vrcatalog.R;
|
||||||
import ru.volgorobot.vrcatalog.ViewBinderPresenter;
|
import ru.volgorobot.vrcatalog.ViewBinderPresenter;
|
||||||
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.model.ThirdLevelModel;
|
import ru.volgorobot.vrcatalog.model.ThirdLevelModel;
|
||||||
import ru.volgorobot.vrcatalog.view.DetailActivity;
|
|
||||||
|
|
||||||
public class ThirdLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder {
|
public class ThirdLevelNodeViewBinder extends BaseNodeViewBinder implements MainContract.ViewBinder {
|
||||||
TextView textView;
|
TextView textView;
|
||||||
MainContract.ViewBinderPresenter viewBinderPresenter;
|
MainContract.ViewBinderPresenter viewBinderPresenter;
|
||||||
|
|
||||||
public ThirdLevelNodeViewBinder(View itemView, Context context, MainContract.MainActivityView mView, CoreModel coreModel) {
|
public ThirdLevelNodeViewBinder(View itemView, Context context, MainContract.MainActivityView mView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
viewBinderPresenter = new ViewBinderPresenter(mView, coreModel, this, context);
|
viewBinderPresenter = new ViewBinderPresenter(mView, this, context);
|
||||||
textView = (TextView) itemView.findViewById(R.id.node_name_view);
|
textView = itemView.findViewById(R.id.node_name_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
package ru.volgorobot.vrcatalog.searchNodeViewBinders;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import me.texy.treeview.TreeNode;
|
||||||
|
import me.texy.treeview.base.BaseNodeViewBinder;
|
||||||
|
import ru.volgorobot.vrcatalog.R;
|
||||||
|
|
||||||
|
public class FirstLevelNodeViewBinder extends BaseNodeViewBinder {
|
||||||
|
TextView textView;
|
||||||
|
ImageView imageView;
|
||||||
|
|
||||||
|
public FirstLevelNodeViewBinder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
textView = (TextView) itemView.findViewById(R.id.node_name_view);
|
||||||
|
imageView = (ImageView) itemView.findViewById(R.id.arrow_img);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLayoutId() {
|
||||||
|
return R.layout.first_level_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bindView(TreeNode treeNode) {
|
||||||
|
textView.setText(treeNode.getValue().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNodeToggled(TreeNode treeNode, boolean expand) {
|
||||||
|
if(expand) {
|
||||||
|
imageView.animate().rotation(90).setDuration(200).start();
|
||||||
|
} else {
|
||||||
|
imageView.animate().rotation(0).setDuration(200).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package ru.volgorobot.vrcatalog.searchNodeViewBinders;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import me.texy.treeview.TreeNode;
|
||||||
|
import me.texy.treeview.base.BaseNodeViewBinder;
|
||||||
|
import ru.volgorobot.vrcatalog.R;
|
||||||
|
|
||||||
|
public class SecondLevelNodeViewBinder extends BaseNodeViewBinder {
|
||||||
|
TextView textView;
|
||||||
|
ImageView imageView;
|
||||||
|
|
||||||
|
public SecondLevelNodeViewBinder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
textView = (TextView) itemView.findViewById(R.id.node_name_view);
|
||||||
|
imageView = (ImageView) itemView.findViewById(R.id.arrow_img);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLayoutId() {
|
||||||
|
return R.layout.second_level_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bindView(TreeNode treeNode) {
|
||||||
|
textView.setText(treeNode.getValue().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNodeToggled(TreeNode treeNode, boolean expand) {
|
||||||
|
if(expand) {
|
||||||
|
imageView.animate().rotation(90).setDuration(200).start();
|
||||||
|
} else {
|
||||||
|
imageView.animate().rotation(0).setDuration(200).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,14 @@
|
|||||||
package ru.volgorobot.vrcatalog.view;
|
package ru.volgorobot.vrcatalog.view;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import ru.volgorobot.vrcatalog.R;
|
import ru.volgorobot.vrcatalog.R;
|
||||||
|
|
||||||
|
@ -1,16 +1,23 @@
|
|||||||
package ru.volgorobot.vrcatalog.view;
|
package ru.volgorobot.vrcatalog.view;
|
||||||
|
|
||||||
|
import android.app.SearchManager;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
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 android.support.design.widget.NavigationView;
|
||||||
import android.support.v4.view.GravityCompat;
|
import android.support.v4.view.GravityCompat;
|
||||||
|
import android.support.v4.view.MenuItemCompat;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.support.v7.app.ActionBarDrawerToggle;
|
import android.support.v7.app.ActionBarDrawerToggle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.DefaultItemAnimator;
|
import android.support.v7.widget.DefaultItemAnimator;
|
||||||
|
import android.support.v7.widget.SearchView;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@ -155,6 +162,19 @@ public class MainActivity extends AppCompatActivity
|
|||||||
public void startActivityByIntent(Intent intent) {
|
public void startActivityByIntent(Intent intent) {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.main, menu);
|
||||||
|
|
||||||
|
SearchView search = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search));
|
||||||
|
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
|
||||||
|
search.setSearchableInfo(searchManager.getSearchableInfo(new ComponentName(this, SearchableActivity.class)));
|
||||||
|
search.setQueryHint("Имя детали");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,118 @@
|
|||||||
|
package ru.volgorobot.vrcatalog.view;
|
||||||
|
|
||||||
|
import android.app.SearchManager;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.widget.DefaultItemAnimator;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import me.texy.treeview.TreeNode;
|
||||||
|
import me.texy.treeview.TreeView;
|
||||||
|
import ru.volgorobot.vrcatalog.MainContract;
|
||||||
|
import ru.volgorobot.vrcatalog.R;
|
||||||
|
import ru.volgorobot.vrcatalog.SearchablePresenter;
|
||||||
|
import ru.volgorobot.vrcatalog.additional.SearchableNodeViewFactory;
|
||||||
|
import ru.volgorobot.vrcatalog.model.FirstLevelModel;
|
||||||
|
|
||||||
|
public class SearchableActivity extends AppCompatActivity implements MainContract.SearchableActivityView, MainContract.MainActivityView, SwipeRefreshLayout.OnRefreshListener {
|
||||||
|
private SearchablePresenter searchablePresenter;
|
||||||
|
private SwipeRefreshLayout mSwipeRefreshLayout;
|
||||||
|
private String detailName;
|
||||||
|
private TreeView treeView;
|
||||||
|
private TreeNode rootNode = TreeNode.root();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_searchable);
|
||||||
|
searchablePresenter = new SearchablePresenter(this, SearchableActivity.this, this);
|
||||||
|
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
getSupportActionBar().setHomeButtonEnabled(true);
|
||||||
|
|
||||||
|
mSwipeRefreshLayout = findViewById(R.id.searchableSwipeRefreshLayout);
|
||||||
|
mSwipeRefreshLayout.setOnRefreshListener(SearchableActivity.this);
|
||||||
|
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
|
||||||
|
|
||||||
|
treeView = new TreeView(rootNode, SearchableActivity.this, new SearchableNodeViewFactory(SearchableActivity.this, this));
|
||||||
|
treeView.setItemAnimator(new DefaultItemAnimator());
|
||||||
|
((ViewGroup) findViewById(R.id.searchableTreeViewContainer)).addView(treeView.getView());
|
||||||
|
Intent intent = getIntent();
|
||||||
|
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
|
||||||
|
detailName = intent.getStringExtra(SearchManager.QUERY);
|
||||||
|
getSupportActionBar().setTitle("Поиск: " + detailName);
|
||||||
|
searchablePresenter.fetchDetailsTreeByName(detailName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTreeViewChildren(ArrayList<TreeNode> children) {
|
||||||
|
rootNode.setChildren(children);
|
||||||
|
treeView.expandAll();
|
||||||
|
treeView.refreshTreeView();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onFailureAnswer(int errorCode) {
|
||||||
|
switch (errorCode) {
|
||||||
|
case 1: {
|
||||||
|
Toast.makeText(SearchableActivity.this, "Ошибка сети. Проверьте подключение к сети или данные подключения к API!", Toast.LENGTH_LONG).show();
|
||||||
|
Log.e("VRCatalog", "Network Error! Re-check your connection credentials or network settings! Technical info: null");
|
||||||
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
Toast.makeText(SearchableActivity.this, "Ответ от сервера неверен! Перепроверьте данные подключения!", Toast.LENGTH_LONG).show();
|
||||||
|
Log.e("VRCatalog", "Answer of server is wrong! Re-check your connection credentials! Technical info: null");
|
||||||
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: {
|
||||||
|
Toast.makeText(SearchableActivity.this, "Вы ввели неверный URL. Пример: http://example.ru", Toast.LENGTH_LONG).show();
|
||||||
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRefresh() {
|
||||||
|
searchablePresenter.fetchDetailsTreeByName(detailName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void swipeLayoutSetRefreshing(boolean state) {
|
||||||
|
mSwipeRefreshLayout.setRefreshing(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshTree() {
|
||||||
|
treeView.refreshTreeView();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startActivityByIntent(Intent intent) {
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildFirstLevelTree(ArrayList<FirstLevelModel> firstLevelModels) {
|
||||||
|
// This is for compatibility. Nothing to implement.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch(item.getItemId()) {
|
||||||
|
case android.R.id.home:
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
@ -18,8 +18,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="VRCatalog"
|
android:text="VRCatalog"
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.Large"
|
android:textAppearance="@android:style/TextAppearance.Large" />
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView2"
|
android:id="@+id/textView2"
|
||||||
|
21
app/src/main/res/layout/activity_searchable.xml
Normal file
21
app/src/main/res/layout/activity_searchable.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.v4.widget.SwipeRefreshLayout 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:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
tools:context=".view.MainActivity"
|
||||||
|
tools:showIn="@layout/app_bar_main"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:id="@+id/searchableSwipeRefreshLayout">
|
||||||
|
|
||||||
|
<android.support.v4.widget.NestedScrollView
|
||||||
|
android:id="@+id/searchableTreeViewContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scrollbarAlwaysDrawVerticalTrack="true">
|
||||||
|
</android.support.v4.widget.NestedScrollView>
|
||||||
|
|
||||||
|
|
||||||
|
</android.support.v4.widget.SwipeRefreshLayout>
|
@ -1,7 +1,8 @@
|
|||||||
<?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:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="80dp">
|
android:layout_height="80dp"
|
||||||
|
android:background="?android:selectableItemBackground">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/node_container"
|
android:id="@+id/node_container"
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:background="?android:selectableItemBackground">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/node_container"
|
android:id="@+id/node_container"
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:background="?android:selectableItemBackground">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/node_container"
|
android:id="@+id/node_container"
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu 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">
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_search"
|
||||||
|
android:icon="@drawable/ic_search_white_24dp"
|
||||||
|
app:showAsAction="always|collapseActionView"
|
||||||
|
app:actionViewClass="android.support.v7.widget.SearchView"
|
||||||
|
android:title="Поиск"/>
|
||||||
</menu>
|
</menu>
|
||||||
|
5
app/src/main/res/xml/searchable.xml
Normal file
5
app/src/main/res/xml/searchable.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:hint="Поиск деталей по имени" >
|
||||||
|
</searchable>
|
@ -8,7 +8,7 @@ buildscript {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
classpath 'com.android.tools.build:gradle:3.3.0'
|
||||||
|
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,6 @@
|
|||||||
|
#Tue Jan 15 18:33:56 MSK 2019
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
|
||||||
|
Loading…
Reference in New Issue
Block a user