Prepare major changes
This commit is contained in:
parent
b6417eb128
commit
04faa66341
Before Width: | Height: | Size: 608 B After Width: | Height: | Size: 608 B |
BIN
android/res/drawable/drawer_books.png
Normal file
BIN
android/res/drawable/drawer_books.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 466 B |
BIN
android/res/drawable/no_picture.png
Normal file
BIN
android/res/drawable/no_picture.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
38
android/res/layout/books_page_list_element.xml
Normal file
38
android/res/layout/books_page_list_element.xml
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/LinearLayout1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="6dp"
|
||||
android:background="@color/bkg1"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingTop="4dp"
|
||||
android:showDividers="middle" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="120dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_margin="2dp"
|
||||
android:background="@color/bkg2"
|
||||
android:scaleType="centerInside" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nameTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_margin="2dp"
|
||||
android:text="aaa"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/authorTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp" />
|
||||
|
||||
</LinearLayout>
|
62
android/res/layout/fragment_book_record_page.xml
Normal file
62
android/res/layout/fragment_book_record_page.xml
Normal file
@ -0,0 +1,62 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="0dp"
|
||||
android:background="@color/bkg1"
|
||||
android:orientation="vertical"
|
||||
tools:context="fishrungames.bashgid.MainPageFragment" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_margin="4dp"
|
||||
android:contentDescription="@string/news_content_description"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/transparent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nameTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textColorHint="@color/text_black"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/authorTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/priceTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/descriptionTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buyButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:text="@string/buy" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/readButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:text="@string/read" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
17
android/res/layout/fragment_books_page.xml
Normal file
17
android/res/layout/fragment_books_page.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<GridView
|
||||
android:id="@+id/gridView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:horizontalSpacing="4dp"
|
||||
android:numColumns="3"
|
||||
android:verticalSpacing="4dp" >
|
||||
|
||||
</GridView>
|
||||
|
||||
</LinearLayout>
|
14
android/res/layout/fragment_video_page.xml
Normal file
14
android/res/layout/fragment_video_page.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<GridView
|
||||
android:id="@+id/gridView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:numColumns="3" >
|
||||
</GridView>
|
||||
|
||||
</LinearLayout>
|
27
android/res/layout/fragment_video_record_page.xml
Normal file
27
android/res/layout/fragment_video_record_page.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="6dp"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nameTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/descriptionTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
31
android/res/layout/video_page_list_element.xml
Normal file
31
android/res/layout/video_page_list_element.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/LinearLayout1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="800dp"
|
||||
android:layout_margin="4dp"
|
||||
android:background="@color/bkg1"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingTop="4dp"
|
||||
android:showDividers="middle" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_margin="2dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/img_culture1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nameTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="dsdsd"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
@ -40,10 +40,16 @@
|
||||
<string name="drawer_map">Карта</string>
|
||||
<string name="drawer_video">Видео</string>
|
||||
<string name="drawer_photo_gallery">Фотогалерея</string>
|
||||
<string name="drawer_books">Книги</string>
|
||||
<string name="drawer_for_investor">Инвестору</string>
|
||||
<string name="drawer_settings">Настройки</string>
|
||||
|
||||
|
||||
<string name="go_to_website">Перейти на сайт</string>
|
||||
|
||||
<string name="buy">Купить...</string>
|
||||
<string name="read">Читать</string>
|
||||
<string name="price">Стоимость: </string>
|
||||
<string name="rub">Руб.</string>
|
||||
|
||||
</resources>
|
||||
|
@ -35,6 +35,7 @@
|
||||
<string name="drawer_map">地图</string>
|
||||
<string name="drawer_video">视频</string>
|
||||
<string name="drawer_photo_gallery">图片库</string>
|
||||
<string name="drawer_books">书籍</string>
|
||||
<string name="drawer_for_investor">投资者信息</string>
|
||||
<string name="drawer_settings">设置</string>
|
||||
|
||||
|
@ -41,11 +41,17 @@
|
||||
<string name="drawer_map">Map</string>
|
||||
<string name="drawer_video">Video</string>
|
||||
<string name="drawer_photo_gallery">Photo gallery</string>
|
||||
<string name="drawer_books">Books</string>
|
||||
<string name="drawer_for_investor">For investor</string>
|
||||
<string name="drawer_settings">Settings</string>
|
||||
|
||||
|
||||
<string name="go_to_website">Go to website</string>
|
||||
|
||||
<string name="buy">Buy</string>
|
||||
<string name="read">Read</string>
|
||||
<string name="price">Price: </string>
|
||||
<string name="rub">RUB</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
62
android/src/fishrungames/bashgid/BookRecordFragment.java
Normal file
62
android/src/fishrungames/bashgid/BookRecordFragment.java
Normal file
@ -0,0 +1,62 @@
|
||||
package fishrungames.bashgid;
|
||||
|
||||
|
||||
import fishrungames.networkutils.ImageManager;
|
||||
import fishrungames.bashgid.core.BookManager.BookRecord;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
public class BookRecordFragment extends Fragment
|
||||
{
|
||||
|
||||
BookRecord bookRecord;
|
||||
|
||||
public BookRecordFragment(BookRecord bookRecord)
|
||||
{
|
||||
this.bookRecord = bookRecord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_book_record_page, container, false);
|
||||
|
||||
TextView nameTextView = (TextView) rootView.findViewById(R.id.nameTextView);
|
||||
nameTextView.setText(bookRecord.name);
|
||||
|
||||
TextView authorTextView = (TextView) rootView.findViewById(R.id.authorTextView);
|
||||
authorTextView.setText(bookRecord.author);
|
||||
|
||||
TextView descriptionTextView = (TextView) rootView.findViewById(R.id.descriptionTextView);
|
||||
descriptionTextView.setText(bookRecord.description);
|
||||
|
||||
TextView priceTextView = (TextView) rootView.findViewById(R.id.priceTextView);
|
||||
priceTextView.setText(getResources().getString(R.string.price) + Integer.toString(bookRecord.price) + " " + getResources().getString(R.string.rub));
|
||||
|
||||
ImageView imageView = (ImageView) rootView.findViewById(R.id.imageView);
|
||||
|
||||
if (bookRecord.imageUrl.length() == 0)
|
||||
{
|
||||
imageView.setImageResource(R.drawable.no_picture);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImageManager.getInstance().ApplyImageToImageView(imageView, bookRecord.imageUrl);
|
||||
}
|
||||
|
||||
//ImageManager.getInstance().ApplyImageToImageView(imageView, realImageUrl);
|
||||
|
||||
//Button buyButton = (Button) rootView.findViewById(R.id.buyButton);
|
||||
//Button readButton = (Button) rootView.findViewById(R.id.readButton);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
|
||||
}
|
175
android/src/fishrungames/bashgid/BooksFragment.java
Normal file
175
android/src/fishrungames/bashgid/BooksFragment.java
Normal file
@ -0,0 +1,175 @@
|
||||
package fishrungames.bashgid;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import fishrungames.bashgid.core.BookManager;
|
||||
import fishrungames.networkutils.ImageManager;
|
||||
import fishrungames.networkutils.UniversalActionWithCallback;
|
||||
import fishrungames.networkutils.interfaces.RemoveCallbackInterface;
|
||||
import fishrungames.networkutils.interfaces.UpdateAndFinishCallbackInterface;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
public class BooksFragment extends Fragment implements UpdateAndFinishCallbackInterface
|
||||
{
|
||||
|
||||
ListAdapter listAdapter;
|
||||
|
||||
GridView gridView;
|
||||
|
||||
ArrayList<BookManager.BookRecord> bookRecordArr;
|
||||
|
||||
RemoveCallbackInterface removeCallback = null;
|
||||
Object removeCallbackSynchronizer = new Object();
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
|
||||
bookRecordArr = BookManager.getInstance().getBooks();
|
||||
|
||||
removeCallback = UniversalActionWithCallback.PerformActionIfNotPerforming(BookManager.getInstance(), null, this, "BookManager");
|
||||
|
||||
|
||||
View rootView = inflater.inflate(R.layout.fragment_books_page, container, false);
|
||||
|
||||
gridView = (GridView) rootView.findViewById(R.id.gridView);
|
||||
|
||||
listAdapter = new ListAdapter(getActivity());
|
||||
|
||||
gridView.setAdapter(listAdapter);
|
||||
|
||||
gridView.setOnItemClickListener(new OnItemClickListener()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
|
||||
{
|
||||
MainActivity.getInstance().OpenBookRecordScreen(bookRecordArr.get(position), MainActivity.TAG_FROM_BOOKSFRAGMENT_TO_BOOKRECORDFRAGMENT);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
RefreshBookList();
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView()
|
||||
{
|
||||
synchronized (removeCallbackSynchronizer)
|
||||
{
|
||||
if (removeCallback != null)
|
||||
{
|
||||
removeCallback.RemoveCallback();
|
||||
removeCallback = null;
|
||||
}
|
||||
}
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
public void RefreshBookList()
|
||||
{
|
||||
bookRecordArr = BookManager.getInstance().getBooks();
|
||||
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnFinished()
|
||||
{
|
||||
synchronized (removeCallbackSynchronizer)
|
||||
{
|
||||
removeCallback = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnUpdated(Bundle result)
|
||||
{
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
RefreshBookList();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public class ListAdapter extends BaseAdapter {
|
||||
private Context mContext;
|
||||
|
||||
public ListAdapter(Context c) {
|
||||
mContext = c;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return bookRecordArr.size();
|
||||
}
|
||||
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// create a new ImageView for each item referenced by the Adapter
|
||||
@SuppressLint("InflateParams")
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
|
||||
View view;
|
||||
if (convertView == null) { // if it's not recycled, initialize some attributes
|
||||
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = inflater.inflate(R.layout.books_page_list_element, null);
|
||||
|
||||
|
||||
} else {
|
||||
view = convertView;
|
||||
}
|
||||
|
||||
ImageView imageView = (ImageView)view.findViewById(R.id.imageView);
|
||||
TextView nameTextView = (TextView) view.findViewById(R.id.nameTextView);
|
||||
TextView authorTextView = (TextView) view.findViewById(R.id.authorTextView);
|
||||
|
||||
if (bookRecordArr.get(position).imageUrl.length() == 0)
|
||||
{
|
||||
imageView.setImageResource(R.drawable.no_picture);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImageManager.getInstance().ApplyImageToImageView(imageView, bookRecordArr.get(position).imageUrl);
|
||||
}
|
||||
|
||||
nameTextView.setText(bookRecordArr.get(position).name);
|
||||
|
||||
authorTextView.setText(bookRecordArr.get(position).author);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -4,8 +4,10 @@ package fishrungames.bashgid;
|
||||
import java.util.Locale;
|
||||
|
||||
import fishrungames.bashgid.core.AlbumManager;
|
||||
import fishrungames.bashgid.core.BookManager.BookRecord;
|
||||
import fishrungames.bashgid.core.HtmlDownloadManager.TextFileRecord;
|
||||
import fishrungames.bashgid.core.NewsManager.NewsRecord;
|
||||
import fishrungames.bashgid.core.VideoManager.VideoRecord;
|
||||
import fishrungames.bashgid.core.db.NewsDataSource;
|
||||
import fishrungames.networkutils.ContextHolder;
|
||||
import fishrungames.networkutils.ImageManager;
|
||||
@ -28,6 +30,11 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
||||
public static final String TAG_FROM_MAINFRAGMENT_TO_NEWSRECORDFRAGMENT = "TAG_FROM_MAINFRAGMENT_TO_NEWSRECORDFRAGMENT";
|
||||
public static final String TAG_FROM_NEWSLISTFRAGMENT_TO_NEWSRECORDFRAGMENT = "TAG_FROM_NEWSLISTFRAGMENT_TO_NEWSRECORDFRAGMENT";
|
||||
public static final String TAG_FROM_SEARCHFRAGMENT_TO_NEWSRECORDFRAGMENT = "TAG_FROM_SEARCHFRAGMENT_TO_NEWSRECORDFRAGMENT";
|
||||
public static final String TAG_FROM_BOOKSFRAGMENT_TO_BOOKRECORDFRAGMENT = "TAG_FROM_BOOKSFRAGMENT_TO_BOOKRECORDFRAGMENT";
|
||||
public static final String TAG_FROM_VIDEOLISTFRAGMENT_TO_VIDEORECORDFRAGMENT = "TAG_FROM_VIDEOLISTFRAGMENT_TO_VIDEORECORDFRAGMENT";
|
||||
|
||||
|
||||
|
||||
public static final String TAG_TO_WELCOMEFRAGMENT = "WelcomeFragment";
|
||||
public static final String TAG_TO_SEARCHFRAGMENT = "SearchFragment";
|
||||
public static final String TAG_TO_MAINFRAGMENT = "MainFragment";
|
||||
@ -217,6 +224,57 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
||||
|
||||
mNavigationDrawerFragment.EnableDrawer();
|
||||
}
|
||||
|
||||
public void OpenBooksScreen()
|
||||
{
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new BooksFragment(), TAG_TO_MAINFRAGMENT).commit();
|
||||
|
||||
mNavigationDrawerFragment.EnableDrawer();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void OpenBookRecordScreen(BookRecord bookRecord, String tag)
|
||||
{
|
||||
// Xperimental -- addToBackStack provoke error "Class not found". Need
|
||||
// to resolve somehow!
|
||||
// getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
|
||||
// new NewsRecordFragment(newsRecord)).addToBackStack(null).commit();
|
||||
|
||||
// I added workaround:
|
||||
|
||||
BookRecordFragment bookRecordFragment = new BookRecordFragment(bookRecord);
|
||||
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, bookRecordFragment, tag).commit();
|
||||
|
||||
mNavigationDrawerFragment.EnableDrawer();
|
||||
}
|
||||
|
||||
//TAG_FROM_VIDEOLISTFRAGMENT_TO_VIDEORECORDFRAGMENT
|
||||
|
||||
public void OpenVideoListScreen()
|
||||
{
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new VideoListFragment(), TAG_TO_MAINFRAGMENT).commit();
|
||||
|
||||
mNavigationDrawerFragment.EnableDrawer();
|
||||
|
||||
}
|
||||
|
||||
public void OpenVideoRecordScreen(VideoRecord videoRecord, String tag)
|
||||
{
|
||||
// Xperimental -- addToBackStack provoke error "Class not found". Need
|
||||
// to resolve somehow!
|
||||
// getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
|
||||
// new NewsRecordFragment(newsRecord)).addToBackStack(null).commit();
|
||||
|
||||
// I added workaround:
|
||||
|
||||
VideoRecordFragment videoRecordFragment = new VideoRecordFragment(videoRecord);
|
||||
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, videoRecordFragment, tag).commit();
|
||||
|
||||
mNavigationDrawerFragment.EnableDrawer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachFragment(Fragment fragment)
|
||||
@ -283,16 +341,23 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
||||
{
|
||||
OpenNewsScreen();
|
||||
}
|
||||
else if (position == 4)
|
||||
{
|
||||
OpenMapScreen();
|
||||
}
|
||||
else if (position == 5)
|
||||
{
|
||||
OpenVideoListScreen();
|
||||
}
|
||||
else if (position == 6)
|
||||
{
|
||||
OpenPhotoAlbumListScreen();
|
||||
}
|
||||
else if (position == 4)
|
||||
else if (position == 7)
|
||||
{
|
||||
OpenMapScreen();
|
||||
//OpenStreetViewScreen();
|
||||
OpenBooksScreen();
|
||||
}
|
||||
else if (position == 8)
|
||||
else if (position == 9)
|
||||
{
|
||||
OpenSettingsScreen();
|
||||
}
|
||||
@ -316,6 +381,22 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
||||
return;
|
||||
}
|
||||
|
||||
if (getSupportFragmentManager().findFragmentByTag(TAG_FROM_BOOKSFRAGMENT_TO_BOOKRECORDFRAGMENT) != null)
|
||||
{
|
||||
OpenBooksScreen();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (getSupportFragmentManager().findFragmentByTag(TAG_FROM_VIDEOLISTFRAGMENT_TO_VIDEORECORDFRAGMENT) != null)
|
||||
{
|
||||
OpenVideoListScreen();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (getSupportFragmentManager().findFragmentByTag(TAG_FROM_SEARCHFRAGMENT_TO_NEWSRECORDFRAGMENT) != null)
|
||||
{
|
||||
OpenSearchScreen(true);
|
||||
@ -344,9 +425,9 @@ public class MainActivity extends ActionBarActivity implements NavigationDrawerF
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super.onBackPressed();
|
||||
|
||||
/*
|
||||
|
@ -324,6 +324,7 @@ public class NavigationDrawerFragment extends Fragment {
|
||||
R.string.drawer_map,
|
||||
R.string.drawer_video,
|
||||
R.string.drawer_photo_gallery,
|
||||
R.string.drawer_books,
|
||||
R.string.drawer_for_investor,
|
||||
R.string.drawer_settings
|
||||
};
|
||||
@ -332,10 +333,11 @@ public class NavigationDrawerFragment extends Fragment {
|
||||
R.drawable.drawer_bashgid_logo,
|
||||
R.drawable.drawer_agenda,
|
||||
R.drawable.drawer_news,
|
||||
R.drawable.drawer_book,
|
||||
R.drawable.drawer_bookmark,
|
||||
R.drawable.drawer_pushpin,
|
||||
R.drawable.drawer_tv,
|
||||
R.drawable.drawer_photography,
|
||||
R.drawable.drawer_books,
|
||||
R.drawable.drawer_id,
|
||||
R.drawable.drawer_gear
|
||||
};
|
||||
|
165
android/src/fishrungames/bashgid/VideoListFragment.java
Normal file
165
android/src/fishrungames/bashgid/VideoListFragment.java
Normal file
@ -0,0 +1,165 @@
|
||||
package fishrungames.bashgid;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import fishrungames.bashgid.core.VideoManager;
|
||||
import fishrungames.bashgid.core.VideoManager.VideoRecord;
|
||||
import fishrungames.networkutils.ImageManager;
|
||||
import fishrungames.networkutils.UniversalActionWithCallback;
|
||||
import fishrungames.networkutils.interfaces.RemoveCallbackInterface;
|
||||
import fishrungames.networkutils.interfaces.UpdateAndFinishCallbackInterface;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
public class VideoListFragment extends Fragment implements UpdateAndFinishCallbackInterface
|
||||
{
|
||||
|
||||
ListAdapter listAdapter;
|
||||
|
||||
GridView gridView;
|
||||
|
||||
ArrayList<VideoRecord> videoRecordArr;
|
||||
|
||||
RemoveCallbackInterface removeCallback = null;
|
||||
Object removeCallbackSynchronizer = new Object();
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
|
||||
videoRecordArr = VideoManager.getInstance().getVideoList();
|
||||
|
||||
removeCallback = UniversalActionWithCallback.PerformActionIfNotPerforming(VideoManager.getInstance(), null, this, "VideoManager");
|
||||
|
||||
View rootView = inflater.inflate(R.layout.fragment_video_page, container, false);
|
||||
|
||||
gridView = (GridView) rootView.findViewById(R.id.gridView);
|
||||
|
||||
listAdapter = new ListAdapter(getActivity());
|
||||
|
||||
gridView.setAdapter(listAdapter);
|
||||
|
||||
gridView.setOnItemClickListener(new OnItemClickListener()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
|
||||
{
|
||||
MainActivity.getInstance().OpenVideoRecordScreen(videoRecordArr.get(position), MainActivity.TAG_FROM_VIDEOLISTFRAGMENT_TO_VIDEORECORDFRAGMENT);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
RefreshVideoList();
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView()
|
||||
{
|
||||
synchronized (removeCallbackSynchronizer)
|
||||
{
|
||||
if (removeCallback != null)
|
||||
{
|
||||
removeCallback.RemoveCallback();
|
||||
removeCallback = null;
|
||||
}
|
||||
}
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
public void RefreshVideoList()
|
||||
{
|
||||
videoRecordArr = VideoManager.getInstance().getVideoList();
|
||||
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnFinished()
|
||||
{
|
||||
synchronized (removeCallbackSynchronizer)
|
||||
{
|
||||
removeCallback = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnUpdated(Bundle result)
|
||||
{
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
RefreshVideoList();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public class ListAdapter extends BaseAdapter {
|
||||
private Context mContext;
|
||||
|
||||
public ListAdapter(Context c) {
|
||||
mContext = c;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return videoRecordArr.size();
|
||||
}
|
||||
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// create a new ImageView for each item referenced by the Adapter
|
||||
@SuppressLint("InflateParams")
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
|
||||
View view;
|
||||
if (convertView == null) { // if it's not recycled, initialize some attributes
|
||||
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = inflater.inflate(R.layout.video_page_list_element, null);
|
||||
|
||||
|
||||
} else {
|
||||
view = convertView;
|
||||
}
|
||||
|
||||
ImageView imageView = (ImageView)view.findViewById(R.id.imageView);
|
||||
TextView nameTextView = (TextView) view.findViewById(R.id.nameTextView);
|
||||
|
||||
ImageManager.getInstance().ApplyImageToImageView(imageView, videoRecordArr.get(position).imageUrl);
|
||||
|
||||
nameTextView.setText(videoRecordArr.get(position).name);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
59
android/src/fishrungames/bashgid/VideoRecordFragment.java
Normal file
59
android/src/fishrungames/bashgid/VideoRecordFragment.java
Normal file
@ -0,0 +1,59 @@
|
||||
package fishrungames.bashgid;
|
||||
|
||||
|
||||
import fishrungames.networkutils.ImageManager;
|
||||
import fishrungames.bashgid.core.VideoManager.VideoRecord;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
public class VideoRecordFragment extends Fragment
|
||||
{
|
||||
|
||||
VideoRecord videoRecord;
|
||||
|
||||
public VideoRecordFragment(VideoRecord videoRecord)
|
||||
{
|
||||
this.videoRecord = videoRecord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_video_record_page, container, false);
|
||||
|
||||
TextView nameTextView = (TextView) rootView.findViewById(R.id.nameTextView);
|
||||
nameTextView.setText(videoRecord.name);
|
||||
|
||||
TextView descriptionTextView = (TextView) rootView.findViewById(R.id.descriptionTextView);
|
||||
descriptionTextView.setText(videoRecord.description);
|
||||
|
||||
ImageView imageView = (ImageView) rootView.findViewById(R.id.imageView);
|
||||
ImageManager.getInstance().ApplyImageToImageView(imageView, videoRecord.imageUrl);
|
||||
|
||||
imageView.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
if (videoRecord.videoType.equals("youtube"))
|
||||
{
|
||||
MainActivity.getInstance().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(videoRecord.videoUrl)));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
|
||||
}
|
92
android/src/fishrungames/bashgid/core/BookManager.java
Normal file
92
android/src/fishrungames/bashgid/core/BookManager.java
Normal file
@ -0,0 +1,92 @@
|
||||
package fishrungames.bashgid.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import fishrungames.networkutils.ImageManager;
|
||||
import fishrungames.networkutils.UpdateCallbackHolder;
|
||||
import fishrungames.networkutils.interfaces.NetworkActionInterface;
|
||||
|
||||
|
||||
public class BookManager implements NetworkActionInterface
|
||||
{
|
||||
|
||||
public static class BookRecord
|
||||
{
|
||||
public String name;
|
||||
public String author;
|
||||
public String imageUrl;
|
||||
public Integer price;
|
||||
public String description;
|
||||
|
||||
public BookRecord(String name, String author, String imageUrl, Integer price, String description)
|
||||
{
|
||||
this.name = name;
|
||||
this.author = author;
|
||||
this.imageUrl = imageUrl;
|
||||
this.price = price;
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<BookRecord> BookArr = new ArrayList<BookRecord>();
|
||||
|
||||
public static BookManager instance = null;
|
||||
|
||||
public static BookManager getInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new BookManager();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public BookManager()
|
||||
{
|
||||
initBooks();
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<BookRecord> getBooks()
|
||||
{
|
||||
ArrayList<BookRecord> books = new ArrayList<BookRecord>();
|
||||
|
||||
synchronized(BookArr)
|
||||
{
|
||||
books.addAll(BookArr);
|
||||
}
|
||||
|
||||
return books;
|
||||
}
|
||||
|
||||
private void initBooks()
|
||||
{
|
||||
BookArr.add(new BookRecord("Репка", "", "http://www.kitap-ufa.ru/upload/iblock/079/575.jpg", 40, "Русская народная сказка..."));
|
||||
BookArr.add(new BookRecord("Уроки поэзии", "Рахматуллин С.И.", "http://www.kitap-ufa.ru/upload/iblock/6e7/012.jpg", 85, "В книгу вошли стихотворные произведения..."));
|
||||
BookArr.add(new BookRecord("Новые валенки", "Калимуллина Г.К.", "http://www.kitap-ufa.ru/upload/iblock/edd/010.jpg", 75, "Детство - самая прекрасная, веселая и интересная пора в жизни человека..."));
|
||||
BookArr.add(new BookRecord("В стране Урала", "Рафиков Б.З.", "", 90, "Эта книга настоящего мастера пера не оставит..."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void InThreadAction(Bundle query, UpdateCallbackHolder callbackHolder)
|
||||
{
|
||||
|
||||
ArrayList<String> imageToDownloadList = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < BookArr.size(); i++)
|
||||
{
|
||||
imageToDownloadList.add(BookArr.get(i).imageUrl);
|
||||
}
|
||||
|
||||
Bundle innerQuery = new Bundle();
|
||||
|
||||
innerQuery.putStringArray("imageUrlArr", imageToDownloadList.toArray(new String[imageToDownloadList.size()]));
|
||||
|
||||
ImageManager.getInstance().InThreadAction(innerQuery, callbackHolder);
|
||||
|
||||
callbackHolder.OnUpdated(null);
|
||||
}
|
||||
}
|
95
android/src/fishrungames/bashgid/core/VideoManager.java
Normal file
95
android/src/fishrungames/bashgid/core/VideoManager.java
Normal file
@ -0,0 +1,95 @@
|
||||
package fishrungames.bashgid.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import fishrungames.networkutils.ImageManager;
|
||||
import fishrungames.networkutils.UpdateCallbackHolder;
|
||||
import fishrungames.networkutils.interfaces.NetworkActionInterface;
|
||||
|
||||
|
||||
public class VideoManager implements NetworkActionInterface
|
||||
{
|
||||
|
||||
public static class VideoRecord
|
||||
{
|
||||
public String name;
|
||||
public String videoUrl;
|
||||
public String imageUrl;
|
||||
public String videoType;
|
||||
public String description;
|
||||
|
||||
public VideoRecord(String name, String videoUrl, String imageUrl, String videoType, String description)
|
||||
{
|
||||
this.name = name;
|
||||
this.videoUrl = videoUrl;
|
||||
this.imageUrl = imageUrl;
|
||||
this.videoType = videoType;
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<VideoRecord> VideoArr = new ArrayList<VideoRecord>();
|
||||
|
||||
public static VideoManager instance = null;
|
||||
|
||||
public static VideoManager getInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new VideoManager();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public VideoManager()
|
||||
{
|
||||
initVideos();
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<VideoRecord> getVideoList()
|
||||
{
|
||||
ArrayList<VideoRecord> videos = new ArrayList<VideoRecord>();
|
||||
|
||||
synchronized(VideoArr)
|
||||
{
|
||||
videos.addAll(VideoArr);
|
||||
}
|
||||
|
||||
return videos;
|
||||
}
|
||||
|
||||
private void initVideos()
|
||||
{
|
||||
VideoArr.add(new VideoRecord("Rickroll", "http://www.youtube.com/watch?v=dQw4w9WgXcQ", "http://img.youtube.com/vi/dQw4w9WgXcQ/0.jpg", "youtube", "Rickroll"));
|
||||
/*
|
||||
BookArr.add(new BookRecord("Репка", "", "http://www.kitap-ufa.ru/upload/iblock/079/575.jpg", 40, "Русская народная сказка..."));
|
||||
BookArr.add(new BookRecord("Уроки поэзии", "Рахматуллин С.И.", "http://www.kitap-ufa.ru/upload/iblock/6e7/012.jpg", 85, "В книгу вошли стихотворные произведения..."));
|
||||
BookArr.add(new BookRecord("Новые валенки", "Калимуллина Г.К.", "http://www.kitap-ufa.ru/upload/iblock/edd/010.jpg", 75, "Детство - самая прекрасная, веселая и интересная пора в жизни человека..."));
|
||||
BookArr.add(new BookRecord("В стране Урала", "Рафиков Б.З.", "", 90, "Эта книга настоящего мастера пера не оставит..."));
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void InThreadAction(Bundle query, UpdateCallbackHolder callbackHolder)
|
||||
{
|
||||
|
||||
ArrayList<String> imageToDownloadList = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < VideoArr.size(); i++)
|
||||
{
|
||||
imageToDownloadList.add(VideoArr.get(i).imageUrl);
|
||||
}
|
||||
|
||||
Bundle innerQuery = new Bundle();
|
||||
|
||||
innerQuery.putStringArray("imageUrlArr", imageToDownloadList.toArray(new String[imageToDownloadList.size()]));
|
||||
|
||||
ImageManager.getInstance().InThreadAction(innerQuery, callbackHolder);
|
||||
|
||||
callbackHolder.OnUpdated(null);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user