Android Open Source - irma_android_verifier Verification Detail Fragment






From Project

Back to project page irma_android_verifier.

License

The source code is released under:

GNU General Public License

If you think the Android project irma_android_verifier listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.irmacard.androidverifier;
//from  w ww.  ja  v a  2s  . c  o  m
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.support.v4.app.Fragment;
import android.content.ContentUris;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class VerificationDetailFragment extends Fragment {

    public static final String ARG_ITEM_ID = "item_id";
    private static DateFormat dateFormat = new SimpleDateFormat("EEEE, MMMMM dd, yyyy 'at' HH:mm:ss");
    private Cursor mCursor;

    public VerificationDetailFragment() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments().containsKey(ARG_ITEM_ID)) {
          long itemId = getArguments().getLong(ARG_ITEM_ID);
          Uri uri = ContentUris.withAppendedId(VerificationData.Verifications.CONTENT_ID_URI_BASE, itemId);
            mCursor = getActivity().getContentResolver().query(uri,
                  null, null, null, null);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_verification_detail, container, false);
        if (mCursor.moveToNext()) {
          int result = Integer.parseInt(mCursor.getString(mCursor.getColumnIndex("result")));
          long timestamp = Long.parseLong(mCursor.getString(mCursor.getColumnIndex("timestamp")));
          Date timestampDate = new Date(timestamp);
          String info = mCursor.getString(mCursor.getColumnIndex("info"));
          String carduid = mCursor.getString(mCursor.getColumnIndex("carduid"));
          int resultStringRes = 0;
          switch (result) {
      case Verification.RESULT_VALID:
        resultStringRes = R.string.verification_list_valid;
        break;
      case Verification.RESULT_INVALID:
        resultStringRes = R.string.verification_list_invalid;
        break;
      case Verification.RESULT_FAILED:
        resultStringRes = R.string.verification_list_failed;
        break;

      default:
        break;
      }
          ((TextView)rootView.findViewById(R.id.resultfield)).setText(resultStringRes);
          ((TextView)rootView.findViewById(R.id.timestampfield)).setText(dateFormat.format(timestampDate));
          ((TextView)rootView.findViewById(R.id.carduidfield)).setText(carduid);
          ((TextView)rootView.findViewById(R.id.infofield)).setText(info);
        }
        return rootView;
    }
}




Java Source Code List

org.irmacard.androidverifier.AnimatedArrow.java
org.irmacard.androidverifier.AnonCredCheckActivity.java
org.irmacard.androidverifier.SettingsActivity.java
org.irmacard.androidverifier.StatsActivity.java
org.irmacard.androidverifier.VerificationCursorAdapter.java
org.irmacard.androidverifier.VerificationData.java
org.irmacard.androidverifier.VerificationDetailActivity.java
org.irmacard.androidverifier.VerificationDetailFragment.java
org.irmacard.androidverifier.VerificationListActivity.java
org.irmacard.androidverifier.VerificationListFragment.java
org.irmacard.androidverifier.Verification.java
org.irmacard.androidverifier.VerificationsProvider.java