2016-04-21 23:28:01 +00:00
|
|
|
package org.schabi.newpipe.download;
|
|
|
|
|
|
|
|
import android.app.FragmentTransaction;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
2019-10-04 12:59:08 +00:00
|
|
|
import androidx.appcompat.app.ActionBar;
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
import androidx.appcompat.widget.Toolbar;
|
2016-05-02 13:19:58 +00:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuInflater;
|
2016-04-21 23:28:01 +00:00
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.ViewTreeObserver;
|
|
|
|
|
2017-01-17 10:37:36 +00:00
|
|
|
import org.schabi.newpipe.R;
|
2016-08-02 19:17:54 +00:00
|
|
|
import org.schabi.newpipe.settings.SettingsActivity;
|
2017-02-27 11:55:15 +00:00
|
|
|
import org.schabi.newpipe.util.ThemeHelper;
|
2016-04-21 23:28:01 +00:00
|
|
|
|
|
|
|
import us.shandian.giga.service.DownloadManagerService;
|
|
|
|
import us.shandian.giga.ui.fragment.MissionsFragment;
|
2017-01-10 10:41:24 +00:00
|
|
|
|
2017-06-29 10:02:21 +00:00
|
|
|
public class DownloadActivity extends AppCompatActivity {
|
2016-04-21 23:28:01 +00:00
|
|
|
|
2018-06-11 12:44:00 +00:00
|
|
|
private static final String MISSIONS_FRAGMENT_TAG = "fragment_tag";
|
|
|
|
|
2016-04-21 23:28:01 +00:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
// Service
|
|
|
|
Intent i = new Intent();
|
|
|
|
i.setClass(this, DownloadManagerService.class);
|
|
|
|
startService(i);
|
|
|
|
|
2017-04-26 19:32:04 +00:00
|
|
|
ThemeHelper.setTheme(this);
|
2016-04-21 23:28:01 +00:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.activity_downloader);
|
|
|
|
|
2017-09-03 06:04:18 +00:00
|
|
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
2017-04-26 19:32:04 +00:00
|
|
|
setSupportActionBar(toolbar);
|
2016-05-25 21:51:22 +00:00
|
|
|
|
|
|
|
ActionBar actionBar = getSupportActionBar();
|
2017-04-26 19:32:04 +00:00
|
|
|
if (actionBar != null) {
|
|
|
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
|
|
actionBar.setTitle(R.string.downloads_title);
|
|
|
|
actionBar.setDisplayShowTitleEnabled(true);
|
|
|
|
}
|
2016-04-21 23:28:01 +00:00
|
|
|
|
2018-09-23 18:12:23 +00:00
|
|
|
getWindow().getDecorView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
|
|
@Override
|
|
|
|
public void onGlobalLayout() {
|
|
|
|
updateFragments();
|
2019-03-05 17:05:44 +00:00
|
|
|
getWindow().getDecorView().getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
2018-09-23 18:12:23 +00:00
|
|
|
}
|
|
|
|
});
|
2018-06-11 12:44:00 +00:00
|
|
|
}
|
2016-04-21 23:28:01 +00:00
|
|
|
|
2018-06-11 12:44:00 +00:00
|
|
|
private void updateFragments() {
|
2018-09-23 18:12:23 +00:00
|
|
|
MissionsFragment fragment = new MissionsFragment();
|
2018-06-11 12:44:00 +00:00
|
|
|
|
2019-04-05 17:45:39 +00:00
|
|
|
getSupportFragmentManager().beginTransaction()
|
2018-06-11 12:44:00 +00:00
|
|
|
.replace(R.id.frame, fragment, MISSIONS_FRAGMENT_TAG)
|
2016-04-21 23:28:01 +00:00
|
|
|
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
|
|
|
.commit();
|
|
|
|
}
|
|
|
|
|
2019-08-01 21:55:37 +00:00
|
|
|
@Override
|
2016-05-02 13:19:58 +00:00
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
|
super.onCreateOptionsMenu(menu);
|
|
|
|
MenuInflater inflater = getMenuInflater();
|
|
|
|
|
|
|
|
inflater.inflate(R.menu.download_menu, menu);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-23 10:22:29 +00:00
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
2017-06-29 10:02:21 +00:00
|
|
|
switch (item.getItemId()) {
|
2016-05-02 13:19:58 +00:00
|
|
|
case android.R.id.home: {
|
2017-02-19 15:07:45 +00:00
|
|
|
onBackPressed();
|
2016-05-02 13:19:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case R.id.action_settings: {
|
|
|
|
Intent intent = new Intent(this, SettingsActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
default:
|
2017-01-19 18:38:33 +00:00
|
|
|
return super.onOptionsItemSelected(item);
|
2016-04-23 10:22:29 +00:00
|
|
|
}
|
|
|
|
}
|
2016-04-21 23:28:01 +00:00
|
|
|
}
|