@Override
public void onBackPressed() {
Log.e("TAG","pos: "+mViewPager.getCurrentItem());
if (mViewPager.getCurrentItem()==0) {
if (googleFlag) {
String path = "root";
String title = "MCloud";
if (presenterGoogle.getPathGoogle().size() - 2 >= 0) {
Log.w(TAG, "path = " + path);
Log.w(TAG, "title = " + title + " title -1 = " + presenterGoogle.getTitleGoogle().get(presenterGoogle.getTitleGoogle().size() - 2));
path = presenterGoogle.getPathGoogle().get(presenterGoogle.getPathGoogle().size() - 2);
title = presenterGoogle.getTitleGoogle().get(presenterGoogle.getTitleGoogle().size() - 2);
}
Log.w("back", path);
if (presenterGoogle.getPathGoogle().size() - 1 > 0) {
Log.w(TAG, "удаляем из getPath последний элемент = " + path);
presenterGoogle.getPathGoogle().remove(presenterGoogle.getPathGoogle().size() - 1);
presenterGoogle.getTitleGoogle().remove(presenterGoogle.getTitleGoogle().size() - 1);
setTitle(title);
if (path == "root")
path = presenterGoogle.googleMoveFolder(path);
presenterGoogle.listGDriveUserFiles(path);
}
else {
super.onBackPressed();
}
}
}
else
super.onBackPressed();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login_activity_all);
Log.w(TAG, "onCreate");
if (allModels == null) {
converter = new Converter();
mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
fileWork = new FileWork();
server = RetrofitBuilder.getOAuthClient(this);
presenterGoogle = new GoogleCloudPresenter(server, context, this);
presenterGoogle.setPathGoogle(presenterGoogle.googleMoveFolder("root"));
presenterGoogle.setTitleGoogle("MCloud");
// progressBar = (ProgressBar) findViewById(R.id.progress);
ActivityCompat.requestPermissions(LoginActivity.this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager(), getApplicationContext());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
} else adapter = new Data_Adapter(context, R.layout.list_item, allModels);
}
public SectionsPagerAdapter(FragmentManager fm, Context ctx) {
super(fm);
fragments = new Fragment[3];
fragments[0] = PlaceholderFragment.newInstance(1);
fragments[1] = PlaceholderFragment.newInstance(2);
fragments[2] = PlaceholderFragment.newInstance(3);
titles = new String[3];
titles[0] = ctx.getString(R.string.googleTitle);
titles[1] = ctx.getString(R.string.yandexTitle);
titles[2] = ctx.getString(R.string.oneDriveTitle);
}
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
public static OAuthServerIntf getYandex() {
Retrofit raCustom = new Retrofit.Builder()
.client(new OkHttpClient())
.baseUrl("https://cloud-api.yandex.net")
.addConverterFactory(GsonConverterFactory.create())
.build();
OAuthServerIntf webServer = raCustom.create(OAuthServerIntf.class);
return webServer;
}
@POST("/v1/disk/resources/move")
Link move(@Query("from") String from, @Query("path") String path,
@Query("overwrite") Boolean overwrite)
throws IOException, ServerIOException;
FATAL EXCEPTION: AsyncTask #1
Process: com.example.gibkin.multycloud, PID: 20053
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.os.Handler.post(java.lang.Runnable)' on a null object reference
at com.example.gibkin.multycloud.yandex.example.IODialogRetainedFragment.sendException(IODialogRetainedFragment.java:32)
at com.example.gibkin.multycloud.yandex.example.IODialogRetainedFragment.sendException(IODialogRetainedFragment.java:28)
at com.example.gibkin.multycloud.yandex.example.RenameMoveItemFragment$RenameMoveItemRetainedFragment$1.doInBackground(RenameMoveItemFragment.java:139)
at com.example.gibkin.multycloud.yandex.example.RenameMoveItemFragment$RenameMoveItemRetainedFragment$1.doInBackground(RenameMoveItemFragment.java:126)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
protected void sendException(final String message) {
handler.post(new Runnable() {
@Override
public void run () {
IODialogFragment targetFragment = (IODialogFragment) getTargetFragment();
if (targetFragment != null) {
targetFragment.sendException(message);
}
}
});
}