Commit 928435c6 authored by Choirunnisa Fatima's avatar Choirunnisa Fatima
Browse files

add inventory, tradebox, find item, offersbox, offer item

parent 617b9f83
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ichakid.grandquest3" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".FullscreenActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:theme="@style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".InventoryActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/FullscreenTheme" >
</activity>
<activity
android:name=".FindActivity"
android:label="@string/title_activity_find" >
</activity>
<activity
android:name=".TradeboxActivity"
android:label="@string/title_activity_tradebox" >
</activity>
<activity
android:name=".OffersboxActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/title_activity_offersbox"
android:theme="@style/FullscreenTheme" >
</activity>
<activity
android:name=".OfferActivity"
android:label="@string/title_activity_offer" >
</activity>
</application>
</manifest>
This file is downloaded from fonts101.com, all fonts on the website are available for free and may not be resold.
Credits to original creators. Let us know how we can serve you better @ fonts101.com
Visit http://www.fonts101.com
\ No newline at end of file
package ichakid.grandquest3;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Typeface;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.GridView;
import android.widget.ImageButton;
import android.widget.TextView;
import java.util.ArrayList;
public class FindActivity extends Activity implements View.OnClickListener {
GridView gridView;
ArrayList<Item> itemGridArray = new ArrayList<Item>();
InventoryGridViewAdapter itemGridAdapter;
GridView gridView2;
ArrayList<Item> itemGridArray2 = new ArrayList<Item>();
InventoryGridViewAdapter itemGridAdapter2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_find);
TextView title = (TextView) findViewById(R.id.findTitle);
Typeface font = Typeface.createFromAsset(getAssets(), "OneDirection.ttf");
title.setTypeface(font);
final ImageButton closeButton = (ImageButton) findViewById(R.id.closeButton);
closeButton.setOnClickListener(this);
itemGridArray.add(new Item(Item.findBitmapById(this, 0), Item.findNameById(0), true, false, 0));
itemGridArray.add(new Item(Item.findBitmapById(this, 1), Item.findNameById(1), true, false, 1));
itemGridArray.add(new Item(Item.findBitmapById(this, 2), Item.findNameById(2), true, false, 2));
itemGridArray.add(new Item(Item.findBitmapById(this, 3), Item.findNameById(3), true, false, 3));
itemGridArray.add(new Item(Item.findBitmapById(this, 4), Item.findNameById(4), true, false, 4));
itemGridArray.add(new Item(Item.findBitmapById(this, 5), Item.findNameById(5), true, false, 5));
itemGridArray.add(new Item(Item.findBitmapById(this, 6), Item.findNameById(6), true, false, 6));
itemGridArray.add(new Item(Item.findBitmapById(this, 7), Item.findNameById(7), true, false, 7));
itemGridArray.add(new Item(Item.findBitmapById(this, 8), Item.findNameById(8), true, false, 8));
itemGridArray.add(new Item(Item.findBitmapById(this, 9), Item.findNameById(9), true, false, 9));
gridView = (GridView) findViewById(R.id.gridView1);
itemGridAdapter = new InventoryGridViewAdapter(this, R.layout.inventory_grid_row, itemGridArray);
gridView.setAdapter(itemGridAdapter);
itemGridArray2.add(new Item(true, true));
gridView2 = (GridView) findViewById(R.id.gridView2);
itemGridAdapter2 = new InventoryGridViewAdapter(this, R.layout.inventory_grid_row, itemGridArray2);
gridView2.setAdapter(itemGridAdapter2);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_find, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.closeButton:
finish();
break;
}
}
}
package ichakid.grandquest3;
import ichakid.grandquest3.util.SystemUiHider;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
/**
* An example full-screen activity that shows and hides the system UI (i.e.
* status bar and navigation/system bar) with user interaction.
*
* @see SystemUiHider
*/
public class FullscreenActivity extends Activity implements View.OnClickListener{
/**
* Whether or not the system UI should be auto-hidden after
* {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
*/
private static final boolean AUTO_HIDE = true;
/**
* If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after
* user interaction before hiding the system UI.
*/
private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
/**
* If set, will toggle the system UI visibility upon interaction. Otherwise,
* will show the system UI visibility upon interaction.
*/
private static final boolean TOGGLE_ON_CLICK = true;
/**
* The flags to pass to {@link SystemUiHider#getInstance}.
*/
private static final int HIDER_FLAGS = SystemUiHider.FLAG_HIDE_NAVIGATION;
/**
* The instance of the {@link SystemUiHider} for this activity.
*/
private SystemUiHider mSystemUiHider;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fullscreen);
final View controlsView = findViewById(R.id.fullscreen_content_controls);
final View contentView = findViewById(R.id.fullscreen_content);
final Button inventoryButton = (Button) findViewById(R.id.inventoryButton);
inventoryButton.setOnClickListener(this);
final Button findButton = (Button) findViewById(R.id.findButton);
findButton.setOnClickListener(this);
final Button tradeboxButton = (Button) findViewById(R.id.tradeboxButton);
tradeboxButton.setOnClickListener(this);
final Button offersButton = (Button) findViewById(R.id.offerButton);
offersButton.setOnClickListener(this);
final Button offerButton = (Button) findViewById(R.id.offeringButton);
offerButton.setOnClickListener(this);
// Set up an instance of SystemUiHider to control the system UI for
// this activity.
mSystemUiHider = SystemUiHider.getInstance(this, contentView, HIDER_FLAGS);
mSystemUiHider.setup();
mSystemUiHider
.setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() {
// Cached values.
int mControlsHeight;
int mShortAnimTime;
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public void onVisibilityChange(boolean visible) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
// If the ViewPropertyAnimator API is available
// (Honeycomb MR2 and later), use it to animate the
// in-layout UI controls at the bottom of the
// screen.
if (mControlsHeight == 0) {
mControlsHeight = controlsView.getHeight();
}
if (mShortAnimTime == 0) {
mShortAnimTime = getResources().getInteger(
android.R.integer.config_shortAnimTime);
}
controlsView.animate()
.translationY(visible ? 0 : mControlsHeight)
.setDuration(mShortAnimTime);
} else {
// If the ViewPropertyAnimator APIs aren't
// available, simply show or hide the in-layout UI
// controls.
controlsView.setVisibility(visible ? View.VISIBLE : View.GONE);
}
if (visible && AUTO_HIDE) {
// Schedule a hide().
delayedHide(AUTO_HIDE_DELAY_MILLIS);
}
}
});
// Set up the user interaction to manually show or hide the system UI.
contentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (TOGGLE_ON_CLICK) {
mSystemUiHider.toggle();
} else {
mSystemUiHider.show();
}
}
});
// Upon interacting with UI controls, delay any scheduled hide()
// operations to prevent the jarring behavior of controls going away
// while interacting with the UI.
findViewById(R.id.dummy_button).setOnTouchListener(mDelayHideTouchListener);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Trigger the initial hide() shortly after the activity has been
// created, to briefly hint to the user that UI controls
// are available.
delayedHide(100);
}
/**
* Touch listener to use for in-layout UI controls to delay hiding the
* system UI. This is to prevent the jarring behavior of controls going away
* while interacting with activity UI.
*/
View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (AUTO_HIDE) {
delayedHide(AUTO_HIDE_DELAY_MILLIS);
}
return false;
}
};
Handler mHideHandler = new Handler();
Runnable mHideRunnable = new Runnable() {
@Override
public void run() {
mSystemUiHider.hide();
}
};
/**
* Schedules a call to hide() in [delay] milliseconds, canceling any
* previously scheduled calls.
*/
private void delayedHide(int delayMillis) {
mHideHandler.removeCallbacks(mHideRunnable);
mHideHandler.postDelayed(mHideRunnable, delayMillis);
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.inventoryButton:
Intent inventoryIntent = new Intent(this, InventoryActivity.class);
startActivity(inventoryIntent);
break;
case R.id.offerButton:
Intent offersboxIntent = new Intent(this, OffersboxActivity.class);
startActivity(offersboxIntent);
break;
case R.id.offeringButton:
Intent offeringIntent = new Intent(this, OfferActivity.class);
startActivity(offeringIntent);
break;
case R.id.tradeboxButton:
Intent tradeboxIntent = new Intent(this, TradeboxActivity.class);
startActivity(tradeboxIntent);
break;
case R.id.findButton:
Intent findIntent = new Intent(this, FindActivity.class);
startActivity(findIntent);
break;
}
}
}
package ichakid.grandquest3;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.ImageButton;
import android.widget.TextView;
import java.util.ArrayList;
/**
* Created by User on 4/23/2015.
*/
public class InventoryActivity extends Activity implements View.OnClickListener{
//Inventory
GridView gridView;
ArrayList<Item> inventoryGridArray = new ArrayList<Item>();
InventoryGridViewAdapter inventoryGridAdapter;
//Mixing item
GridView mixView;
ArrayList<Item> mixGridArray = new ArrayList<Item>();
InventoryGridViewAdapter mixGridAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.inventory_grid);
TextView title = (TextView) findViewById(R.id.inventoryTitle);
Typeface font = Typeface.createFromAsset(getAssets(), "OneDirection.ttf");
title.setTypeface(font);
TextView title2 = (TextView) findViewById(R.id.mixTitle);
title2.setTypeface(font);
final ImageButton closeButton = (ImageButton) findViewById(R.id.closeButton);
closeButton.setOnClickListener(this);
inventoryGridArray.add(new Item(Item.findBitmapById(this, 0), 5, true, false, 0));
inventoryGridArray.add(new Item(Item.findBitmapById(this, 1), 5, true, false, 1));
inventoryGridArray.add(new Item(Item.findBitmapById(this, 2), 5, true, false, 2));
inventoryGridArray.add(new Item(Item.findBitmapById(this, 3), 5, true, false, 3));
inventoryGridArray.add(new Item(Item.findBitmapById(this, 4), 5, true, false, 4));
inventoryGridArray.add(new Item(Item.findBitmapById(this, 5), 5, true, false, 5));
inventoryGridArray.add(new Item(Item.findBitmapById(this, 6), 5, true, false, 6));
inventoryGridArray.add(new Item(Item.findBitmapById(this, 7), 5, true, false, 7));
inventoryGridArray.add(new Item(Item.findBitmapById(this, 8), 5, true, false, 8));
inventoryGridArray.add(new Item(Item.findBitmapById(this, 9), 5, true, false, 9));
gridView = (GridView) findViewById(R.id.gridView1);
inventoryGridAdapter = new InventoryGridViewAdapter(this, R.layout.inventory_grid_row, inventoryGridArray);
gridView.setAdapter(inventoryGridAdapter);
//set mix grid view item
Bitmap plusIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.plus);
Bitmap equalIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.equal);
mixGridArray.add(new Item(true, true));
mixGridArray.add(new Item(plusIcon, false));
mixGridArray.add(new Item(true, true));
mixGridArray.add(new Item(equalIcon, false));
mixGridArray.add(new Item(true, false));
mixView = (GridView) findViewById(R.id.gridView);
mixGridAdapter = new InventoryGridViewAdapter(this, R.layout.inventory_grid_row, mixGridArray);
mixView.setAdapter(mixGridAdapter);
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.closeButton:
finish();
break;
}
}
}
package ichakid.grandquest3;
import android.app.Activity;
import android.content.ClipData;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.DragEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.NumberPicker;
import android.widget.TextView;
import org.w3c.dom.Text;
import java.util.ArrayList;
import java.util.logging.Logger;
/**
* Created by User on 4/23/2015.
*/
public class InventoryGridViewAdapter extends ArrayAdapter<Item>{
Context context;
int layoutResourceId;
ArrayList<Item> data = new ArrayList<>();
public InventoryGridViewAdapter(Context context, int layoutResourceId, ArrayList<Item> data) {
super(context, layoutResourceId, data);
this.layoutResourceId = layoutResourceId;
this.context = context;
this.data = data;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
ItemHolder holder = null;
if (row == null) {
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent, false);
holder = new ItemHolder();
holder.txtTitle = (TextView) row.findViewById(R.id.item_text);
holder.imageItem = (ImageView) row.findViewById(R.id.item_image);
holder.container = (FrameLayout) row.findViewById(R.id.container);
holder.itemId = (TextView) row.findViewById(R.id.item_id);
row.setTag(holder);
} else {
holder = (ItemHolder) row.getTag();
}
Item item = data.get(position);
if (item.getNumberOf() > 0) {
holder.txtTitle.setText("" + item.getNumberOf());
} else {
holder.txtTitle.setText(item.getTitle());
}
holder.imageItem.setImageBitmap(item.getImage());
if (item.getId() >= 0){
holder.itemId.setText("" + item.getId());
}
if(item.getContainer()) {
holder.container.setBackgroundResource(R.drawable.empty);
if (!(getContext().toString().contains("TradeboxActivity")) && !(getContext().toString().contains("OffersboxActivity")))
holder.imageItem.setOnTouchListener(new MyTouchListener());
}
if(item.isTargetDrop()){
holder.container.setOnDragListener(new MyDragListener());
}
return row;
}
static class ItemHolder {
TextView txtTitle;
ImageView imageItem;
FrameLayout container;
TextView itemId;
}
private class MyTouchListener implements View.OnTouchListener {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
ClipData data = ClipData.newPlainText("", "");
View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
view.startDrag(data, shadowBuilder, view, 0);
return true;
} else {
return false;
}
}
}
private class MyDragListener implements View.OnDragListener {
Drawable enterShape = context.getResources().getDrawable(R.drawable.empty);
Drawable normalShape = context.getResources().getDrawable(R.drawable.empty);
@Override
public boolean onDrag(View v, DragEvent event) {
int action = event.getAction();
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
// do nothing
break;
case DragEvent.ACTION_DRAG_ENTERED:
v.setBackgroundDrawable(enterShape);
break;
case DragEvent.ACTION_DRAG_EXITED:
v.setBackgroundDrawable(normalShape);
break;
case DragEvent.ACTION_DROP:
FrameLayout container = (FrameLayout) v;
// Dropped, reassign View to ViewGroup
ImageView view = (ImageView) event.getLocalState();
ViewGroup owner = (ViewGroup) view.getParent();
ImageView oldView = new ImageView(context);
oldView.setImageDrawable(view.getDrawable());
owner.removeView(view);
owner.addView(oldView);
String id = "" + ((TextView) owner.getChildAt(0)).getText();
TextView number = (TextView) ((ViewGroup) owner.getParent()).getChildAt(1);
if ((!getContext().toString().contains("InventoryActivity")) || (Integer.parseInt(number.getText().toString()) >= 3)){
//Replace item image
container.removeView((ImageView) container.getChildAt(1));
container.addView(view);
((TextView) container.getChildAt(0)).setText(id);
view.setVisibility(View.VISIBLE);
//Decrease number of items by 3