mirror of
https://github.com/cupcakearmy/R6S.git
synced 2026-04-02 09:55:27 +00:00
Latest Version (v1.4)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -18,6 +19,8 @@ import java.util.List;
|
||||
|
||||
public class OpsListAdapter extends RecyclerView.Adapter<OpsListAdapter.ViewHolder> {
|
||||
|
||||
private Activity root;
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public TextView txt_n;
|
||||
@@ -37,8 +40,9 @@ public class OpsListAdapter extends RecyclerView.Adapter<OpsListAdapter.ViewHold
|
||||
|
||||
private List<OpsListItem> data;
|
||||
|
||||
public OpsListAdapter(List<OpsListItem> d) {
|
||||
public OpsListAdapter(List<OpsListItem> d, Activity r) {
|
||||
data = d;
|
||||
root = r;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +59,7 @@ public class OpsListAdapter extends RecyclerView.Adapter<OpsListAdapter.ViewHold
|
||||
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);
|
||||
InputStream ims = root.getAssets().open(data.get(position).i);
|
||||
viewHolder.txt_i.setImageDrawable(Drawable.createFromStream(ims, null));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -67,7 +71,7 @@ public class OpsListAdapter extends RecyclerView.Adapter<OpsListAdapter.ViewHold
|
||||
b.putInt("id", data.get(position).id);
|
||||
Fragment f = new op_view();
|
||||
f.setArguments(b);
|
||||
home.ChangeFragment(f);
|
||||
home.ChangeFragment(f, root);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
1295
R6S/app/src/main/java/io/nicco/r6s/TouchImageView.java
Normal file
1295
R6S/app/src/main/java/io/nicco/r6s/TouchImageView.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -14,6 +15,8 @@ import java.util.List;
|
||||
|
||||
public class WeaponsListAdapter extends RecyclerView.Adapter<WeaponsListAdapter.ViewHolder> {
|
||||
|
||||
private Activity root;
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public TextView txt_l;
|
||||
@@ -31,8 +34,9 @@ public class WeaponsListAdapter extends RecyclerView.Adapter<WeaponsListAdapter.
|
||||
|
||||
private List<WeaponListItem> data;
|
||||
|
||||
public WeaponsListAdapter(List<WeaponListItem> d) {
|
||||
public WeaponsListAdapter(List<WeaponListItem> d, Activity r) {
|
||||
data = d;
|
||||
root = r;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,7 +58,7 @@ public class WeaponsListAdapter extends RecyclerView.Adapter<WeaponsListAdapter.
|
||||
b.putInt("id", data.get(position).id);
|
||||
Fragment f = new weapon_view();
|
||||
f.setArguments(b);
|
||||
home.ChangeFragment(f);
|
||||
home.ChangeFragment(f, root);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ public class home extends AppCompatActivity
|
||||
|
||||
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";
|
||||
@@ -39,8 +38,6 @@ public class home extends AppCompatActivity
|
||||
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);
|
||||
@@ -50,7 +47,7 @@ public class home extends AppCompatActivity
|
||||
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
|
||||
ChangeFragment(new ops_view());
|
||||
ChangeFragment(new ops_view(), this);
|
||||
setTitle("Operators");
|
||||
|
||||
// Save DB from assets to storage
|
||||
@@ -129,22 +126,18 @@ public class home extends AppCompatActivity
|
||||
}
|
||||
|
||||
setTitle(title);
|
||||
c.getFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
ChangeFragment(curFrag);
|
||||
getFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
ChangeFragment(curFrag, this);
|
||||
|
||||
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 void ChangeFragment(Fragment f, Activity a) {
|
||||
a.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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -11,33 +11,37 @@ 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 android.widget.Toast;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
public class maps_view extends Fragment {
|
||||
|
||||
|
||||
public maps_view() {
|
||||
}
|
||||
|
||||
private Context root = null;
|
||||
private Activity root;
|
||||
private Spinner maps_sel;
|
||||
private TextView cur_floor_txt;
|
||||
private Button btn_l;
|
||||
private Button btn_r;
|
||||
private ImageView img;
|
||||
private TouchImageView img;
|
||||
|
||||
private final String path = "Maps";
|
||||
private int cur_floor = 0;
|
||||
private String cur_map;
|
||||
private String[] maps = null;
|
||||
|
||||
private final static String PREF_A = "maps_view_show_toast";
|
||||
|
||||
private void setImg() {
|
||||
InputStream ims;
|
||||
try {
|
||||
@@ -52,17 +56,16 @@ public class maps_view extends Fragment {
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
root = getActivity();
|
||||
|
||||
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);
|
||||
img = (TouchImageView) view.findViewById(R.id.maps_img);
|
||||
|
||||
List<String> maps_sel_cont = new ArrayList<>();
|
||||
|
||||
@@ -113,6 +116,14 @@ public class maps_view extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
img.resetZoom();
|
||||
|
||||
int showed_toast = Integer.parseInt(root.getPreferences(MODE_PRIVATE).getString(PREF_A, "0"));
|
||||
if (showed_toast < 5) {
|
||||
Toast.makeText(root, "Pinch the Map, You can ZOOM!", Toast.LENGTH_LONG).show();
|
||||
root.getPreferences(MODE_PRIVATE).edit().putString(PREF_A, String.valueOf(++showed_toast)).apply();
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
@@ -9,30 +10,34 @@ import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
public class op_view extends Fragment {
|
||||
|
||||
|
||||
public op_view() {
|
||||
}
|
||||
|
||||
private Activity root;
|
||||
private final static String PREF_A = "op_view_show_toast";
|
||||
|
||||
private LinearLayout mkItem(String s) {
|
||||
LinearLayout frame = new LinearLayout(home.root());
|
||||
TextView tmp = new TextView(home.root());
|
||||
LinearLayout frame = new LinearLayout(root);
|
||||
TextView tmp = new TextView(root);
|
||||
|
||||
LinearLayout.LayoutParams fp = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1);
|
||||
fp.setMargins(8, 8, 8, 8);
|
||||
@@ -59,6 +64,8 @@ public class op_view extends Fragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
root = getActivity();
|
||||
|
||||
final View v = inflater.inflate(R.layout.fragment_op_view, container, false);
|
||||
|
||||
//Get Operator Info
|
||||
@@ -98,7 +105,7 @@ public class op_view extends Fragment {
|
||||
b.putInt("id", cur_id);
|
||||
Fragment f = new weapon_view();
|
||||
f.setArguments(b);
|
||||
home.ChangeFragment(f);
|
||||
home.ChangeFragment(f, root);
|
||||
}
|
||||
});
|
||||
if (w.getString(w.getColumnIndex("class")).equals("Secondary")) {
|
||||
@@ -117,7 +124,8 @@ public class op_view extends Fragment {
|
||||
|
||||
//Setting Images
|
||||
try {
|
||||
InputStream ims = home.root().getAssets().open("Operators/" + c.getString(c.getColumnIndex("type")) + "/" + c.getString(c.getColumnIndex("name")) + ".png");
|
||||
|
||||
InputStream ims = 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();
|
||||
@@ -126,38 +134,37 @@ public class op_view extends Fragment {
|
||||
v.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
Log.i("Trelelele", "ok");
|
||||
try {
|
||||
|
||||
//Drawable d = Drawable.createFromStream(home.root().getAssets().open("OPs/" + String.valueOf(id) + ".jpg"), null);
|
||||
//Drawable d = Drawable.createFromStream(c.getAssets().open("OPs/" + String.valueOf(id) + ".jpg"), null);
|
||||
ImageView op_bg = (ImageView) v.findViewById(R.id.op_bg);
|
||||
RelativeLayout img_cont = (RelativeLayout) v.findViewById(R.id.img_cont);
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(home.root().getAssets().open("OPs/" + String.valueOf(id) + ".jpg"));
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(root.getAssets().open("OPs/" + String.valueOf(id) + ".jpg"));
|
||||
|
||||
int b_h = bitmap.getHeight();
|
||||
int b_w = bitmap.getWidth();
|
||||
//float ratio = op_bg.getHeight() / op_bg.getWidth();
|
||||
Log.i("W & H: ", op_bg.getMeasuredHeight() + " - " + op_bg.getHeight());
|
||||
/*
|
||||
if (ratio > 1) {
|
||||
// BG is portrait
|
||||
if (b_h > b_w) {
|
||||
//img is portrait
|
||||
bitmap = Bitmap.createBitmap(bitmap, 0, 0, b_h, (int) (b_h * ratio));
|
||||
} else {
|
||||
//img is landscape
|
||||
bitmap = Bitmap.createBitmap(bitmap, 0, 0, (int) (b_w / ratio), b_w);
|
||||
}
|
||||
} else {
|
||||
//BG is landscape
|
||||
if (b_h > b_w) {
|
||||
//img is portrait
|
||||
bitmap = Bitmap.createBitmap(bitmap, 0, 0, (int) (b_w / ratio), b_w);
|
||||
} else {
|
||||
//img is landscape
|
||||
bitmap = Bitmap.createBitmap(bitmap, 0, 0, b_h, (int) (b_h * ratio));
|
||||
}
|
||||
}*/
|
||||
int bg_h = op_bg.getHeight();
|
||||
int bg_w = op_bg.getWidth();
|
||||
float ratio = (float) bg_h / bg_w;
|
||||
|
||||
try {
|
||||
if (ratio > 1) {
|
||||
// BG is portrait
|
||||
if (b_h > b_w) {
|
||||
bitmap = Bitmap.createBitmap(bitmap, 0, 0, b_w, Math.min((int) (b_w * ratio), b_h));
|
||||
} else {
|
||||
bitmap = Bitmap.createBitmap(bitmap, 0, 0, Math.min((int) (b_w / ratio), b_h), b_w);
|
||||
}
|
||||
} else {
|
||||
// BG is landscape
|
||||
if (b_h > b_w) {
|
||||
bitmap = Bitmap.createBitmap(bitmap, 0, 0, b_w, (int) (b_w * ratio));
|
||||
} else {
|
||||
bitmap = Bitmap.createBitmap(bitmap, 0, 0, b_h, (int) (b_h * ratio));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
||||
}
|
||||
|
||||
//Crop
|
||||
op_bg.setImageBitmap(bitmap);
|
||||
@@ -169,6 +176,12 @@ public class op_view extends Fragment {
|
||||
|
||||
db.close();
|
||||
|
||||
int showed_toast = Integer.parseInt(root.getPreferences(MODE_PRIVATE).getString(PREF_A, "0"));
|
||||
if (showed_toast < 5) {
|
||||
Toast.makeText(root, "Scroll down to see more!", Toast.LENGTH_LONG).show();
|
||||
root.getPreferences(MODE_PRIVATE).edit().putString(PREF_A, String.valueOf(++showed_toast)).apply();
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
@@ -19,10 +21,14 @@ public class ops_view extends Fragment {
|
||||
public ops_view() {
|
||||
}
|
||||
|
||||
private Activity root;
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
root = getActivity();
|
||||
|
||||
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);
|
||||
@@ -54,10 +60,10 @@ public class ops_view extends Fragment {
|
||||
}
|
||||
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()));
|
||||
op_a_list.setAdapter(new OpsListAdapter(data_a, root));
|
||||
op_a_list.setLayoutManager(new LinearLayoutManager(root));
|
||||
op_d_list.setAdapter(new OpsListAdapter(data_d, root));
|
||||
op_d_list.setLayoutManager(new LinearLayoutManager(root));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class weapon_view extends Fragment {
|
||||
|
||||
//Setting Images
|
||||
try {
|
||||
InputStream ims = home.root().getAssets().open("Weapons/" + String.valueOf(id) + ".png");
|
||||
InputStream ims = getActivity().getAssets().open("Weapons/" + String.valueOf(id) + ".png");
|
||||
((ImageView) v.findViewById(R.id.weapon_image)).setImageDrawable(Drawable.createFromStream(ims, null));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.nicco.r6s;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
@@ -19,8 +20,12 @@ public class weapons_view extends Fragment {
|
||||
public weapons_view() {
|
||||
}
|
||||
|
||||
private Activity root;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
root = getActivity();
|
||||
|
||||
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<>();
|
||||
@@ -40,8 +45,8 @@ public class weapons_view extends Fragment {
|
||||
}
|
||||
db.close();
|
||||
|
||||
weapon_list.setAdapter(new WeaponsListAdapter(data));
|
||||
weapon_list.setLayoutManager(new LinearLayoutManager(home.root()));
|
||||
weapon_list.setAdapter(new WeaponsListAdapter(data, root));
|
||||
weapon_list.setLayoutManager(new LinearLayoutManager(root));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user