[INTERMEDIATE STATE] Pager implementation started
Seems not to work at all. We need to have a further look into this. At least it is somehow not crashing anymore...
2
.idea/misc.xml
generated
@@ -56,7 +56,7 @@
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
@@ -24,8 +24,10 @@ dependencies {
|
||||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
compile 'com.android.support:appcompat-v7:25.+'
|
||||
compile 'com.android.support:appcompat-v7:25.3.1'
|
||||
compile 'com.android.support.constraint:constraint-layout:1.0.2'
|
||||
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
|
||||
compile 'devlight.io:navigationtabbar:1.2.5'
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:design:25.3.1'
|
||||
}
|
||||
|
||||
@@ -243,4 +243,30 @@ public class Constants {
|
||||
KEY_GAME,
|
||||
KEY_AVAILABLE
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Enum Value defining the position of the Character Tab.
|
||||
*/
|
||||
static final int CHARACTER = 0;
|
||||
|
||||
/**
|
||||
* Enum Value defining the position of the Kart Tab.
|
||||
*/
|
||||
static final int KART = 1;
|
||||
|
||||
/**
|
||||
* Enum Value defining the position of the Track Tab.
|
||||
*/
|
||||
static final int TRACK = 2;
|
||||
|
||||
/**
|
||||
* Enum Value defining the position of the Accessory Tab.
|
||||
*/
|
||||
static final int ACCESSORY = 3;
|
||||
|
||||
/**
|
||||
* Enum Value defining the position of the Wheels Tab.
|
||||
*/
|
||||
static final int WHEELS = 4;
|
||||
}
|
||||
|
||||
@@ -222,11 +222,10 @@ public class DatabaseHandler extends SQLiteAssetHelper {
|
||||
|
||||
final Cursor cursor = database.query(Constants.TABLE_TRACK, Constants.PROJECTION_TRACK,
|
||||
selectionClause, selectionArgs, null, null, null, null);
|
||||
if (cursor != null) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
Log.d(TAG, "getAllTracks: Moving cursor to first.");
|
||||
cursor.moveToFirst();
|
||||
} else {
|
||||
Log.d(TAG, "getAllTracks: cursor is null");
|
||||
Log.d(TAG, "getAllTracks: cursor is null or cannot be moved to first.");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -277,7 +276,7 @@ public class DatabaseHandler extends SQLiteAssetHelper {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (availableIdx < 0) {
|
||||
if (availableIdx >= 0) {
|
||||
track.setAvailable(cursor.getInt(availableIdx));
|
||||
} else {
|
||||
Log.d(TAG, "getAllTracks: No such column [" + Constants.KEY_AVAILABLE + "]");
|
||||
@@ -330,11 +329,10 @@ public class DatabaseHandler extends SQLiteAssetHelper {
|
||||
|
||||
final Cursor cursor = database.query(Constants.TABLE_KART, Constants.PROJECTION_KART,
|
||||
selectionClause, selectionArgs, null, null, null, null);
|
||||
if (cursor != null) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
Log.d(TAG, "getAllKarts: Moving cursor to first.");
|
||||
cursor.moveToFirst();
|
||||
} else {
|
||||
Log.d(TAG, "getAllKarts: cursor is null");
|
||||
Log.d(TAG, "getAllKarts: cursor is null or cannot be moved to first.");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -401,7 +399,7 @@ public class DatabaseHandler extends SQLiteAssetHelper {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (availableIdx < 0) {
|
||||
if (availableIdx >= 0) {
|
||||
kart.setAvailable(cursor.getInt(availableIdx));
|
||||
} else {
|
||||
Log.d(TAG, "getAllKarts: No such column [" + Constants.KEY_AVAILABLE + "]");
|
||||
@@ -456,6 +454,13 @@ public class DatabaseHandler extends SQLiteAssetHelper {
|
||||
Constants.PROJECTION_CHARACTER, selectionClause, selectionArgs, null, null, null,
|
||||
null);
|
||||
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
Log.d(TAG, "getAllCharacters: Moving cursor to first.");
|
||||
} else {
|
||||
Log.d(TAG, "getAllCharacters: cursor is null or cannot be moved to first.");
|
||||
return null;
|
||||
}
|
||||
|
||||
final ArrayList<Character> allAvailableCharacters = new ArrayList<>();
|
||||
|
||||
do {
|
||||
@@ -496,7 +501,7 @@ public class DatabaseHandler extends SQLiteAssetHelper {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (availableIdx < 0) {
|
||||
if (availableIdx >= 0) {
|
||||
character.setAvailable(cursor.getInt(availableIdx));
|
||||
} else {
|
||||
Log.d(TAG, "getAllCharacters: No such column [" + Constants.KEY_AVAILABLE + "]");
|
||||
@@ -550,7 +555,12 @@ public class DatabaseHandler extends SQLiteAssetHelper {
|
||||
|
||||
final Cursor cursor = database.query(Constants.TABLE_RULESET, Constants.PROJECTION_RULESET,
|
||||
selectionClause, selectionArgs, null, null, null, null);
|
||||
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
Log.d(TAG, "getAllRulesets: Moving cursor to first.");
|
||||
} else {
|
||||
Log.d(TAG, "getAllRulesets: cursor is null or cannot be moved to first.");
|
||||
return null;
|
||||
}
|
||||
final ArrayList<Ruleset> allAvailableRulesets = new ArrayList<>();
|
||||
do {
|
||||
final int idIdx = cursor.getColumnIndex(Constants.KEY_ID);
|
||||
@@ -678,6 +688,13 @@ public class DatabaseHandler extends SQLiteAssetHelper {
|
||||
final Cursor cursor = database.query(Constants.TABLE_ACCESSORY,
|
||||
Constants.PROJECTION_ACCESSORY, selectionClause, selectionArgs, null, null, null,
|
||||
null);
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
Log.d(TAG, "getAllAccessories: Moving cursor to first.");
|
||||
} else {
|
||||
Log.d(TAG, "getAllAccessories: cursor is null or cannot be moved to first.");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
final ArrayList<Accessory> allAvailableAccessories = new ArrayList<>();
|
||||
|
||||
@@ -710,7 +727,7 @@ public class DatabaseHandler extends SQLiteAssetHelper {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (availableIdx < 0) {
|
||||
if (availableIdx >= 0) {
|
||||
accessory.setAvailable(cursor.getInt(availableIdx));
|
||||
} else {
|
||||
Log.d(TAG, "getAllAccessories: No such column [" + Constants.KEY_AVAILABLE + "]");
|
||||
@@ -764,11 +781,10 @@ public class DatabaseHandler extends SQLiteAssetHelper {
|
||||
|
||||
final Cursor cursor = database.query(Constants.TABLE_WHEELS, Constants.PROJECTION_WHEELS,
|
||||
selectionClause, selectionArgs, null, null, null, null);
|
||||
if (cursor != null) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
Log.d(TAG, "getAllWheels: Moving cursor to first.");
|
||||
cursor.moveToFirst();
|
||||
} else {
|
||||
Log.d(TAG, "getAllWheels: cursor is null");
|
||||
Log.d(TAG, "getAllWheels: cursor is null or cannot be moved to first.");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -803,7 +819,7 @@ public class DatabaseHandler extends SQLiteAssetHelper {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (availableIdx < 0) {
|
||||
if (availableIdx >= 0) {
|
||||
wheels.setAvailable(cursor.getInt(availableIdx));
|
||||
} else {
|
||||
Log.d(TAG, "getAllWheels: No such column [" + Constants.KEY_AVAILABLE + "]");
|
||||
@@ -835,11 +851,10 @@ public class DatabaseHandler extends SQLiteAssetHelper {
|
||||
|
||||
final Cursor cursor = database.query(Constants.TABLE_GAME, Constants.PROJECTION_GAME, null,
|
||||
null, null, null, null, null);
|
||||
if (cursor != null) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
Log.d(TAG, "getAllGames: Moving cursor to first.");
|
||||
cursor.moveToFirst();
|
||||
} else {
|
||||
Log.d(TAG, "getAllGames: cursor is null");
|
||||
Log.d(TAG, "getAllGames: cursor is null or cannot be moved to first.");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,46 @@
|
||||
package com.de.aldo_apps.aldo.mariokartcircuitselector;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Accessory;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Character;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Kart;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Track;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Wheels;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.fragments.PagerItem;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.fragments.SingleCharacterFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import devlight.io.library.ntb.NavigationTabBar;
|
||||
|
||||
public class GameSelection extends AppCompatActivity {
|
||||
|
||||
private static final String TAG = "GameSelection";
|
||||
|
||||
private PagerItem mCharacterItems;
|
||||
private PagerItem mKartItems;
|
||||
private PagerItem mTrackItems;
|
||||
private PagerItem mAccessoryItems;
|
||||
private PagerItem mWheelsItems;
|
||||
|
||||
private ArrayList<Kart> mAllKarts = new ArrayList<>();
|
||||
private ArrayList<Character> mAllCharacters = new ArrayList<>();
|
||||
private ArrayList<Track> mAllTracks = new ArrayList<>();
|
||||
private ArrayList<Wheels> mAllWheels = new ArrayList<>();
|
||||
private ArrayList<Accessory> mAllAccessories = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -18,24 +48,167 @@ public class GameSelection extends AppCompatActivity {
|
||||
|
||||
final DatabaseHandler handler = new DatabaseHandler(this);
|
||||
|
||||
final EditText editText = (EditText) findViewById(R.id.id_input);
|
||||
mAllKarts = handler.getAllKarts(null, false);
|
||||
mAllCharacters = handler.getAllCharacters(null, false);
|
||||
mAllTracks = handler.getAllTracks(null, false);
|
||||
mAllWheels = handler.getAllWheels(null, false);
|
||||
mAllAccessories = handler.getAllAccessories(null, false);
|
||||
|
||||
final Button button = (Button) findViewById(R.id.ok_button);
|
||||
final String[] colors = getResources().getStringArray(R.array.vertical_ntb);
|
||||
|
||||
final TextView result = (TextView) findViewById(R.id.result_field);
|
||||
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
final ViewPager viewPager = (ViewPager) findViewById(R.id.vp_horizontal_ntb);
|
||||
viewPager.setAdapter(new PagerAdapter() {
|
||||
@Override
|
||||
public void onClick(final View view) {
|
||||
final int id = Integer.parseInt(editText.getText().toString());
|
||||
final Track track = handler.testDBConnection(id);
|
||||
if (track != null) {
|
||||
final String resultStr = track.getGame() + " - " + track.getName()
|
||||
+ " - Available = " + track.getAvailable();
|
||||
result.setText(resultStr);
|
||||
public int getCount() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(final View view, final Object object) {
|
||||
return view.equals(object);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void destroyItem(final View container, final int position, final Object object) {
|
||||
((ViewPager) container).removeView((View) object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object instantiateItem(final ViewGroup container, final int position) {
|
||||
final View view = LayoutInflater.from(
|
||||
getBaseContext()).inflate(R.layout.pager_item, null, false);
|
||||
|
||||
switch (position) {
|
||||
case Constants.CHARACTER:
|
||||
mCharacterItems = new PagerItem(view, handler, GameSelection.this,
|
||||
getSupportFragmentManager());
|
||||
if (mAllCharacters != null) {
|
||||
mCharacterItems.setArguments(mAllCharacters);
|
||||
}
|
||||
break;
|
||||
case Constants.KART:
|
||||
mKartItems = new PagerItem(view, handler, GameSelection.this,
|
||||
getSupportFragmentManager());
|
||||
if (mAllKarts != null) {
|
||||
mKartItems.setArguments(mAllKarts);
|
||||
}
|
||||
break;
|
||||
case Constants.ACCESSORY:
|
||||
mAccessoryItems = new PagerItem(view, handler, GameSelection.this,
|
||||
getSupportFragmentManager());
|
||||
if (mAllAccessories != null) {
|
||||
mAccessoryItems.setArguments(mAllAccessories);
|
||||
}
|
||||
break;
|
||||
case Constants.TRACK:
|
||||
mTrackItems = new PagerItem(view, handler, GameSelection.this,
|
||||
getSupportFragmentManager());
|
||||
if (mAllTracks != null) {
|
||||
mTrackItems.setArguments(mAllTracks);
|
||||
}
|
||||
break;
|
||||
case Constants.WHEELS:
|
||||
mWheelsItems = new PagerItem(view, handler, GameSelection.this,
|
||||
getSupportFragmentManager());
|
||||
if (mAllWheels != null) {
|
||||
mWheelsItems.setArguments(mAllWheels);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Log.d(TAG, "instantiateItem: No available Item for Position ["
|
||||
+ position + "]");
|
||||
break;
|
||||
}
|
||||
|
||||
container.addView(view);
|
||||
return view;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
final NavigationTabBar navigationTabBar
|
||||
= (NavigationTabBar) findViewById(R.id.ntb_vertical);
|
||||
final ArrayList<NavigationTabBar.Model> models = new ArrayList<>();
|
||||
models.add(
|
||||
new NavigationTabBar.Model.Builder(
|
||||
getResources().getDrawable(R.drawable.character_50_dark_grey),
|
||||
Color.parseColor(colors[0])
|
||||
).title(getString(R.string.title_character))
|
||||
.badgeTitle("NTB")
|
||||
.build()
|
||||
);
|
||||
models.add(
|
||||
new NavigationTabBar.Model.Builder(
|
||||
getResources().getDrawable(R.drawable.kart_50_dark_grey),
|
||||
Color.parseColor(colors[1])
|
||||
).title(getString(R.string.title_kart))
|
||||
.badgeTitle("with")
|
||||
.build()
|
||||
);
|
||||
models.add(
|
||||
new NavigationTabBar.Model.Builder(
|
||||
getResources().getDrawable(R.drawable.track_50_dark_grey),
|
||||
Color.parseColor(colors[2])
|
||||
).title(getString(R.string.title_track))
|
||||
.badgeTitle("state")
|
||||
.build()
|
||||
);
|
||||
models.add(
|
||||
new NavigationTabBar.Model.Builder(
|
||||
getResources().getDrawable(R.drawable.accessory_50_dark_grey),
|
||||
Color.parseColor(colors[3])
|
||||
).title(getString(R.string.title_accessory))
|
||||
.badgeTitle("icon")
|
||||
.build()
|
||||
);
|
||||
models.add(
|
||||
new NavigationTabBar.Model.Builder(
|
||||
getResources().getDrawable(R.drawable.wheels_50_dark_grey),
|
||||
Color.parseColor(colors[4])
|
||||
).title(getString(R.string.title_wheels))
|
||||
.badgeTitle("777")
|
||||
.build()
|
||||
);
|
||||
navigationTabBar.setModels(models);
|
||||
navigationTabBar.setViewPager(viewPager, 2);
|
||||
|
||||
navigationTabBar.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(final int position,
|
||||
final float positionOffset,
|
||||
final int positionOffsetPixels) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(final int position) {
|
||||
Log.d(TAG, "onPageSelected: Selected Tab on Position [" + position
|
||||
+ "] with Title [" + navigationTabBar.getModels().get(position).getTitle()
|
||||
+ "]");
|
||||
navigationTabBar.getModels().get(position).hideBadge();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(final int state) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
navigationTabBar.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int i = 0; i < navigationTabBar.getModels().size(); i++) {
|
||||
final NavigationTabBar.Model model = navigationTabBar.getModels().get(i);
|
||||
navigationTabBar.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
model.showBadge();
|
||||
}
|
||||
}, i * 100);
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.de.aldo_apps.aldo.mariokartcircuitselector.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.ContactsContract;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListAdapter;
|
||||
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.DatabaseHandler;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Character;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.fragments.SingleCharacterFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by aldo7224 on 10.08.17.
|
||||
*/
|
||||
|
||||
public class CharacterListAdapter extends ArrayAdapter<Character> {
|
||||
|
||||
private ArrayList<Character> mList;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private DatabaseHandler mHandler;
|
||||
|
||||
public CharacterListAdapter(final Context context, final ArrayList<Character> characters) {
|
||||
super(context, 0, characters);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
SingleCharacterFragment scf = new SingleCharacterFragment();
|
||||
final View view = scf.creatView(LayoutInflater.from(mContext));
|
||||
scf.initViews(view);
|
||||
scf.setArguments(mList.get(position), mHandler);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
public void setListOfItems(final ArrayList<Character> characters) {
|
||||
mList = characters;
|
||||
}
|
||||
|
||||
public void setDatabaseHandler(final DatabaseHandler handler) {
|
||||
mHandler = handler;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.de.aldo_apps.aldo.mariokartcircuitselector.fragments;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.DatabaseHandler;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.R;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.adapter.CharacterListAdapter;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Accessory;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Character;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Kart;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Track;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Wheels;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by aldo7224 on 10.08.17.
|
||||
*/
|
||||
|
||||
public class PagerItem {
|
||||
|
||||
private static final String TAG = "PagerItem";
|
||||
|
||||
private View mView;
|
||||
|
||||
private ListView mListView;
|
||||
|
||||
private DatabaseHandler mHandler;
|
||||
|
||||
private Activity mContext;
|
||||
|
||||
private FragmentManager mFragmentManager;
|
||||
|
||||
public PagerItem(final View view,
|
||||
final DatabaseHandler databaseHandler,
|
||||
final Activity context,
|
||||
final FragmentManager fragmentManager) {
|
||||
mView = view;
|
||||
mHandler = databaseHandler;
|
||||
mContext = context;
|
||||
mFragmentManager = fragmentManager;
|
||||
mListView = (ListView) view.findViewById(R.id.all_items_list_view);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method which sets the real texts/arguments to the view objects.
|
||||
*
|
||||
* @param objects The List of objects of which we will retrieve our texts/arguments.
|
||||
*/
|
||||
public void setArguments(final ArrayList<? extends Object> objects) {
|
||||
if (objects.size() > 0) {
|
||||
final Object bufferTestObject = objects.get(0);
|
||||
if (bufferTestObject instanceof Character) {
|
||||
handleCharacterObject((ArrayList<Character>) objects);
|
||||
} else if (bufferTestObject instanceof Kart) {
|
||||
handleKartObject((ArrayList<Kart>) objects);
|
||||
} else if (bufferTestObject instanceof Track) {
|
||||
handleTrackObject((ArrayList<Track>) objects);
|
||||
} else if (bufferTestObject instanceof Accessory) {
|
||||
handleAccessoryObject((ArrayList<Accessory>) objects);
|
||||
} else if (bufferTestObject instanceof Wheels) {
|
||||
handleWheelsObject((ArrayList<Wheels>) objects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleCharacterObject(final ArrayList<Character> characters) {
|
||||
final CharacterListAdapter adapter = new CharacterListAdapter(mContext, characters);
|
||||
adapter.setListOfItems(characters);
|
||||
adapter.setDatabaseHandler(mHandler);
|
||||
mListView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
private void handleKartObject(final ArrayList<Kart> karts) {
|
||||
|
||||
}
|
||||
|
||||
private void handleTrackObject(final ArrayList<Track> characters) {
|
||||
|
||||
}
|
||||
|
||||
private void handleAccessoryObject(final ArrayList<Accessory> accessories) {
|
||||
|
||||
}
|
||||
|
||||
private void handleWheelsObject(final ArrayList<Wheels> wheels) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -107,6 +107,11 @@ public class SingleAccessoryFragment extends Fragment {
|
||||
// Initialize all single views and make them visible.
|
||||
mAccessoryName = (TextView) view.findViewById(R.id.single_info_name);
|
||||
mAccessoryName.setVisibility(View.VISIBLE);
|
||||
|
||||
if (mAccessory != null) {
|
||||
mAccessoryAvailable.setChecked(mAccessory.getAvailable());
|
||||
mAccessoryName.setText(mAccessory.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,7 +123,11 @@ public class SingleAccessoryFragment extends Fragment {
|
||||
public void setArguments(final Accessory accessory, final DatabaseHandler handler) {
|
||||
mAccessory = accessory;
|
||||
mHandler = handler;
|
||||
if (mAccessoryAvailable != null) {
|
||||
mAccessoryAvailable.setChecked(accessory.getAvailable());
|
||||
}
|
||||
if (mAccessoryName != null) {
|
||||
mAccessoryName.setText(accessory.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.DatabaseHandler;
|
||||
@@ -23,7 +24,7 @@ import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Character;
|
||||
* @version 0.1
|
||||
* @since 10.08.2017
|
||||
*/
|
||||
public class SingleCharacterFragment extends Fragment {
|
||||
public class SingleCharacterFragment {
|
||||
|
||||
/**
|
||||
* The Tag for Debugging Output.
|
||||
@@ -55,32 +56,16 @@ public class SingleCharacterFragment extends Fragment {
|
||||
*/
|
||||
private DatabaseHandler mHandler;
|
||||
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater,
|
||||
final ViewGroup container,
|
||||
final Bundle savedInstanceState) {
|
||||
/**
|
||||
* The View-Instance of this View.
|
||||
*/
|
||||
private View mView;
|
||||
|
||||
public View creatView(final LayoutInflater inflater) {
|
||||
// Inflate the GenericListItem and return it. All Operations on the View will be handled
|
||||
// in own functions.
|
||||
return inflater.inflate(R.layout.generic_list_item, container, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated(final View view, final Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
// Initialize the Views and member variables.
|
||||
// Make all the Visible/Invisible/Gone Actions here as we know which information will be
|
||||
// shown here.
|
||||
initViews(view);
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View view) {
|
||||
if (mCharacterAvailable != null) {
|
||||
mCharacterAvailable.toggle();
|
||||
}
|
||||
}
|
||||
});
|
||||
Log.d(TAG, "onCreateView: Creating View");
|
||||
return inflater.inflate(R.layout.generic_list_item, null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,8 +74,17 @@ public class SingleCharacterFragment extends Fragment {
|
||||
*
|
||||
* @param view The Parent View.
|
||||
*/
|
||||
private void initViews(final View view) {
|
||||
public void initViews(final View view) {
|
||||
mCharacterAvailable = (CheckBox) view.findViewById(R.id.availability_checkbox);
|
||||
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View view) {
|
||||
if (mCharacterAvailable != null) {
|
||||
mCharacterAvailable.toggle();
|
||||
}
|
||||
}
|
||||
});
|
||||
// Assign a CheckedChange Listener to the Checkbox, so we can update the status in the
|
||||
// database as well.
|
||||
mCharacterAvailable.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@@ -121,6 +115,12 @@ public class SingleCharacterFragment extends Fragment {
|
||||
// Mark the single name view (without additional information) as GONE
|
||||
final View singleName = view.findViewById(R.id.single_info_name);
|
||||
singleName.setVisibility(View.GONE);
|
||||
|
||||
if (mCharacter != null) {
|
||||
mCharacterAvailable.setChecked(mCharacter.getAvailable());
|
||||
mCharacterName.setText(mCharacter.getName());
|
||||
mCharacterWeight.setText(mCharacter.getWeight());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,9 +132,24 @@ public class SingleCharacterFragment extends Fragment {
|
||||
public void setArguments(final Character character, final DatabaseHandler handler) {
|
||||
mCharacter = character;
|
||||
mHandler = handler;
|
||||
if (mCharacterAvailable != null) {
|
||||
mCharacterAvailable.setChecked(character.getAvailable());
|
||||
}
|
||||
if (mCharacterName != null) {
|
||||
mCharacterName.setText(character.getName());
|
||||
}
|
||||
if (mCharacterWeight != null) {
|
||||
mCharacterWeight.setText(character.getWeight());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the View Instance of this View.
|
||||
*
|
||||
* @return the View Instance of this View.
|
||||
*/
|
||||
public View getView() {
|
||||
return mView;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -126,6 +126,13 @@ public class SingleKartFragment extends Fragment {
|
||||
// Mark the single name view (without additional information) as GONE
|
||||
final View singleName = view.findViewById(R.id.single_info_name);
|
||||
singleName.setVisibility(View.GONE);
|
||||
|
||||
if (mKart != null) {
|
||||
mKartAvailable.setChecked(mKart.getAvailable());
|
||||
mKartName.setText(mKart.getName());
|
||||
mKartWeight.setText(mKart.getWeight());
|
||||
mKartDedicatedDriver.setText(mKart.getDedicatedDriver());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,10 +144,18 @@ public class SingleKartFragment extends Fragment {
|
||||
public void setArguments(final Kart kart, final DatabaseHandler handler) {
|
||||
mKart = kart;
|
||||
mHandler = handler;
|
||||
if (mKartAvailable != null) {
|
||||
mKartAvailable.setChecked(kart.getAvailable());
|
||||
}
|
||||
if (mKartName != null) {
|
||||
mKartName.setText(kart.getName());
|
||||
}
|
||||
if (mKartWeight != null) {
|
||||
mKartWeight.setText(kart.getWeight());
|
||||
}
|
||||
if (mKartDedicatedDriver != null) {
|
||||
mKartDedicatedDriver.setText(kart.getDedicatedDriver());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -126,6 +126,13 @@ public class SingleTrackFragment extends Fragment {
|
||||
// Mark the single name view (without additional information) as GONE
|
||||
final View singleName = view.findViewById(R.id.single_info_name);
|
||||
singleName.setVisibility(View.GONE);
|
||||
|
||||
if (mTrack != null) {
|
||||
mTrackAvailable.setChecked(mTrack.getAvailable());
|
||||
mTrackName.setText(mTrack.getName());
|
||||
mTrackPackage.setText(mTrack.getPackage());
|
||||
mTrackNumber.setText(mTrack.getNumber());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,9 +144,17 @@ public class SingleTrackFragment extends Fragment {
|
||||
public void setArguments(final Track track, final DatabaseHandler handler) {
|
||||
mTrack = track;
|
||||
mHandler = handler;
|
||||
if (mTrackAvailable != null) {
|
||||
mTrackAvailable.setChecked(track.getAvailable());
|
||||
}
|
||||
if (mTrackName != null) {
|
||||
mTrackName.setText(track.getName());
|
||||
}
|
||||
if (mTrackPackage != null) {
|
||||
mTrackPackage.setText(track.getPackage());
|
||||
}
|
||||
if (mTrackNumber != null) {
|
||||
mTrackNumber.setText(track.getNumber());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,11 @@ public class SingleWheelsFragment extends Fragment {
|
||||
// Initialize all single views and make them visible.
|
||||
mWheelsName = (TextView) view.findViewById(R.id.single_info_name);
|
||||
mWheelsName.setVisibility(View.VISIBLE);
|
||||
|
||||
if (mWheels != null) {
|
||||
mWheelsAvailable.setChecked(mWheels.getAvailable());
|
||||
mWheelsName.setText(mWheels.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,8 +123,12 @@ public class SingleWheelsFragment extends Fragment {
|
||||
public void setArguments(final Wheels wheels, final DatabaseHandler handler) {
|
||||
mWheels = wheels;
|
||||
mHandler = handler;
|
||||
if (mWheelsAvailable != null) {
|
||||
mWheelsAvailable.setChecked(wheels.getAvailable());
|
||||
}
|
||||
if (mWheelsName != null) {
|
||||
mWheelsName.setText(wheels.getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BIN
app/src/main/res/drawable/accessory_24_white.png
Normal file
|
After Width: | Height: | Size: 476 B |
BIN
app/src/main/res/drawable/accessory_50_dark_grey.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable/character_24_white.png
Normal file
|
After Width: | Height: | Size: 324 B |
BIN
app/src/main/res/drawable/character_50_dark_grey.png
Normal file
|
After Width: | Height: | Size: 846 B |
BIN
app/src/main/res/drawable/kart_24_white.png
Normal file
|
After Width: | Height: | Size: 317 B |
BIN
app/src/main/res/drawable/kart_50_dark_grey.png
Normal file
|
After Width: | Height: | Size: 607 B |
BIN
app/src/main/res/drawable/track_24_white.png
Normal file
|
After Width: | Height: | Size: 277 B |
BIN
app/src/main/res/drawable/track_50_dark_grey.png
Normal file
|
After Width: | Height: | Size: 565 B |
BIN
app/src/main/res/drawable/wheels_24_white.png
Normal file
|
After Width: | Height: | Size: 536 B |
BIN
app/src/main/res/drawable/wheels_50_dark_grey.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
@@ -7,24 +7,19 @@
|
||||
android:orientation="vertical"
|
||||
tools:context="com.de.aldo_apps.aldo.mariokartcircuitselector.GameSelection">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/id_input"
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/vp_horizontal_ntb"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<devlight.io.library.ntb.NavigationTabBar
|
||||
app:ntb_title_mode="all"
|
||||
app:ntb_titled="true"
|
||||
app:ntb_title_size="14sp"
|
||||
android:id="@+id/ntb_vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/ok_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Get Track"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/result_field"
|
||||
android:text="TestContent Goes here" />
|
||||
android:layout_height="50dp"
|
||||
app:ntb_preview_colors="@array/vertical_ntb"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
12
app/src/main/res/layout/pager_item.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ListView
|
||||
android:id="@+id/all_items_list_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
|
||||
</ScrollView>
|
||||
15
app/src/main/res/values/arrays.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string-array name="vertical_ntb">
|
||||
<item>#df5a55</item>
|
||||
<item>#f9bb72</item>
|
||||
<item>#76afcf</item>
|
||||
<item>#dd6495</item>
|
||||
<item>#72d3b4</item>
|
||||
<item>#563d91</item>
|
||||
<item>#56342e</item>
|
||||
<item>#8c9f58</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
@@ -2,4 +2,11 @@
|
||||
<string name="app_name">MarioKartCircuitSelector</string>
|
||||
|
||||
<string name="separator">-</string>
|
||||
|
||||
<string name="title_track">Strecken</string>
|
||||
<string name="title_character">Fahrer</string>
|
||||
<string name="title_kart">Karts</string>
|
||||
<string name="title_accessory">Sonstiges</string>
|
||||
<string name="title_wheels">Reifen</string>
|
||||
|
||||
</resources>
|
||||
|
||||