Android Open Source - BarcodeTest Search Result Activity






From Project

Back to project page BarcodeTest.

License

The source code is released under:

Copyright (c) 2014, zhongwcool All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * R...

If you think the Android project BarcodeTest 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 com.qr.activity;
/*ww w  .  ja  v a2s  . c o  m*/
import java.util.List;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import com.ericssonlabs.R;
import com.qr.utils.Parser;
import com.zxing.view.ResultUrlAdapter;
import com.zxing.view.Utility;

public class SearchResultActivity extends Activity {
    /** Called when the activity is first created. */
  private TextView tv_search_result = null;
  private Button btn_cancel = null;
  private ListView lv_search_result_url = null;
  private ListView lv_search_result_number = null;
  public ResultUrlAdapter _urladapter = null;
  public ResultUrlAdapter _numadaper = null;
  private List<String> rUrlList = null;
  private List<String> rNumberList = null;
  private TextView tv_draw_url = null; 
  private TextView tv_draw_number = null;
  private int urlFlag =0;
  private int numFlag = 1;
  
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_show_search_result);
        initView();
        Intent _sIntent = getIntent();
        String _scanResult = _sIntent.getStringExtra("searchResult");
      
        if(_scanResult ==null){
           tv_search_result.setText(getResources().getString(R.string.notification_no_result));
        }else{
           tv_search_result.setText(_scanResult);
           rUrlList = Parser.urlParser(_scanResult);
           if(rUrlList.size()>0 ){
             tv_draw_url.setVisibility(View.VISIBLE);
             lv_search_result_url.setVisibility(View.VISIBLE);
             loadResultUrl();
           }
           
           rNumberList = Parser.phoneParser(_scanResult);
           if(rNumberList.size()>0){
             tv_draw_number.setVisibility(View.VISIBLE);
             lv_search_result_number.setVisibility(View.VISIBLE);
             loadResultNumber();
           }
        }
       
       
        
        btn_cancel.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        // TODO Auto-generated method stub
        finish();
      }
    });
    }
   
    private void initView(){
      tv_draw_url = (TextView) findViewById(R.id.tv_draw_url);
      tv_draw_number = (TextView) findViewById(R.id.tv_draw_number);
      tv_search_result = (TextView)findViewById(R.id.tv_search_result);
        lv_search_result_url = (ListView) findViewById(R.id.lv_search_result_url);
        lv_search_result_number = (ListView) findViewById(R.id.lv_search_result_num);
        btn_cancel = (Button) this.findViewById(R.id.btnBack);
    }
  
    private void loadResultUrl(){
      _urladapter = new ResultUrlAdapter(SearchResultActivity.this, rUrlList, urlFlag);
      lv_search_result_url.setAdapter(_urladapter);
      Utility.setListViewHeightBasedOnChildren(lv_search_result_url);  
      lv_search_result_url.setOnItemClickListener(new OnItemClickListener() {

      @Override
      public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        String currUrl = lv_search_result_url.getItemAtPosition(position).toString();
        Intent intent= new Intent();        
          intent.setAction("android.intent.action.VIEW");    
          Uri content_url = Uri.parse(currUrl);   
          intent.setData(content_url);  
          startActivity(intent);
      }
    });
       }
    
    private void loadResultNumber(){
      _numadaper = new ResultUrlAdapter(SearchResultActivity.this, rNumberList, numFlag);
      lv_search_result_number.setAdapter(_numadaper);
      Utility.setListViewHeightBasedOnChildren(lv_search_result_number);  
      lv_search_result_number.setOnItemClickListener(new OnItemClickListener() {

      @Override
      public void onItemClick(AdapterView<?> parent, View view,
          int position, long id) {
        String phone_number = lv_search_result_number.getItemAtPosition(position).toString();
        Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+ phone_number));
              startActivity(intent);
      }
    });
       }
}




Java Source Code List

com.qr.activity.MainActivity.java
com.qr.activity.SearchResultActivity.java
com.qr.activity.WebviewActivity.java
com.qr.utils.Parser.java
com.zxing.activity.CaptureActivity.java
com.zxing.camera.AutoFocusCallback.java
com.zxing.camera.CameraConfigurationManager.java
com.zxing.camera.CameraManager.java
com.zxing.camera.FlashlightManager.java
com.zxing.camera.PlanarYUVLuminanceSource.java
com.zxing.camera.PreviewCallback.java
com.zxing.decoding.CaptureActivityHandler.java
com.zxing.decoding.DecodeFormatManager.java
com.zxing.decoding.DecodeHandler.java
com.zxing.decoding.DecodeThread.java
com.zxing.decoding.FinishListener.java
com.zxing.decoding.InactivityTimer.java
com.zxing.decoding.Intents.java
com.zxing.encoding.EncodingHandler.java
com.zxing.view.ResultUrlAdapter.java
com.zxing.view.Utility.java
com.zxing.view.ViewfinderResultPointCallback.java
com.zxing.view.ViewfinderView.java