Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private View fillTheView(final View view, final Match match, final boolean found) {
- TextView tv2;
- new Thread(new Runnable() {
- @Override
- public void run() {
- final String filename = "" + match.getSubjectid() + "." + match.getPhotoIDs();
- if (mainActivity.restService != null && found && !new File(Utils.getPathMediaFile(mainActivity, filename)).exists()) {
- final Call<ResponseBody> call = mainActivity.restService.image(match.getSubjectid(), match.getPhotoIDs());
- call.enqueue(new Callback<ResponseBody>() {
- @Override
- public void onResponse(Call<ResponseBody> call, final Response<ResponseBody> response) {
- final InputStream is = response.body().byteStream();
- new Thread(new Runnable() {
- @Override
- public void run() {
- final Bitmap bitmap = BitmapFactory.decodeStream(is);
- mainActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- ((ImageView) view.findViewById(R.id.profilepicture)).setImageDrawable(new BitmapDrawable(mainActivity.getResources(), bitmap));
- if (bitmap != null) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- Bitmap bpm = bitmap;
- if (bitmap.getWidth() > 320) {
- final Matrix matrix = new Matrix();
- final Bitmap pbm = Bitmap.createBitmap(bitmap, 0, 0, 256, bitmap.getHeight() / bitmap.getWidth() * 256, matrix, true);
- if (pbm != bitmap) {
- bitmap.recycle();
- }
- bpm = pbm;
- }
- if (!bpm.isRecycled()) {
- bpm.compress(Bitmap.CompressFormat.JPEG, 94, new FileOutputStream(Utils.getPathMediaFile(mainActivity, filename)));
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
- }).start();
- }
- }
- });
- }
- }).start();
- }
- @Override
- public void onFailure(Call<ResponseBody> call, Throwable t) {
- }
- });
- } else {
- try {
- final BitmapDrawable drawable = new BitmapDrawable(mainActivity.getResources(), Utils.getOutputMediaFileAP(mainActivity, filename));
- mainActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- ((ImageView) view.findViewById(R.id.profilepicture)).setImageDrawable(drawable);
- }
- });
- } catch (FileNotFoundException ignored) {
- }
- }
- }
- }).start();
- if (match.getScannedPath() != null) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- final BitmapDrawable drawable = new BitmapDrawable(mainActivity.getResources(), Utils.getOutputMediaFileAP(mainActivity, match.getScannedPath()));
- mainActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- ((ImageView) view.findViewById(R.id.subjectpicture)).setImageDrawable(drawable);
- if (((int)view.getTag(R.id.age)) == 2) {
- view.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- ContinuousVisionActivity.showEnrollment(mainActivity, match.getScannedPath());
- }
- });
- }
- }
- });
- } catch (FileNotFoundException e) {
- //e.printStackTrace();
- mainActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- ((ImageView) view.findViewById(R.id.subjectpicture)).setImageDrawable(null);
- }
- });
- }
- }
- }).start();
- } else {
- ((ImageView) view.findViewById(R.id.subjectpicture)).setImageDrawable(null);
- }
- if (found) {
- tv2 = (TextView) view.findViewById(R.id.name);
- tv2.setText(match.getFirstname() + " " + match.getLastname());
- } else {
- final TextView age = (TextView)view.findViewById(R.id.age);
- final String ages = match.getEstage() != 0 ? ""+match.getEstage() : "unknown";
- age.setText(ages);
- final TextView gender = (TextView)view.findViewById(R.id.gender);
- final String genders = match.getEstgender() != null ? match.getEstgender() : "unknown";
- gender.setText(genders);
- }
- //tv2 = (TextView)view.findViewById(R.id.advanced);
- tv2 = (TextView)view.findViewById(R.id.created);
- tv2.setText("" + match.getCreated());
- setGpsOnClickListener(tv2, match);
- return view;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement