mirror of
https://github.com/cupcakearmy/R6S.git
synced 2026-04-02 09:55:27 +00:00
Added R6S Companion App
This commit is contained in:
79
R6S/app/src/main/java/io/nicco/r6s/OpsListAdapter.java
Normal file
79
R6S/app/src/main/java/io/nicco/r6s/OpsListAdapter.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
public class OpsListAdapter extends RecyclerView.Adapter<OpsListAdapter.ViewHolder> {
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public TextView txt_n;
|
||||
public TextView txt_f;
|
||||
public ImageView txt_i;
|
||||
public LinearLayout l;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
txt_n = (TextView) itemView.findViewById(R.id.ops_li_name);
|
||||
txt_f = (TextView) itemView.findViewById(R.id.ops_li_faction);
|
||||
txt_i = (ImageView) itemView.findViewById(R.id.ops_li_img);
|
||||
l = (LinearLayout) itemView.findViewById(R.id.ops_list_item);
|
||||
}
|
||||
}
|
||||
|
||||
private List<OpsListItem> data;
|
||||
|
||||
public OpsListAdapter(List<OpsListItem> d) {
|
||||
data = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpsListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
Context context = parent.getContext();
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
View contactView = inflater.inflate(R.layout.ops_list_item, parent, false);
|
||||
ViewHolder viewHolder = new ViewHolder(contactView);
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(OpsListAdapter.ViewHolder viewHolder, final int position) {
|
||||
viewHolder.txt_n.setText(data.get(position).n);
|
||||
viewHolder.txt_f.setText(data.get(position).f);
|
||||
try {
|
||||
InputStream ims = home.root().getAssets().open(data.get(position).i);
|
||||
viewHolder.txt_i.setImageDrawable(Drawable.createFromStream(ims, null));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
viewHolder.l.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Bundle b = new Bundle();
|
||||
b.putInt("id", data.get(position).id);
|
||||
Fragment f = new op_view();
|
||||
f.setArguments(b);
|
||||
home.ChangeFragment(f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
}
|
||||
15
R6S/app/src/main/java/io/nicco/r6s/OpsListItem.java
Normal file
15
R6S/app/src/main/java/io/nicco/r6s/OpsListItem.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
public class OpsListItem {
|
||||
public String n;
|
||||
public String f;
|
||||
public String i;
|
||||
public int id;
|
||||
|
||||
public OpsListItem(String N, String F, String I, int ID) {
|
||||
this.n = N;
|
||||
this.f = F;
|
||||
this.i = I;
|
||||
this.id = ID;
|
||||
}
|
||||
}
|
||||
13
R6S/app/src/main/java/io/nicco/r6s/WeaponListItem.java
Normal file
13
R6S/app/src/main/java/io/nicco/r6s/WeaponListItem.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
public class WeaponListItem {
|
||||
public String l;
|
||||
public String r;
|
||||
public int id;
|
||||
|
||||
public WeaponListItem(String L, String R, int ID) {
|
||||
this.l = L;
|
||||
this.r = R;
|
||||
this.id = ID;
|
||||
}
|
||||
}
|
||||
66
R6S/app/src/main/java/io/nicco/r6s/WeaponsListAdapter.java
Normal file
66
R6S/app/src/main/java/io/nicco/r6s/WeaponsListAdapter.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WeaponsListAdapter extends RecyclerView.Adapter<WeaponsListAdapter.ViewHolder> {
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public TextView txt_l;
|
||||
public TextView txt_r;
|
||||
public LinearLayout l;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
txt_l = (TextView) itemView.findViewById(R.id.weapons_li_l);
|
||||
txt_r = (TextView) itemView.findViewById(R.id.weapons_li_r);
|
||||
l = (LinearLayout) itemView.findViewById(R.id.weapons_list_item);
|
||||
}
|
||||
}
|
||||
|
||||
private List<WeaponListItem> data;
|
||||
|
||||
public WeaponsListAdapter(List<WeaponListItem> d) {
|
||||
data = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeaponsListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
Context context = parent.getContext();
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
View contactView = inflater.inflate(R.layout.weapons_list_item, parent, false);
|
||||
ViewHolder viewHolder = new ViewHolder(contactView);
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(WeaponsListAdapter.ViewHolder viewHolder, final int position) {
|
||||
viewHolder.txt_l.setText(data.get(position).l);
|
||||
viewHolder.txt_r.setText(data.get(position).r);
|
||||
viewHolder.l.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Bundle b = new Bundle();
|
||||
b.putInt("id", data.get(position).id);
|
||||
Fragment f = new weapon_view();
|
||||
f.setArguments(b);
|
||||
home.ChangeFragment(f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
}
|
||||
172
R6S/app/src/main/java/io/nicco/r6s/home.java
Normal file
172
R6S/app/src/main/java/io/nicco/r6s/home.java
Normal file
@@ -0,0 +1,172 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class home extends AppCompatActivity
|
||||
implements NavigationView.OnNavigationItemSelectedListener {
|
||||
|
||||
private DrawerLayout drawer;
|
||||
private Fragment curFrag = null;
|
||||
private static Activity c;
|
||||
private static String DB_PATH;
|
||||
private static String DB_NAME;
|
||||
private final String DB_URL = "https://raw.githubusercontent.com/CupCakeArmy/static/master/R6S/R6S.sqlite";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_home);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
c = this;
|
||||
|
||||
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
drawer.addDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
|
||||
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
|
||||
ChangeFragment(new ops_view());
|
||||
setTitle("Operators");
|
||||
|
||||
((TextView) findViewById(R.id.home_op)).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ChangeFragment(new ops_view());
|
||||
setTitle("Operators");
|
||||
}
|
||||
});
|
||||
|
||||
((TextView) findViewById(R.id.home_weapons)).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ChangeFragment(new weapons_view());
|
||||
setTitle("Operators");
|
||||
}
|
||||
});
|
||||
|
||||
((TextView) findViewById(R.id.home_rand)).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ChangeFragment(new random_view());
|
||||
setTitle("Operators");
|
||||
}
|
||||
});
|
||||
|
||||
// Save DB from assets to storage
|
||||
DB_PATH = getFilesDir().getAbsolutePath() + "/databases/";
|
||||
DB_NAME = "R6S.sqlite";
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
OutputStream myOutput = null;
|
||||
InputStream myInput = null;
|
||||
try {
|
||||
File file = new File(DB_PATH + DB_NAME);
|
||||
if (file.exists())
|
||||
return;
|
||||
new File(DB_PATH).mkdirs();
|
||||
myInput = getAssets().open(DB_NAME);
|
||||
myOutput = new FileOutputStream(DB_PATH + DB_NAME);
|
||||
while ((length = myInput.read(buffer)) > 0) {
|
||||
myOutput.write(buffer, 0, length);
|
||||
}
|
||||
myOutput.close();
|
||||
myOutput.flush();
|
||||
myInput.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
} else {
|
||||
if (getFragmentManager().getBackStackEntryCount() == 0) {
|
||||
this.finish();
|
||||
} else {
|
||||
getFragmentManager().popBackStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.home, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
if (id == R.id.action_settings) {
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@SuppressWarnings("StatementWithEmptyBody")
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
String title = "";
|
||||
|
||||
if (id == R.id.nav_weapon) {
|
||||
title = "Weapons";
|
||||
curFrag = new weapons_view();
|
||||
} else if (id == R.id.nav_op) {
|
||||
title = "Operators";
|
||||
curFrag = new ops_view();
|
||||
} else if (id == R.id.nav_maps) {
|
||||
title = "Maps";
|
||||
curFrag = new maps_view();
|
||||
} else if (id == R.id.nav_gen) {
|
||||
title = "Generator";
|
||||
curFrag = new random_view();
|
||||
}
|
||||
|
||||
setTitle(title);
|
||||
c.getFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
ChangeFragment(curFrag);
|
||||
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void ChangeFragment(Fragment f) {
|
||||
c.getFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.main_cont, f).commit();
|
||||
}
|
||||
|
||||
public static SQLiteDatabase mkdb() {
|
||||
return SQLiteDatabase.openDatabase(DB_PATH + DB_NAME, null, 0);
|
||||
}
|
||||
|
||||
public static Activity root() {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
119
R6S/app/src/main/java/io/nicco/r6s/maps_view.java
Normal file
119
R6S/app/src/main/java/io/nicco/r6s/maps_view.java
Normal file
@@ -0,0 +1,119 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class maps_view extends Fragment {
|
||||
|
||||
|
||||
public maps_view() {
|
||||
}
|
||||
|
||||
private Context root = null;
|
||||
private Spinner maps_sel;
|
||||
private TextView cur_floor_txt;
|
||||
private Button btn_l;
|
||||
private Button btn_r;
|
||||
private ImageView img;
|
||||
|
||||
private final String path = "Maps";
|
||||
private int cur_floor = 0;
|
||||
private String cur_map;
|
||||
private String[] maps = null;
|
||||
|
||||
private void setImg() {
|
||||
InputStream ims;
|
||||
try {
|
||||
ims = root.getAssets().open(path + "/" + cur_map + "/" + String.valueOf(cur_floor) + ".jpg");
|
||||
Drawable d = Drawable.createFromStream(ims, null);
|
||||
img.setImageDrawable(d);
|
||||
cur_floor_txt.setText(String.valueOf(cur_floor));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
View view = inflater.inflate(R.layout.fragment_maps_view, container, false);
|
||||
|
||||
root = getActivity();
|
||||
maps_sel = (Spinner) view.findViewById(R.id.maps_spinner);
|
||||
cur_floor_txt = (TextView) view.findViewById(R.id.maps_cur_floor);
|
||||
btn_l = (Button) view.findViewById(R.id.maps_btn_l);
|
||||
btn_r = (Button) view.findViewById(R.id.maps_btn_r);
|
||||
img = (ImageView) view.findViewById(R.id.maps_img);
|
||||
|
||||
List<String> maps_sel_cont = new ArrayList<>();
|
||||
|
||||
try {
|
||||
maps = root.getAssets().list(path);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
for (String map : maps) {
|
||||
maps_sel_cont.add(map);
|
||||
}
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(root, android.R.layout.simple_spinner_dropdown_item, maps_sel_cont);
|
||||
maps_sel.setAdapter(adapter);
|
||||
|
||||
maps_sel.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
|
||||
cur_map = maps[position];
|
||||
setImg();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parentView) {
|
||||
}
|
||||
});
|
||||
|
||||
btn_l.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
root.getAssets().open(path + '/' + cur_map + "/" + String.valueOf(cur_floor - 1) + ".jpg");
|
||||
cur_floor--;
|
||||
setImg();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
btn_r.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
root.getAssets().open(path + '/' + cur_map + "/" + String.valueOf(cur_floor + 1) + ".jpg");
|
||||
cur_floor++;
|
||||
setImg();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
||||
125
R6S/app/src/main/java/io/nicco/r6s/op_view.java
Normal file
125
R6S/app/src/main/java/io/nicco/r6s/op_view.java
Normal file
@@ -0,0 +1,125 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class op_view extends Fragment {
|
||||
|
||||
|
||||
public op_view() {
|
||||
}
|
||||
|
||||
private LinearLayout mkItem(String s) {
|
||||
LinearLayout frame = new LinearLayout(home.root());
|
||||
TextView tmp = new TextView(home.root());
|
||||
|
||||
LinearLayout.LayoutParams fp = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1);
|
||||
fp.setMargins(8, 8, 8, 8);
|
||||
frame.setLayoutParams(fp);
|
||||
frame.setOrientation(LinearLayout.HORIZONTAL);
|
||||
|
||||
LinearLayout.LayoutParams tmpp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
|
||||
tmp.setText(s);
|
||||
tmp.setLayoutParams(tmpp);
|
||||
tmp.setPadding(16, 16, 16, 16);
|
||||
tmp.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
||||
tmp.setBackgroundResource(R.drawable.weapon_selector);
|
||||
if (Build.VERSION.SDK_INT < 23) {
|
||||
tmp.setTextAppearance(home.root(), android.R.style.TextAppearance_Medium);
|
||||
} else {
|
||||
tmp.setTextAppearance(android.R.style.TextAppearance_DeviceDefault_Medium);
|
||||
}
|
||||
tmp.setTextColor(0xffffffff);
|
||||
frame.addView(tmp);
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.fragment_op_view, container, false);
|
||||
|
||||
//Get Operator Info
|
||||
Bundle b = this.getArguments();
|
||||
SQLiteDatabase db = home.mkdb();
|
||||
Cursor c = db.rawQuery("SELECT * FROM operators WHERE id=" + b.getInt("id"), null);
|
||||
c.moveToFirst();
|
||||
|
||||
// Map Of Text Views
|
||||
Map<String, TextView> txts = new HashMap();
|
||||
txts.put("name", (TextView) v.findViewById(R.id.op_name));
|
||||
txts.put("faction", (TextView) v.findViewById(R.id.op_faction));
|
||||
txts.put("armor", (TextView) v.findViewById(R.id.op_armor));
|
||||
txts.put("speed", (TextView) v.findViewById(R.id.op_speed));
|
||||
txts.put("type", (TextView) v.findViewById(R.id.op_type));
|
||||
txts.put("ability", (TextView) v.findViewById(R.id.op_ability));
|
||||
|
||||
txts.get("name").setText(c.getString(c.getColumnIndex("name")));
|
||||
txts.get("faction").setText(c.getString(c.getColumnIndex("faction")));
|
||||
txts.get("armor").setText(c.getString(c.getColumnIndex("armor")));
|
||||
txts.get("speed").setText(c.getString(c.getColumnIndex("speed")));
|
||||
txts.get("type").setText(c.getString(c.getColumnIndex("type")));
|
||||
txts.get("ability").setText(c.getString(c.getColumnIndex("ability")));
|
||||
|
||||
// Set Weapons
|
||||
Cursor w = db.rawQuery("SELECT * FROM weapons WHERE id IN (" + c.getString(c.getColumnIndex("wid")) + ")", null);
|
||||
LinearLayout primary = (LinearLayout) v.findViewById(R.id.op_p_w);
|
||||
LinearLayout secondary = (LinearLayout) v.findViewById(R.id.op_s_w);
|
||||
while (w.moveToNext()) {
|
||||
final int cur_id = w.getInt(w.getColumnIndex("id"));
|
||||
LinearLayout tmp = mkItem(w.getString(w.getColumnIndex("name")));
|
||||
tmp.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Bundle b = new Bundle();
|
||||
b.putInt("id", cur_id);
|
||||
Fragment f = new weapon_view();
|
||||
f.setArguments(b);
|
||||
home.ChangeFragment(f);
|
||||
}
|
||||
});
|
||||
if (w.getString(w.getColumnIndex("class")).equals("Secondary")) {
|
||||
secondary.addView(tmp);
|
||||
} else {
|
||||
primary.addView(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
// Set Gadgets
|
||||
Cursor g = db.rawQuery("SELECT * FROM gadget WHERE id IN (" + c.getString(c.getColumnIndex("gadget")) + ")", null);
|
||||
LinearLayout gl = (LinearLayout) v.findViewById(R.id.op_g);
|
||||
while (g.moveToNext()) {
|
||||
gl.addView(mkItem(g.getString(g.getColumnIndex("name"))));
|
||||
}
|
||||
|
||||
//Setting Images
|
||||
try {
|
||||
InputStream ims = home.root().getAssets().open("Operators/" + c.getString(c.getColumnIndex("type")) + "/" + c.getString(c.getColumnIndex("name")) + ".png");
|
||||
((ImageView) v.findViewById(R.id.op_img)).setImageDrawable(Drawable.createFromStream(ims, null));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
db.close();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
65
R6S/app/src/main/java/io/nicco/r6s/ops_view.java
Normal file
65
R6S/app/src/main/java/io/nicco/r6s/ops_view.java
Normal file
@@ -0,0 +1,65 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ops_view extends Fragment {
|
||||
|
||||
public ops_view() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_ops_view, container, false);
|
||||
RecyclerView op_a_list = (RecyclerView) v.findViewById(R.id.ops_list_a);
|
||||
RecyclerView op_d_list = (RecyclerView) v.findViewById(R.id.ops_list_d);
|
||||
List<OpsListItem> data_a = new ArrayList<>();
|
||||
List<OpsListItem> data_d = new ArrayList<>();
|
||||
|
||||
// Get DB List
|
||||
SQLiteDatabase db = home.mkdb();
|
||||
Cursor op_a = db.rawQuery("SELECT * FROM operators WHERE type='Attacker' ORDER BY id ASC", null);
|
||||
Cursor op_d = db.rawQuery("SELECT * FROM operators WHERE type='Defender' ORDER BY id ASC", null);
|
||||
try {
|
||||
while (op_a.moveToNext()) {
|
||||
data_a.add(new OpsListItem(
|
||||
op_a.getString(op_a.getColumnIndex("name")),
|
||||
op_a.getString(op_a.getColumnIndex("faction")),
|
||||
"Operators/" + op_a.getString(op_a.getColumnIndex("type")) + "/" + op_a.getString(op_a.getColumnIndex("name")) + ".png",
|
||||
op_a.getInt(op_a.getColumnIndex("id"))));
|
||||
}
|
||||
while (op_d.moveToNext()) {
|
||||
data_d.add(new OpsListItem(
|
||||
op_d.getString(op_d.getColumnIndex("name")),
|
||||
op_d.getString(op_d.getColumnIndex("faction")),
|
||||
"Operators/" + op_d.getString(op_d.getColumnIndex("type")) + "/" + op_d.getString(op_d.getColumnIndex("name")) + ".png",
|
||||
op_d.getInt(op_d.getColumnIndex("id"))));
|
||||
}
|
||||
} finally {
|
||||
op_a.close();
|
||||
op_d.close();
|
||||
}
|
||||
db.close();
|
||||
|
||||
op_a_list.setAdapter(new OpsListAdapter(data_a));
|
||||
op_a_list.setLayoutManager(new LinearLayoutManager(home.root()));
|
||||
op_d_list.setAdapter(new OpsListAdapter(data_d));
|
||||
op_d_list.setLayoutManager(new LinearLayoutManager(home.root()));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
125
R6S/app/src/main/java/io/nicco/r6s/random_view.java
Normal file
125
R6S/app/src/main/java/io/nicco/r6s/random_view.java
Normal file
@@ -0,0 +1,125 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class random_view extends Fragment {
|
||||
|
||||
TextView gen_op;
|
||||
TextView gen_p;
|
||||
TextView gen_s;
|
||||
TextView gen_g;
|
||||
|
||||
public random_view() {
|
||||
}
|
||||
|
||||
class op {
|
||||
public String n;
|
||||
public String t;
|
||||
public List<String> p = new ArrayList<>();
|
||||
public List<String> s = new ArrayList<>();
|
||||
public List<String> g = new ArrayList<>();
|
||||
|
||||
public op(String N, String T, List<String> P, List<String> S, List<String> G) {
|
||||
n = N;
|
||||
t = T;
|
||||
p = P;
|
||||
s = S;
|
||||
g = G;
|
||||
}
|
||||
}
|
||||
|
||||
void randop(List<op> ops, boolean ad) {
|
||||
op cur;
|
||||
String sel = "Defender";
|
||||
|
||||
if (ad)
|
||||
sel = "Attacker";
|
||||
|
||||
do {
|
||||
cur = ops.get(rand(ops.size()));
|
||||
}
|
||||
while (cur.t.equals(sel));
|
||||
|
||||
gen_op.setText(cur.n);
|
||||
gen_p.setText(cur.p.get(rand(cur.p.size())));
|
||||
gen_s.setText(cur.s.get(rand(cur.s.size())));
|
||||
gen_g.setText(cur.g.get(rand(cur.g.size())));
|
||||
}
|
||||
|
||||
int rand(int max) {
|
||||
return new Random().nextInt(max);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.fragment_random_view, container, false);
|
||||
|
||||
Button gen_a = (Button) v.findViewById(R.id.rand_a);
|
||||
Button gen_d = (Button) v.findViewById(R.id.rand_d);
|
||||
|
||||
gen_op = (TextView) v.findViewById(R.id.rand_op);
|
||||
gen_p = (TextView) v.findViewById(R.id.rand_primary);
|
||||
gen_s = (TextView) v.findViewById(R.id.rand_secondary);
|
||||
gen_g = (TextView) v.findViewById(R.id.rand_gadget);
|
||||
|
||||
final List<op> ops = new ArrayList();
|
||||
|
||||
SQLiteDatabase db = home.mkdb();
|
||||
Cursor c = db.rawQuery("SELECT * FROM operators", null);
|
||||
while (c.moveToNext()) {
|
||||
List<String> p = new ArrayList<>();
|
||||
List<String> s = new ArrayList<>();
|
||||
List<String> g = new ArrayList<>();
|
||||
for (String weapon : c.getString(c.getColumnIndex("wid")).split(",")) {
|
||||
Cursor wc = db.rawQuery("SELECT * FROM weapons WHERE id=" + weapon, null);
|
||||
wc.moveToFirst();
|
||||
if (wc.getString(wc.getColumnIndex("class")).equals("Secondary"))
|
||||
s.add(wc.getString(wc.getColumnIndex("name")));
|
||||
else
|
||||
p.add(wc.getString(wc.getColumnIndex("name")));
|
||||
}
|
||||
for (String weapon : c.getString(c.getColumnIndex("gadget")).split(",")) {
|
||||
Cursor wc = db.rawQuery("SELECT * FROM gadget WHERE id=" + weapon, null);
|
||||
wc.moveToFirst();
|
||||
g.add(wc.getString(wc.getColumnIndex("name")));
|
||||
}
|
||||
ops.add(new op(
|
||||
c.getString(c.getColumnIndex("name")),
|
||||
c.getString(c.getColumnIndex("type")),
|
||||
p, s, g
|
||||
));
|
||||
}
|
||||
db.close();
|
||||
|
||||
gen_a.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
randop(ops, true);
|
||||
}
|
||||
});
|
||||
|
||||
gen_d.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
randop(ops, false);
|
||||
}
|
||||
});
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
63
R6S/app/src/main/java/io/nicco/r6s/weapon_view.java
Normal file
63
R6S/app/src/main/java/io/nicco/r6s/weapon_view.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class weapon_view extends Fragment {
|
||||
|
||||
public weapon_view() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
//Save the view for modification
|
||||
View v = inflater.inflate(R.layout.fragment_weapon_view, container, false);
|
||||
|
||||
//Get Gun Info
|
||||
Bundle b = this.getArguments();
|
||||
SQLiteDatabase db = home.mkdb();
|
||||
Cursor c = db.rawQuery("SELECT * FROM weapons WHERE id=" + b.getInt("id"), null);
|
||||
c.moveToFirst();
|
||||
|
||||
// Map Of Text Views
|
||||
Map<String, TextView> txts = new HashMap();
|
||||
txts.put("name", (TextView) v.findViewById(R.id.weapon_name));
|
||||
txts.put("class", (TextView) v.findViewById(R.id.weapon_class));
|
||||
txts.put("dmg_n", (TextView) v.findViewById(R.id.weapon_dmg_n));
|
||||
txts.put("dmg_s", (TextView) v.findViewById(R.id.weapon_dmg_s));
|
||||
txts.put("rpm", (TextView) v.findViewById(R.id.weapon_rpm));
|
||||
txts.put("mob", (TextView) v.findViewById(R.id.weapon_mob));
|
||||
txts.put("mag", (TextView) v.findViewById(R.id.weapon_mag));
|
||||
txts.put("ops", (TextView) v.findViewById(R.id.weapon_ops));
|
||||
|
||||
txts.get("name").setText(c.getString(c.getColumnIndex("name")));
|
||||
txts.get("class").setText(c.getString(c.getColumnIndex("class")));
|
||||
txts.get("dmg_n").setText(c.getString(c.getColumnIndex("dmg_n")));
|
||||
txts.get("dmg_s").setText(c.getString(c.getColumnIndex("dmg_s")));
|
||||
if (c.getString(c.getColumnIndex("rpm")).equals("0"))
|
||||
txts.get("rpm").setText("-");
|
||||
else
|
||||
txts.get("rpm").setText(c.getString(c.getColumnIndex("rpm")));
|
||||
txts.get("mob").setText(c.getString(c.getColumnIndex("mobility")));
|
||||
txts.get("mag").setText(c.getString(c.getColumnIndex("mag")));
|
||||
txts.get("ops").setText(
|
||||
Arrays.toString(c.getString(c.getColumnIndex("op")).split(","))
|
||||
);
|
||||
|
||||
db.close();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
49
R6S/app/src/main/java/io/nicco/r6s/weapons_view.java
Normal file
49
R6S/app/src/main/java/io/nicco/r6s/weapons_view.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class weapons_view extends Fragment {
|
||||
|
||||
public weapons_view() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.fragment_weapons_view, container, false);
|
||||
RecyclerView weapon_list = (RecyclerView) v.findViewById(R.id.weapons_list);
|
||||
List<WeaponListItem> data = new ArrayList<>();
|
||||
|
||||
// Get DB List
|
||||
SQLiteDatabase db = home.mkdb();
|
||||
Cursor c = db.rawQuery("SELECT * FROM weapons ORDER BY class ASC, name ASC", null);
|
||||
try {
|
||||
while (c.moveToNext()) {
|
||||
data.add(new WeaponListItem(
|
||||
c.getString(c.getColumnIndex("name")),
|
||||
c.getString(c.getColumnIndex("class")),
|
||||
c.getInt(c.getColumnIndex("id"))));
|
||||
}
|
||||
} finally {
|
||||
c.close();
|
||||
}
|
||||
db.close();
|
||||
|
||||
weapon_list.setAdapter(new WeaponsListAdapter(data));
|
||||
weapon_list.setLayoutManager(new LinearLayoutManager(home.root()));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user