예제 #1
1
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //    overridePendingTransition(R.anim.fadeinanimation, 0);
    setContentView(R.layout.activity_main);

    Backendless.setUrl(Defaults.SERVER_URL);
    Backendless.initApp(this, Defaults.APPLICATION_ID, Defaults.SECRET_KEY, Defaults.VERSION);

    mainScreen = findViewById(R.id.mainscreen);

    mlbbutton = findViewById(R.id.button1);
    nflbutton = findViewById(R.id.button2);
    nhlbutton = findViewById(R.id.button3);
    nbabutton = findViewById(R.id.button4);
    cfbbutton = findViewById(R.id.button5);
    cbbbutton = findViewById(R.id.button6);
    olybutton = findViewById(R.id.button7);

    //    String uri =
    // "https://api.backendless.com/B40D13D5-E84B-F009-FF57-3871FCA5AE00/v1/files/sportsreflinks.db";

    android.support.v7.app.ActionBar bar = getSupportActionBar();

    if (bar != null) {
      bar.setTitle("Sports Reference");
    }

    //  detector = new GestureDetector(this);

    prefs =
        this.getSharedPreferences("comapps.com.thenewsportsreference.app", Context.MODE_PRIVATE);

    boolean hasVisited = prefs.getBoolean("HAS_VISISTED_BEFORE", false);

    if (!hasVisited) {

      mlbbutton.setVisibility(View.INVISIBLE);
      nhlbutton.setVisibility(View.INVISIBLE);
      nbabutton.setVisibility(View.INVISIBLE);
      nflbutton.setVisibility(View.INVISIBLE);
      cfbbutton.setVisibility(View.INVISIBLE);
      cbbbutton.setVisibility(View.INVISIBLE);
      olybutton.setVisibility(View.INVISIBLE);

      /* //    Toast instructions = Toast.makeText(MainActivity.this,
      //            "Click for search.", Toast.LENGTH_LONG);
      //    instructions.setGravity(Gravity.CENTER, 0, -250);
      //    instructions.show();

      Toast instructions2 = Toast.makeText(MainActivity.this,
              "Click enter with no text in search box \n " +
                      "         to go to the main site.", Toast.LENGTH_LONG);
      instructions2.setGravity(Gravity.CENTER, 0, -200);
      instructions2.show();

      //   Toast instructions3 = Toast.makeText(MainActivity.this,
      //           "Touch above search box to close keyboard.", Toast.LENGTH_LONG);
      //   instructions3.setGravity(Gravity.CENTER, 0, -150);
      //   instructions3.show();*/

      prefs.edit().putBoolean("HAS_VISISTED_BEFORE", true).commit();

      downloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);

      DownloadManager.Request request = new DownloadManager.Request(Uri.parse(downloadFileUrl));
      request.setTitle("Suggestions download.");
      request.setDescription("Suggestions database being downloaded...");

      request.setDestinationInExternalFilesDir(
          getApplicationContext(), "/dbase", "sportsreflinks.db");
      request.setNotificationVisibility(
          DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
      request.allowScanningByMediaScanner();
      // request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,
      // "sportsreflinks.db");

      /*  if (!hasVisited) {

           request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
           request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE);

      } else {

          request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);

      }*/

      String filePath = prefs.getString("filepath", "");

      Log.i(TAG, "file path is " + filePath);

      fileExist = doesFileExist(filePath);
      Log.i(TAG, "file exists is " + fileExist.toString());

      if (fileExist == true) {

        deleteFileIfExists(filePath);
      }

      myDownloadReference = downloadManager.enqueue(request);

      intentFilter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);

      receiverDownloadComplete =
          new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
              long reference = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);

              if (myDownloadReference == reference) {
                DownloadManager.Query query = new DownloadManager.Query();
                query.setFilterById(reference);
                Cursor cursor = downloadManager.query(query);

                cursor.moveToFirst();
                int columnIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS);
                int status = cursor.getInt(columnIndex);
                int fileNameIndex = cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME);
                String saveFilePath = cursor.getString(fileNameIndex);

                fileExist = doesFileExist(saveFilePath);

                Log.i(TAG, "file exists download complete " + saveFilePath);

                prefs.edit().putString("filepath", saveFilePath).commit();

                int columnReason = cursor.getColumnIndex(DownloadManager.COLUMN_REASON);
                int reason = cursor.getInt(columnReason);

                mlbbutton.setVisibility(View.VISIBLE);
                nhlbutton.setVisibility(View.VISIBLE);
                nbabutton.setVisibility(View.VISIBLE);
                nflbutton.setVisibility(View.VISIBLE);
                cfbbutton.setVisibility(View.VISIBLE);
                cbbbutton.setVisibility(View.VISIBLE);
                olybutton.setVisibility(View.VISIBLE);

                //     mainScreen.setEnabled(true);

                //     mainScreen.setClickable(true);

              }
            }
          };
    }

    mlbbutton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent intentbaseballsearch = new Intent();
            intentbaseballsearch.setClass(getApplicationContext(), MLBsearch.class);
            startActivity(intentbaseballsearch);
          }
        });

    nflbutton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent intentfootballsearch = new Intent();
            intentfootballsearch.setClass(getApplicationContext(), NFLsearch.class);
            startActivity(intentfootballsearch);
          }
        });

    nhlbutton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent intenthockeysearch = new Intent();
            intenthockeysearch.setClass(getApplicationContext(), NHLsearch.class);
            startActivity(intenthockeysearch);
          }
        });

    nbabutton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent intentbasketballsearch = new Intent();
            intentbasketballsearch.setClass(getApplicationContext(), NBAsearch.class);
            startActivity(intentbasketballsearch);
          }
        });

    cfbbutton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent intentcollegefootballsearch = new Intent();
            intentcollegefootballsearch.setClass(getApplicationContext(), CFBsearch.class);
            startActivity(intentcollegefootballsearch);
          }
        });

    cbbbutton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent intentcollegebasketballsearch = new Intent();
            intentcollegebasketballsearch.setClass(getApplicationContext(), CBBsearch.class);
            startActivity(intentcollegebasketballsearch);
          }
        });

    olybutton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent intentolympicssearch = new Intent();
            intentolympicssearch.setClass(getApplicationContext(), OLYsearch.class);
            startActivity(intentolympicssearch);
          }
        });
  }
예제 #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Backendless.initApp(this, APP_ID, SECRET_KEY, VERSION);
    mToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    mNavigationDrawerFragment =
        (NavigationDrawerFragment) getFragmentManager().findFragmentById(R.id.fragment_drawer);

    // Set up the drawer.
    mNavigationDrawerFragment.setup(
        R.id.fragment_drawer, (DrawerLayout) findViewById(R.id.drawer), mToolbar);

    this.loaded =
        true; // without this line, onNavigationDrawerItemSelected will run first for some reason

    isOnline();

    initOfferList();
    offerGridView = (GridView) findViewById(R.id.gridView);
    adapter = new OfferAdapter(this, offerList);
    offerGridView.setAdapter(adapter);
    // offerGridView.setOnItemClickListener();

  }
예제 #3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fence_demo_activity);

    Backendless.initApp(
        getBaseContext(), Defaults.APPLICATION_ID, Defaults.SECRET_KEY, Defaults.VERSION);
    startService(new Intent(this, AndroidService.class));

    initGeoPoint();
    initUI();
  }
예제 #4
0
  public static void main(String[] args) {

    String aplicationId = "1DC5DECB-9957-7B29-FFC3-C57A36745300";
    String secretKey = "ACBD1ACF-7B9A-C572-FF0F-882A25814E00";
    String version = "v1";
    Backendless.initApp(aplicationId, secretKey, version);

    //		BackendlessDataQuery consultaBack = new BackendlessDataQuery();
    //		List<Funcionario> retorno =
    // Backendless.Persistence.of(Funcionario.class).find(consultaBack).getCurrentPage();

    Funcionario funcionario = new Funcionario();
    //		List<Funcionario> lista = new ArrayList<Funcionario>();

    //		funcionario.setNome("Gilberto Azevedo Monteiro");
    //		funcionario.setMatricula("0002");
    //		funcionario.setEndereco("Avenida Alcindo Cancela");
    //		funcionario.setReferencia("Proximo a Uname");
    //		funcionario.setEmail("*****@*****.**");
    //		funcionario.setTelefone("988140135");
    //		funcionario.setCpf("61272914291");
    //		funcionario.setRg("3216428");
    //		funcionario.setSexo("M");
    //		funcionario.setFuncao("Administrador");
    //		System.out.println(funcionario.getNome());
    //		Backendless.Persistence.of(Funcionario.class).save(funcionario);

    //		BackendlessDataQuery consulta = new BackendlessDataQuery();
    //		consulta.setWhereClause("nome = 'Wev Kleyton Miranda de Oliveira'" );
    //		List<Funcionario> retorno =
    // Backendless.Persistence.of(Funcionario.class).find(consulta).getCurrentPage();

    //		for (Funcionario funcionario2 : retorno) {
    //			System.out.println(funcionario2.getNome());
    //
    //		}
  }
예제 #5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    volley = VolleyS.getInstance(this);
    fRequestQueue = volley.getRequestQueue();
    setContentView(R.layout.activity_main);
    current = Backendless.UserService.CurrentUser();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    String appVersion = "v1";
    Backendless.initApp(
        this,
        "F89F55EE-64AD-32BF-FFE1-96C258DA8800",
        "C7F9D9B6-6A7E-6FCF-FF7E-B1D7272E9900",
        appVersion);
    SharedPreferences sharedPreferences = getSharedPreferences("myData", Context.MODE_PRIVATE);
    String name = sharedPreferences.getString("name", "");

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawer,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    String urlpost = "http://10.10.3.21:3000/topcandidatos";
    JsonArrayRequest req =
        new JsonArrayRequest(
            urlpost,
            new Response.Listener<JSONArray>() {
              @Override
              public void onResponse(JSONArray response) {
                for (int i = 0; i < response.length(); i++) {
                  Candidato candidato = new Candidato();
                  try {
                    JSONObject jsonObject = response.getJSONObject(i);
                    candidato.setApellidos(jsonObject.getString("can_Apellido"));
                    candidato.setNombres(jsonObject.getString("can_Nombre"));
                    candidato.setId(jsonObject.getInt("can_Codigo"));
                    candidato.setFoto(jsonObject.getString("can_Foto"));
                    candidato.setPopularidad(jsonObject.getDouble("percent"));
                    candidato.setVotos(jsonObject.getInt("Respuestas"));
                    candidatos.add(candidato);
                  } catch (JSONException e) {
                    e.printStackTrace();
                  }
                }
                candidatoAdapter =
                    new CandidatoAdapter(
                        MainActivity.this, R.layout.top_item_candidato, candidatos);
                ListView tablesListView = (ListView) findViewById(R.id.mainList);
                candidatoAdapter.notifyDataSetChanged();
                tablesListView.setAdapter(candidatoAdapter);
                /*try {
                    VolleyLog.v("Response:%n %s", response.toString(4));
                } catch (JSONException e) {
                    e.printStackTrace();
                }*/
              }
            },
            new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                VolleyLog.e("Error: ", error.getMessage());
              }
            });
    addToQueue(req);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    View header = navigationView.getHeaderView(0);
    ImageView imageView = (ImageView) header.findViewById(R.id.imageView);
    TextView title = (TextView) header.findViewById(R.id.titleHeader);
    TextView email = (TextView) header.findViewById(R.id.email);
    Picasso.with(this)
        .load(
            "https://graph.facebook.com/"
                + current.getProperty("email").toString()
                + "/picture?type=large")
        .resize(110, 110)
        .centerCrop()
        .into(imageView);
    title.setText(current.getProperty("name").toString());
    email.setText(current.getProperty("fb_email").toString());
  }