mirror of
https://github.com/cupcakearmy/R6S.git
synced 2024-12-22 08:06:24 +00:00
V1.2
This commit is contained in:
parent
f9ea7fe2c8
commit
2a7d9d0786
@ -4,14 +4,19 @@ package io.nicco.r6s;
|
|||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -49,15 +54,17 @@ public class op_view extends Fragment {
|
|||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int id = 0;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View v = inflater.inflate(R.layout.fragment_op_view, container, false);
|
final View v = inflater.inflate(R.layout.fragment_op_view, container, false);
|
||||||
|
|
||||||
//Get Operator Info
|
//Get Operator Info
|
||||||
Bundle b = this.getArguments();
|
Bundle b = this.getArguments();
|
||||||
SQLiteDatabase db = home.mkdb();
|
SQLiteDatabase db = home.mkdb();
|
||||||
int id = b.getInt("id");
|
id = b.getInt("id");
|
||||||
Cursor c = db.rawQuery("SELECT * FROM operators WHERE id=" + id, null);
|
Cursor c = db.rawQuery("SELECT * FROM operators WHERE id=" + id, null);
|
||||||
c.moveToFirst();
|
c.moveToFirst();
|
||||||
|
|
||||||
@ -116,15 +123,49 @@ public class op_view extends Fragment {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
v.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
Log.i("Trelelele", "ok");
|
||||||
try {
|
try {
|
||||||
Drawable d = Drawable.createFromStream(home.root().getAssets().open("OPs/" + String.valueOf(id) + ".jpg"), null);
|
|
||||||
|
//Drawable d = Drawable.createFromStream(home.root().getAssets().open("OPs/" + String.valueOf(id) + ".jpg"), null);
|
||||||
ImageView op_bg = (ImageView) v.findViewById(R.id.op_bg);
|
ImageView op_bg = (ImageView) v.findViewById(R.id.op_bg);
|
||||||
//Matrix m = (Matrix) new Matrix.ScaleToFit("START");
|
RelativeLayout img_cont = (RelativeLayout) v.findViewById(R.id.img_cont);
|
||||||
//op_bg.setImageMatrix(m);
|
Bitmap bitmap = BitmapFactory.decodeStream(home.root().getAssets().open("OPs/" + String.valueOf(id) + ".jpg"));
|
||||||
op_bg.setImageDrawable(d);
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
//Crop
|
||||||
|
op_bg.setImageBitmap(bitmap);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import android.database.Cursor;
|
|||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -63,7 +62,6 @@ public class weapon_view extends Fragment {
|
|||||||
|
|
||||||
//Setting Images
|
//Setting Images
|
||||||
try {
|
try {
|
||||||
Log.i("ID: ", String.valueOf(id));
|
|
||||||
InputStream ims = home.root().getAssets().open("Weapons/" + String.valueOf(id) + ".png");
|
InputStream ims = home.root().getAssets().open("Weapons/" + String.valueOf(id) + ".png");
|
||||||
((ImageView) v.findViewById(R.id.weapon_image)).setImageDrawable(Drawable.createFromStream(ims, null));
|
((ImageView) v.findViewById(R.id.weapon_image)).setImageDrawable(Drawable.createFromStream(ims, null));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -9,14 +9,15 @@
|
|||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1"
|
||||||
|
android:id="@+id/img_cont">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/op_bg"
|
android:id="@+id/op_bg"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="false"
|
||||||
android:foregroundGravity="top" />
|
android:foregroundGravity="top" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
Loading…
Reference in New Issue
Block a user