public void setTextStatus(String msn, boolean hasError) {
    if (mActivity != null) {
      mSnackbar =
          Snackbar.with(mActivity)
              .type(SnackbarType.MULTI_LINE)
              .text(msn)
              .animation(false)
              .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE);

      if (hasError) {
        mSnackbar
            .actionLabel("Volver a Intenar")
            .actionListener(
                new ActionClickListener() {
                  @Override
                  public void onActionClicked(Snackbar snackbar) {
                    snackbar.dismiss();
                    searchDataInfo(callBack);
                  }
                })
            .color(Color.RED);
      }
      SnackbarManager.show(mSnackbar, mActivity);
    } else {
      Toast.makeText(mContext, msn, Toast.LENGTH_LONG).show();
    }
  }
Esempio n. 2
0
 private void processFindId(int code, String id) {
   if (code == Global.CODE_SUCCESS) {
     findIdFragment.setId(id);
   } else if (code == Global.CODE_FIND_ID_NULL) {
     Snackbar.with(this).text(R.string.find_id_null).show(this);
   } else {
     Snackbar.with(this).text(R.string.fail_again).show(this);
   }
 }
Esempio n. 3
0
 private void processFindPw(int code) {
   if (code == Global.CODE_SUCCESS) {
     findPwFragment.setPw();
   } else if (code == Global.CODE_FIND_PW_NULL) {
     Snackbar.with(this).text(R.string.find_id_null).show(this);
   } else {
     Snackbar.with(this).text(R.string.fail_again).show(this);
   }
 }
 private static void show(Activity activity, int msg, Style style, Integer tempo) {
   Snackbar snackbar = Snackbar.with(activity).text(activity.getResources().getText(msg));
   switch (style) {
     case INFO:
       snackbar.color(Color.BLUE);
       break;
     case ALERT:
       snackbar.color(Color.RED);
       break;
     case CONFIRM:
       snackbar.color(Color.GREEN);
       break;
   }
   if (tempo != null) {
     snackbar.duration(tempo);
   }
   snackbar.type(SnackbarType.MULTI_LINE);
   snackbar.actionLabel(activity.getResources().getString(R.string.close));
   snackbar.actionListener(
       new ActionClickListener() {
         @Override
         public void onActionClicked(Snackbar snackbar) {
           SnackbarManager.dismiss();
         }
       });
   SnackbarManager.show(snackbar);
 }
Esempio n. 5
0
  /**
   * TODO: 회원가입 응답
   *
   * @param cond : 응답 코드
   */
  private void processSignUp(int cond) {
    if (cond == Global.CODE_ID_ALREADY) { // 아이디 이미 사용 시
      Snackbar.with(getApplicationContext()).text(R.string.sign_up_id_already).show(this);
    } else if (cond == Global.CODE_SIGN_UP_FAIL) { // 회원가입 실패 시
      Snackbar.with(getApplicationContext()).text(R.string.sign_up_fail).show(this);
    } else if (cond == Global.CODE_SUCCESS) {
      Snackbar.with(getApplicationContext()).text(R.string.success).show(this);

      getSupportFragmentManager().beginTransaction().remove(signUpFragment).commit();
    }
  }
Esempio n. 6
0
  private void processSetPw(int code) {
    if (code == Global.CODE_SUCCESS) {
      Snackbar.with(this).text(R.string.success).show(this);

      getSupportFragmentManager().beginTransaction().remove(findPwFragment).commit();
    }
  }
Esempio n. 7
0
  @Override
  public void onResume() {
    if (activity != null) {

      Boolean a = s.getBoolean(IS_TIME_TABLE_CHANGED, true);
      timetable = s.getString(GET_TIME_TABLE, null);
      adapter2 = new CustomList_calendar(activity, days, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
      lvTest.setAdapter(adapter2);
      lvTest.setItemMargin(10);

      if (a || timetable == null) {
        if (Utils.isNetworkAvailable(activity)) new DownloadWebPageTask2().execute();
        else {
          if (activity != null)
            SnackbarManager.show(
                Snackbar.with(activity.getApplicationContext())
                    .text("Check Your Internet Connection")
                    .duration(Snackbar.SnackbarDuration.LENGTH_SHORT),
                activity);
        }
      } else {
        load();
      }
    }
    super.onResume();
  }
Esempio n. 8
0
  private Snackbar createSnackbar() {
    return Snackbar.with(getApplicationContext())
        .swipeToDismiss(true)
        .eventListener(
            new EventListener() {
              @Override
              public void onShow(Snackbar snackbar) {
                int snackbarHeight = snackbar.getHeight();
                ViewUtils.addMarginBottom(backButton, snackbarHeight);
                ViewUtils.addMarginBottom(nextButton, snackbarHeight);
                ViewUtils.addMarginBottom(refreshButton, snackbarHeight);
              }

              @Override
              public void onShown(Snackbar snackbar) {
                snackbar.animation(false);
              }

              @Override
              public void onDismiss(Snackbar snackbar) {
                int snackbarHeight = snackbar.getHeight();
                ViewUtils.addMarginBottom(backButton, -snackbarHeight);
                ViewUtils.addMarginBottom(nextButton, -snackbarHeight);
                ViewUtils.addMarginBottom(refreshButton, -snackbarHeight);
              }

              @Override
              public void onDismissed(Snackbar snackbar) {}
            });
  }
 public void backupDB(View view) {
   final String filename = DBUtils.backupDB(this);
   SnackbarManager.show(
       Snackbar.with(this)
           .type(SnackbarType.SINGLE_LINE)
           .text(String.format("Saved on: '%s'", filename))
           .swipeToDismiss(false)
           .animation(false)
           .color(Color.RED)
           .actionLabel("OPEN")
           .actionLabelTypeface(Typeface.DEFAULT_BOLD)
           .actionListener(
               new ActionClickListener() {
                 @Override
                 public void onActionClicked(Snackbar snackbar) {
                   try {
                     File fileToOpen = new File(filename);
                     Intent myIntent = new Intent();
                     myIntent.setAction(android.content.Intent.ACTION_VIEW);
                     myIntent.setDataAndType(Uri.fromFile(fileToOpen), "*/*");
                     startActivity(myIntent);
                   } catch (Exception e) {
                     Timber.e(e, "Exception during ActionsView enableWifiClickListener action");
                   }
                 }
               })
           .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE));
 }
 @Override
 protected void onResume() {
   super.onResume();
   final int entryCount = getSupportFragmentManager().getBackStackEntryCount();
   final ClipboardManager clipboardManager =
       (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
   if (entryCount == 0
       && clipboardManager.hasPrimaryClip()
       && clipboardManager.getPrimaryClip().getItemCount() > 0) {
     final ClipData primaryClip = clipboardManager.getPrimaryClip();
     final ClipData.Item item = primaryClip.getItemAt(0);
     final String text = item.coerceToText(this).toString();
     if (text.trim().length() > 0) {
       final Snackbar snackbar =
           Snackbar.with(this)
               .text(getString(R.string.paste_from_clipboard_prompt))
               .actionLabel(getString(R.string.paste_clipboard_action))
               .actionColorResource(R.color.sharelock_orange)
               .actionListener(
                   new ActionClickListener() {
                     @Override
                     public void onActionClicked(Snackbar snackbar) {
                       bus.postSticky(new ClipboardSecretEvent(text));
                       clipboardManager.setPrimaryClip(ClipData.newPlainText("", ""));
                     }
                   })
               .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE);
       SnackbarManager.show(snackbar);
     }
   }
 }
Esempio n. 11
0
  @UiThread
  protected void showError(String s) {
    if (navigator.isInForeground()) {
      Snackbar errorSnack;
      if (snackBarBackgroundColor != null) {
        errorSnack =
            Snackbar.with(context)
                .text(s)
                .duration(Snackbar.SnackbarDuration.LENGTH_SHORT)
                .color(snackBarBackgroundColor);
      } else {
        errorSnack =
            Snackbar.with(context).text(s).duration(Snackbar.SnackbarDuration.LENGTH_SHORT);
      }

      SnackbarManager.show(errorSnack, navigator.getCurrentActivityOnScreen());
    }
  }
Esempio n. 12
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_calender, container, false);
    lvTest = (TwoWayView) rootView.findViewById(R.id.lvItems);
    if (activity == null) return rootView;

    s = PreferenceManager.getDefaultSharedPreferences(activity);
    e = s.edit();
    Boolean b = s.getBoolean(IS_CLASS_SET, false);
    if (!b) {
      Intent i = new Intent(activity, ChooseClass.class);
      startActivity(i);
    }

    Boolean a = s.getBoolean(IS_TIME_TABLE_CHANGED, true);
    timetable = s.getString(GET_TIME_TABLE, null);

    adapter2 = new CustomList_calendar(activity, days, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
    lvTest.setAdapter(adapter2);
    lvTest.setItemMargin(10);

    if (a == true || timetable == null) {
      if (Utils.isNetworkAvailable(activity)) new DownloadWebPageTask2().execute();
      else {
        SnackbarManager.show(
            Snackbar.with(activity.getApplicationContext())
                .text("Check Your Internet Connection")
                .duration(Snackbar.SnackbarDuration.LENGTH_SHORT),
            activity);
      }
    } else {
      load();
    }

    lvTest.setOnScrollListener(
        new TwoWayView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(TwoWayView view, int scrollState) {}

          @Override
          public void onScroll(
              TwoWayView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            int lastInScreen = firstVisibleItem + visibleItemCount;
            if ((lastInScreen == totalItemCount) && !(loadingMore)) {
              load();
            }
            adapter2.notifyDataSetChanged();
          }
        });
    return rootView;
  }
Esempio n. 13
0
    @Override
    protected void onPostExecute(String result) {
      timetable = result;
      if (activity == null) return;

      e.putBoolean(IS_TIME_TABLE_CHANGED, false);
      e.putString(GET_TIME_TABLE, result);
      e.commit();

      JSONObject ob;

      if (timetable == null) return;
      try {
        ob = new JSONObject(timetable);
        ob = ob.getJSONObject("metadata");
        String s2 = ob.optString("last_updated", "null");
        if (s2.equals("null")) {
          SnackbarManager.show(
              Snackbar.with(activity.getApplicationContext())
                  .text("Sorry, Time Table is not available now. It will be updated shortly.")
                  .duration(Snackbar.SnackbarDuration.LENGTH_SHORT),
              activity);
        }

      } catch (JSONException e) {
        e.printStackTrace();
      }

      adapter2 = new CustomList_calendar(activity, days, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
      load();
      lvTest.setAdapter(adapter2);
      lvTest.setItemMargin(10);
      lvTest.setOnScrollListener(
          new TwoWayView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(TwoWayView view, int scrollState) {}

            @Override
            public void onScroll(
                TwoWayView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
              int lastInScreen = firstVisibleItem + visibleItemCount;
              if ((lastInScreen == totalItemCount) && !(loadingMore)) {
                load();
              }
              adapter2.notifyDataSetChanged();
            }
          });

      progress.dismiss();
    }
Esempio n. 14
0
  /**
   * TODO: 로그인 응답 처리
   *
   * @param code : 상태 NULL = 실패 SUCCESS = 성공
   * @param id : 아이디
   * @param image : 프로필 사진
   */
  private void processLogin(int code, String id, String name, String image) {
    if (code == Global.CODE_LOGIN_NO_ID) { // 로그인 실패 시
      Snackbar.with(getApplicationContext()) // 스낵바 띄우기
          .text(R.string.sign_up_null)
          .showAnimation(true)
          .show(this);
    } else if (code == Global.CODE_SUCCESS) { // 로그인 성공 시
      Intent intent = new Intent(LoginActivity.this, MainActivity.class); // 메인 액티비티로 이동
      intent.putExtra(Global.KEY_USER_ID, id);
      intent.putExtra(Global.KEY_USER_NAME, name);
      intent.putExtra(Global.KEY_USER_IMAGE, image);
      startActivity(intent);
      finish();

      setAutoLogin(id);
    }
  }
Esempio n. 15
0
 /**
  * The first time the app is ever opened, there will be no data present in the local db. So, we
  * HAVE to download from Parse This function checks if a download is completely necessary and if
  * it is, it starts the download and if it isn't it lets the app function with offline data
  */
 public void checkForDownload() {
   Cursor cursor =
       Login.db.rawQuery(
           "SELECT COUNT(name) FROM "
               + Login.USERNAME
               + "_projects WHERE username='******';",
           null);
   cursor.moveToFirst();
   int count = cursor.getInt(0);
   if (count == 0) {
     if (checkConnection()) {
       download();
     } else {
       // Toast.makeText(this, "Please check your Internet Connection!", Toast.LENGTH_LONG).show();
       // SnackbarManager.show(Snackbar.with(Login.this).text("Username and Password do not
       // match!"));
       SnackbarManager.show(
           Snackbar.with(getApplicationContext())
               .type(SnackbarType.MULTI_LINE)
               .duration(Snackbar.SnackbarDuration.LENGTH_LONG)
               .text("No Internet Connection!")
               .actionLabel("CLOSE")
               .actionListener(
                   new ActionClickListener() {
                     @Override
                     public void onActionClicked(Snackbar snackbar) {
                       SnackbarManager.dismiss();
                     }
                   }),
           MainActivity.this);
       (findViewById(R.id.viewVirtualTours)).setVisibility(View.GONE);
     }
   }
   cursor.close();
 }