|
29 | 29 | import com.moithepro.instatoolsandroid.jInstaloader.JInvalidArgumentException; |
30 | 30 | import com.moithepro.instatoolsandroid.jInstaloader.JTwoFactorAuthRequiredException; |
31 | 31 |
|
| 32 | +import java.io.FileNotFoundException; |
| 33 | + |
32 | 34 | public class LoginActivity extends AppCompatActivity { |
33 | 35 | private EditText password; |
34 | 36 | private EditText username; |
@@ -74,7 +76,11 @@ protected void onCreate(Bundle savedInstanceState) { |
74 | 76 | String u = username.getText().toString().trim(); |
75 | 77 | String p = password.getText().toString().trim(); |
76 | 78 | loader.login(u, p); |
77 | | - |
| 79 | + try { |
| 80 | + loader.saveSession("session"); |
| 81 | + } catch (Exception e) { |
| 82 | + e.printStackTrace(); |
| 83 | + } |
78 | 84 | mainHandler.post(() -> { |
79 | 85 | sp.edit().putString(getString(R.string.username_key), u).putString(getString(R.string.password_key), p).apply(); |
80 | 86 |
|
@@ -332,7 +338,40 @@ protected void onCreate(Bundle savedInstanceState) { |
332 | 338 | Handler mainHandler = new Handler(Looper.getMainLooper()); |
333 | 339 | loginThread = new Thread(() -> { |
334 | 340 |
|
| 341 | + try { |
| 342 | + loader.loadSession("session"); |
| 343 | + mainHandler.post(() -> { |
| 344 | + Intent intent = new Intent(this, UsersActivity.class); |
| 345 | + startActivity(intent); |
| 346 | + loggingIn = false; |
| 347 | + password.setEnabled(true); |
| 348 | + username.setEnabled(true); |
| 349 | + login.setText(R.string.log_in); |
| 350 | + finish(); |
| 351 | + //setContentView(R.layout.users_activity); |
| 352 | + |
| 353 | + }); |
| 354 | + }catch (FileNotFoundException e){ |
| 355 | + mainHandler.post(() -> { |
| 356 | + AD = new AlertDialog.Builder(this) |
| 357 | + .setTitle("Error") |
| 358 | + .setMessage("Session File Not Found") |
| 359 | + |
| 360 | + // Specifying a listener allows you to take an action before dismissing the dialog. |
| 361 | + // The dialog is automatically dismissed when a dialog button is clicked. |
| 362 | + .setPositiveButton(android.R.string.ok, null) |
335 | 363 |
|
| 364 | + // A null listener allows the button to dismiss the dialog and take no further action. |
| 365 | + .show(); |
| 366 | + loggingIn = false; |
| 367 | + password.setEnabled(true); |
| 368 | + username.setEnabled(true); |
| 369 | + login.setText(R.string.log_in); |
| 370 | + }); |
| 371 | + } |
| 372 | + catch (Exception e){ |
| 373 | + e.printStackTrace(); |
| 374 | + } |
336 | 375 | try { |
337 | 376 | loader.login(spu, spp); |
338 | 377 |
|
|
0 commit comments