Skip to content

Commit

Permalink
fix backpress issue(#314) raised in Toolkit-Android
Browse files Browse the repository at this point in the history
  • Loading branch information
Teja Vojjala committed Jan 24, 2017
1 parent f126353 commit 2b28189
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {

defaultConfig {
applicationId "org.buildmlearn.dictation"
minSdkVersion 15
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.buildmlearn.dictation.fragment;

import android.app.FragmentManager;
import android.app.TaskStackBuilder;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
Expand All @@ -18,6 +19,7 @@
import org.buildmlearn.dictation.Constants;
import org.buildmlearn.dictation.R;
import org.buildmlearn.dictation.activities.DetailActivity;
import org.buildmlearn.dictation.activities.MainActivity;
import org.buildmlearn.dictation.data.DictContract;
import org.buildmlearn.dictation.data.DictDb;

Expand Down Expand Up @@ -113,11 +115,11 @@ public void onLoadFinished(Loader<Cursor> loader, final Cursor data) {
@Override
public void onClick(View v) {
getActivity().getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
Intent intent = new Intent(getActivity(), DetailActivity.class)
.setType("text/plain")
.putExtra(Intent.EXTRA_TEXT, dict_Id)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
TaskStackBuilder.create(getContext())
.addParentStack(MainActivity.class)
.addNextIntent(new Intent(getContext(),MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP))
.addNextIntent(new Intent(getContext(),DetailActivity.class).setType("text/plain").putExtra(Intent.EXTRA_TEXT,dict_Id))
.startActivities();
}
});

Expand Down
17 changes: 7 additions & 10 deletions DictationTemplate/source/DictationTemplateApp/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

## Project-wide Gradle settings.
#
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
#Sun Jan 22 07:11:15 IST 2017
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,16 @@ protected void onCreate(Bundle savedInstanceState) {
topChannelMenu.add(String.format(Locale.getDefault(), "Flash Card %1$d", i));
topChannelMenu.getItem(i - 1).setIcon(R.drawable.ic_assignment_black_24dp);
final int finalI = i;
final int flashId = Integer.parseInt(FlashId);
topChannelMenu.getItem(i - 1).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Intent intent = new Intent(mContext, MainActivity.class)
.setType("text/plain")
.putExtra(Intent.EXTRA_TEXT, String.valueOf(finalI))
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
if(flashId!=finalI) {
Intent intent = new Intent(mContext, MainActivity.class)
.setType("text/plain")
.putExtra(Intent.EXTRA_TEXT, String.valueOf(finalI));
startActivity(intent);
}
return false;
}
});
Expand Down Expand Up @@ -154,10 +155,8 @@ public void onClick(View v) {
long nextFlashId = Integer.parseInt(finalFlashId1) - 1;
Intent intent = new Intent(mContext, MainActivity.class)
.setType("text/plain")
.putExtra(Intent.EXTRA_TEXT, String.valueOf(nextFlashId))
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
.putExtra(Intent.EXTRA_TEXT, String.valueOf(nextFlashId));
startActivity(intent);
finish();
}
});

Expand All @@ -172,17 +171,14 @@ public void onClick(View v) {

Intent intent = new Intent(mContext, MainActivity.class)
.setType("text/plain")
.putExtra(Intent.EXTRA_TEXT, String.valueOf(nextFlashId))
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
.putExtra(Intent.EXTRA_TEXT, String.valueOf(nextFlashId));
startActivity(intent);
finish();

} else {

Intent intent = new Intent(mContext, LastActivity.class)
.setType("text/plain");
startActivity(intent);
finish();
}
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

## Project-wide Gradle settings.
#
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
#Sun Jan 22 07:13:19 IST 2017
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.app.Activity;
import android.app.FragmentManager;
import android.app.TaskStackBuilder;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
Expand All @@ -28,12 +29,11 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public void onClick(View v) {
getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
Intent intent = new Intent(activity, DetailActivity.class)
.setType("text/plain")
.putExtra(Intent.EXTRA_TEXT, "1")
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);

startActivity(intent);
TaskStackBuilder.create(activity)
.addParentStack(MainActivity.class)
.addNextIntent(new Intent(activity,MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP))
.addNextIntent(new Intent(activity,DetailActivity.class).setType("text/plain").putExtra(Intent.EXTRA_TEXT,"1"))
.startActivities();
finish();
}
});
Expand Down

0 comments on commit 2b28189

Please sign in to comment.