Ejemplo n.º 1
0
  private void featchData() {

    progressBar.startIntro();
    progressBar.setProgress(0);
    if (!MyApplication.instance.isNetworkAvailable()) {
      try {
        Snackbar snackbar =
            Snackbar.make(relativeLayout, "لا يوجد اتصال بالانترنت", Snackbar.LENGTH_INDEFINITE)
                .setAction(
                    "اعد المحاولة",
                    new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                        featchData();
                      }
                    });
        snackbar.setActionTextColor(Color.RED);

        View sbView = snackbar.getView();
        TextView textView =
            (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
        textView.setTextColor(Color.YELLOW);

        snackbar.show();
      } catch (Exception e) {

      }
    } else {

      webView.stopLoading();
      webView.loadUrl(MyApplication.BASE_URL + urlExtention);
    }
  }
 private void showErrorMessage(
     @StringRes int messageResId,
     @StringRes int actionLabelResid,
     View.OnClickListener actionListener) {
   Snackbar instance = Snackbar.make(getView(), messageResId, Snackbar.LENGTH_LONG);
   if (actionLabelResid != 0 && actionListener != null) {
     instance.setAction(actionLabelResid, actionListener);
     int colorRes = ViewUtils.getThemeColorAccent(getActivity().getTheme());
     instance.setActionTextColor(colorRes);
   }
   instance.show();
 }
Ejemplo n.º 3
0
 protected void showColorfulSnackbar(
     String text,
     String action,
     View.OnClickListener actionListener,
     int bgColor,
     int textColor,
     int actionTextColor) {
   Snackbar snackbar =
       Snackbar.make(findViewById(android.R.id.content), text, Snackbar.LENGTH_SHORT)
           .setAction(action, actionListener);
   snackbar.setActionTextColor(actionTextColor);
   View bgView = snackbar.getView();
   bgView.setBackgroundColor(bgColor);
   TextView textView = (TextView) bgView.findViewById(android.support.design.R.id.snackbar_text);
   textView.setTextColor(textColor);
   snackbar.show();
 }
Ejemplo n.º 4
0
  public void checkInternet() {
    if (!MyApplication.instance.isNetworkAvailable()) {
      Snackbar snackbar =
          Snackbar.make(relativeLayout, "لا يوجد اتصال بالانترنت", Snackbar.LENGTH_INDEFINITE)
              .setAction(
                  "اعد المحاولة",
                  new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                      checkInternet();
                    }
                  });
      snackbar.setActionTextColor(Color.RED);

      View sbView = snackbar.getView();
      TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
      textView.setTextColor(Color.YELLOW);

      snackbar.show();
    }
  }
Ejemplo n.º 5
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       return true;
     case R.id.action_credits:
       final Snackbar snackbar =
           Snackbar.make(mLayout, "Made by Dhruv, Bharat, Ankit, Kirti", Snackbar.LENGTH_LONG);
       snackbar.setAction(
           R.string.dismiss,
           new View.OnClickListener() {
             @Override
             public void onClick(View v) {
               snackbar.dismiss();
             }
           });
       snackbar.setActionTextColor(getResources().getColor(R.color.white));
       snackbar.show();
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
Ejemplo n.º 6
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.submit) {
      final EditText highBlock = (EditText) findViewById(R.id.high_block);
      if (highBlock.getText().toString().equals("")) {
        FrameLayout layoutRoot = (FrameLayout) findViewById(R.id.layout_root);
        final Snackbar snackbar =
            Snackbar.make(
                layoutRoot,
                getResources().getString(R.string.empty_high_password),
                Snackbar.LENGTH_LONG);
        View snackBarView = snackbar.getView();
        TextView text =
            (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_text);
        text.setTextColor(getResources().getColor(R.color.icons));
        snackBarView.setBackgroundColor(getResources().getColor(R.color.primary));
        snackbar.setActionTextColor(getResources().getColor(R.color.snack_action));
        snackbar.setAction(
            getString(R.string.i_know),
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                snackbar.dismiss();
              }
            });
        snackbar.show();
        return false;
      }

      final EditText deviceSeed = (EditText) findViewById(R.id.user_input);
      if (deviceSeed.getText().toString().length() == 6) {
        AlertDialog.Builder builder = new AlertDialog.Builder(SetDeviceActivity.this);
        builder
            .setTitle(getString(R.string.submit_warning_title))
            .setMessage(getString(R.string.submit_warning))
            .setPositiveButton(
                getString(R.string.alert_yes),
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    SharedPreferences sharedPreferences =
                        getSharedPreferences("user_data", Context.MODE_PRIVATE);
                    SharedPreferences.Editor editor = sharedPreferences.edit();
                    editor.putString("device_id", deviceSeed.getText().toString());
                    editor.putString(
                        "md5_password", Md5Utils.getMd5(highBlock.getText().toString()));
                    editor.apply();

                    Intent intent = new Intent(SetDeviceActivity.this, MainActivity.class);
                    SetDeviceActivity.this.startActivity(intent);
                    SetDeviceActivity.this.finish();
                  }
                })
            .setNegativeButton(getString(R.string.alert_cancel), null)
            .show();
      } else {
        FrameLayout layoutRoot = (FrameLayout) findViewById(R.id.layout_root);
        final Snackbar snackbar =
            Snackbar.make(
                layoutRoot,
                getResources().getString(R.string.incorrect_seed),
                Snackbar.LENGTH_LONG);
        View snackBarView = snackbar.getView();
        TextView text =
            (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_text);
        text.setTextColor(getResources().getColor(R.color.icons));
        snackBarView.setBackgroundColor(getResources().getColor(R.color.primary));
        snackbar.setActionTextColor(getResources().getColor(R.color.snack_action));
        snackbar.setAction(
            getString(R.string.i_know),
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                snackbar.dismiss();
              }
            });
        snackbar.show();
      }
    }
    return super.onOptionsItemSelected(item);
  }