From b987854fb22d97598523ef844149df2762fa062a Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Tue, 5 Feb 2019 17:56:52 +0400 Subject: [PATCH] Made setting content of ViewPager in ItemActivity (old DetailActivity) (this sets images) --- .../java/ru/volgorobot/vrcatalog/ItemPresenter.java | 4 +++- .../java/ru/volgorobot/vrcatalog/MainContract.java | 3 +-- .../volgorobot/vrcatalog/ViewBinderPresenter.java | 1 + .../additional/SearchableNodeViewFactory.java | 2 +- .../ru/volgorobot/vrcatalog/view/AboutActivity.java | 1 - .../volgorobot/vrcatalog/view/DetailActivity.java | 13 +++++++++---- .../ru/volgorobot/vrcatalog/view/MainActivity.java | 2 -- .../vrcatalog/view/SearchableActivity.java | 3 +-- .../volgorobot/vrcatalog/view/SettingsActivity.java | 1 - 9 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/ItemPresenter.java b/app/src/main/java/ru/volgorobot/vrcatalog/ItemPresenter.java index a0b6cae..876fd96 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/ItemPresenter.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/ItemPresenter.java @@ -63,7 +63,9 @@ public class ItemPresenter implements MainContract.ItemPresenter { for (Bitmap bitmap : bitmaps) { uriStrings.add(processImages(bitmap).toString()); } - // TODO: setViewPagerContent() + String[] uriStringsArray = new String[uriStrings.size()]; + uriStrings.toArray(uriStringsArray); + mView.setViewPagerContent(uriStringsArray); break; } case 1: { diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/MainContract.java b/app/src/main/java/ru/volgorobot/vrcatalog/MainContract.java index 5bba085..62247c0 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/MainContract.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/MainContract.java @@ -1,7 +1,6 @@ package ru.volgorobot.vrcatalog; import android.content.Intent; -import android.net.Uri; import java.util.ArrayList; @@ -67,6 +66,6 @@ public interface MainContract { interface ItemView { void onFailureAnswer(int errorCode); - void setViewPagerContent(Uri uri); + void setViewPagerContent(String[] uris); } } diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/ViewBinderPresenter.java b/app/src/main/java/ru/volgorobot/vrcatalog/ViewBinderPresenter.java index 5f02f40..9d1d236 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/ViewBinderPresenter.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/ViewBinderPresenter.java @@ -170,6 +170,7 @@ public class ViewBinderPresenter implements MainContract.ViewBinderPresenter { switch (result.getErrorCode()) { case 0: { Intent intent = new Intent(context, DetailActivity.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()); diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/additional/SearchableNodeViewFactory.java b/app/src/main/java/ru/volgorobot/vrcatalog/additional/SearchableNodeViewFactory.java index 15274d1..baca273 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/additional/SearchableNodeViewFactory.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/additional/SearchableNodeViewFactory.java @@ -7,8 +7,8 @@ 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; +import ru.volgorobot.vrcatalog.searchNodeViewBinders.SecondLevelNodeViewBinder; public class SearchableNodeViewFactory extends BaseNodeViewFactory { private Context context; diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/view/AboutActivity.java b/app/src/main/java/ru/volgorobot/vrcatalog/view/AboutActivity.java index 77ef4fe..6dc752c 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/view/AboutActivity.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/view/AboutActivity.java @@ -2,7 +2,6 @@ package ru.volgorobot.vrcatalog.view; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; -import android.view.Menu; import android.view.MenuItem; import ru.volgorobot.vrcatalog.R; diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/view/DetailActivity.java b/app/src/main/java/ru/volgorobot/vrcatalog/view/DetailActivity.java index c8be4b5..bf9d6e8 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/view/DetailActivity.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/view/DetailActivity.java @@ -1,8 +1,8 @@ package ru.volgorobot.vrcatalog.view; import android.content.Intent; -import android.net.Uri; import android.os.Bundle; +import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.text.method.LinkMovementMethod; import android.util.Log; @@ -16,6 +16,7 @@ import java.util.HashMap; import ru.volgorobot.vrcatalog.ItemPresenter; import ru.volgorobot.vrcatalog.MainContract; import ru.volgorobot.vrcatalog.R; +import ru.volgorobot.vrcatalog.additional.ImagePagerAdapter; public class DetailActivity extends AppCompatActivity implements MainContract.ItemView { TextView nameView; @@ -26,6 +27,7 @@ public class DetailActivity extends AppCompatActivity implements MainContract.It TextView datasheetView; EditText notesView; private MainContract.ItemPresenter mPresenter; + private ViewPager viewPager; @Override protected void onCreate(Bundle savedInstanceState) { @@ -35,7 +37,6 @@ public class DetailActivity extends AppCompatActivity implements MainContract.It getSupportActionBar().setHomeButtonEnabled(true); initializeViews(); mPresenter = new ItemPresenter(DetailActivity.this, this); - Intent intent = getIntent(); HashMap extrasMap = getIntentExtras(intent); @@ -47,6 +48,7 @@ public class DetailActivity extends AppCompatActivity implements MainContract.It analogueView.setText(extrasMap.get("detailAnalogue")); datasheetView.setText(extrasMap.get("detailDatasheet")); notesView.setText(extrasMap.get("detailNotes")); + mPresenter.getImagesByItemID(Integer.parseInt(extrasMap.get("itemID"))); } void initializeViews() { @@ -58,6 +60,7 @@ public class DetailActivity extends AppCompatActivity implements MainContract.It analogueView = findViewById(R.id.analogue); datasheetView = findViewById(R.id.datasheet); datasheetView.setMovementMethod(LinkMovementMethod.getInstance()); + viewPager = findViewById(R.id.viewPager); } HashMap getIntentExtras(Intent intent) { @@ -140,7 +143,9 @@ public class DetailActivity extends AppCompatActivity implements MainContract.It } @Override - public void setViewPagerContent(Uri uri) { - + public void setViewPagerContent(String[] uris) { + ImagePagerAdapter imagePagerAdapter = new ImagePagerAdapter(DetailActivity.this, uris); + viewPager.setAdapter(imagePagerAdapter); + imagePagerAdapter.notifyDataSetChanged(); } } diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/view/MainActivity.java b/app/src/main/java/ru/volgorobot/vrcatalog/view/MainActivity.java index bb41b27..117e17d 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/view/MainActivity.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/view/MainActivity.java @@ -9,7 +9,6 @@ import android.support.design.widget.NavigationView; import android.support.v4.view.GravityCompat; import android.support.v4.view.MenuItemCompat; import android.support.v4.widget.DrawerLayout; -import android.support.v4.widget.NestedScrollView; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; @@ -17,7 +16,6 @@ import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.SearchView; import android.support.v7.widget.Toolbar; import android.util.Log; -import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/view/SearchableActivity.java b/app/src/main/java/ru/volgorobot/vrcatalog/view/SearchableActivity.java index f3a1de9..19d1a40 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/view/SearchableActivity.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/view/SearchableActivity.java @@ -2,10 +2,10 @@ package ru.volgorobot.vrcatalog.view; import android.app.SearchManager; import android.content.Intent; +import android.os.Bundle; import android.support.v4.widget.NestedScrollView; 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; @@ -13,7 +13,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; -import android.widget.Toast; import java.util.ArrayList; diff --git a/app/src/main/java/ru/volgorobot/vrcatalog/view/SettingsActivity.java b/app/src/main/java/ru/volgorobot/vrcatalog/view/SettingsActivity.java index 0e0714b..8f57d8a 100644 --- a/app/src/main/java/ru/volgorobot/vrcatalog/view/SettingsActivity.java +++ b/app/src/main/java/ru/volgorobot/vrcatalog/view/SettingsActivity.java @@ -1,7 +1,6 @@ package ru.volgorobot.vrcatalog.view; import android.os.Bundle; -import android.view.Menu; import android.view.MenuItem; import ru.volgorobot.vrcatalog.R;